compilation fixes
[wxWidgets.git] / src / msw / renderer.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: 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 license
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 #endif //WX_PRECOMP
32
33 #include "wx/renderer.h"
34
35 #include "wx/msw/uxtheme.h"
36
37 // ----------------------------------------------------------------------------
38 // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
39 // ----------------------------------------------------------------------------
40
41 class WXDLLEXPORT wxRendererMSW : public wxDelegateRendererNative
42 {
43 public:
44 wxRendererMSW() { }
45
46 static wxRendererNative& Get();
47
48 private:
49 DECLARE_NO_COPY_CLASS(wxRendererMSW)
50 };
51
52 // ----------------------------------------------------------------------------
53 // wxRendererXP: wxRendererNative implementation for Windows XP and later
54 // ----------------------------------------------------------------------------
55
56 class WXDLLEXPORT wxRendererXP : public wxDelegateRendererNative
57 {
58 public:
59 wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { }
60
61 static wxRendererNative& Get();
62
63 virtual void DrawSplitterBorder(wxWindow *win,
64 wxDC& dc,
65 const wxRect& rect);
66 virtual void DrawSplitterSash(wxWindow *win,
67 wxDC& dc,
68 const wxSize& size,
69 wxCoord position,
70 wxOrientation orient);
71 virtual wxPoint GetSplitterSashAndBorder(const wxWindow *win);
72
73 private:
74 DECLARE_NO_COPY_CLASS(wxRendererXP)
75 };
76
77 // ============================================================================
78 // wxRendererNative and wxRendererMSW implementation
79 // ============================================================================
80
81 /* static */
82 wxRendererNative& wxRendererNative::GetDefault()
83 {
84 wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get();
85 return themeEngine && themeEngine->IsThemeActive() ? wxRendererXP::Get()
86 : wxRendererMSW::Get();
87 }
88
89 /* static */
90 wxRendererNative& wxRendererMSW::Get()
91 {
92 static wxRendererMSW s_rendererMSW;
93
94 return s_rendererMSW;
95 }
96
97 // ============================================================================
98 // wxRendererXP implementation
99 // ============================================================================
100
101 /* static */
102 wxRendererNative& wxRendererXP::Get()
103 {
104 static wxRendererXP s_rendererXP;
105
106 return s_rendererXP;
107 }
108
109 // ----------------------------------------------------------------------------
110 // splitter drawing
111 // ----------------------------------------------------------------------------
112
113 // the width of the sash: this is the same as used by Explorer...
114 static const wxCoord SASH_WIDTH = 4;
115
116 wxPoint wxRendererXP::GetSplitterSashAndBorder(const wxWindow * WXUNUSED(win))
117 {
118 return wxPoint(SASH_WIDTH, 0);
119 }
120
121 void
122 wxRendererXP::DrawSplitterBorder(wxWindow * WXUNUSED(win),
123 wxDC& WXUNUSED(dc),
124 const wxRect& WXUNUSED(rect))
125 {
126 }
127
128 void
129 wxRendererXP::DrawSplitterSash(wxWindow *win,
130 wxDC& dc,
131 const wxSize& size,
132 wxCoord position,
133 wxOrientation orient)
134 {
135 // I don't know if it is correct to use the rebar background for the
136 // splitter but it least this works ok in the default theme
137 wxUxThemeHandle hTheme(win, L"REBAR");
138 if ( hTheme )
139 {
140 RECT rect;
141 if ( orient == wxVERTICAL )
142 {
143 rect.left = position;
144 rect.right = position + SASH_WIDTH;
145 rect.top = 0;
146 rect.bottom = size.y;
147 }
148 else // wxHORIZONTAL
149 {
150 rect.left = 0;
151 rect.right = size.x;
152 rect.top = position;
153 rect.bottom = position + SASH_WIDTH;
154 }
155
156 wxUxThemeEngine::Get()->DrawThemeBackground
157 (
158 (WXHTHEME)hTheme,
159 dc.GetHDC(),
160 3 /* RP_BAND */,
161 0 /* no state */ ,
162 &rect,
163 NULL
164 );
165 }
166 }
167