Implement wxRenderer::DrawRadioBitmap() for classic MSW renderer.
[wxWidgets.git] / src / msw / renderer.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/renderer.cpp
3 // Purpose: implementation of wxRendererNative for Windows
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 20.07.2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #ifndef WX_PRECOMP
28 #include "wx/string.h"
29 #include "wx/window.h"
30 #include "wx/dc.h"
31 #include "wx/settings.h"
32 #endif //WX_PRECOMP
33
34 #include "wx/scopeguard.h"
35 #include "wx/splitter.h"
36 #include "wx/renderer.h"
37 #include "wx/msw/private.h"
38 #include "wx/msw/dc.h"
39 #include "wx/msw/uxtheme.h"
40
41 #if wxUSE_GRAPHICS_CONTEXT
42 // TODO remove this dependency (gdiplus needs the macros)
43 #ifndef max
44 #define max(a,b) (((a) > (b)) ? (a) : (b))
45 #endif
46
47 #ifndef min
48 #define min(a,b) (((a) < (b)) ? (a) : (b))
49 #endif
50
51 #include "wx/dcgraph.h"
52 #include "gdiplus.h"
53 using namespace Gdiplus;
54 #endif // wxUSE_GRAPHICS_CONTEXT
55
56 // tmschema.h is in Win32 Platform SDK and might not be available with earlier
57 // compilers
58 #ifndef CP_DROPDOWNBUTTON
59 #define BP_PUSHBUTTON 1
60 #define BP_RADIOBUTTON 2
61 #define BP_CHECKBOX 3
62 #define RBS_UNCHECKEDNORMAL 1
63 #define RBS_CHECKEDNORMAL (RBS_UNCHECKEDNORMAL + 4)
64 #define RBS_MIXEDNORMAL (RBS_CHECKEDNORMAL + 4)
65 #define CBS_UNCHECKEDNORMAL 1
66 #define CBS_CHECKEDNORMAL (CBS_UNCHECKEDNORMAL + 4)
67 #define CBS_MIXEDNORMAL (CBS_CHECKEDNORMAL + 4)
68
69 #define PBS_NORMAL 1
70 #define PBS_HOT 2
71 #define PBS_PRESSED 3
72 #define PBS_DISABLED 4
73 #define PBS_DEFAULTED 5
74
75 #define CP_DROPDOWNBUTTON 1
76
77 #define CBXS_NORMAL 1
78 #define CBXS_HOT 2
79 #define CBXS_PRESSED 3
80 #define CBXS_DISABLED 4
81
82 #define TVP_GLYPH 2
83
84 #define GLPS_CLOSED 1
85 #define GLPS_OPENED 2
86
87 #define HP_HEADERITEM 1
88
89 #define HIS_NORMAL 1
90 #define HIS_HOT 2
91 #define HIS_PRESSED 3
92
93 #define TMT_HEIGHT 2417
94
95 #define HP_HEADERSORTARROW 4
96 #define HSAS_SORTEDUP 1
97 #define HSAS_SORTEDDOWN 2
98
99 #define EP_EDITTEXT 1
100 #define ETS_NORMAL 1
101 #define ETS_HOT 2
102 #define ETS_SELECTED 3
103 #define ETS_DISABLED 4
104 #define ETS_FOCUSED 5
105 #define ETS_READONLY 6
106 #define ETS_ASSIST 7
107 #define TMT_FILLCOLOR 3802
108 #define TMT_TEXTCOLOR 3803
109 #define TMT_BORDERCOLOR 3801
110 #define TMT_EDGEFILLCOLOR 3808
111 #endif
112
113
114 // ----------------------------------------------------------------------------
115 // If the DC is a wxGCDC then pull out the HDC from the GraphicsContext when
116 // it is needed, and handle the Release when done.
117
118 class GraphicsHDC
119 {
120 public:
121 GraphicsHDC(wxDC* dc)
122 {
123 #if wxUSE_GRAPHICS_CONTEXT
124 m_graphics = NULL;
125 wxGCDC* gcdc = wxDynamicCast(dc, wxGCDC);
126 if (gcdc) {
127 m_graphics = (Graphics*)gcdc->GetGraphicsContext()->GetNativeContext();
128 m_hdc = m_graphics->GetHDC();
129 }
130 else
131 #endif
132 m_hdc = GetHdcOf(*((wxMSWDCImpl*)dc->GetImpl()));
133 }
134
135 ~GraphicsHDC()
136 {
137 #if wxUSE_GRAPHICS_CONTEXT
138 if (m_graphics)
139 m_graphics->ReleaseHDC(m_hdc);
140 #endif
141 }
142
143 operator HDC() const { return m_hdc; }
144
145 private:
146 HDC m_hdc;
147 #if wxUSE_GRAPHICS_CONTEXT
148 Graphics* m_graphics;
149 #endif
150 };
151
152 #if defined(__WXWINCE__)
153 #ifndef DFCS_FLAT
154 #define DFCS_FLAT 0
155 #endif
156 #ifndef DFCS_MONO
157 #define DFCS_MONO 0
158 #endif
159 #endif
160
161 #ifndef DFCS_HOT
162 #define DFCS_HOT 0x1000
163 #endif
164
165 // ----------------------------------------------------------------------------
166 // methods common to wxRendererMSW and wxRendererXP
167 // ----------------------------------------------------------------------------
168
169 class wxRendererMSWBase : public wxDelegateRendererNative
170 {
171 public:
172 wxRendererMSWBase() { }
173 wxRendererMSWBase(wxRendererNative& rendererNative)
174 : wxDelegateRendererNative(rendererNative) { }
175
176 void DrawFocusRect(wxWindow * win,
177 wxDC& dc,
178 const wxRect& rect,
179 int flags = 0);
180
181 void DrawItemSelectionRect(wxWindow *win,
182 wxDC& dc,
183 const wxRect& rect,
184 int flags = 0);
185 };
186
187 // ----------------------------------------------------------------------------
188 // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
189 // ----------------------------------------------------------------------------
190
191 class wxRendererMSW : public wxRendererMSWBase
192 {
193 public:
194 wxRendererMSW() { }
195
196 static wxRendererNative& Get();
197
198 virtual void DrawComboBoxDropButton(wxWindow *win,
199 wxDC& dc,
200 const wxRect& rect,
201 int flags = 0);
202
203 virtual void DrawCheckBox(wxWindow *win,
204 wxDC& dc,
205 const wxRect& rect,
206 int flags = 0)
207 {
208 DoDrawButton(DFCS_BUTTONCHECK, win, dc, rect, flags);
209 }
210
211 virtual void DrawPushButton(wxWindow *win,
212 wxDC& dc,
213 const wxRect& rect,
214 int flags = 0);
215
216 virtual void DrawChoice(wxWindow* win,
217 wxDC& dc,
218 const wxRect& rect,
219 int flags = 0);
220
221 virtual void DrawComboBox(wxWindow* win,
222 wxDC& dc,
223 const wxRect& rect,
224 int flags = 0);
225
226 virtual void DrawTextCtrl(wxWindow* win,
227 wxDC& dc,
228 const wxRect& rect,
229 int flags = 0);
230
231 virtual void DrawRadioBitmap(wxWindow* win,
232 wxDC& dc,
233 const wxRect& rect,
234 int flags = 0)
235 {
236 DoDrawButton(DFCS_BUTTONRADIO, win, dc, rect, flags);
237 }
238
239 virtual wxSize GetCheckBoxSize(wxWindow *win);
240
241 virtual int GetHeaderButtonHeight(wxWindow *win);
242
243 private:
244 // common part of Draw{PushButton,CheckBox,RadioBitmap}(): wraps
245 // DrawFrameControl(DFC_BUTTON)
246 void DoDrawButton(UINT kind,
247 wxWindow *win,
248 wxDC& dc,
249 const wxRect& rect,
250 int flags);
251
252 wxDECLARE_NO_COPY_CLASS(wxRendererMSW);
253 };
254
255 // ----------------------------------------------------------------------------
256 // wxRendererXP: wxRendererNative implementation for Windows XP and later
257 // ----------------------------------------------------------------------------
258
259 #if wxUSE_UXTHEME
260
261 class wxRendererXP : public wxRendererMSWBase
262 {
263 public:
264 wxRendererXP() : wxRendererMSWBase(wxRendererMSW::Get()) { }
265
266 static wxRendererNative& Get();
267
268 virtual int DrawHeaderButton(wxWindow *win,
269 wxDC& dc,
270 const wxRect& rect,
271 int flags = 0,
272 wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
273 wxHeaderButtonParams* params = NULL);
274
275 virtual void DrawTreeItemButton(wxWindow *win,
276 wxDC& dc,
277 const wxRect& rect,
278 int flags = 0);
279 virtual void DrawSplitterBorder(wxWindow *win,
280 wxDC& dc,
281 const wxRect& rect,
282 int flags = 0);
283 virtual void DrawSplitterSash(wxWindow *win,
284 wxDC& dc,
285 const wxSize& size,
286 wxCoord position,
287 wxOrientation orient,
288 int flags = 0);
289 virtual void DrawComboBoxDropButton(wxWindow *win,
290 wxDC& dc,
291 const wxRect& rect,
292 int flags = 0);
293 virtual void DrawCheckBox(wxWindow *win,
294 wxDC& dc,
295 const wxRect& rect,
296 int flags = 0);
297
298 virtual void DrawPushButton(wxWindow *win,
299 wxDC& dc,
300 const wxRect& rect,
301 int flags = 0);
302
303 virtual void DrawRadioBitmap(wxWindow *win,
304 wxDC& dc,
305 const wxRect& rect,
306 int flags = 0);
307
308 virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
309
310 private:
311 wxDECLARE_NO_COPY_CLASS(wxRendererXP);
312 };
313
314 #endif // wxUSE_UXTHEME
315
316
317 // ============================================================================
318 // wxRendererMSWBase implementation
319 // ============================================================================
320
321 void wxRendererMSWBase::DrawFocusRect(wxWindow * WXUNUSED(win),
322 wxDC& dc,
323 const wxRect& rect,
324 int WXUNUSED(flags))
325 {
326 RECT rc;
327 wxCopyRectToRECT(rect, rc);
328
329 ::DrawFocusRect(GraphicsHDC(&dc), &rc);
330 }
331
332 void wxRendererMSWBase::DrawItemSelectionRect(wxWindow *win,
333 wxDC& dc,
334 const wxRect& rect,
335 int flags)
336 {
337 wxBrush brush;
338 if ( flags & wxCONTROL_SELECTED )
339 {
340 if ( flags & wxCONTROL_FOCUSED )
341 {
342 brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
343 }
344 else // !focused
345 {
346 brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
347 }
348 }
349 else // !selected
350 {
351 brush = *wxTRANSPARENT_BRUSH;
352 }
353
354 dc.SetBrush(brush);
355 dc.SetPen(*wxTRANSPARENT_PEN);
356 dc.DrawRectangle( rect );
357
358 if ((flags & wxCONTROL_FOCUSED) && (flags & wxCONTROL_CURRENT))
359 DrawFocusRect( win, dc, rect, flags );
360 }
361
362
363 // ============================================================================
364 // wxRendererNative and wxRendererMSW implementation
365 // ============================================================================
366
367 /* static */
368 wxRendererNative& wxRendererNative::GetDefault()
369 {
370 #if wxUSE_UXTHEME
371 wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get();
372 if ( themeEngine && themeEngine->IsAppThemed() )
373 return wxRendererXP::Get();
374 #endif // wxUSE_UXTHEME
375
376 return wxRendererMSW::Get();
377 }
378
379 /* static */
380 wxRendererNative& wxRendererMSW::Get()
381 {
382 static wxRendererMSW s_rendererMSW;
383
384 return s_rendererMSW;
385 }
386
387 void
388 wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win),
389 wxDC& dc,
390 const wxRect& rect,
391 int flags)
392 {
393 RECT r;
394 wxCopyRectToRECT(rect, r);
395
396 int style = DFCS_SCROLLCOMBOBOX;
397 if ( flags & wxCONTROL_DISABLED )
398 style |= DFCS_INACTIVE;
399 if ( flags & wxCONTROL_PRESSED )
400 style |= DFCS_PUSHED | DFCS_FLAT;
401
402 ::DrawFrameControl(GraphicsHDC(&dc), &r, DFC_SCROLL, style);
403 }
404
405 void
406 wxRendererMSW::DoDrawButton(UINT kind,
407 wxWindow * WXUNUSED(win),
408 wxDC& dc,
409 const wxRect& rect,
410 int flags)
411 {
412 RECT r;
413 wxCopyRectToRECT(rect, r);
414
415 int style = kind;
416 if ( flags & wxCONTROL_CHECKED )
417 style |= DFCS_CHECKED;
418 if ( flags & wxCONTROL_DISABLED )
419 style |= DFCS_INACTIVE;
420 if ( flags & wxCONTROL_FLAT )
421 style |= DFCS_MONO;
422 if ( flags & wxCONTROL_PRESSED )
423 style |= DFCS_PUSHED;
424 if ( flags & wxCONTROL_CURRENT )
425 style |= DFCS_HOT;
426
427 ::DrawFrameControl(GraphicsHDC(&dc), &r, DFC_BUTTON, style);
428 }
429
430 void
431 wxRendererMSW::DrawPushButton(wxWindow *win,
432 wxDC& dc,
433 const wxRect& rectOrig,
434 int flags)
435 {
436 wxRect rect(rectOrig);
437 if ( flags & wxCONTROL_ISDEFAULT )
438 {
439 // DrawFrameControl() doesn't seem to support default buttons so we
440 // have to draw the border ourselves
441 wxDCPenChanger pen(dc, *wxBLACK_PEN);
442 wxDCBrushChanger brush(dc, *wxTRANSPARENT_BRUSH);
443 dc.DrawRectangle(rect);
444 rect.Deflate(1);
445 }
446
447 DoDrawButton(DFCS_BUTTONPUSH, win, dc, rect, flags);
448 }
449
450 wxSize wxRendererMSW::GetCheckBoxSize(wxWindow * WXUNUSED(win))
451 {
452 return wxSize(::GetSystemMetrics(SM_CXMENUCHECK),
453 ::GetSystemMetrics(SM_CYMENUCHECK));
454 }
455
456 int wxRendererMSW::GetHeaderButtonHeight(wxWindow * WXUNUSED(win))
457 {
458 // some "reasonable" value returned in case of error, it doesn't really
459 // correspond to anything but it's better than returning 0
460 static const int DEFAULT_HEIGHT = 20;
461
462
463 // create a temporary header window just to get its geometry
464 HWND hwndHeader = ::CreateWindow(WC_HEADER, NULL, 0,
465 0, 0, 0, 0, NULL, NULL, NULL, NULL);
466 if ( !hwndHeader )
467 return DEFAULT_HEIGHT;
468
469 wxON_BLOCK_EXIT1( ::DestroyWindow, hwndHeader );
470
471 // initialize the struct filled with the values by Header_Layout()
472 RECT parentRect = { 0, 0, 100, 100 };
473 WINDOWPOS wp = { 0, 0, 0, 0, 0, 0, 0 };
474 HDLAYOUT hdl = { &parentRect, &wp };
475
476 return Header_Layout(hwndHeader, &hdl) ? wp.cy : DEFAULT_HEIGHT;
477 }
478
479 // Uses the theme to draw the border and fill for something like a wxTextCtrl
480 void wxRendererMSW::DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
481 {
482 wxColour fill;
483 wxColour bdr;
484 COLORREF cref;
485
486 #if wxUSE_UXTHEME
487 wxUxThemeHandle hTheme(win, L"EDIT");
488 if (hTheme)
489 {
490 wxUxThemeEngine::Get()->GetThemeColor(hTheme, EP_EDITTEXT,
491 ETS_NORMAL, TMT_FILLCOLOR, &cref);
492 fill = wxRGBToColour(cref);
493
494 int etsState;
495 if ( flags & wxCONTROL_DISABLED )
496 etsState = ETS_DISABLED;
497 else
498 etsState = ETS_NORMAL;
499
500 wxUxThemeEngine::Get()->GetThemeColor(hTheme, EP_EDITTEXT,
501 etsState, TMT_BORDERCOLOR, &cref);
502 bdr = wxRGBToColour(cref);
503 }
504 else
505 #endif
506 {
507 fill = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
508 bdr = *wxBLACK;
509 }
510
511 dc.SetPen( bdr );
512 dc.SetBrush( fill );
513 dc.DrawRectangle(rect);
514 }
515
516
517 // Draw the equivalent of a wxComboBox
518 void wxRendererMSW::DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
519 {
520 // Draw the main part of the control same as TextCtrl
521 DrawTextCtrl(win, dc, rect, flags);
522
523 // Draw the button inside the border, on the right side
524 wxRect br(rect);
525 br.height -= 2;
526 br.x += br.width - br.height - 1;
527 br.width = br.height;
528 br.y += 1;
529
530 DrawComboBoxDropButton(win, dc, br, flags);
531 }
532
533
534 void wxRendererMSW::DrawChoice(wxWindow* win, wxDC& dc,
535 const wxRect& rect, int flags)
536 {
537 DrawComboBox(win, dc, rect, flags);
538 }
539
540 // ============================================================================
541 // wxRendererXP implementation
542 // ============================================================================
543
544 #if wxUSE_UXTHEME
545
546 /* static */
547 wxRendererNative& wxRendererXP::Get()
548 {
549 static wxRendererXP s_rendererXP;
550
551 return s_rendererXP;
552 }
553
554 // NOTE: There is no guarantee that the button drawn fills the entire rect (XP
555 // default theme, for example), so the caller should have cleared button's
556 // background before this call. This is quite likely a wxMSW-specific thing.
557 void
558 wxRendererXP::DrawComboBoxDropButton(wxWindow * win,
559 wxDC& dc,
560 const wxRect& rect,
561 int flags)
562 {
563 wxUxThemeHandle hTheme(win, L"COMBOBOX");
564 if ( !hTheme )
565 {
566 m_rendererNative.DrawComboBoxDropButton(win, dc, rect, flags);
567 return;
568 }
569
570 RECT r;
571 wxCopyRectToRECT(rect, r);
572
573 int state;
574 if ( flags & wxCONTROL_PRESSED )
575 state = CBXS_PRESSED;
576 else if ( flags & wxCONTROL_CURRENT )
577 state = CBXS_HOT;
578 else if ( flags & wxCONTROL_DISABLED )
579 state = CBXS_DISABLED;
580 else
581 state = CBXS_NORMAL;
582
583 wxUxThemeEngine::Get()->DrawThemeBackground
584 (
585 hTheme,
586 GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())),
587 CP_DROPDOWNBUTTON,
588 state,
589 &r,
590 NULL
591 );
592
593 }
594
595 int
596 wxRendererXP::DrawHeaderButton(wxWindow *win,
597 wxDC& dc,
598 const wxRect& rect,
599 int flags,
600 wxHeaderSortIconType sortArrow,
601 wxHeaderButtonParams* params)
602 {
603 wxUxThemeHandle hTheme(win, L"HEADER");
604 if ( !hTheme )
605 {
606 return m_rendererNative.DrawHeaderButton(win, dc, rect, flags, sortArrow, params);
607 }
608
609 RECT r;
610 wxCopyRectToRECT(rect, r);
611
612 int state;
613 if ( flags & wxCONTROL_PRESSED )
614 state = HIS_PRESSED;
615 else if ( flags & wxCONTROL_CURRENT )
616 state = HIS_HOT;
617 else
618 state = HIS_NORMAL;
619 wxUxThemeEngine::Get()->DrawThemeBackground
620 (
621 hTheme,
622 GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())),
623 HP_HEADERITEM,
624 state,
625 &r,
626 NULL
627 );
628
629 // NOTE: Using the theme to draw HP_HEADERSORTARROW doesn't do anything.
630 // Why? If this can be fixed then draw the sort arrows using the theme
631 // and then clear those flags before calling DrawHeaderButtonContents.
632
633 // Add any extras that are specified in flags and params
634 return DrawHeaderButtonContents(win, dc, rect, flags, sortArrow, params);
635 }
636
637
638 void
639 wxRendererXP::DrawTreeItemButton(wxWindow *win,
640 wxDC& dc,
641 const wxRect& rect,
642 int flags)
643 {
644 wxUxThemeHandle hTheme(win, L"TREEVIEW");
645 if ( !hTheme )
646 {
647 m_rendererNative.DrawTreeItemButton(win, dc, rect, flags);
648 return;
649 }
650
651 RECT r;
652 wxCopyRectToRECT(rect, r);
653
654 int state = flags & wxCONTROL_EXPANDED ? GLPS_OPENED : GLPS_CLOSED;
655 wxUxThemeEngine::Get()->DrawThemeBackground
656 (
657 hTheme,
658 GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())),
659 TVP_GLYPH,
660 state,
661 &r,
662 NULL
663 );
664 }
665
666 void
667 wxRendererXP::DrawCheckBox(wxWindow *win,
668 wxDC& dc,
669 const wxRect& rect,
670 int flags)
671 {
672 wxUxThemeHandle hTheme(win, L"BUTTON");
673 if ( !hTheme )
674 {
675 m_rendererNative.DrawCheckBox(win, dc, rect, flags);
676 return;
677 }
678
679 RECT r;
680 wxCopyRectToRECT(rect, r);
681
682 int state;
683 if ( flags & wxCONTROL_CHECKED )
684 state = CBS_CHECKEDNORMAL;
685 else if ( flags & wxCONTROL_UNDETERMINED )
686 state = CBS_MIXEDNORMAL;
687 else
688 state = CBS_UNCHECKEDNORMAL;
689
690 // CBS_XXX is followed by CBX_XXXHOT, then CBS_XXXPRESSED and DISABLED
691 enum
692 {
693 CBS_HOT_OFFSET = 1,
694 CBS_PRESSED_OFFSET = 2,
695 CBS_DISABLED_OFFSET = 3
696 };
697
698 if ( flags & wxCONTROL_DISABLED )
699 state += CBS_DISABLED_OFFSET;
700 else if ( flags & wxCONTROL_PRESSED )
701 state += CBS_PRESSED_OFFSET;
702 else if ( flags & wxCONTROL_CURRENT )
703 state += CBS_HOT_OFFSET;
704
705 wxUxThemeEngine::Get()->DrawThemeBackground
706 (
707 hTheme,
708 GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())),
709 BP_CHECKBOX,
710 state,
711 &r,
712 NULL
713 );
714 }
715
716 void wxRendererXP::DrawRadioBitmap(wxWindow* win,
717 wxDC& dc,
718 const wxRect& rect,
719 int flags)
720 {
721 wxUxThemeHandle hTheme(win, L"BUTTON");
722 if ( !hTheme )
723 {
724 m_rendererNative.DrawRadioBitmap(win, dc, rect, flags);
725 return;
726 }
727
728 RECT r;
729 wxCopyRectToRECT(rect, r);
730
731 int state;
732 if ( flags & wxCONTROL_CHECKED )
733 state = RBS_CHECKEDNORMAL;
734 else if ( flags & wxCONTROL_UNDETERMINED )
735 state = RBS_MIXEDNORMAL;
736 else
737 state = RBS_UNCHECKEDNORMAL;
738
739 // RBS_XXX is followed by RBX_XXXGOT, then RBS_XXXPRESSED and DISABLED
740 if ( flags & wxCONTROL_CURRENT )
741 state += 1;
742 else if ( flags & wxCONTROL_PRESSED )
743 state += 2;
744 else if ( flags & wxCONTROL_DISABLED )
745 state += 3;
746
747 wxUxThemeEngine::Get()->DrawThemeBackground
748 (
749 hTheme,
750 GraphicsHDC(&dc),
751 BP_RADIOBUTTON,
752 state,
753 &r,
754 NULL
755 );
756 }
757
758 void
759 wxRendererXP::DrawPushButton(wxWindow * win,
760 wxDC& dc,
761 const wxRect& rect,
762 int flags)
763 {
764 wxUxThemeHandle hTheme(win, L"BUTTON");
765 if ( !hTheme )
766 {
767 m_rendererNative.DrawPushButton(win, dc, rect, flags);
768 return;
769 }
770
771 RECT r;
772 wxCopyRectToRECT(rect, r);
773
774 int state;
775 if ( flags & wxCONTROL_PRESSED )
776 state = PBS_PRESSED;
777 else if ( flags & wxCONTROL_CURRENT )
778 state = PBS_HOT;
779 else if ( flags & wxCONTROL_DISABLED )
780 state = PBS_DISABLED;
781 else if ( flags & wxCONTROL_ISDEFAULT )
782 state = PBS_DEFAULTED;
783 else
784 state = PBS_NORMAL;
785
786 wxUxThemeEngine::Get()->DrawThemeBackground
787 (
788 hTheme,
789 GetHdcOf(*((wxMSWDCImpl*)dc.GetImpl())),
790 BP_PUSHBUTTON,
791 state,
792 &r,
793 NULL
794 );
795 }
796
797
798 // ----------------------------------------------------------------------------
799 // splitter drawing
800 // ----------------------------------------------------------------------------
801
802 // the width of the sash: this is the same as used by Explorer...
803 static const wxCoord SASH_WIDTH = 4;
804
805 wxSplitterRenderParams
806 wxRendererXP::GetSplitterParams(const wxWindow * win)
807 {
808 if ( win->HasFlag(wxSP_NO_XP_THEME) )
809 return m_rendererNative.GetSplitterParams(win);
810 else
811 return wxSplitterRenderParams(SASH_WIDTH, 0, false);
812 }
813
814 void
815 wxRendererXP::DrawSplitterBorder(wxWindow * win,
816 wxDC& dc,
817 const wxRect& rect,
818 int flags)
819 {
820 if ( win->HasFlag(wxSP_NO_XP_THEME) )
821 {
822 m_rendererNative.DrawSplitterBorder(win, dc, rect, flags);
823 }
824 }
825
826 void
827 wxRendererXP::DrawSplitterSash(wxWindow *win,
828 wxDC& dc,
829 const wxSize& size,
830 wxCoord position,
831 wxOrientation orient,
832 int flags)
833 {
834 if ( !win->HasFlag(wxSP_NO_XP_THEME) )
835 {
836 dc.SetPen(*wxTRANSPARENT_PEN);
837 dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)));
838 if ( orient == wxVERTICAL )
839 {
840 dc.DrawRectangle(position, 0, SASH_WIDTH, size.y);
841 }
842 else // wxHORIZONTAL
843 {
844 dc.DrawRectangle(0, position, size.x, SASH_WIDTH);
845 }
846
847 return;
848 }
849
850 m_rendererNative.DrawSplitterSash(win, dc, size, position, orient, flags);
851 }
852
853 #endif // wxUSE_UXTHEME