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:
parent
b5a5362e55
commit
86ac84b8ce
@ -601,42 +601,45 @@ 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
|
||||||
int marginH = 0,
|
// border at all in which case the button has exactly the same size as
|
||||||
marginV = 0;
|
// bitmap and so no margins should be used)
|
||||||
#if wxUSE_UXTHEME
|
if ( !HasFlag(wxBORDER_NONE) )
|
||||||
if ( wxUxThemeEngine::GetIfActive() )
|
|
||||||
{
|
{
|
||||||
wxUxThemeHandle theme(const_cast<wxButton *>(this), L"BUTTON");
|
int marginH = 0,
|
||||||
|
marginV = 0;
|
||||||
MARGINS margins;
|
#if wxUSE_UXTHEME
|
||||||
wxUxThemeEngine::Get()->GetThemeMargins(theme, NULL,
|
if ( wxUxThemeEngine::GetIfActive() )
|
||||||
BP_PUSHBUTTON, PBS_NORMAL,
|
|
||||||
TMT_CONTENTMARGINS, NULL,
|
|
||||||
&margins);
|
|
||||||
|
|
||||||
// XP doesn't draw themed buttons correctly when the client area is
|
|
||||||
// smaller than 8x8 - enforce this minimum size for small bitmaps
|
|
||||||
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) )
|
|
||||||
{
|
{
|
||||||
|
wxUxThemeHandle theme(const_cast<wxButton *>(this), L"BUTTON");
|
||||||
|
|
||||||
|
MARGINS margins;
|
||||||
|
wxUxThemeEngine::Get()->GetThemeMargins(theme, NULL,
|
||||||
|
BP_PUSHBUTTON,
|
||||||
|
PBS_NORMAL,
|
||||||
|
TMT_CONTENTMARGINS,
|
||||||
|
NULL,
|
||||||
|
&margins);
|
||||||
|
|
||||||
|
// XP doesn't draw themed buttons correctly when the client
|
||||||
|
// area is smaller than 8x8 - enforce this minimum size for
|
||||||
|
// small bitmaps
|
||||||
|
size.IncTo(wxSize(8, 8));
|
||||||
|
|
||||||
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
|
||||||
{
|
{
|
||||||
marginH =
|
marginH =
|
||||||
marginV = OD_BUTTON_MARGIN;
|
marginV = OD_BUTTON_MARGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
size.IncBy(marginH, marginV);
|
size.IncBy(marginH, marginV);
|
||||||
|
}
|
||||||
|
|
||||||
CacheBestSize(size);
|
CacheBestSize(size);
|
||||||
}
|
}
|
||||||
@ -1263,48 +1266,51 @@ 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() )
|
||||||
{
|
|
||||||
DrawXPBackground(this, hdc, rectBtn, state);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif // wxUSE_UXTHEME
|
|
||||||
{
|
|
||||||
COLORREF colBg = wxColourToRGB(GetBackgroundColour());
|
|
||||||
|
|
||||||
// first, draw the background
|
|
||||||
AutoHBRUSH hbrushBackground(colBg);
|
|
||||||
FillRect(hdc, &rectBtn, hbrushBackground);
|
|
||||||
|
|
||||||
// draw the border for the current state
|
|
||||||
bool selected = (state & ODS_SELECTED) != 0;
|
|
||||||
if ( !selected )
|
|
||||||
{
|
{
|
||||||
wxTopLevelWindow *
|
DrawXPBackground(this, hdc, rectBtn, state);
|
||||||
tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
|
}
|
||||||
if ( tlw )
|
else
|
||||||
|
#endif // wxUSE_UXTHEME
|
||||||
|
{
|
||||||
|
COLORREF colBg = wxColourToRGB(GetBackgroundColour());
|
||||||
|
|
||||||
|
// first, draw the background
|
||||||
|
AutoHBRUSH hbrushBackground(colBg);
|
||||||
|
FillRect(hdc, &rectBtn, hbrushBackground);
|
||||||
|
|
||||||
|
// draw the border for the current state
|
||||||
|
bool selected = (state & ODS_SELECTED) != 0;
|
||||||
|
if ( !selected )
|
||||||
{
|
{
|
||||||
selected = tlw->GetDefaultItem() == this;
|
wxTopLevelWindow *
|
||||||
|
tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
|
||||||
|
if ( tlw )
|
||||||
|
{
|
||||||
|
selected = tlw->GetDefaultItem() == this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrawButtonFrame(hdc, rectBtn, selected, pushed);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawButtonFrame(hdc, rectBtn, selected, pushed);
|
// draw the focus rectangle if we need it
|
||||||
}
|
if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) )
|
||||||
|
{
|
||||||
// draw the focus rectangle if we need it
|
DrawFocusRect(hdc, &rectBtn);
|
||||||
if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) )
|
|
||||||
{
|
|
||||||
DrawFocusRect(hdc, &rectBtn);
|
|
||||||
|
|
||||||
#if wxUSE_UXTHEME
|
#if wxUSE_UXTHEME
|
||||||
if ( !wxUxThemeEngine::GetIfActive() )
|
if ( !wxUxThemeEngine::GetIfActive() )
|
||||||
#endif // wxUSE_UXTHEME
|
#endif // wxUSE_UXTHEME
|
||||||
{
|
|
||||||
if ( pushed )
|
|
||||||
{
|
{
|
||||||
// the label is shifted by 1 pixel to create "pushed" effect
|
if ( pushed )
|
||||||
OffsetRect(&rectBtn, 1, 1);
|
{
|
||||||
|
// the label is shifted by 1 pixel to create "pushed" effect
|
||||||
|
OffsetRect(&rectBtn, 1, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user