decoupled attributes inheritance and m_hasXXX flags
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28100 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -725,13 +725,13 @@ public:
|
|||||||
|
|
||||||
// set/retrieve the window colours (system defaults are used by
|
// set/retrieve the window colours (system defaults are used by
|
||||||
// default): SetXXX() functions return true if colour was changed,
|
// default): SetXXX() functions return true if colour was changed,
|
||||||
// SetDefaultXXX() reset the "m_hasXXX" flag after setting the value
|
// SetDefaultXXX() reset the "m_inheritXXX" flag after setting the
|
||||||
// to prevent it from being inherited by our children
|
// value to prevent it from being inherited by our children
|
||||||
virtual bool SetBackgroundColour(const wxColour& colour);
|
virtual bool SetBackgroundColour(const wxColour& colour);
|
||||||
void SetDefaultBackgroundColour(const wxColour& colour)
|
void SetDefaultBackgroundColour(const wxColour& colour)
|
||||||
{
|
{
|
||||||
if ( SetBackgroundColour(colour) )
|
if ( SetBackgroundColour(colour) )
|
||||||
m_hasBgCol = false;
|
m_inheritBgCol = false;
|
||||||
}
|
}
|
||||||
wxColour GetBackgroundColour() const;
|
wxColour GetBackgroundColour() const;
|
||||||
|
|
||||||
@@ -739,7 +739,7 @@ public:
|
|||||||
void SetDefaultForegroundColour(const wxColour& colour)
|
void SetDefaultForegroundColour(const wxColour& colour)
|
||||||
{
|
{
|
||||||
if ( SetForegroundColour(colour) )
|
if ( SetForegroundColour(colour) )
|
||||||
m_hasFgCol = false;
|
m_inheritFgCol = false;
|
||||||
}
|
}
|
||||||
wxColour GetForegroundColour() const;
|
wxColour GetForegroundColour() const;
|
||||||
|
|
||||||
@@ -749,7 +749,7 @@ public:
|
|||||||
void SetDefaultFont(const wxFont& font)
|
void SetDefaultFont(const wxFont& font)
|
||||||
{
|
{
|
||||||
if ( SetFont(font) )
|
if ( SetFont(font) )
|
||||||
m_hasFont = false;
|
m_inheritFont = false;
|
||||||
}
|
}
|
||||||
wxFont GetFont() const;
|
wxFont GetFont() const;
|
||||||
|
|
||||||
@@ -1121,6 +1121,11 @@ protected:
|
|||||||
bool m_hasFgCol:1;
|
bool m_hasFgCol:1;
|
||||||
bool m_hasFont:1;
|
bool m_hasFont:1;
|
||||||
|
|
||||||
|
// and should it be inherited by children?
|
||||||
|
bool m_inheritBgCol:1;
|
||||||
|
bool m_inheritFgCol:1;
|
||||||
|
bool m_inheritFont:1;
|
||||||
|
|
||||||
// window attributes
|
// window attributes
|
||||||
long m_windowStyle,
|
long m_windowStyle,
|
||||||
m_exStyle;
|
m_exStyle;
|
||||||
|
@@ -145,6 +145,9 @@ wxWindowBase::wxWindowBase()
|
|||||||
m_hasBgCol =
|
m_hasBgCol =
|
||||||
m_hasFgCol =
|
m_hasFgCol =
|
||||||
m_hasFont = false;
|
m_hasFont = false;
|
||||||
|
m_inheritBgCol =
|
||||||
|
m_inheritFgCol =
|
||||||
|
m_inheritFont = false;
|
||||||
|
|
||||||
// no style bits
|
// no style bits
|
||||||
m_exStyle =
|
m_exStyle =
|
||||||
@@ -942,17 +945,17 @@ void wxWindowBase::InheritAttributes()
|
|||||||
// which ensures that this only happens if the user really wants it and
|
// which ensures that this only happens if the user really wants it and
|
||||||
// not by default which wouldn't make any sense in modern GUIs where the
|
// not by default which wouldn't make any sense in modern GUIs where the
|
||||||
// controls don't all use the same fonts (nor colours)
|
// controls don't all use the same fonts (nor colours)
|
||||||
if ( parent->m_hasFont && !m_hasFont )
|
if ( parent->m_inheritFont && !m_hasFont )
|
||||||
SetFont(parent->GetFont());
|
SetFont(parent->GetFont());
|
||||||
|
|
||||||
// in addition, there is a possibility to explicitly forbid inheriting
|
// in addition, there is a possibility to explicitly forbid inheriting
|
||||||
// colours at each class level by overriding ShouldInheritColours()
|
// colours at each class level by overriding ShouldInheritColours()
|
||||||
if ( ShouldInheritColours() )
|
if ( ShouldInheritColours() )
|
||||||
{
|
{
|
||||||
if ( parent->m_hasFgCol && !m_hasFgCol )
|
if ( parent->m_inheritFgCol && !m_hasFgCol )
|
||||||
SetForegroundColour(parent->GetForegroundColour());
|
SetForegroundColour(parent->GetForegroundColour());
|
||||||
|
|
||||||
if ( parent->m_hasBgCol && !m_hasBgCol )
|
if ( parent->m_inheritBgCol && !m_hasBgCol )
|
||||||
SetBackgroundColour(parent->GetBackgroundColour());
|
SetBackgroundColour(parent->GetBackgroundColour());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1017,6 +1020,7 @@ bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_hasBgCol = colour.Ok();
|
m_hasBgCol = colour.Ok();
|
||||||
|
m_inheritBgCol = m_hasBgCol;
|
||||||
m_backgroundColour = colour;
|
m_backgroundColour = colour;
|
||||||
SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.Ok() );
|
SetThemeEnabled( !m_hasBgCol && !m_foregroundColour.Ok() );
|
||||||
return true;
|
return true;
|
||||||
@@ -1028,6 +1032,7 @@ bool wxWindowBase::SetForegroundColour( const wxColour &colour )
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_hasFgCol = colour.Ok();
|
m_hasFgCol = colour.Ok();
|
||||||
|
m_inheritFgCol = m_hasFgCol;
|
||||||
m_foregroundColour = colour;
|
m_foregroundColour = colour;
|
||||||
SetThemeEnabled( !m_hasFgCol && !m_backgroundColour.Ok() );
|
SetThemeEnabled( !m_hasFgCol && !m_backgroundColour.Ok() );
|
||||||
return true;
|
return true;
|
||||||
@@ -1075,6 +1080,7 @@ bool wxWindowBase::SetFont(const wxFont& font)
|
|||||||
|
|
||||||
m_font = font;
|
m_font = font;
|
||||||
m_hasFont = font.Ok();
|
m_hasFont = font.Ok();
|
||||||
|
m_inheritFont = m_hasFont;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user