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"
37 // ----------------------------------------------------------------------------
38 // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
39 // ----------------------------------------------------------------------------
41 class WXDLLEXPORT wxRendererMSW
: public wxDelegateRendererNative
46 static wxRendererNative
& Get();
48 virtual void DrawComboBoxDropButton(wxWindow
*win
,
54 DECLARE_NO_COPY_CLASS(wxRendererMSW
)
57 // ----------------------------------------------------------------------------
58 // wxRendererXP: wxRendererNative implementation for Windows XP and later
59 // ----------------------------------------------------------------------------
61 class WXDLLEXPORT wxRendererXP
: public wxDelegateRendererNative
64 wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { }
66 static wxRendererNative
& Get();
68 virtual void DrawSplitterBorder(wxWindow
*win
,
72 virtual void DrawSplitterSash(wxWindow
*win
,
79 virtual wxSplitterRenderParams
GetSplitterParams(const wxWindow
*win
);
82 DECLARE_NO_COPY_CLASS(wxRendererXP
)
85 // ============================================================================
86 // wxRendererNative and wxRendererMSW implementation
87 // ============================================================================
90 wxRendererNative
& wxRendererNative::GetDefault()
92 wxUxThemeEngine
*themeEngine
= wxUxThemeEngine::Get();
93 return themeEngine
&& themeEngine
->IsAppThemed() ? wxRendererXP::Get()
94 : wxRendererMSW::Get();
98 wxRendererNative
& wxRendererMSW::Get()
100 static wxRendererMSW s_rendererMSW
;
102 return s_rendererMSW
;
106 wxRendererMSW::DrawComboBoxDropButton(wxWindow
* WXUNUSED(win
),
112 r
.left
= rect
.GetLeft();
113 r
.top
= rect
.GetTop();
114 r
.bottom
= rect
.GetBottom();
115 r
.right
= rect
.GetRight();
117 int style
= DFCS_SCROLLCOMBOBOX
;
118 if ( flags
& wxCONTROL_DISABLED
)
119 style
|= DFCS_INACTIVE
;
120 if ( flags
& wxCONTROL_PRESSED
)
121 style
|= DFCS_PUSHED
;
123 ::DrawFrameControl(GetHdcOf(dc
), &r
, DFC_SCROLL
, style
);
126 // ============================================================================
127 // wxRendererXP implementation
128 // ============================================================================
131 wxRendererNative
& wxRendererXP::Get()
133 static wxRendererXP s_rendererXP
;
138 // ----------------------------------------------------------------------------
140 // ----------------------------------------------------------------------------
142 // the width of the sash: this is the same as used by Explorer...
143 static const wxCoord SASH_WIDTH
= 4;
145 wxSplitterRenderParams
146 wxRendererXP::GetSplitterParams(const wxWindow
* win
)
148 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
149 return m_rendererNative
.GetSplitterParams(win
);
151 return wxSplitterRenderParams(SASH_WIDTH
, 0, false);
155 wxRendererXP::DrawSplitterBorder(wxWindow
* win
,
160 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
162 m_rendererNative
.DrawSplitterBorder(win
, dc
, rect
, flags
);
167 wxRendererXP::DrawSplitterSash(wxWindow
*win
,
171 wxOrientation orient
,
174 if ( !win
->HasFlag(wxSP_NO_XP_THEME
) )
176 wxUxThemeHandle
hTheme(win
, L
"WINDOW");
180 if ( orient
== wxVERTICAL
)
182 rect
.left
= position
;
183 rect
.right
= position
+ SASH_WIDTH
;
185 rect
.bottom
= size
.y
;
192 rect
.bottom
= position
+ SASH_WIDTH
;
195 wxUxThemeEngine::Get()->DrawThemeBackground
199 29, // WP_DIALOG: dlg background
200 0, // no particular state
208 m_rendererNative
.DrawSplitterSash(win
, dc
, size
, position
, orient
, flags
);