]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/renderer.cpp
Warning fix and source cleaning.
[wxWidgets.git] / src / msw / renderer.cpp
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/renderer.cpp
3// Purpose: implementation of wxRendererNative for Windows
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>
9// License: wxWindows licence
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"
29 #include "wx/window.h"
30 #include "wx/dc.h"
31#endif //WX_PRECOMP
32
33#include "wx/splitter.h"
34#include "wx/renderer.h"
35#include "wx/msw/uxtheme.h"
36
37// ----------------------------------------------------------------------------
38// wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
39// ----------------------------------------------------------------------------
40
41class WXDLLEXPORT wxRendererMSW : public wxDelegateRendererNative
42{
43public:
44 wxRendererMSW() { }
45
46 static wxRendererNative& Get();
47
48private:
49 DECLARE_NO_COPY_CLASS(wxRendererMSW)
50};
51
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,
65 const wxRect& rect,
66 int flags = 0);
67 virtual void DrawSplitterSash(wxWindow *win,
68 wxDC& dc,
69 const wxSize& size,
70 wxCoord position,
71 wxOrientation orient,
72 int flags = 0);
73 virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
74
75private:
76 DECLARE_NO_COPY_CLASS(wxRendererXP)
77};
78
79// ============================================================================
80// wxRendererNative and wxRendererMSW implementation
81// ============================================================================
82
83/* static */
84wxRendererNative& wxRendererNative::GetDefault()
85{
86 wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get();
87 return themeEngine && themeEngine->IsAppThemed() ? wxRendererXP::Get()
88 : wxRendererMSW::Get();
89}
90
91/* static */
92wxRendererNative& wxRendererMSW::Get()
93{
94 static wxRendererMSW s_rendererMSW;
95
96 return s_rendererMSW;
97}
98
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
118wxSplitterRenderParams
119wxRendererXP::GetSplitterParams(const wxWindow * win)
120{
121 if (win->GetWindowStyle() & wxSP_NO_XP_THEME)
122 return m_rendererNative.GetSplitterParams(win);
123 else
124 return wxSplitterRenderParams(SASH_WIDTH, 0, false);
125}
126
127void
128wxRendererXP::DrawSplitterBorder(wxWindow * win,
129 wxDC& dc,
130 const wxRect& rect,
131 int flags)
132{
133 if (win->GetWindowStyle() & wxSP_NO_XP_THEME)
134 {
135 m_rendererNative.DrawSplitterBorder(win, dc, rect, flags);
136 }
137}
138
139void
140wxRendererXP::DrawSplitterSash(wxWindow *win,
141 wxDC& dc,
142 const wxSize& size,
143 wxCoord position,
144 wxOrientation orient,
145 int flags)
146{
147 if ( !win->HasFlag(wxSP_NO_XP_THEME) )
148 {
149 wxUxThemeHandle hTheme(win, L"WINDOW");
150 if ( hTheme )
151 {
152 RECT rect;
153 if ( orient == wxVERTICAL )
154 {
155 rect.left = position;
156 rect.right = position + SASH_WIDTH;
157 rect.top = 0;
158 rect.bottom = size.y;
159 }
160 else // wxHORIZONTAL
161 {
162 rect.left = 0;
163 rect.right = size.x;
164 rect.top = position;
165 rect.bottom = position + SASH_WIDTH;
166 }
167
168 wxUxThemeEngine::Get()->DrawThemeBackground
169 (
170 (WXHTHEME)hTheme,
171 dc.GetHDC(),
172 29, // WP_DIALOG: dlg background
173 0, // no particular state
174 &rect,
175 NULL
176 );
177 return;
178 }
179 }
180
181 m_rendererNative.DrawSplitterSash(win, dc, size, position, orient, flags);
182}
183