From: Robert Roebling Date: Fri, 5 Apr 2002 20:39:08 +0000 (+0000) Subject: Fixed the background colour bug. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/994bc575d8a9d0efb440efaaa36b9a4c8f157f8f?hp=f94dd12dc18afd8518a88e9edac75f6dff907c9c Fixed the background colour bug. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14957 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index fff2dd0bab..d8285266ab 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2352,6 +2352,9 @@ bool wxWindowGTK::Create( wxWindow *parent, } m_insertCallback = wxInsertChildInWindow; + + // always needed for background clearing + m_delayedBackgroundColour = TRUE; m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); @@ -3394,6 +3397,11 @@ void wxWindowGTK::GtkSendPaintEvents() if (!GetEventHandler()->ProcessEvent(erase_event)) { + if (!g_eraseGC) + { + g_eraseGC = gdk_gc_new( GTK_PIZZA(m_wxwindow)->bin_window ); + gdk_gc_set_fill( g_eraseGC, GDK_SOLID ); + } gdk_gc_set_foreground( g_eraseGC, m_backgroundColour.GetColor() ); wxRegionIterator upd( m_clearRegion ); @@ -3474,7 +3482,7 @@ void wxWindowGTK::Clear() if (m_wxwindow && m_wxwindow->window) { -// gdk_window_clear( m_wxwindow->window ); + gdk_window_clear( m_wxwindow->window ); } } @@ -3518,6 +3526,12 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) m_delayedBackgroundColour = TRUE; } + if (window) + { + // We need the pixel value e.g. for background clearing. + m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); + } + if ((m_wxwindow) && (m_wxwindow->window) && (m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))) @@ -3525,7 +3539,6 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) /* wxMSW doesn't clear the window here. I don't do that either to provide compatibility. call Clear() to do the job. */ - m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); gdk_window_set_background( window, m_backgroundColour.GetColor() ); } @@ -4162,14 +4175,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxWinModule, wxModule) bool wxWinModule::OnInit() { - g_eraseGC = gdk_gc_new( GDK_ROOT_PARENT() ); - gdk_gc_set_fill( g_eraseGC, GDK_SOLID ); + // g_eraseGC = gdk_gc_new( GDK_ROOT_PARENT() ); + // gdk_gc_set_fill( g_eraseGC, GDK_SOLID ); return TRUE; } void wxWinModule::OnExit() { - gdk_gc_unref( g_eraseGC ); + if (g_eraseGC) + gdk_gc_unref( g_eraseGC ); } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index fff2dd0bab..d8285266ab 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2352,6 +2352,9 @@ bool wxWindowGTK::Create( wxWindow *parent, } m_insertCallback = wxInsertChildInWindow; + + // always needed for background clearing + m_delayedBackgroundColour = TRUE; m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); @@ -3394,6 +3397,11 @@ void wxWindowGTK::GtkSendPaintEvents() if (!GetEventHandler()->ProcessEvent(erase_event)) { + if (!g_eraseGC) + { + g_eraseGC = gdk_gc_new( GTK_PIZZA(m_wxwindow)->bin_window ); + gdk_gc_set_fill( g_eraseGC, GDK_SOLID ); + } gdk_gc_set_foreground( g_eraseGC, m_backgroundColour.GetColor() ); wxRegionIterator upd( m_clearRegion ); @@ -3474,7 +3482,7 @@ void wxWindowGTK::Clear() if (m_wxwindow && m_wxwindow->window) { -// gdk_window_clear( m_wxwindow->window ); + gdk_window_clear( m_wxwindow->window ); } } @@ -3518,6 +3526,12 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) m_delayedBackgroundColour = TRUE; } + if (window) + { + // We need the pixel value e.g. for background clearing. + m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); + } + if ((m_wxwindow) && (m_wxwindow->window) && (m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))) @@ -3525,7 +3539,6 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) /* wxMSW doesn't clear the window here. I don't do that either to provide compatibility. call Clear() to do the job. */ - m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); gdk_window_set_background( window, m_backgroundColour.GetColor() ); } @@ -4162,14 +4175,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxWinModule, wxModule) bool wxWinModule::OnInit() { - g_eraseGC = gdk_gc_new( GDK_ROOT_PARENT() ); - gdk_gc_set_fill( g_eraseGC, GDK_SOLID ); + // g_eraseGC = gdk_gc_new( GDK_ROOT_PARENT() ); + // gdk_gc_set_fill( g_eraseGC, GDK_SOLID ); return TRUE; } void wxWinModule::OnExit() { - gdk_gc_unref( g_eraseGC ); + if (g_eraseGC) + gdk_gc_unref( g_eraseGC ); }