From b185fa1efb96ae3662fa4632a41060bcadb332b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 5 Mar 2008 15:09:16 +0000 Subject: [PATCH] backported wxSizer::SetSizeHints() fix to make it work correctly when the best size decreases git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52332 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/sizer.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index a274b25064..bc90483f12 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -122,6 +122,7 @@ All (GUI): wxRESERVE_SPACE_EVEN_IF_HIDDEN sizer flag. - Added wxWindow::ClientToWindowSize() and WindowToClientSize() helpers. - Added wxSizer::ComputeFittingClientSize() and ComputeFittingWindowSize(). +- Fixed wxSizer::SetSizeHints() to work when the best size decreases. All (Unix): diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index de4b8c3bdb..9b5a6c148f 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -885,12 +885,19 @@ void wxSizer::SetSizeHints( wxWindow *window ) // Preserve the window's max size hints, but set the // lower bound according to the sizer calculations. - wxSize size = Fit( window ); + // This is equivalent to calling Fit(), except that we need to set + // the size hints _in between_ the two steps performed by Fit + // (1. ComputeFittingWindowSize, 2. SetSize). That's because + // otherwise SetSize() could have no effect if there already are + // size hints in effect that forbid requested size. + const wxSize size = ComputeFittingWindowSize(window); window->SetSizeHints( size.x, size.y, window->GetMaxWidth(), window->GetMaxHeight() ); + + window->SetSize(size); } void wxSizer::SetVirtualSizeHints( wxWindow *window )