]> git.saurik.com Git - wxWidgets.git/commitdiff
Set/Reset ThemeEnabled when changing the fore/background colours.
authorRobin Dunn <robin@alldunn.com>
Thu, 17 Jun 2004 21:31:13 +0000 (21:31 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 17 Jun 2004 21:31:13 +0000 (21:31 +0000)
Using wxNullColour will reset to defaults.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27864 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/wincmn.cpp
src/gtk/window.cpp
src/gtk1/window.cpp

index 5ba278de5fcd4b9a3611b4d46c102789ced2455a..26c63a13f5e14b8b6467d134ac3ffbde1ebb551b 100644 (file)
@@ -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;
 }
 
index 171eecae9d13839e1ab4914cdce9b9171ff9df9e..4b7a6ed8ae89345e0d4be812d52d3a1d786ce100 100644 (file)
@@ -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__
index 171eecae9d13839e1ab4914cdce9b9171ff9df9e..4b7a6ed8ae89345e0d4be812d52d3a1d786ce100 100644 (file)
@@ -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__