bool wxWindowBase::CreateBase(wxWindowBase *parent,
wxWindowID id,
const wxPoint& WXUNUSED(pos),
- const wxSize& WXUNUSED(size),
+ const wxSize& size,
long style,
const wxValidator& wxVALIDATOR_PARAM(validator),
const wxString& name)
SetWindowStyleFlag(style);
SetParent(parent);
+ // Set the minsize to be the size passed to the ctor (if any) for
+ // non-TLWs. This is so items used in a sizer will use this explicitly
+ // set size for layout, instead of falling back the (probably smaller)
+ // bestsize.
+ if (! IsTopLevel())
+ SetSizeHints(size);
+
+
#if wxUSE_VALIDATORS
SetValidator(validator);
#endif // wxUSE_VALIDATORS
return wxSize(maxX, maxY);
}
#endif // wxUSE_CONSTRAINTS
- else if ( GetChildren().GetCount() > 0 )
+ else if ( !GetChildren().empty() )
{
// our minimal acceptable size is such that all our windows fit inside
int maxX = 0,
return wxSize(maxX, maxY);
}
- else
+ else // has children
{
// for a generic window there is no natural best size - just use the
- // current one
+ // current size
return GetSize();
}
}
// colours, fonts &c
// ----------------------------------------------------------------------------
+void wxWindowBase::InheritAttributes()
+{
+ const wxWindowBase * 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))
{