Keep the button bitmap centered if the button has no label in wxMSW.

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
This commit is contained in:
Vadim Zeitlin
2010-08-10 18:58:02 +00:00
parent aa83b6fc90
commit 1cd44b9c5f

View 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() )
// move bitmap only if we have a label, otherwise keep it centered
if ( ShowsLabel() )
{
default:
wxFAIL_MSG( "invalid direction" );
// fall through
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 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 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 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;
case wxBOTTOM:
rectBitmap.y = rectButton.GetBottom() - sizeBmp.y - margin.y;
rectButton.height -= sizeBmpWithMargins.y;
break;
}
}
wxDCTemp dst((WXHDC)hdc);