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/trunk@78127 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-11-11 01:02:20 +00:00
parent b30f2a8ce6
commit c813c30c34

View File

@ -519,8 +519,9 @@ void wxAnyButton::AdjustForBitmapSize(wxSize &size) const
{ {
wxCHECK_RET( m_imageData, wxT("shouldn't be called if no image") ); wxCHECK_RET( m_imageData, wxT("shouldn't be called if no image") );
// account for the bitmap size // account for the bitmap size, including the user-specified margins
const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize(); const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize()
+ 2*m_imageData->GetBitmapMargins();
const wxDirection dirBmp = m_imageData->GetBitmapPosition(); const wxDirection dirBmp = m_imageData->GetBitmapPosition();
if ( dirBmp == wxLEFT || dirBmp == wxRIGHT ) if ( dirBmp == wxLEFT || dirBmp == wxRIGHT )
{ {
@ -535,9 +536,6 @@ void wxAnyButton::AdjustForBitmapSize(wxSize &size) const
size.x = sizeBmp.x; 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 // 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 // border at all in which case the button has exactly the same size as
// bitmap and so no margins should be used) // bitmap and so no margins should be used)