X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fd20ceff24ca5f002d6424856e9d19f6d9178fb5..77c8efc8c37da6d6a5e2e8022d21d1cd7d76371d:/src/common/wincmn.cpp diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 2921c1f04b..13370f51c6 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -620,20 +620,13 @@ void wxWindowBase::DoCentre(int dir) // fits the window around the children void wxWindowBase::Fit() { - if ( !GetChildren().empty() ) - { - SetSize(GetBestSize()); - } - //else: do nothing if we have no children + SetSize(GetBestSize()); } // fits virtual size (ie. scrolled area etc.) around children void wxWindowBase::FitInside() { - if ( GetChildren().GetCount() > 0 ) - { - SetVirtualSize( GetBestVirtualSize() ); - } + SetVirtualSize( GetBestVirtualSize() ); } // On Mac, scrollbars are explicitly children. @@ -906,14 +899,19 @@ wxSize wxWindowBase::GetBestSize() const // it to be used wxSize size = DoGetBestClientSize(); if ( size != wxDefaultSize ) - { size += DoGetBorderSize(); + else + size = DoGetBestSize(); - CacheBestSize(size); - return size; - } + // Ensure that the best size is at least as large as min size. + size.IncTo(GetMinSize()); - return DoGetBestSize(); + // And not larger than max size. + size.DecToIfSpecified(GetMaxSize()); + + // Finally cache result and return. + CacheBestSize(size); + return size; } int wxWindowBase::GetBestHeight(int width) const @@ -938,12 +936,16 @@ void wxWindowBase::SetMinSize(const wxSize& minSize) { m_minWidth = minSize.x; m_minHeight = minSize.y; + + InvalidateBestSize(); } void wxWindowBase::SetMaxSize(const wxSize& maxSize) { m_maxWidth = maxSize.x; m_maxHeight = maxSize.y; + + InvalidateBestSize(); } void wxWindowBase::SetInitialSize(const wxSize& size) @@ -2747,6 +2749,8 @@ wxSize wxWindowBase::GetDlgUnitBase() const { const wxWindowBase * const parent = wxGetTopLevelParent((wxWindow*)this); + wxCHECK_MSG( parent, wxDefaultSize, wxS("Must have TLW parent") ); + if ( !parent->m_font.IsOk() ) { // Default GUI font is used. This is the most common case, so