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
50 // ----------------------------------------------------------------------------
51 // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
52 // ----------------------------------------------------------------------------
54 class WXDLLEXPORT wxRendererMSW
: public wxDelegateRendererNative
59 static wxRendererNative
& Get();
61 virtual void DrawComboBoxDropButton(wxWindow
*win
,
67 DECLARE_NO_COPY_CLASS(wxRendererMSW
)
70 // ----------------------------------------------------------------------------
71 // wxRendererXP: wxRendererNative implementation for Windows XP and later
72 // ----------------------------------------------------------------------------
76 class WXDLLEXPORT wxRendererXP
: public wxDelegateRendererNative
79 wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { }
81 static wxRendererNative
& Get();
83 virtual void DrawSplitterBorder(wxWindow
*win
,
87 virtual void DrawSplitterSash(wxWindow
*win
,
94 virtual wxSplitterRenderParams
GetSplitterParams(const wxWindow
*win
);
96 virtual void DrawComboBoxDropButton(wxWindow
*win
,
101 DECLARE_NO_COPY_CLASS(wxRendererXP
)
104 #endif // wxUSE_UXTHEME
106 // ============================================================================
107 // wxRendererNative and wxRendererMSW implementation
108 // ============================================================================
111 wxRendererNative
& wxRendererNative::GetDefault()
114 wxUxThemeEngine
*themeEngine
= wxUxThemeEngine::Get();
115 if ( themeEngine
&& themeEngine
->IsAppThemed() )
116 return wxRendererXP::Get();
117 #endif // wxUSE_UXTHEME
119 return wxRendererMSW::Get();
123 wxRendererNative
& wxRendererMSW::Get()
125 static wxRendererMSW s_rendererMSW
;
127 return s_rendererMSW
;
130 #if defined(__WXWINCE__) && !defined(DFCS_FLAT)
135 wxRendererMSW::DrawComboBoxDropButton(wxWindow
* WXUNUSED(win
),
141 r
.left
= rect
.GetLeft();
142 r
.top
= rect
.GetTop();
143 r
.bottom
= rect
.y
+ rect
.height
;
144 r
.right
= rect
.x
+ rect
.width
;
146 int style
= DFCS_SCROLLCOMBOBOX
;
147 if ( flags
& wxCONTROL_DISABLED
)
148 style
|= DFCS_INACTIVE
;
149 if ( flags
& wxCONTROL_PRESSED
)
150 style
|= DFCS_PUSHED
| DFCS_FLAT
;
152 ::DrawFrameControl(GetHdcOf(dc
), &r
, DFC_SCROLL
, style
);
155 // ============================================================================
156 // wxRendererXP implementation
157 // ============================================================================
162 wxRendererNative
& wxRendererXP::Get()
164 static wxRendererXP s_rendererXP
;
169 // NOTE: There is no guarantee that the button drawn fills the entire rect (XP
170 // default theme, for example), so the caller should have cleared button's
171 // background before this call. This is quite likely a wxMSW-specific thing.
173 wxRendererXP::DrawComboBoxDropButton(wxWindow
* win
,
178 wxUxThemeHandle
hTheme(win
, L
"COMBOBOX");
184 r
.right
= rect
.x
+ rect
.width
;
185 r
.bottom
= rect
.y
+ rect
.height
;
188 if ( flags
& wxCONTROL_PRESSED
)
189 state
= CBXS_PRESSED
;
190 else if ( flags
& wxCONTROL_CURRENT
)
192 else if ( flags
& wxCONTROL_DISABLED
)
193 state
= CBXS_DISABLED
;
197 wxUxThemeEngine::Get()->DrawThemeBackground
210 // ----------------------------------------------------------------------------
212 // ----------------------------------------------------------------------------
214 // the width of the sash: this is the same as used by Explorer...
215 static const wxCoord SASH_WIDTH
= 4;
217 wxSplitterRenderParams
218 wxRendererXP::GetSplitterParams(const wxWindow
* win
)
220 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
221 return m_rendererNative
.GetSplitterParams(win
);
223 return wxSplitterRenderParams(SASH_WIDTH
, 0, false);
227 wxRendererXP::DrawSplitterBorder(wxWindow
* win
,
232 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
234 m_rendererNative
.DrawSplitterBorder(win
, dc
, rect
, flags
);
239 wxRendererXP::DrawSplitterSash(wxWindow
*win
,
243 wxOrientation orient
,
246 if ( !win
->HasFlag(wxSP_NO_XP_THEME
) )
248 dc
.SetPen(*wxTRANSPARENT_PEN
);
249 dc
.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE
)));
250 if ( orient
== wxVERTICAL
)
252 dc
.DrawRectangle(position
, 0, SASH_WIDTH
, size
.y
);
256 dc
.DrawRectangle(0, position
, size
.x
, SASH_WIDTH
);
262 m_rendererNative
.DrawSplitterSash(win
, dc
, size
, position
, orient
, flags
);
265 #endif // wxUSE_UXTHEME