From aff6c6037d4e22ec766d42db542a72326fedaa60 Mon Sep 17 00:00:00 2001 From: Ron Lee Date: Thu, 7 Nov 2002 08:04:19 +0000 Subject: [PATCH] Added GetAdjustedBestSize which returns the largest of BestSize and any user specified Min size hints. Put it to use with wxADJUST_MINSIZE, which now has a chance of working; a) if the item gets smaller, and b) with controls (like wxButton) for whom BestSize and the user MinSize share only the most tenuous relationship. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17749 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/window.h | 13 ++++++++++++- src/common/sizer.cpp | 13 +++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/wx/window.h b/include/wx/window.h index b65632afad..ff67a3f113 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -271,7 +271,18 @@ public: *h = s.y; } - // the generic centre function - centers the window on parent by + // There are times (and windows) where 'Best' size and 'Min' size + // are vastly out of sync. This should be remedied somehow, but in + // the meantime, this method will return the larger of BestSize + // (the window's smallest legible size), and any user specified + // MinSize hint. + wxSize GetAdjustedBestSize() const + { + wxSize s( DoGetBestSize() ); + return wxSize( wxMax( s.x, GetMinWidth() ), wxMax( s.y, GetMinHeight() ) ); + } + + // the generic centre function - centers the window on parent by` // default or on screen if it doesn't have parent or // wxCENTER_ON_SCREEN flag is given void Centre( int direction = wxBOTH ); diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index d189ba79e4..0e1039a6c2 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -148,14 +148,11 @@ wxSize wxSizerItem::CalcMin() { if ( IsWindow() && (m_flag & wxADJUST_MINSIZE) ) { - // check if the best (minimal, in fact) window size hadn't changed - // by chance: this may happen for, e.g. static text if its label - // changed - wxSize size = m_window->GetBestSize(); - if ( size.x > m_minSize.x ) - m_minSize.x = size.x; - if ( size.y > m_minSize.y ) - m_minSize.y = size.y; + // By user request, keep the minimal size for this item + // in sync with the largest of BestSize and any user supplied + // minimum size hint. Useful in cases where the item is + // changeable -- static text labels, etc. + m_minSize = m_window->GetAdjustedBestSize(); } ret = m_minSize;