X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a433fbd51de352a2a1e64c56f42c957c9af789c5..a7a5165ca70b2b246a782089b7fb65b7042967c6:/src/gtk1/window.cpp diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 6a39ba448d..859efed9c5 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2798,21 +2798,6 @@ bool wxWindowGTK::PreCreation( wxWindowGTK *parent, const wxPoint &pos, const w m_x = (int)pos.x; m_y = (int)pos.y; - // some reasonable defaults - if (!parent) - { - if (m_x == -1) - { - m_x = (gdk_screen_width () - m_width) / 2; - if (m_x < 10) m_x = 10; - } - if (m_y == -1) - { - m_y = (gdk_screen_height () - m_height) / 2; - if (m_y < 10) m_y = 10; - } - } - return TRUE; } @@ -3009,13 +2994,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; } @@ -3428,7 +3413,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; @@ -3438,7 +3424,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); @@ -3451,9 +3437,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 } @@ -3461,7 +3447,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; @@ -3471,7 +3458,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); @@ -3484,9 +3471,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 } @@ -3497,8 +3484,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") ); @@ -3903,7 +3889,7 @@ void wxWindowGTK::GtkSendPaintEvents() g_eraseGC = gdk_gc_new( pizza->bin_window ); gdk_gc_set_fill( g_eraseGC, GDK_SOLID ); } - gdk_gc_set_foreground( g_eraseGC, m_backgroundColour.GetColor() ); + gdk_gc_set_foreground( g_eraseGC, GetBackgroundColour().GetColor() ); wxRegionIterator upd( m_clearRegion ); while (upd) @@ -4205,7 +4191,7 @@ void wxWindowGTK::SetWidgetStyle() } } - if ( m_hasBgCol ) + if ( m_hasBgCol && m_backgroundColour.Ok() ) { m_backgroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) ); if (m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))