X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b0d053c1eac3100e02468c73798111028819ad0a..87b621a5b737c09cef079bb4a9ef53be132d2ce0:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 64d11330d5..3805f1ba5a 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1982,12 +1982,14 @@ void wxWindowGTK::GTKHandleRealized() if (IsFrozen()) DoFreeze(); + GdkWindow* const window = GTKGetDrawingWindow(); + if (m_imData) { gtk_im_context_set_client_window ( m_imData->context, - m_wxwindow ? GTKGetDrawingWindow() + window ? window : gtk_widget_get_window(m_widget) ); } @@ -1998,7 +2000,6 @@ void wxWindowGTK::GTKHandleRealized() #if wxGTK_HAS_COMPOSITING_SUPPORT if (IsTransparentBackgroundSupported()) { - GdkWindow* const window = GTKGetDrawingWindow(); if (window) gdk_window_set_composited(window, true); } @@ -2010,16 +2011,14 @@ void wxWindowGTK::GTKHandleRealized() } } - - // We cannot set colours and fonts before the widget - // been realized, so we do this directly after realization - // or otherwise in idle time - - if (m_needsStyleChange) +#ifndef __WXGTK3__ + if (window && ( + m_backgroundStyle == wxBG_STYLE_PAINT || + m_backgroundStyle == wxBG_STYLE_TRANSPARENT)) { - SetBackgroundStyle(GetBackgroundStyle()); - m_needsStyleChange = false; + gdk_window_set_back_pixmap(window, NULL, false); } +#endif wxWindowCreateEvent event(static_cast(this)); event.SetEventObject( this ); @@ -2214,8 +2213,6 @@ void wxWindowGTK::Init() m_clipPaintRegion = false; - m_needsStyleChange = false; - m_cursor = *wxSTANDARD_CURSOR; m_imData = NULL; @@ -2583,6 +2580,9 @@ void wxWindowGTK::PostCreation() if (!WX_IS_PIZZA(gtk_widget_get_parent(m_widget)) && !GTK_IS_WINDOW(m_widget)) gtk_widget_set_size_request(m_widget, m_width, m_height); + // apply any font or color changes made before creation + GTKApplyWidgetStyle(); + InheritAttributes(); SetLayoutDirection(wxLayout_Default); @@ -4012,46 +4012,46 @@ void wxWindowGTK::GTKApplyToolTip(const char* tip) bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) { - wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") ); - if (!wxWindowBase::SetBackgroundColour(colour)) return false; -#ifndef __WXGTK3__ - if (colour.IsOk()) + if (m_widget) { - // We need the pixel value e.g. for background clearing. - m_backgroundColour.CalcPixel(gtk_widget_get_colormap(m_widget)); - } +#ifndef __WXGTK3__ + if (colour.IsOk()) + { + // We need the pixel value e.g. for background clearing. + m_backgroundColour.CalcPixel(gtk_widget_get_colormap(m_widget)); + } #endif - // apply style change (forceStyle=true so that new style is applied - // even if the bg colour changed from valid to wxNullColour) - GTKApplyWidgetStyle(true); + // apply style change (forceStyle=true so that new style is applied + // even if the bg colour changed from valid to wxNullColour) + GTKApplyWidgetStyle(true); + } return true; } bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) { - wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") ); - if (!wxWindowBase::SetForegroundColour(colour)) - { return false; - } -#ifndef __WXGTK3__ - if (colour.IsOk()) + if (m_widget) { - // We need the pixel value e.g. for background clearing. - m_foregroundColour.CalcPixel(gtk_widget_get_colormap(m_widget)); - } +#ifndef __WXGTK3__ + if (colour.IsOk()) + { + // We need the pixel value e.g. for background clearing. + m_foregroundColour.CalcPixel(gtk_widget_get_colormap(m_widget)); + } #endif - // apply style change (forceStyle=true so that new style is applied - // even if the bg colour changed from valid to wxNullColour): - GTKApplyWidgetStyle(true); + // apply style change (forceStyle=true so that new style is applied + // even if the bg colour changed from valid to wxNullColour): + GTKApplyWidgetStyle(true); + } return true; } @@ -4221,40 +4221,10 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style) #ifndef __WXGTK3__ GdkWindow *window; - if ( m_wxwindow ) - { - window = GTKGetDrawingWindow(); - } - else - { - GtkWidget * const w = GetConnectWidget(); - window = w ? gtk_widget_get_window(w) : NULL; - } - - bool wantNoBackPixmap = style == wxBG_STYLE_PAINT || style == wxBG_STYLE_TRANSPARENT; - - if ( wantNoBackPixmap ) - { - if (window) - { - // Make sure GDK/X11 doesn't refresh the window - // automatically. - gdk_window_set_back_pixmap( window, NULL, FALSE ); - m_needsStyleChange = false; - } - else // window not realized yet - { - // Do when window is realized - m_needsStyleChange = true; - } - - // Don't apply widget style, or we get a grey background - } - else + if ((style == wxBG_STYLE_PAINT || style == wxBG_STYLE_TRANSPARENT) && + (window = GTKGetDrawingWindow())) { - // apply style change (forceStyle=true so that new style is applied - // even if the bg colour changed from valid to wxNullColour): - GTKApplyWidgetStyle(true); + gdk_window_set_back_pixmap(window, NULL, false); } #endif // !__WXGTK3__ @@ -4423,14 +4393,15 @@ GdkWindow *wxWindowGTK::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const bool wxWindowGTK::SetFont( const wxFont &font ) { - wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") ); - if (!wxWindowBase::SetFont(font)) return false; - // apply style change (forceStyle=true so that new style is applied - // even if the font changed from valid to wxNullFont): - GTKApplyWidgetStyle(true); + if (m_widget) + { + // apply style change (forceStyle=true so that new style is applied + // even if the font changed from valid to wxNullFont): + GTKApplyWidgetStyle(true); + } return true; }