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
This commit is contained in:
@@ -1007,25 +1007,23 @@ wxColour wxWindowBase::GetForegroundColour() const
|
|||||||
|
|
||||||
bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
|
bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
|
||||||
{
|
{
|
||||||
if ( !colour.Ok() || (colour == m_backgroundColour) )
|
if ( colour == m_backgroundColour )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
m_hasBgCol = colour.Ok();
|
||||||
m_backgroundColour = colour;
|
m_backgroundColour = colour;
|
||||||
|
SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.Ok() );
|
||||||
m_hasBgCol = true;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowBase::SetForegroundColour( const wxColour &colour )
|
bool wxWindowBase::SetForegroundColour( const wxColour &colour )
|
||||||
{
|
{
|
||||||
if ( !colour.Ok() || (colour == m_foregroundColour) )
|
if (colour == m_foregroundColour )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
m_hasFgCol = colour.Ok();
|
||||||
m_foregroundColour = colour;
|
m_foregroundColour = colour;
|
||||||
|
SetThemeEnabled( !m_hasFgCol && !m_backgroundColour.Ok() );
|
||||||
m_hasFgCol = true;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3985,13 +3985,19 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour )
|
|||||||
|
|
||||||
wxASSERT( window );
|
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.
|
// 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)
|
if (m_wxwindow)
|
||||||
{
|
{
|
||||||
// wxMSW doesn't clear the window here, either.
|
// wxMSW doesn't clear the window here, either.
|
||||||
gdk_window_set_background( window, m_backgroundColour.GetColor() );
|
gdk_window_set_background( window, newColour.GetColor() );
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyWidgetStyle();
|
ApplyWidgetStyle();
|
||||||
@@ -3999,10 +4005,10 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour )
|
|||||||
|
|
||||||
bool wxWindowGTK::SetBackgroundColour( 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))
|
if (!wxWindowBase::SetBackgroundColour(colour))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
GdkWindow *window = (GdkWindow*) NULL;
|
GdkWindow *window = (GdkWindow*) NULL;
|
||||||
if (m_wxwindow)
|
if (m_wxwindow)
|
||||||
@@ -4015,15 +4021,15 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour )
|
|||||||
// indicate that a new style has been set
|
// indicate that a new style has been set
|
||||||
// but it couldn't get applied as the
|
// but it couldn't get applied as the
|
||||||
// widget hasn't been realized yet.
|
// widget hasn't been realized yet.
|
||||||
m_delayedBackgroundColour = TRUE;
|
m_delayedBackgroundColour = true;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkSetBackgroundColour( colour );
|
GtkSetBackgroundColour( colour );
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowGTK::GtkSetForegroundColour( const wxColour &colour )
|
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
|
// don't leave if the GTK widget has just
|
||||||
// been realized
|
// been realized
|
||||||
if (!m_delayedForegroundColour) return FALSE;
|
if (!m_delayedForegroundColour) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkWindow *window = (GdkWindow*) NULL;
|
GdkWindow *window = (GdkWindow*) NULL;
|
||||||
@@ -4061,14 +4067,14 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour )
|
|||||||
// indicate that a new style has been set
|
// indicate that a new style has been set
|
||||||
// but it couldn't get applied as the
|
// but it couldn't get applied as the
|
||||||
// widget hasn't been realized yet.
|
// widget hasn't been realized yet.
|
||||||
m_delayedForegroundColour = TRUE;
|
m_delayedForegroundColour = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkSetForegroundColour( colour );
|
GtkSetForegroundColour( colour );
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
|
@@ -3985,13 +3985,19 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour )
|
|||||||
|
|
||||||
wxASSERT( window );
|
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.
|
// 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)
|
if (m_wxwindow)
|
||||||
{
|
{
|
||||||
// wxMSW doesn't clear the window here, either.
|
// wxMSW doesn't clear the window here, either.
|
||||||
gdk_window_set_background( window, m_backgroundColour.GetColor() );
|
gdk_window_set_background( window, newColour.GetColor() );
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyWidgetStyle();
|
ApplyWidgetStyle();
|
||||||
@@ -3999,10 +4005,10 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour )
|
|||||||
|
|
||||||
bool wxWindowGTK::SetBackgroundColour( 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))
|
if (!wxWindowBase::SetBackgroundColour(colour))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
GdkWindow *window = (GdkWindow*) NULL;
|
GdkWindow *window = (GdkWindow*) NULL;
|
||||||
if (m_wxwindow)
|
if (m_wxwindow)
|
||||||
@@ -4015,15 +4021,15 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour )
|
|||||||
// indicate that a new style has been set
|
// indicate that a new style has been set
|
||||||
// but it couldn't get applied as the
|
// but it couldn't get applied as the
|
||||||
// widget hasn't been realized yet.
|
// widget hasn't been realized yet.
|
||||||
m_delayedBackgroundColour = TRUE;
|
m_delayedBackgroundColour = true;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkSetBackgroundColour( colour );
|
GtkSetBackgroundColour( colour );
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowGTK::GtkSetForegroundColour( const wxColour &colour )
|
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
|
// don't leave if the GTK widget has just
|
||||||
// been realized
|
// been realized
|
||||||
if (!m_delayedForegroundColour) return FALSE;
|
if (!m_delayedForegroundColour) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkWindow *window = (GdkWindow*) NULL;
|
GdkWindow *window = (GdkWindow*) NULL;
|
||||||
@@ -4061,14 +4067,14 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour )
|
|||||||
// indicate that a new style has been set
|
// indicate that a new style has been set
|
||||||
// but it couldn't get applied as the
|
// but it couldn't get applied as the
|
||||||
// widget hasn't been realized yet.
|
// widget hasn't been realized yet.
|
||||||
m_delayedForegroundColour = TRUE;
|
m_delayedForegroundColour = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkSetForegroundColour( colour );
|
GtkSetForegroundColour( colour );
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
|
Reference in New Issue
Block a user