X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1b69c815746d9ca7cbfcbe96423e2021ed3fbdb2..207e624382313a5081d4af16dc76778d6cbb03a4:/src/common/wincmn.cpp diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 25a98cc3d2..d15660c398 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -193,7 +193,7 @@ wxWindowBase::wxWindowBase() 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) @@ -222,6 +222,14 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent, 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 @@ -536,7 +544,7 @@ wxSize wxWindowBase::DoGetBestSize() const 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, @@ -583,10 +591,10 @@ wxSize wxWindowBase::DoGetBestSize() const 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(); } } @@ -870,6 +878,31 @@ bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handler) // 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)) {