1. moved InheritAttributes() from wxControl to wxWindow

2. made it inherit only the attributes explicitly set for the parent
3. "explicitly set" means set with SetXXX(), not newly added SetDefaultXXX()
4. documented InheritAttributes(), ShouldInheritColours() and SetDefaultXXX()


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26670 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-04-08 12:11:22 +00:00
parent 26b6f3d3d8
commit b8e7b6738f
4 changed files with 169 additions and 21 deletions

View File

@@ -888,6 +888,31 @@ bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler)
// colours, fonts &c
// ----------------------------------------------------------------------------
void wxWindowBase::InheritAttributes()
{
const wxWindow * const parent = GetParent();
if ( !parent )
return;
// we only inherit attributes which had been explicitly set for the parent
// 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
// controls don't all use the same fonts (nor colours)
if ( parent->m_hasFont && !m_hasFont )
SetFont(parent->GetFont());
// in addition, there is a possibility to explicitly forbid inheriting
// colours at each class level by overriding ShouldInheritColours()
if ( ShouldInheritColours() )
{
if ( parent->m_hasFgCol && !m_hasFgCol )
SetForegroundColour(parent->GetForegroundColour());
if ( parent->m_hasBgCol && !m_hasBgCol )
SetBackgroundColour(parent->GetBackgroundColour());
}
}
/* static */ wxVisualAttributes
wxWindowBase::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
{