X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c5fc899bf29ca7d9c4e2a070e28228b430a68dd3..86b79b93fbbb0c2e90e6595f7fea0f979b80881c:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 819a909325..e5144820ee 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2732,9 +2732,6 @@ bool wxWindowGTK::Create( wxWindow *parent, PostCreation(); - if ( IsShown() ) - gtk_widget_show( m_widget ); - return TRUE; } @@ -2919,6 +2916,11 @@ void wxWindowGTK::PostCreation() } m_hasVMT = TRUE; + + // unless the window was created initially hidden (i.e. Hide() had been + // called before Create()), we should show it at GTK+ level as well + if ( IsShown() ) + gtk_widget_show( m_widget ); } void wxWindowGTK::ConnectWidget( GtkWidget *widget ) @@ -3007,13 +3009,13 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags } // calculate the best size if we should auto size the window - if ( (sizeFlags & wxSIZE_AUTO_WIDTH) || - (sizeFlags & wxSIZE_AUTO_HEIGHT) ) + if ( ((sizeFlags & wxSIZE_AUTO_WIDTH) && width == -1) || + ((sizeFlags & wxSIZE_AUTO_HEIGHT) && height == -1) ) { const wxSize sizeBest = GetBestSize(); - if ( sizeFlags & wxSIZE_AUTO_WIDTH ) + if ( (sizeFlags & wxSIZE_AUTO_WIDTH) && width == -1 ) width = sizeBest.x; - if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) + if ( (sizeFlags & wxSIZE_AUTO_HEIGHT) && height == -1 ) height = sizeBest.y; } @@ -3426,7 +3428,8 @@ int wxWindowGTK::GetCharHeight() const { wxCHECK_MSG( (m_widget != NULL), 12, wxT("invalid window") ); - wxCHECK_MSG( m_font.Ok(), 12, wxT("invalid font") ); + wxFont font = GetFont(); + wxCHECK_MSG( font.Ok(), 12, wxT("invalid font") ); #ifdef __WXGTK20__ PangoContext *context = NULL; @@ -3436,7 +3439,7 @@ int wxWindowGTK::GetCharHeight() const if (!context) return 0; - PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; + PangoFontDescription *desc = font.GetNativeFontInfo()->description; PangoLayout *layout = pango_layout_new(context); pango_layout_set_font_description(layout, desc); pango_layout_set_text(layout, "H", 1); @@ -3449,9 +3452,9 @@ int wxWindowGTK::GetCharHeight() const return (int) (rect.height / PANGO_SCALE); #else - GdkFont *font = m_font.GetInternalFont( 1.0 ); + GdkFont *gfont = font.GetInternalFont( 1.0 ); - return font->ascent + font->descent; + return gfont->ascent + gfont->descent; #endif } @@ -3459,7 +3462,8 @@ int wxWindowGTK::GetCharWidth() const { wxCHECK_MSG( (m_widget != NULL), 8, wxT("invalid window") ); - wxCHECK_MSG( m_font.Ok(), 8, wxT("invalid font") ); + wxFont font = GetFont(); + wxCHECK_MSG( font.Ok(), 8, wxT("invalid font") ); #ifdef __WXGTK20__ PangoContext *context = NULL; @@ -3469,7 +3473,7 @@ int wxWindowGTK::GetCharWidth() const if (!context) return 0; - PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; + PangoFontDescription *desc = font.GetNativeFontInfo()->description; PangoLayout *layout = pango_layout_new(context); pango_layout_set_font_description(layout, desc); pango_layout_set_text(layout, "g", 1); @@ -3482,9 +3486,9 @@ int wxWindowGTK::GetCharWidth() const return (int) (rect.width / PANGO_SCALE); #else - GdkFont *font = m_font.GetInternalFont( 1.0 ); + GdkFont *gfont = font.GetInternalFont( 1.0 ); - return gdk_string_width( font, "g" ); + return gdk_string_width( gfont, "g" ); #endif } @@ -3495,8 +3499,7 @@ void wxWindowGTK::GetTextExtent( const wxString& string, int *externalLeading, const wxFont *theFont ) const { - wxFont fontToUse = m_font; - if (theFont) fontToUse = *theFont; + wxFont fontToUse = theFont ? *theFont : GetFont(); wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") ); @@ -4166,7 +4169,7 @@ void wxWindowGTK::SetWidgetStyle() GtkStyle *style = GetWidgetStyle(); - if (m_font != wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT )) + if ( m_hasFont ) { #ifdef __WXGTK20__ pango_font_description_free( style->font_desc ); @@ -4177,7 +4180,7 @@ void wxWindowGTK::SetWidgetStyle() #endif } - if (m_foregroundColour.Ok()) + if ( m_hasFgCol ) { m_foregroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) ); if (m_foregroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT)) @@ -4203,7 +4206,7 @@ void wxWindowGTK::SetWidgetStyle() } } - if (m_backgroundColour.Ok()) + if ( m_hasBgCol ) { m_backgroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) ); if (m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))