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 )