]> git.saurik.com Git - wxWidgets.git/commitdiff
Only use wxBU_EXACTFIT for width calculations in wxMSW wxButton.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 27 Feb 2011 12:45:24 +0000 (12:45 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 27 Feb 2011 12:45:24 +0000 (12:45 +0000)
wxBU_EXACTFIT should affect the width of the button best size but not its
height which should be at least the same as the height of a standard button
even when wxBU_EXACTFIT is specified, otherwise buttons created with it (like
the one in generic wxCollapsiblePane implementation) look completely ugly.

This commit restores the old behaviour which was recently changed by wxButton
sizing code simplifications.

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

src/msw/button.cpp

index 1a9b4d6ca25c7b7c63e31b3a88ac33e17fd44866..e08d58e3be205d021d25665a2bea92486a16f707 100644 (file)
@@ -410,22 +410,27 @@ wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size
 {
     wxSize sizeBtn(size);
 
-    // all buttons have at least the standard size unless the user explicitly
-    // wants them to be of smaller size and used wxBU_EXACTFIT style when
-    // creating the button
+    // 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) )
     {
-        // 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.
-        wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14));
         if ( sizeBtn.x < sizeDef.x )
             sizeBtn.x = sizeDef.x;
-        if ( sizeBtn.y < sizeDef.y )
-            sizeBtn.y = sizeDef.y;
     }
+    if ( sizeBtn.y < sizeDef.y )
+        sizeBtn.y = sizeDef.y;
 
     btn->CacheBestSize(sizeBtn);