From: Vadim Zeitlin Date: Tue, 5 Feb 2013 20:46:10 +0000 (+0000) Subject: Only impose minimal height for buttons with non-empty label in wxMSW. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f2f18548a7e303fb5edd497884e689b39009985a Only impose minimal height for buttons with non-empty label in wxMSW. wxBU_EXACTFIT in wxMSW only affected the width of the button but not its height, which was still made as big as the standard button size as otherwise the button text was rendered badly. However there is no reason to do this for the buttons without any text, so let wxBU_EXACTFIT be really exact, in both directions, in this case. Also document this rather non obvious wxBU_EXACTFIT behaviour. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73461 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/interface/wx/button.h b/interface/wx/button.h index ae001f3fcc..9be66609d8 100644 --- a/interface/wx/button.h +++ b/interface/wx/button.h @@ -72,8 +72,13 @@ @style{wxBU_BOTTOM} Aligns the label to the bottom of the button. Windows and GTK+ only. @style{wxBU_EXACTFIT} - Creates the button as small as possible instead of making it of the - standard size (which is the default behaviour ). + By default, all buttons are made of at least the standard button size, + even if their contents is small enough to fit into a smaller size. This + is done for consistency as most platforms use buttons of the same size + in the native dialogs, but can be overridden by specifying this flag. + If it is given, the button will be made just big enough for its + contents. Notice that under MSW the button will still have at least the + standard height, even with this style, if it has a non-empty label. @style{wxBU_NOTEXT} Disables the display of the text label in the button even if it has one or its id is one of the standard stock ids with an associated label: diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index 2bf1b41f4c..b8fc1ad197 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -429,27 +429,31 @@ wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size { wxSize sizeBtn(size); - // All buttons have at least the standard height and, unless the user - // explicitly wants them to be as small as possible and used wxBU_EXACTFIT - // style to indicate this, of at least the standard width too. - // - // Notice that we really want to make all buttons equally high, otherwise - // they look ugly and the existing code using wxBU_EXACTFIT only uses it to - // control width and not height. - // The 50x14 button size is documented in the "Recommended sizing and // spacing" section of MSDN layout article. // // Note that we intentionally don't use GetDefaultSize() here, because // it's inexact -- dialog units depend on this dialog's font. const wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14)); - if ( !btn->HasFlag(wxBU_EXACTFIT) ) + + // All buttons should have at least the standard size, unless the user + // explicitly wants them to be as small as possible and used wxBU_EXACTFIT + // style to indicate this. + const bool incToStdSize = !btn->HasFlag(wxBU_EXACTFIT); + if ( incToStdSize ) { if ( sizeBtn.x < sizeDef.x ) sizeBtn.x = sizeDef.x; } - if ( sizeBtn.y < sizeDef.y ) - sizeBtn.y = sizeDef.y; + + // Notice that we really want to make all buttons with text label equally + // high, otherwise they look ugly and the existing code using wxBU_EXACTFIT + // only uses it to control width and not height. + if ( incToStdSize || !btn->GetLabel().empty() ) + { + if ( sizeBtn.y < sizeDef.y ) + sizeBtn.y = sizeDef.y; + } btn->CacheBestSize(sizeBtn);