]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/renderer.cpp
Fix for GCC compilation
[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#include "wx/msw/private.h"
37
38// ----------------------------------------------------------------------------
39// wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
40// ----------------------------------------------------------------------------
41
42class WXDLLEXPORT wxRendererMSW : public wxDelegateRendererNative
43{
44public:
45 wxRendererMSW() { }
46
47 static wxRendererNative& Get();
48
49 virtual void DrawComboBoxDropButton(wxWindow *win,
50 wxDC& dc,
51 const wxRect& rect,
52 int flags = 0);
53
54private:
55 DECLARE_NO_COPY_CLASS(wxRendererMSW)
56};
57
58// ----------------------------------------------------------------------------
59// wxRendererXP: wxRendererNative implementation for Windows XP and later
60// ----------------------------------------------------------------------------
61
62class WXDLLEXPORT wxRendererXP : public wxDelegateRendererNative
63{
64public:
65 wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { }
66
67 static wxRendererNative& Get();
68
69 virtual void DrawSplitterBorder(wxWindow *win,
70 wxDC& dc,
71 const wxRect& rect,
72 int flags = 0);
73 virtual void DrawSplitterSash(wxWindow *win,
74 wxDC& dc,
75 const wxSize& size,
76 wxCoord position,
77 wxOrientation orient,
78 int flags = 0);
79
80 virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
81
82private:
83 DECLARE_NO_COPY_CLASS(wxRendererXP)
84};
85
86// ============================================================================
87// wxRendererNative and wxRendererMSW implementation
88// ============================================================================
89
90/* static */
91wxRendererNative& wxRendererNative::GetDefault()
92{
93 wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get();
94 return themeEngine && themeEngine->IsAppThemed() ? wxRendererXP::Get()
95 : wxRendererMSW::Get();
96}
97
98/* static */
99wxRendererNative& wxRendererMSW::Get()
100{
101 static wxRendererMSW s_rendererMSW;
102
103 return s_rendererMSW;
104}
105
106void
107wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win),
108 wxDC& dc,
109 const wxRect& rect,
110 int flags)
111{
112 RECT r;
113 r.left = rect.GetLeft();
114 r.top = rect.GetTop();
115 r.bottom = rect.GetBottom();
116 r.right = rect.GetRight();
117
118 int style = DFCS_SCROLLCOMBOBOX;
119 if ( flags & wxCONTROL_DISABLED )
120 style |= DFCS_INACTIVE;
121 if ( flags & wxCONTROL_PRESSED )
122 style |= DFCS_PUSHED;
123
124 ::DrawFrameControl(GetHdcOf(dc), &r, DFC_SCROLL, style);
125}
126
127// ============================================================================
128// wxRendererXP implementation
129// ============================================================================
130
131/* static */
132wxRendererNative& wxRendererXP::Get()
133{
134 static wxRendererXP s_rendererXP;
135
136 return s_rendererXP;
137}
138
139// ----------------------------------------------------------------------------
140// splitter drawing
141// ----------------------------------------------------------------------------
142
143// the width of the sash: this is the same as used by Explorer...
144static const wxCoord SASH_WIDTH = 4;
145
146wxSplitterRenderParams
147wxRendererXP::GetSplitterParams(const wxWindow * win)
148{
149 if (win->GetWindowStyle() & wxSP_NO_XP_THEME)
150 return m_rendererNative.GetSplitterParams(win);
151 else
152 return wxSplitterRenderParams(SASH_WIDTH, 0, false);
153}
154
155void
156wxRendererXP::DrawSplitterBorder(wxWindow * win,
157 wxDC& dc,
158 const wxRect& rect,
159 int flags)
160{
161 if (win->GetWindowStyle() & wxSP_NO_XP_THEME)
162 {
163 m_rendererNative.DrawSplitterBorder(win, dc, rect, flags);
164 }
165}
166
167void
168wxRendererXP::DrawSplitterSash(wxWindow *win,
169 wxDC& dc,
170 const wxSize& size,
171 wxCoord position,
172 wxOrientation orient,
173 int flags)
174{
175 if ( !win->HasFlag(wxSP_NO_XP_THEME) )
176 {
177 wxUxThemeHandle hTheme(win, L"WINDOW");
178 if ( hTheme )
179 {
180 RECT rect;
181 if ( orient == wxVERTICAL )
182 {
183 rect.left = position;
184 rect.right = position + SASH_WIDTH;
185 rect.top = 0;
186 rect.bottom = size.y;
187 }
188 else // wxHORIZONTAL
189 {
190 rect.left = 0;
191 rect.right = size.x;
192 rect.top = position;
193 rect.bottom = position + SASH_WIDTH;
194 }
195
196 wxUxThemeEngine::Get()->DrawThemeBackground
197 (
198 (WXHTHEME)hTheme,
199 dc.GetHDC(),
200 29, // WP_DIALOG: dlg background
201 0, // no particular state
202 &rect,
203 NULL
204 );
205 return;
206 }
207 }
208
209 m_rendererNative.DrawSplitterSash(win, dc, size, position, orient, flags);
210}
211