]> git.saurik.com Git - wxWidgets.git/commitdiff
Keep the button bitmap centered if the button has no label in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 10 Aug 2010 18:58:02 +0000 (18:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 10 Aug 2010 18:58:02 +0000 (18:58 +0000)
We should only honour the bitmap alignment if the button shows both the bitmap
and the label. If only the bitmap is shown (e.g. when wxBitmapButton is used),
it should always be centered as it used to be done in 2.8.

Closes #12323.

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

src/msw/button.cpp

index 407981a03a3061dc0a9de3ebc684ed6649df9c2f..0c36af5313baa4144f987eb7e9662dfd67d9bf0f 100644 (file)
@@ -1391,33 +1391,38 @@ bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis)
         // for simplicity, we start with centred rectangle and then move it to
         // the appropriate edge
         wxRect rectBitmap = wxRect(sizeBmp).CentreIn(rectButton);
-        switch ( m_imageData->GetBitmapPosition() )
-        {
-            default:
-                wxFAIL_MSG( "invalid direction" );
-                // fall through
-
-            case wxLEFT:
-                rectBitmap.x = rectButton.x + margin.x;
-                rectButton.x += sizeBmpWithMargins.x;
-                rectButton.width -= sizeBmpWithMargins.x;
-                break;
-
-            case wxRIGHT:
-                rectBitmap.x = rectButton.GetRight() - sizeBmp.x - margin.x;
-                rectButton.width -= sizeBmpWithMargins.x;
-                break;
 
-            case wxTOP:
-                rectBitmap.y = rectButton.y + margin.y;
-                rectButton.y += sizeBmpWithMargins.y;
-                rectButton.height -= sizeBmpWithMargins.y;
-                break;
-
-            case wxBOTTOM:
-                rectBitmap.y = rectButton.GetBottom() - sizeBmp.y - margin.y;
-                rectButton.height -= sizeBmpWithMargins.y;
-                break;
+        // move bitmap only if we have a label, otherwise keep it centered
+        if ( ShowsLabel() )
+        {
+            switch ( m_imageData->GetBitmapPosition() )
+            {
+                default:
+                    wxFAIL_MSG( "invalid direction" );
+                    // fall through
+
+                case wxLEFT:
+                    rectBitmap.x = rectButton.x + margin.x;
+                    rectButton.x += sizeBmpWithMargins.x;
+                    rectButton.width -= sizeBmpWithMargins.x;
+                    break;
+
+                case wxRIGHT:
+                    rectBitmap.x = rectButton.GetRight() - sizeBmp.x - margin.x;
+                    rectButton.width -= sizeBmpWithMargins.x;
+                    break;
+
+                case wxTOP:
+                    rectBitmap.y = rectButton.y + margin.y;
+                    rectButton.y += sizeBmpWithMargins.y;
+                    rectButton.height -= sizeBmpWithMargins.y;
+                    break;
+
+                case wxBOTTOM:
+                    rectBitmap.y = rectButton.GetBottom() - sizeBmp.y - margin.y;
+                    rectButton.height -= sizeBmpWithMargins.y;
+                    break;
+            }
         }
 
         wxDCTemp dst((WXHDC)hdc);