]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't use the current size in DoGetBestSize() by default.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 5 Oct 2009 22:58:10 +0000 (22:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 5 Oct 2009 22:58:10 +0000 (22:58 +0000)
Doing this means that a window which was made initially large because no other
windows were present or shown will refuse to shrink to make space for them
later even if it doesn't need to be that large. The issue was masked under MSW
and GTK because the first size event under these ports is sent so early that
the top level parent window is not realized yet and has default size of 20*20
pixels meaning that its children will cache their initial (very small) size as
their best size, but it was very visible under OS X where the initial layout
is done using the real top level window size and broke wxInfoBar showing in
the dialogs sample, for example.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62306 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/wincmn.cpp

index 1ffda0d5892066596489dedc47c7cef221c9066a..1a03e224efbbff798ddf748a495f025f410368c9 100644 (file)
@@ -593,19 +593,14 @@ wxSize wxWindowBase::DoGetBestSize() const
     }
     else // ! has children
     {
-        // for a generic window there is no natural best size so, if the
-        // minimal size is not set, use the current size but take care to
-        // remember it as minimal size for the next time because our best size
-        // should be constant: otherwise we could get into a situation when the
-        // window is initially at some size, then expanded to a larger size and
-        // then, when the containing window is shrunk back (because our initial
-        // best size had been used for computing the parent min size), we can't
-        // be shrunk back any more because our best size is now bigger
         wxSize size = GetMinSize();
         if ( !size.IsFullySpecified() )
         {
-            size.SetDefaults(GetSize());
-            wxConstCast(this, wxWindowBase)->SetMinSize(size);
+            // if the window doesn't define its best size we assume that it can
+            // be arbitrarily small -- usually this is not the case, of course,
+            // but we have no way to know what the limit is, it should really
+            // override DoGetBestClientSize() itself to tell us
+            size.SetDefaults(wxSize(1, 1));
         }
 
         // return as-is, unadjusted by the client size difference.