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/msw/uxtheme.h"
36 #include "wx/msw/private.h"
38 // tmschema.h is in Win32 Platform SDK and might not be available with earlier
40 #ifndef CP_DROPDOWNBUTTON
41 #define CP_DROPDOWNBUTTON 1
45 #define CBXS_PRESSED 3
46 #define CBXS_DISABLED 4
49 // ----------------------------------------------------------------------------
50 // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
51 // ----------------------------------------------------------------------------
53 class WXDLLEXPORT wxRendererMSW
: public wxDelegateRendererNative
58 static wxRendererNative
& Get();
60 virtual void DrawComboBoxDropButton(wxWindow
*win
,
66 DECLARE_NO_COPY_CLASS(wxRendererMSW
)
69 // ----------------------------------------------------------------------------
70 // wxRendererXP: wxRendererNative implementation for Windows XP and later
71 // ----------------------------------------------------------------------------
75 class WXDLLEXPORT wxRendererXP
: public wxDelegateRendererNative
78 wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { }
80 static wxRendererNative
& Get();
82 virtual void DrawSplitterBorder(wxWindow
*win
,
86 virtual void DrawSplitterSash(wxWindow
*win
,
93 virtual wxSplitterRenderParams
GetSplitterParams(const wxWindow
*win
);
95 virtual void DrawComboBoxDropButton(wxWindow
*win
,
100 DECLARE_NO_COPY_CLASS(wxRendererXP
)
103 #endif // wxUSE_UXTHEME
105 // ============================================================================
106 // wxRendererNative and wxRendererMSW implementation
107 // ============================================================================
110 wxRendererNative
& wxRendererNative::GetDefault()
113 wxUxThemeEngine
*themeEngine
= wxUxThemeEngine::Get();
114 if ( themeEngine
&& themeEngine
->IsAppThemed() )
115 return wxRendererXP::Get();
116 #endif // wxUSE_UXTHEME
118 return wxRendererMSW::Get();
122 wxRendererNative
& wxRendererMSW::Get()
124 static wxRendererMSW s_rendererMSW
;
126 return s_rendererMSW
;
129 #if defined(__WXWINCE__) && !defined(DFCS_FLAT)
134 wxRendererMSW::DrawComboBoxDropButton(wxWindow
* WXUNUSED(win
),
140 r
.left
= rect
.GetLeft();
141 r
.top
= rect
.GetTop();
142 r
.bottom
= rect
.y
+ rect
.height
;
143 r
.right
= rect
.x
+ rect
.width
;
145 int style
= DFCS_SCROLLCOMBOBOX
;
146 if ( flags
& wxCONTROL_DISABLED
)
147 style
|= DFCS_INACTIVE
;
148 if ( flags
& wxCONTROL_PRESSED
)
149 style
|= DFCS_PUSHED
| DFCS_FLAT
;
151 ::DrawFrameControl(GetHdcOf(dc
), &r
, DFC_SCROLL
, style
);
154 // ============================================================================
155 // wxRendererXP implementation
156 // ============================================================================
161 wxRendererNative
& wxRendererXP::Get()
163 static wxRendererXP s_rendererXP
;
168 // NOTE: There is no guarantee that the button drawn fills the entire rect (XP
169 // default theme, for example), so the caller should have cleared button's
170 // background before this call. This is quite likely a wxMSW-specific thing.
172 wxRendererXP::DrawComboBoxDropButton(wxWindow
* win
,
177 wxUxThemeHandle
hTheme(win
, L
"COMBOBOX");
183 r
.right
= rect
.x
+ rect
.width
;
184 r
.bottom
= rect
.y
+ rect
.height
;
187 if ( flags
& wxCONTROL_PRESSED
)
188 state
= CBXS_PRESSED
;
189 else if ( flags
& wxCONTROL_CURRENT
)
191 else if ( flags
& wxCONTROL_DISABLED
)
192 state
= CBXS_DISABLED
;
196 wxUxThemeEngine::Get()->DrawThemeBackground
209 // ----------------------------------------------------------------------------
211 // ----------------------------------------------------------------------------
213 // the width of the sash: this is the same as used by Explorer...
214 static const wxCoord SASH_WIDTH
= 4;
216 wxSplitterRenderParams
217 wxRendererXP::GetSplitterParams(const wxWindow
* win
)
219 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
220 return m_rendererNative
.GetSplitterParams(win
);
222 return wxSplitterRenderParams(SASH_WIDTH
, 0, false);
226 wxRendererXP::DrawSplitterBorder(wxWindow
* win
,
231 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
233 m_rendererNative
.DrawSplitterBorder(win
, dc
, rect
, flags
);
238 wxRendererXP::DrawSplitterSash(wxWindow
*win
,
242 wxOrientation orient
,
245 if ( !win
->HasFlag(wxSP_NO_XP_THEME
) )
247 wxUxThemeHandle
hTheme(win
, L
"WINDOW");
251 if ( orient
== wxVERTICAL
)
253 rect
.left
= position
;
254 rect
.right
= position
+ SASH_WIDTH
;
256 rect
.bottom
= size
.y
;
263 rect
.bottom
= position
+ SASH_WIDTH
;
266 wxUxThemeEngine::Get()->DrawThemeBackground
270 29, // WP_DIALOG: dlg background
271 0, // no particular state
279 m_rendererNative
.DrawSplitterSash(win
, dc
, size
, position
, orient
, flags
);
282 #endif // wxUSE_UXTHEME