From: Robin Dunn Date: Tue, 5 Jun 2012 21:26:53 +0000 (+0000) Subject: If there is a sizer then use it's calculated minimum in wxStaticBox::DoGetBestSize X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/d18eb918f447ebb3b9e28154839392fe6b32995a If there is a sizer then use it's calculated minimum in wxStaticBox::DoGetBestSize git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71653 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 784d07481d..c86566cf0b 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -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; }