From: Robin Dunn Date: Thu, 17 Jun 2004 21:31:13 +0000 (+0000) Subject: Set/Reset ThemeEnabled when changing the fore/background colours. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/44dfb5ce92980483d077896c92cc5b388c33cf5e Set/Reset ThemeEnabled when changing the fore/background colours. Using wxNullColour will reset to defaults. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27864 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 5ba278de5f..26c63a13f5 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -1007,25 +1007,23 @@ wxColour wxWindowBase::GetForegroundColour() const bool wxWindowBase::SetBackgroundColour( const wxColour &colour ) { - if ( !colour.Ok() || (colour == m_backgroundColour) ) + if ( colour == m_backgroundColour ) return false; + m_hasBgCol = colour.Ok(); m_backgroundColour = colour; - - m_hasBgCol = true; - + SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.Ok() ); return true; } bool wxWindowBase::SetForegroundColour( const wxColour &colour ) { - if ( !colour.Ok() || (colour == m_foregroundColour) ) + if (colour == m_foregroundColour ) return false; + m_hasFgCol = colour.Ok(); m_foregroundColour = colour; - - m_hasFgCol = true; - + SetThemeEnabled( !m_hasFgCol && !m_backgroundColour.Ok() ); return true; } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 171eecae9d..4b7a6ed8ae 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3985,13 +3985,19 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour ) wxASSERT( window ); + // This will work around the fact that I don't know what to do to reset to + // theme settings when colour == wxNullColour, GetBackgroundColour will + // fetch the default if needed, giving us a valid colour to use below. + // Vaclav needs to help here to implement the RightThing... + wxColour newColour = GetBackgroundColour(); + // We need the pixel value e.g. for background clearing. - m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); + newColour.CalcPixel( gdk_window_get_colormap( window ) ); if (m_wxwindow) { // wxMSW doesn't clear the window here, either. - gdk_window_set_background( window, m_backgroundColour.GetColor() ); + gdk_window_set_background( window, newColour.GetColor() ); } ApplyWidgetStyle(); @@ -3999,10 +4005,10 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour ) bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) { - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); + wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") ); if (!wxWindowBase::SetBackgroundColour(colour)) - return FALSE; + return false; GdkWindow *window = (GdkWindow*) NULL; if (m_wxwindow) @@ -4015,15 +4021,15 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) // indicate that a new style has been set // but it couldn't get applied as the // widget hasn't been realized yet. - m_delayedBackgroundColour = TRUE; - return TRUE; + m_delayedBackgroundColour = true; + return true; } else { GtkSetBackgroundColour( colour ); } - return TRUE; + return true; } void wxWindowGTK::GtkSetForegroundColour( const wxColour &colour ) @@ -4047,7 +4053,7 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) { // don't leave if the GTK widget has just // been realized - if (!m_delayedForegroundColour) return FALSE; + if (!m_delayedForegroundColour) return false; } GdkWindow *window = (GdkWindow*) NULL; @@ -4061,14 +4067,14 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) // indicate that a new style has been set // but it couldn't get applied as the // widget hasn't been realized yet. - m_delayedForegroundColour = TRUE; + m_delayedForegroundColour = true; } else { GtkSetForegroundColour( colour ); } - return TRUE; + return true; } #ifdef __WXGTK20__ diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 171eecae9d..4b7a6ed8ae 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -3985,13 +3985,19 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour ) wxASSERT( window ); + // This will work around the fact that I don't know what to do to reset to + // theme settings when colour == wxNullColour, GetBackgroundColour will + // fetch the default if needed, giving us a valid colour to use below. + // Vaclav needs to help here to implement the RightThing... + wxColour newColour = GetBackgroundColour(); + // We need the pixel value e.g. for background clearing. - m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); + newColour.CalcPixel( gdk_window_get_colormap( window ) ); if (m_wxwindow) { // wxMSW doesn't clear the window here, either. - gdk_window_set_background( window, m_backgroundColour.GetColor() ); + gdk_window_set_background( window, newColour.GetColor() ); } ApplyWidgetStyle(); @@ -3999,10 +4005,10 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour ) bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) { - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); + wxCHECK_MSG( m_widget != NULL, false, wxT("invalid window") ); if (!wxWindowBase::SetBackgroundColour(colour)) - return FALSE; + return false; GdkWindow *window = (GdkWindow*) NULL; if (m_wxwindow) @@ -4015,15 +4021,15 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) // indicate that a new style has been set // but it couldn't get applied as the // widget hasn't been realized yet. - m_delayedBackgroundColour = TRUE; - return TRUE; + m_delayedBackgroundColour = true; + return true; } else { GtkSetBackgroundColour( colour ); } - return TRUE; + return true; } void wxWindowGTK::GtkSetForegroundColour( const wxColour &colour ) @@ -4047,7 +4053,7 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) { // don't leave if the GTK widget has just // been realized - if (!m_delayedForegroundColour) return FALSE; + if (!m_delayedForegroundColour) return false; } GdkWindow *window = (GdkWindow*) NULL; @@ -4061,14 +4067,14 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) // indicate that a new style has been set // but it couldn't get applied as the // widget hasn't been realized yet. - m_delayedForegroundColour = TRUE; + m_delayedForegroundColour = true; } else { GtkSetForegroundColour( colour ); } - return TRUE; + return true; } #ifdef __WXGTK20__