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();
49 DECLARE_NO_COPY_CLASS(wxRendererMSW
)
52 // ----------------------------------------------------------------------------
53 // wxRendererXP: wxRendererNative implementation for Windows XP and later
54 // ----------------------------------------------------------------------------
56 class WXDLLEXPORT wxRendererXP
: public wxDelegateRendererNative
59 wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { }
61 static wxRendererNative
& Get();
63 virtual void DrawSplitterBorder(wxWindow
*win
,
67 virtual void DrawSplitterSash(wxWindow
*win
,
73 virtual wxSplitterRenderParams
GetSplitterParams(const wxWindow
*win
);
76 DECLARE_NO_COPY_CLASS(wxRendererXP
)
79 // ============================================================================
80 // wxRendererNative and wxRendererMSW implementation
81 // ============================================================================
84 wxRendererNative
& wxRendererNative::GetDefault()
86 wxUxThemeEngine
*themeEngine
= wxUxThemeEngine::Get();
87 return themeEngine
&& themeEngine
->IsAppThemed() ? wxRendererXP::Get()
88 : wxRendererMSW::Get();
92 wxRendererNative
& wxRendererMSW::Get()
94 static wxRendererMSW s_rendererMSW
;
99 // ============================================================================
100 // wxRendererXP implementation
101 // ============================================================================
104 wxRendererNative
& wxRendererXP::Get()
106 static wxRendererXP s_rendererXP
;
111 // ----------------------------------------------------------------------------
113 // ----------------------------------------------------------------------------
115 // the width of the sash: this is the same as used by Explorer...
116 static const wxCoord SASH_WIDTH
= 4;
118 wxSplitterRenderParams
119 wxRendererXP::GetSplitterParams(const wxWindow
* win
)
121 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
122 return m_rendererNative
.GetSplitterParams(win
);
124 return wxSplitterRenderParams(SASH_WIDTH
, 0, false);
128 wxRendererXP::DrawSplitterBorder(wxWindow
* win
,
133 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
135 m_rendererNative
.DrawSplitterBorder(win
, dc
, rect
, flags
);
140 wxRendererXP::DrawSplitterSash(wxWindow
*win
,
144 wxOrientation orient
,
147 if (win
->GetWindowStyle() & wxSP_NO_XP_THEME
)
149 m_rendererNative
.DrawSplitterSash(
150 win
, dc
, size
, position
, orient
, flags
);
154 // I don't know if it is correct to use the rebar background for the
155 // splitter but it least this works ok in the default theme
156 wxUxThemeHandle
hTheme(win
, L
"REBAR");
160 if ( orient
== wxVERTICAL
)
162 rect
.left
= position
;
163 rect
.right
= position
+ SASH_WIDTH
;
165 rect
.bottom
= size
.y
;
172 rect
.bottom
= position
+ SASH_WIDTH
;
175 wxUxThemeEngine::Get()->DrawThemeBackground