]> git.saurik.com Git - wxWidgets.git/commitdiff
If there is a sizer then use it's calculated minimum in wxStaticBox::DoGetBestSize
authorRobin Dunn <robin@alldunn.com>
Tue, 5 Jun 2012 21:26:53 +0000 (21:26 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 5 Jun 2012 21:26:53 +0000 (21:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71653 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/statbox.cpp

index 784d07481d07136b14adf8b9a307145ab8b8f86f..c86566cf0b701ebb29312b8d3733934afbc2c01c 100644 (file)
@@ -118,6 +118,9 @@ WXDWORD wxStaticBox::MSWGetStyle(long style, WXDWORD *exstyle) const
 
 wxSize wxStaticBox::DoGetBestSize() const
 {
+    wxSize best;
+
+    // Calculate the size needed by the label
     int cx, cy;
     wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
 
@@ -127,8 +130,19 @@ wxSize wxStaticBox::DoGetBestSize() const
     wBox += 3*cx;
     int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
 
-    wxSize best(wBox, hBox);
-    CacheBestSize(best);
+    // If there is a sizer then the base best size is the sizer's minimum
+    if (GetSizer() != NULL)
+    {
+        wxSize cm(GetSizer()->CalcMin());
+        best = ClientToWindowSize(cm);
+        // adjust for a long label if needed
+        best.x = wxMax(best.x, wBox);
+    }
+    // otherwise the best size falls back to the label size
+    else
+    {
+        best = wxSize(wBox, hBox);
+    }
     return best;
 }