+
+bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis)
+{
+ LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis;
+
+ RECT rectBtn;
+ CopyRect(&rectBtn, &lpDIS->rcItem);
+
+ COLORREF colBg = wxColourToRGB(GetBackgroundColour()),
+ colFg = wxColourToRGB(GetForegroundColour());
+
+ HDC hdc = lpDIS->hDC;
+ UINT state = lpDIS->itemState;
+
+ // first, draw the background
+ HBRUSH hbrushBackground = ::CreateSolidBrush(colBg);
+
+ FillRect(hdc, &rectBtn, hbrushBackground);
+
+ // draw the border for the current state
+ bool selected = (state & ODS_SELECTED) != 0;
+ if ( !selected )
+ {
+ wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
+ if ( panel )
+ {
+ selected = panel->GetDefaultItem() == this;
+ }
+ }
+ bool pushed = (SendMessage(GetHwnd(), BM_GETSTATE, 0, 0) & BST_PUSHED) != 0;
+
+ DrawButtonFrame(hdc, rectBtn, selected, pushed);
+
+ // draw the focus rect if needed
+ if ( state & ODS_FOCUS )
+ {
+ 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);
+ }
+
+ DrawButtonText(hdc, &rectBtn, GetLabel(),
+ state & ODS_DISABLED ? GetSysColor(COLOR_GRAYTEXT)
+ : colFg);
+
+ ::DeleteObject(hbrushBackground);
+
+ return TRUE;
+}
+
+#endif // __WIN32__
+
+#endif // wxUSE_BUTTON
+