+// NOTE: There is no guarantee that the button drawn fills the entire rect (XP
+// default theme, for example), so the caller should have cleared button's
+// background before this call. This is quite likely a wxMSW-specific thing.
+void
+wxRendererXP::DrawComboBoxDropButton(wxWindow * win,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags)
+{
+ wxUxThemeHandle hTheme(win, L"COMBOBOX");
+ if ( !hTheme )
+ {
+ m_rendererNative.DrawComboBoxDropButton(win, dc, rect, flags);
+ return;
+ }
+
+ wxCHECK_RET( dc.GetImpl(), wxT("Invalid wxDC") );
+
+ wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect);
+
+ RECT r;
+ wxCopyRectToRECT(adjustedRect, r);
+
+ int state;
+ if ( flags & wxCONTROL_PRESSED )
+ state = CBXS_PRESSED;
+ else if ( flags & wxCONTROL_CURRENT )
+ state = CBXS_HOT;
+ else if ( flags & wxCONTROL_DISABLED )
+ state = CBXS_DISABLED;
+ else
+ state = CBXS_NORMAL;
+
+ wxUxThemeEngine::Get()->DrawThemeBackground
+ (
+ hTheme,
+ GetHdcOf(dc.GetTempHDC()),
+ CP_DROPDOWNBUTTON,
+ state,
+ &r,
+ NULL
+ );
+
+}
+
+int
+wxRendererXP::DrawHeaderButton(wxWindow *win,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags,
+ wxHeaderSortIconType sortArrow,
+ wxHeaderButtonParams* params)
+{
+ wxUxThemeHandle hTheme(win, L"HEADER");
+ if ( !hTheme )
+ {
+ return m_rendererNative.DrawHeaderButton(win, dc, rect, flags, sortArrow, params);
+ }
+
+ wxCHECK_MSG( dc.GetImpl(), -1, wxT("Invalid wxDC") );
+
+ wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect);
+
+ RECT r;
+ wxCopyRectToRECT(adjustedRect, r);
+
+ int state;
+ if ( flags & wxCONTROL_PRESSED )
+ state = HIS_PRESSED;
+ else if ( flags & wxCONTROL_CURRENT )
+ state = HIS_HOT;
+ else
+ state = HIS_NORMAL;
+ wxUxThemeEngine::Get()->DrawThemeBackground
+ (
+ hTheme,
+ GetHdcOf(dc.GetTempHDC()),
+ HP_HEADERITEM,
+ state,
+ &r,
+ NULL
+ );
+
+ // NOTE: Using the theme to draw HP_HEADERSORTARROW doesn't do anything.
+ // Why? If this can be fixed then draw the sort arrows using the theme
+ // and then clear those flags before calling DrawHeaderButtonContents.
+
+ // Add any extras that are specified in flags and params
+ return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
+}
+
+
+void
+wxRendererXP::DrawTreeItemButton(wxWindow *win,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags)
+{
+ wxUxThemeHandle hTheme(win, L"TREEVIEW");
+ if ( !hTheme )
+ {
+ m_rendererNative.DrawTreeItemButton(win, dc, rect, flags);
+ return;
+ }
+
+ wxCHECK_RET( dc.GetImpl(), wxT("Invalid wxDC") );
+
+ wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect);
+
+ RECT r;
+ wxCopyRectToRECT(adjustedRect, r);
+
+ int state = flags & wxCONTROL_EXPANDED ? GLPS_OPENED : GLPS_CLOSED;
+ wxUxThemeEngine::Get()->DrawThemeBackground
+ (
+ hTheme,
+ GetHdcOf(dc.GetTempHDC()),
+ TVP_GLYPH,
+ state,
+ &r,
+ NULL
+ );
+}
+
+bool
+wxRendererXP::DoDrawXPButton(int kind,
+ wxWindow *win,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags)
+{
+ wxUxThemeHandle hTheme(win, L"BUTTON");
+ if ( !hTheme )
+ return false;
+
+ DoDrawButtonLike(hTheme, kind, dc, rect, flags);
+
+ return true;
+}
+
+void
+wxRendererXP::DoDrawButtonLike(HTHEME htheme,
+ int part,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags)
+{
+ wxCHECK_RET( dc.GetImpl(), wxT("Invalid wxDC") );
+
+ wxRect adjustedRect = dc.GetImpl()->MSWApplyGDIPlusTransform(rect);
+
+ RECT r;
+ wxCopyRectToRECT(adjustedRect, r);
+
+ // the base state is always 1, whether it is PBS_NORMAL,
+ // {CBS,RBS}_UNCHECKEDNORMAL or CBS_NORMAL
+ int state = 1;
+
+ // XBS_XXX is followed by XBX_XXXHOT, then XBS_XXXPRESSED and DISABLED
+ enum
+ {
+ NORMAL_OFFSET,
+ HOT_OFFSET,
+ PRESSED_OFFSET,
+ DISABLED_OFFSET,
+ STATES_COUNT
+ };
+
+ // in both RBS_ and CBS_ enums CHECKED elements are offset by 4 from base
+ // (UNCHECKED) ones and MIXED are offset by 4 again as there are all states
+ // from the above enum in between them
+ if ( flags & wxCONTROL_CHECKED )
+ state += STATES_COUNT;
+ else if ( flags & wxCONTROL_UNDETERMINED )
+ state += 2*STATES_COUNT;
+
+ if ( flags & wxCONTROL_DISABLED )
+ state += DISABLED_OFFSET;
+ else if ( flags & wxCONTROL_PRESSED )
+ state += PRESSED_OFFSET;
+ else if ( flags & wxCONTROL_CURRENT )
+ state += HOT_OFFSET;
+ // wxCONTROL_ISDEFAULT flag is only valid for push buttons
+ else if ( part == BP_PUSHBUTTON && (flags & wxCONTROL_ISDEFAULT) )
+ state = PBS_DEFAULTED;
+
+ wxUxThemeEngine::Get()->DrawThemeBackground
+ (
+ htheme,
+ GetHdcOf(dc.GetTempHDC()),
+ part,
+ state,
+ &r,
+ NULL
+ );
+}
+
+void
+wxRendererXP::DrawTitleBarBitmap(wxWindow *win,
+ wxDC& dc,
+ const wxRect& rect,
+ wxTitleBarButton button,
+ int flags)
+{
+ wxUxThemeHandle hTheme(win, L"WINDOW");
+ if ( !hTheme )
+ {
+ m_rendererNative.DrawTitleBarBitmap(win, dc, rect, button, flags);
+ return;
+ }
+
+ int part;
+ switch ( button )
+ {
+ case wxTITLEBAR_BUTTON_CLOSE:
+ part = WP_CLOSEBUTTON;
+ break;
+
+ case wxTITLEBAR_BUTTON_MAXIMIZE:
+ part = WP_MAXBUTTON;
+ break;
+
+ case wxTITLEBAR_BUTTON_ICONIZE:
+ part = WP_MINBUTTON;
+ break;
+
+ case wxTITLEBAR_BUTTON_RESTORE:
+ part = WP_RESTOREBUTTON;
+ break;
+
+ case wxTITLEBAR_BUTTON_HELP:
+ part = WP_HELPBUTTON;
+ break;
+
+ default:
+ wxFAIL_MSG( "unsupported title bar button" );
+ return;
+ }
+
+ DoDrawButtonLike(hTheme, part, dc, rect, flags);
+}
+