1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/renderer.cpp
3 // Purpose: implementation of wxRendererNative for Windows
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
28 #include "wx/string.h"
29 #include "wx/window.h"
33 #include "wx/splitter.h"
34 #include "wx/renderer.h"
35 #include "wx/settings.h"
36 #include "wx/msw/uxtheme.h"
37 #include "wx/msw/private.h"
39 // tmschema.h is in Win32 Platform SDK and might not be available with earlier
41 #ifndef CP_DROPDOWNBUTTON
42 #define CP_DROPDOWNBUTTON 1
46 #define CBXS_PRESSED 3
47 #define CBXS_DISABLED 4
54 #define HP_HEADERITEM 1
61 // ----------------------------------------------------------------------------
62 // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
63 // ----------------------------------------------------------------------------
65 class WXDLLEXPORT wxRendererMSW
: public wxDelegateRendererNative
70 static wxRendererNative
& Get();
72 virtual void DrawComboBoxDropButton(wxWindow
*win
,
78 DECLARE_NO_COPY_CLASS(wxRendererMSW
)
81 // ----------------------------------------------------------------------------
82 // wxRendererXP: wxRendererNative implementation for Windows XP and later
83 // ----------------------------------------------------------------------------
87 class WXDLLEXPORT wxRendererXP
: public wxDelegateRendererNative
90 wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { }
92 static wxRendererNative
& Get();
94 virtual void DrawSplitterBorder(wxWindow
*win
,
98 virtual void DrawSplitterSash(wxWindow
*win
,
102 wxOrientation orient
,
105 virtual wxSplitterRenderParams
GetSplitterParams(const wxWindow
*win
);
107 virtual void DrawComboBoxDropButton(wxWindow
*win
,
111 virtual void DrawTreeItemButton(wxWindow
*win
,
115 virtual void DrawHeaderButton(wxWindow
*win
,
120 DECLARE_NO_COPY_CLASS(wxRendererXP
)
123 #endif // wxUSE_UXTHEME
125 // ============================================================================
126 // wxRendererNative and wxRendererMSW implementation
127 // ============================================================================
130 wxRendererNative
& wxRendererNative::GetDefault()
133 wxUxThemeEngine
*themeEngine
= wxUxThemeEngine::Get();
134 if ( themeEngine
&& themeEngine
->IsAppThemed() )
135 return wxRendererXP::Get();
136 #endif // wxUSE_UXTHEME
138 return wxRendererMSW::Get();
142 wxRendererNative
& wxRendererMSW::Get()
144 static wxRendererMSW s_rendererMSW
;
146 return s_rendererMSW
;
149 #if defined(__WXWINCE__) && !defined(DFCS_FLAT)
154 wxRendererMSW::DrawComboBoxDropButton(wxWindow
* WXUNUSED(win
),
160 r
.left
= rect
.GetLeft();
161 r
.top
= rect
.GetTop();
162 r
.bottom
= rect
.y
+ rect
.height
;
163 r
.right
= rect
.x
+ rect
.width
;
165 int style
= DFCS_SCROLLCOMBOBOX
;
166 if ( flags
& wxCONTROL_DISABLED
)
167 style
|= DFCS_INACTIVE
;
168 if ( flags
& wxCONTROL_PRESSED
)
169 style
|= DFCS_PUSHED
| DFCS_FLAT
;
171 ::DrawFrameControl(GetHdcOf(dc
), &r
, DFC_SCROLL
, style
);
174 // ============================================================================
175 // wxRendererXP implementation
176 // ============================================================================
181 wxRendererNative
& wxRendererXP::Get()
183 static wxRendererXP s_rendererXP
;
188 // NOTE: There is no guarantee that the button drawn fills the entire rect (XP
189 // default theme, for example), so the caller should have cleared button's
190 // background before this call. This is quite likely a wxMSW-specific thing.
192 wxRendererXP::DrawComboBoxDropButton(wxWindow
* win
,
197 wxUxThemeHandle
hTheme(win
, L
"COMBOBOX");
203 r
.right
= rect
.x
+ rect
.width
;
204 r
.bottom
= rect
.y
+ rect
.height
;
207 if ( flags
& wxCONTROL_PRESSED
)
208 state
= CBXS_PRESSED
;
209 else if ( flags
& wxCONTROL_CURRENT
)
211 else if ( flags
& wxCONTROL_DISABLED
)
212 state
= CBXS_DISABLED
;
216 wxUxThemeEngine::Get()->DrawThemeBackground
229 // ----------------------------------------------------------------------------
231 // ----------------------------------------------------------------------------
233 // the width of the sash: this is the same as used by Explorer...
234 static const wxCoord SASH_WIDTH
= 4;
236 wxSplitterRenderParams
237 wxRendererXP::GetSplitterParams(const wxWindow
* win
)
239 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
240 return m_rendererNative
.GetSplitterParams(win
);
242 return wxSplitterRenderParams(SASH_WIDTH
, 0, false);
246 wxRendererXP::DrawSplitterBorder(wxWindow
* win
,
251 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
253 m_rendererNative
.DrawSplitterBorder(win
, dc
, rect
, flags
);
258 wxRendererXP::DrawSplitterSash(wxWindow
*win
,
262 wxOrientation orient
,
265 if ( !win
->HasFlag(wxSP_NO_XP_THEME
) )
267 dc
.SetPen(*wxTRANSPARENT_PEN
);
268 dc
.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
)));
269 if ( orient
== wxVERTICAL
)
271 dc
.DrawRectangle(position
, 0, SASH_WIDTH
, size
.y
);
275 dc
.DrawRectangle(0, position
, size
.x
, SASH_WIDTH
);
281 m_rendererNative
.DrawSplitterSash(win
, dc
, size
, position
, orient
, flags
);
285 wxRendererXP::DrawTreeItemButton(wxWindow
*win
,
290 wxUxThemeHandle
hTheme(win
, L
"TREEVIEW");
294 r
.right
= rect
.x
+ rect
.width
;
295 r
.bottom
= rect
.y
+ rect
.height
;
296 int state
= (flags
& wxCONTROL_EXPANDED
) ? GLPS_OPENED
: GLPS_CLOSED
;
297 wxUxThemeEngine::Get()->DrawThemeBackground
309 wxRendererXP::DrawHeaderButton(wxWindow
*win
,
314 wxUxThemeHandle
hTheme(win
, L
"HEADER");
318 r
.right
= rect
.x
+ rect
.width
;
319 r
.bottom
= rect
.y
+ rect
.height
;
321 if ( flags
& wxCONTROL_PRESSED
)
323 else if ( flags
& wxCONTROL_CURRENT
)
327 wxUxThemeEngine::Get()->DrawThemeBackground
338 #endif // wxUSE_UXTHEME