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
;
130 wxRendererMSW::DrawComboBoxDropButton(wxWindow
* WXUNUSED(win
),
136 r
.left
= rect
.GetLeft();
137 r
.top
= rect
.GetTop();
138 r
.bottom
= rect
.y
+ rect
.height
;
139 r
.right
= rect
.x
+ rect
.width
;
141 int style
= DFCS_SCROLLCOMBOBOX
;
142 if ( flags
& wxCONTROL_DISABLED
)
143 style
|= DFCS_INACTIVE
;
144 if ( flags
& wxCONTROL_PRESSED
)
145 style
|= DFCS_PUSHED
| DFCS_FLAT
;
147 ::DrawFrameControl(GetHdcOf(dc
), &r
, DFC_SCROLL
, style
);
150 // ============================================================================
151 // wxRendererXP implementation
152 // ============================================================================
157 wxRendererNative
& wxRendererXP::Get()
159 static wxRendererXP s_rendererXP
;
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.
168 wxRendererXP::DrawComboBoxDropButton(wxWindow
* win
,
173 wxUxThemeHandle
hTheme(win
, L
"COMBOBOX");
179 r
.right
= rect
.x
+ rect
.width
;
180 r
.bottom
= rect
.y
+ rect
.height
;
183 if ( flags
& wxCONTROL_PRESSED
)
184 state
= CBXS_PRESSED
;
185 else if ( flags
& wxCONTROL_CURRENT
)
187 else if ( flags
& wxCONTROL_DISABLED
)
188 state
= CBXS_DISABLED
;
192 wxUxThemeEngine::Get()->DrawThemeBackground
205 // ----------------------------------------------------------------------------
207 // ----------------------------------------------------------------------------
209 // the width of the sash: this is the same as used by Explorer...
210 static const wxCoord SASH_WIDTH
= 4;
212 wxSplitterRenderParams
213 wxRendererXP::GetSplitterParams(const wxWindow
* win
)
215 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
216 return m_rendererNative
.GetSplitterParams(win
);
218 return wxSplitterRenderParams(SASH_WIDTH
, 0, false);
222 wxRendererXP::DrawSplitterBorder(wxWindow
* win
,
227 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
229 m_rendererNative
.DrawSplitterBorder(win
, dc
, rect
, flags
);
234 wxRendererXP::DrawSplitterSash(wxWindow
*win
,
238 wxOrientation orient
,
241 if ( !win
->HasFlag(wxSP_NO_XP_THEME
) )
243 wxUxThemeHandle
hTheme(win
, L
"WINDOW");
247 if ( orient
== wxVERTICAL
)
249 rect
.left
= position
;
250 rect
.right
= position
+ SASH_WIDTH
;
252 rect
.bottom
= size
.y
;
259 rect
.bottom
= position
+ SASH_WIDTH
;
262 wxUxThemeEngine::Get()->DrawThemeBackground
266 29, // WP_DIALOG: dlg background
267 0, // no particular state
275 m_rendererNative
.DrawSplitterSash(win
, dc
, size
, position
, orient
, flags
);
278 #endif // wxUSE_UXTHEME