From b3dc6b7ba21627ecd34828e2d8352566628e7998 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 11 Nov 2014 00:58:58 +0000 Subject: [PATCH] Fix best size calculation for buttons with bitmaps in wxMSW. Add the bitmap margins to the bitmap size, not the total button size. This fixes the buttons becoming unnecessarily tall as soon as they were assigned even a tiny bitmap. Closes #16536. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@78118 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/anybutton.cpp | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f2b0cd09c1..b7880e5327 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -591,6 +591,7 @@ wxMSW: - Fix compilation with C++Builder XE compiler (Nichka). - Fix best height of wxSlider with labels but without ticks (Artur Wieczorek). - Fix initial text value of wxSpinCtrlDouble (Laurent Poujoulat). +- Fix best size calculation for bitmaps with buttons (Artur Wieczorek). 3.0.2: (released 2014-10-06) diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index b5d6dc84c0..2ee28d1e57 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -519,8 +519,9 @@ void wxAnyButton::AdjustForBitmapSize(wxSize &size) const { wxCHECK_RET( m_imageData, wxT("shouldn't be called if no image") ); - // account for the bitmap size - const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize(); + // account for the bitmap size, including the user-specified margins + const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize() + + 2*m_imageData->GetBitmapMargins(); const wxDirection dirBmp = m_imageData->GetBitmapPosition(); if ( dirBmp == wxLEFT || dirBmp == wxRIGHT ) { @@ -535,9 +536,6 @@ void wxAnyButton::AdjustForBitmapSize(wxSize &size) const size.x = sizeBmp.x; } - // account for the user-specified margins - size += 2*m_imageData->GetBitmapMargins(); - // and also for the margins we always add internally (unless we have no // border at all in which case the button has exactly the same size as // bitmap and so no margins should be used)