From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Thu, 15 Aug 2002 17:47:13 +0000 (+0000)
Subject: fixed a harmless warning (patch 595096) and added a comment
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1e023926ec5e304729bff81f8650ff82129f338f

fixed a harmless warning (patch 595096) and added a comment


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

diff --git a/src/msw/button.cpp b/src/msw/button.cpp
index 172cf7de5b..6060421549 100644
--- a/src/msw/button.cpp
+++ b/src/msw/button.cpp
@@ -134,29 +134,33 @@ WXDWORD wxButton::MSWGetStyle(long style, WXDWORD *exstyle) const
 
 wxSize wxButton::DoGetBestSize() const
 {
-    wxString label = wxGetWindowText(GetHWND());
     int wBtn;
-    GetTextExtent(label, &wBtn, NULL);
+    GetTextExtent(wxGetWindowText(GetHWND()), &wBtn, NULL);
 
     int wChar, hChar;
     wxGetCharSize(GetHWND(), &wChar, &hChar, &GetFont());
 
-    // add a margin - the button is wider than just its label
+    // add a margin -- the button is wider than just its label
     wBtn += 3*wChar;
 
     // the button height is proportional to the height of the font used
     int hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
 
-    if (!HasFlag(wxBU_EXACTFIT))
+    // 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
+    if ( !HasFlag(wxBU_EXACTFIT) )
     {
         wxSize sz = GetDefaultSize();
-        if (wBtn > sz.x) sz.x = wBtn;
-        if (hBtn > sz.y) sz.y = hBtn;
+        if (wBtn > sz.x)
+            sz.x = wBtn;
+        if (hBtn > sz.y)
+            sz.y = hBtn;
+
         return sz;
     }
-    else
-        return wxSize(wBtn, hBtn);
 
+    return wxSize(wBtn, hBtn);
 }
 
 /* static */