]> git.saurik.com Git - wxWidgets.git/blame - src/msw/renderer.cpp
* build and distrib tweaks.
[wxWidgets.git] / src / msw / renderer.cpp
CommitLineData
9c7f49f5
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/renderer.cpp
38c4cb6a 3// Purpose: implementation of wxRendererNative for Windows
9c7f49f5
VZ
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 20.07.2003
7// RCS-ID: $Id$
8// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
65571936 9// License: wxWindows licence
9c7f49f5
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20// for compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#ifndef WX_PRECOMP
28 #include "wx/string.h"
85b657c7
VS
29 #include "wx/window.h"
30 #include "wx/dc.h"
9c7f49f5
VZ
31#endif //WX_PRECOMP
32
3c2544bb 33#include "wx/splitter.h"
9c7f49f5 34#include "wx/renderer.h"
8b97949e
VZ
35#include "wx/msw/uxtheme.h"
36
9c7f49f5 37// ----------------------------------------------------------------------------
8b97949e 38// wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
9c7f49f5
VZ
39// ----------------------------------------------------------------------------
40
38c4cb6a 41class WXDLLEXPORT wxRendererMSW : public wxDelegateRendererNative
9c7f49f5 42{
2eb10e2a
VZ
43public:
44 wxRendererMSW() { }
45
8b97949e
VZ
46 static wxRendererNative& Get();
47
2eb10e2a
VZ
48private:
49 DECLARE_NO_COPY_CLASS(wxRendererMSW)
9c7f49f5
VZ
50};
51
8b97949e
VZ
52// ----------------------------------------------------------------------------
53// wxRendererXP: wxRendererNative implementation for Windows XP and later
54// ----------------------------------------------------------------------------
55
56class WXDLLEXPORT wxRendererXP : public wxDelegateRendererNative
57{
58public:
59 wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { }
60
61 static wxRendererNative& Get();
62
63 virtual void DrawSplitterBorder(wxWindow *win,
64 wxDC& dc,
c4e6c15e
VZ
65 const wxRect& rect,
66 int flags = 0);
8b97949e
VZ
67 virtual void DrawSplitterSash(wxWindow *win,
68 wxDC& dc,
69 const wxSize& size,
70 wxCoord position,
c4e6c15e
VZ
71 wxOrientation orient,
72 int flags = 0);
73 virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
8b97949e
VZ
74
75private:
76 DECLARE_NO_COPY_CLASS(wxRendererXP)
77};
78
9c7f49f5 79// ============================================================================
8b97949e 80// wxRendererNative and wxRendererMSW implementation
9c7f49f5
VZ
81// ============================================================================
82
83/* static */
f0244295 84wxRendererNative& wxRendererNative::GetDefault()
8b97949e
VZ
85{
86 wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get();
3afc693f
VZ
87 return themeEngine && themeEngine->IsAppThemed() ? wxRendererXP::Get()
88 : wxRendererMSW::Get();
8b97949e
VZ
89}
90
91/* static */
92wxRendererNative& wxRendererMSW::Get()
9c7f49f5
VZ
93{
94 static wxRendererMSW s_rendererMSW;
95
96 return s_rendererMSW;
97}
98
8b97949e
VZ
99// ============================================================================
100// wxRendererXP implementation
101// ============================================================================
102
103/* static */
104wxRendererNative& wxRendererXP::Get()
105{
106 static wxRendererXP s_rendererXP;
107
108 return s_rendererXP;
109}
110
111// ----------------------------------------------------------------------------
112// splitter drawing
113// ----------------------------------------------------------------------------
114
115// the width of the sash: this is the same as used by Explorer...
116static const wxCoord SASH_WIDTH = 4;
117
c4e6c15e 118wxSplitterRenderParams
3c2544bb 119wxRendererXP::GetSplitterParams(const wxWindow * win)
8b97949e 120{
3c2544bb
JS
121 if (win->GetWindowStyle() & wxSP_NO_XP_THEME)
122 return m_rendererNative.GetSplitterParams(win);
123 else
124 return wxSplitterRenderParams(SASH_WIDTH, 0, false);
8b97949e
VZ
125}
126
127void
3c2544bb
JS
128wxRendererXP::DrawSplitterBorder(wxWindow * win,
129 wxDC& dc,
130 const wxRect& rect,
131 int flags)
8b97949e 132{
3c2544bb
JS
133 if (win->GetWindowStyle() & wxSP_NO_XP_THEME)
134 {
135 m_rendererNative.DrawSplitterBorder(win, dc, rect, flags);
136 }
8b97949e
VZ
137}
138
139void
140wxRendererXP::DrawSplitterSash(wxWindow *win,
141 wxDC& dc,
142 const wxSize& size,
143 wxCoord position,
c4e6c15e 144 wxOrientation orient,
3c2544bb 145 int flags)
8b97949e 146{
3c2544bb
JS
147 if (win->GetWindowStyle() & wxSP_NO_XP_THEME)
148 {
149 m_rendererNative.DrawSplitterSash(
150 win, dc, size, position, orient, flags);
151 return;
152 }
4d08943e 153
8b97949e
VZ
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");
157 if ( hTheme )
158 {
159 RECT rect;
160 if ( orient == wxVERTICAL )
161 {
162 rect.left = position;
4d08943e 163 rect.right = position + SASH_WIDTH;
8b97949e
VZ
164 rect.top = 0;
165 rect.bottom = size.y;
166 }
167 else // wxHORIZONTAL
168 {
169 rect.left = 0;
170 rect.right = size.x;
171 rect.top = position;
172 rect.bottom = position + SASH_WIDTH;
173 }
174
175 wxUxThemeEngine::Get()->DrawThemeBackground
176 (
85b657c7 177 (WXHTHEME)hTheme,
8b97949e
VZ
178 dc.GetHDC(),
179 3 /* RP_BAND */,
180 0 /* no state */ ,
181 &rect,
182 NULL
4d08943e 183 );
8b97949e
VZ
184 }
185}
186