- iState = PBS_PRESSED;
- }
- else if ( button->HasCapture() || button->IsMouseInWindow() )
- {
- iState = PBS_HOT;
- }
- else if ( state & ODS_FOCUS )
- {
- iState = PBS_DEFAULTED;
- }
- else if ( state & ODS_DISABLED )
- {
- iState = PBS_DISABLED;
- }
- else
- {
- iState = PBS_NORMAL;
- }
-
- // draw parent background if needed
- if ( wxUxThemeEngine::Get()->IsThemeBackgroundPartiallyTransparent(theme,
- BP_PUSHBUTTON,
- iState) )
- {
- wxUxThemeEngine::Get()->DrawThemeParentBackground(GetHwndOf(button), hdc, &rectBtn);
- }
-
- // draw background
- wxUxThemeEngine::Get()->DrawThemeBackground(theme, hdc, BP_PUSHBUTTON, iState,
- &rectBtn, NULL);
-
- // calculate content area margins
- MARGINS margins;
- wxUxThemeEngine::Get()->GetThemeMargins(theme, hdc, BP_PUSHBUTTON, iState,
- TMT_CONTENTMARGINS, &rectBtn, &margins);
- RECT rectClient;
- ::CopyRect(&rectClient, &rectBtn);
- ::InflateRect(&rectClient, -margins.cxLeftWidth, -margins.cyTopHeight);
-
- // if focused and !nofocus rect
- if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) )
- {
- DrawFocusRect(hdc, &rectClient);
- }
-
- if ( button->UseBgCol() )
- {
- COLORREF colBg = wxColourToRGB(button->GetBackgroundColour());
- HBRUSH hbrushBackground = ::CreateSolidBrush(colBg);
-
- // don't overwrite the focus rect
- ::InflateRect(&rectClient, -1, -1);
- FillRect(hdc, &rectClient, hbrushBackground);
- ::DeleteObject(hbrushBackground);
- }
-}
-#endif // wxUSE_UXTHEME
-
-bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis)
-{
- LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis;
- HDC hdc = lpDIS->hDC;
- UINT state = lpDIS->itemState;
- RECT rectBtn;
- CopyRect(&rectBtn, &lpDIS->rcItem);
-
-#if wxUSE_UXTHEME
- if ( wxUxThemeEngine::GetIfActive() )
- {
- MSWDrawXPBackground(this, wxdis);
- }
- else
-#endif // wxUSE_UXTHEME
- {
- COLORREF colBg = wxColourToRGB(GetBackgroundColour());
-
- // first, draw the background
- HBRUSH hbrushBackground = ::CreateSolidBrush(colBg);
- FillRect(hdc, &rectBtn, hbrushBackground);
- ::DeleteObject(hbrushBackground);
-
- // draw the border for the current state
- bool selected = (state & ODS_SELECTED) != 0;
- if ( !selected )
- {
- wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
- if ( tlw )
- {
- selected = tlw->GetDefaultItem() == this;
- }
- }
- bool pushed = (SendMessage(GetHwnd(), BM_GETSTATE, 0, 0) & BST_PUSHED) != 0;
-
- DrawButtonFrame(hdc, rectBtn, selected, pushed);
-
- // if focused and !nofocus rect
- if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) )
- {
- RECT rectFocus;
- CopyRect(&rectFocus, &rectBtn);
-
- // I don't know where does this constant come from, but this is how
- // Windows draws them
- InflateRect(&rectFocus, -4, -4);
-
- DrawFocusRect(hdc, &rectFocus);
- }
-
- if ( pushed )
- {
- // the label is shifted by 1 pixel to create "pushed" effect
- OffsetRect(&rectBtn, 1, 1);
- }