don't draw borders for bitmap buttons with wxBORDER_NONE style

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-06-18 17:13:51 +00:00
parent b5a5362e55
commit 86ac84b8ce

View File

@@ -601,7 +601,11 @@ wxSize wxButton::DoGetBestSize() const
// account for the user-specified margins // account for the user-specified margins
size += 2*m_imageData->GetBitmapMargins(); size += 2*m_imageData->GetBitmapMargins();
// and also for the margins we always add internally // 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)
if ( !HasFlag(wxBORDER_NONE) )
{
int marginH = 0, int marginH = 0,
marginV = 0; marginV = 0;
#if wxUSE_UXTHEME #if wxUSE_UXTHEME
@@ -611,24 +615,22 @@ wxSize wxButton::DoGetBestSize() const
MARGINS margins; MARGINS margins;
wxUxThemeEngine::Get()->GetThemeMargins(theme, NULL, wxUxThemeEngine::Get()->GetThemeMargins(theme, NULL,
BP_PUSHBUTTON, PBS_NORMAL, BP_PUSHBUTTON,
TMT_CONTENTMARGINS, NULL, PBS_NORMAL,
TMT_CONTENTMARGINS,
NULL,
&margins); &margins);
// XP doesn't draw themed buttons correctly when the client area is // XP doesn't draw themed buttons correctly when the client
// smaller than 8x8 - enforce this minimum size for small bitmaps // area is smaller than 8x8 - enforce this minimum size for
// small bitmaps
size.IncTo(wxSize(8, 8)); size.IncTo(wxSize(8, 8));
// don't add margins for the borderless buttons, they don't need
// them and it just makes them appear larger than needed
if ( !HasFlag(wxBORDER_NONE) )
{
marginH = margins.cxLeftWidth + margins.cxRightWidth marginH = margins.cxLeftWidth + margins.cxRightWidth
+ 2*XP_BUTTON_EXTRA_MARGIN; + 2*XP_BUTTON_EXTRA_MARGIN;
marginV = margins.cyTopHeight + margins.cyBottomHeight marginV = margins.cyTopHeight + margins.cyBottomHeight
+ 2*XP_BUTTON_EXTRA_MARGIN; + 2*XP_BUTTON_EXTRA_MARGIN;
} }
}
else else
#endif // wxUSE_UXTHEME #endif // wxUSE_UXTHEME
{ {
@@ -637,6 +639,7 @@ wxSize wxButton::DoGetBestSize() const
} }
size.IncBy(marginH, marginV); size.IncBy(marginH, marginV);
}
CacheBestSize(size); CacheBestSize(size);
} }
@@ -1263,6 +1266,8 @@ bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis)
CopyRect(&rectBtn, &lpDIS->rcItem); CopyRect(&rectBtn, &lpDIS->rcItem);
// draw the button background // draw the button background
if ( !HasFlag(wxBORDER_NONE) )
{
#if wxUSE_UXTHEME #if wxUSE_UXTHEME
if ( wxUxThemeEngine::GetIfActive() ) if ( wxUxThemeEngine::GetIfActive() )
{ {
@@ -1308,6 +1313,7 @@ bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis)
} }
} }
} }
}
// draw the image, if any // draw the image, if any