From 3b6595184f3d03abed63cbe7a27bde7cd9a792ea Mon Sep 17 00:00:00 2001 From: Kumazuma Date: Thu, 16 Jun 2022 01:18:31 +0900 Subject: [PATCH] Ensure wxMiniFrame title bar height is big enough in wxGTK Hardcoded 16px could be insufficient for the font size being used, resulting in the title text being truncated. Closes #22534. --- src/gtk/minifram.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gtk/minifram.cpp b/src/gtk/minifram.cpp index 7e27767048..c31a3ad16c 100644 --- a/src/gtk/minifram.cpp +++ b/src/gtk/minifram.cpp @@ -92,6 +92,7 @@ static gboolean expose_event(GtkWidget* widget, GdkEventExpose* gdk_event, wxMin if (win->m_miniTitle && !win->GetTitle().empty()) { dc.SetFont( *wxSMALL_FONT ); + int height = wxMax(dc.GetTextExtent("X").y, 16); wxBrush brush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); dc.SetBrush( brush ); @@ -99,16 +100,20 @@ static gboolean expose_event(GtkWidget* widget, GdkEventExpose* gdk_event, wxMin dc.DrawRectangle( win->m_miniEdge-1, win->m_miniEdge-1, win->m_width - (2*(win->m_miniEdge-1)), - 15 ); + height ); const wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); dc.SetTextForeground(textColor); - dc.DrawText( win->GetTitle(), 6, 4 ); + dc.DrawText( win->GetTitle(), 6, 2 ); if (style & wxCLOSE_BOX) { dc.SetTextBackground(textColor); - dc.DrawBitmap( win->m_closeButton, win->m_width-18, 3, true ); + dc.DrawBitmap( + win->m_closeButton, + win->m_width-18, + win->m_miniEdge - 1 + (height - 16) / 2, + true ); } } @@ -323,10 +328,16 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { + wxFrame::Create( parent, id, title, pos, size, style, name ); + m_isDragMove = false; m_miniTitle = 0; if (style & wxCAPTION) - m_miniTitle = 16; + { + wxClientDC dc(this); + dc.SetFont(*wxSMALL_FONT); + m_miniTitle = wxMax(dc.GetTextExtent("X").y, 16); + } if (style & wxRESIZE_BORDER) m_miniEdge = 4; @@ -341,8 +352,6 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title if (m_minHeight < minHeight) m_minHeight = minHeight; - wxFrame::Create( parent, id, title, pos, size, style, name ); - // Use a GtkEventBox for the title and borders. Using m_widget for this // almost works, except that setting the resize cursor has no effect. GtkWidget* eventbox = gtk_event_box_new();