]> git.saurik.com Git - wxWidgets.git/blame - src/msw/renderer.cpp
added debug/release DLL configurations so that VC++ chooses the right one when buildi...
[wxWidgets.git] / src / msw / renderer.cpp
CommitLineData
9c7f49f5
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/renderer.cpp
38c4cb6a 3// Purpose: implementation of wxRendererNative for Windows
9c7f49f5
VZ
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>
65571936 9// License: wxWindows licence
9c7f49f5
VZ
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"
85b657c7
VS
29 #include "wx/window.h"
30 #include "wx/dc.h"
9c7f49f5
VZ
31#endif //WX_PRECOMP
32
3c2544bb 33#include "wx/splitter.h"
9c7f49f5 34#include "wx/renderer.h"
8b97949e 35#include "wx/msw/uxtheme.h"
03f01e63 36#include "wx/msw/private.h"
8b97949e 37
7cf3223a
VZ
38// tmschema.h is in Win32 Platform SDK and might not be available with earlier
39// compilers
40#ifndef CP_DROPDOWNBUTTON
41 #define CP_DROPDOWNBUTTON 1
42
43 #define CBXS_NORMAL 1
44 #define CBXS_HOT 2
45 #define CBXS_PRESSED 3
46 #define CBXS_DISABLED 4
47#endif
48
9c7f49f5 49// ----------------------------------------------------------------------------
8b97949e 50// wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
9c7f49f5
VZ
51// ----------------------------------------------------------------------------
52
38c4cb6a 53class WXDLLEXPORT wxRendererMSW : public wxDelegateRendererNative
9c7f49f5 54{
2eb10e2a
VZ
55public:
56 wxRendererMSW() { }
57
8b97949e
VZ
58 static wxRendererNative& Get();
59
7402677a
VZ
60 virtual void DrawComboBoxDropButton(wxWindow *win,
61 wxDC& dc,
62 const wxRect& rect,
63 int flags = 0);
64
2eb10e2a
VZ
65private:
66 DECLARE_NO_COPY_CLASS(wxRendererMSW)
9c7f49f5
VZ
67};
68
8b97949e
VZ
69// ----------------------------------------------------------------------------
70// wxRendererXP: wxRendererNative implementation for Windows XP and later
71// ----------------------------------------------------------------------------
72
7cf3223a
VZ
73#if wxUSE_UXTHEME
74
8b97949e
VZ
75class WXDLLEXPORT wxRendererXP : public wxDelegateRendererNative
76{
77public:
78 wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { }
79
80 static wxRendererNative& Get();
81
82 virtual void DrawSplitterBorder(wxWindow *win,
83 wxDC& dc,
c4e6c15e
VZ
84 const wxRect& rect,
85 int flags = 0);
8b97949e
VZ
86 virtual void DrawSplitterSash(wxWindow *win,
87 wxDC& dc,
88 const wxSize& size,
89 wxCoord position,
c4e6c15e
VZ
90 wxOrientation orient,
91 int flags = 0);
7402677a 92
c4e6c15e 93 virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
8b97949e 94
7cf3223a
VZ
95 virtual void DrawComboBoxDropButton(wxWindow *win,
96 wxDC& dc,
97 const wxRect& rect,
98 int flags = 0);
8b97949e
VZ
99private:
100 DECLARE_NO_COPY_CLASS(wxRendererXP)
101};
102
7cf3223a
VZ
103#endif // wxUSE_UXTHEME
104
9c7f49f5 105// ============================================================================
8b97949e 106// wxRendererNative and wxRendererMSW implementation
9c7f49f5
VZ
107// ============================================================================
108
109/* static */
f0244295 110wxRendererNative& wxRendererNative::GetDefault()
8b97949e 111{
7cf3223a 112#if wxUSE_UXTHEME
8b97949e 113 wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get();
7cf3223a
VZ
114 if ( themeEngine && themeEngine->IsAppThemed() )
115 return wxRendererXP::Get();
116#endif // wxUSE_UXTHEME
117
118 return wxRendererMSW::Get();
8b97949e
VZ
119}
120
121/* static */
122wxRendererNative& wxRendererMSW::Get()
9c7f49f5
VZ
123{
124 static wxRendererMSW s_rendererMSW;
125
126 return s_rendererMSW;
127}
128
7402677a
VZ
129void
130wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win),
131 wxDC& dc,
132 const wxRect& rect,
133 int flags)
134{
135 RECT r;
136 r.left = rect.GetLeft();
137 r.top = rect.GetTop();
7cf3223a
VZ
138 r.bottom = rect.y + rect.height;
139 r.right = rect.x + rect.width;
7402677a
VZ
140
141 int style = DFCS_SCROLLCOMBOBOX;
142 if ( flags & wxCONTROL_DISABLED )
143 style |= DFCS_INACTIVE;
144 if ( flags & wxCONTROL_PRESSED )
7cf3223a 145 style |= DFCS_PUSHED | DFCS_FLAT;
7402677a
VZ
146
147 ::DrawFrameControl(GetHdcOf(dc), &r, DFC_SCROLL, style);
148}
149
8b97949e
VZ
150// ============================================================================
151// wxRendererXP implementation
152// ============================================================================
153
7cf3223a
VZ
154#if wxUSE_UXTHEME
155
8b97949e
VZ
156/* static */
157wxRendererNative& wxRendererXP::Get()
158{
159 static wxRendererXP s_rendererXP;
160
161 return s_rendererXP;
162}
163
7cf3223a
VZ
164// NOTE: There is no guarantee that the button drawn fills the entire rect (XP
165// default theme, for example), so the caller should have cleared button's
166// background before this call. This is quite likely a wxMSW-specific thing.
167void
168wxRendererXP::DrawComboBoxDropButton(wxWindow * win,
169 wxDC& dc,
170 const wxRect& rect,
171 int flags)
172{
173 wxUxThemeHandle hTheme(win, L"COMBOBOX");
174 if ( hTheme )
175 {
176 RECT r;
177 r.left = rect.x;
178 r.top = rect.y;
179 r.right = rect.x + rect.width;
180 r.bottom = rect.y + rect.height;
181
182 int state;
183 if ( flags & wxCONTROL_PRESSED )
184 state = CBXS_PRESSED;
185 else if ( flags & wxCONTROL_CURRENT )
186 state = CBXS_HOT;
187 else if ( flags & wxCONTROL_DISABLED )
188 state = CBXS_DISABLED;
189 else
190 state = CBXS_NORMAL;
191
192 wxUxThemeEngine::Get()->DrawThemeBackground
193 (
194 hTheme,
195 dc.GetHDC(),
196 CP_DROPDOWNBUTTON,
197 state,
198 &r,
199 NULL
200 );
201
202 }
203}
204
8b97949e
VZ
205// ----------------------------------------------------------------------------
206// splitter drawing
207// ----------------------------------------------------------------------------
208
209// the width of the sash: this is the same as used by Explorer...
210static const wxCoord SASH_WIDTH = 4;
211
c4e6c15e 212wxSplitterRenderParams
3c2544bb 213wxRendererXP::GetSplitterParams(const wxWindow * win)
8b97949e 214{
3c2544bb
JS
215 if (win->GetWindowStyle() & wxSP_NO_XP_THEME)
216 return m_rendererNative.GetSplitterParams(win);
217 else
218 return wxSplitterRenderParams(SASH_WIDTH, 0, false);
8b97949e
VZ
219}
220
221void
3c2544bb
JS
222wxRendererXP::DrawSplitterBorder(wxWindow * win,
223 wxDC& dc,
224 const wxRect& rect,
225 int flags)
8b97949e 226{
3c2544bb
JS
227 if (win->GetWindowStyle() & wxSP_NO_XP_THEME)
228 {
229 m_rendererNative.DrawSplitterBorder(win, dc, rect, flags);
230 }
8b97949e
VZ
231}
232
233void
234wxRendererXP::DrawSplitterSash(wxWindow *win,
235 wxDC& dc,
236 const wxSize& size,
237 wxCoord position,
c4e6c15e 238 wxOrientation orient,
3c2544bb 239 int flags)
8b97949e 240{
6421119d 241 if ( !win->HasFlag(wxSP_NO_XP_THEME) )
8b97949e 242 {
6421119d
VZ
243 wxUxThemeHandle hTheme(win, L"WINDOW");
244 if ( hTheme )
8b97949e 245 {
6421119d
VZ
246 RECT rect;
247 if ( orient == wxVERTICAL )
248 {
249 rect.left = position;
250 rect.right = position + SASH_WIDTH;
251 rect.top = 0;
252 rect.bottom = size.y;
253 }
254 else // wxHORIZONTAL
255 {
256 rect.left = 0;
257 rect.right = size.x;
258 rect.top = position;
259 rect.bottom = position + SASH_WIDTH;
260 }
261
262 wxUxThemeEngine::Get()->DrawThemeBackground
263 (
264 (WXHTHEME)hTheme,
265 dc.GetHDC(),
266 29, // WP_DIALOG: dlg background
267 0, // no particular state
268 &rect,
269 NULL
270 );
271 return;
8b97949e 272 }
8b97949e 273 }
6421119d
VZ
274
275 m_rendererNative.DrawSplitterSash(win, dc, size, position, orient, flags);
8b97949e
VZ
276}
277
7cf3223a
VZ
278#endif // wxUSE_UXTHEME
279