]> git.saurik.com Git - wxWidgets.git/blob - src/msw/renderer.cpp
corrections for buffers
[wxWidgets.git] / src / msw / renderer.cpp
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 license
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/renderer.h"
34
35 #include "wx/msw/uxtheme.h"
36
37 // ----------------------------------------------------------------------------
38 // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
39 // ----------------------------------------------------------------------------
40
41 class WXDLLEXPORT wxRendererMSW : public wxDelegateRendererNative
42 {
43 public:
44 wxRendererMSW() { }
45
46 static wxRendererNative& Get();
47
48 private:
49 DECLARE_NO_COPY_CLASS(wxRendererMSW)
50 };
51
52 // ----------------------------------------------------------------------------
53 // wxRendererXP: wxRendererNative implementation for Windows XP and later
54 // ----------------------------------------------------------------------------
55
56 class WXDLLEXPORT wxRendererXP : public wxDelegateRendererNative
57 {
58 public:
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
75 private:
76 DECLARE_NO_COPY_CLASS(wxRendererXP)
77 };
78
79 // ============================================================================
80 // wxRendererNative and wxRendererMSW implementation
81 // ============================================================================
82
83 /* static */
84 wxRendererNative& wxRendererNative::GetDefault()
85 {
86 wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get();
87 return themeEngine && themeEngine->IsAppThemed() ? wxRendererXP::Get()
88 : wxRendererMSW::Get();
89 }
90
91 /* static */
92 wxRendererNative& wxRendererMSW::Get()
93 {
94 static wxRendererMSW s_rendererMSW;
95
96 return s_rendererMSW;
97 }
98
99 // ============================================================================
100 // wxRendererXP implementation
101 // ============================================================================
102
103 /* static */
104 wxRendererNative& 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...
116 static const wxCoord SASH_WIDTH = 4;
117
118 wxSplitterRenderParams
119 wxRendererXP::GetSplitterParams(const wxWindow * WXUNUSED(win))
120 {
121 return wxSplitterRenderParams(SASH_WIDTH, 0, false);
122 }
123
124 void
125 wxRendererXP::DrawSplitterBorder(wxWindow * WXUNUSED(win),
126 wxDC& WXUNUSED(dc),
127 const wxRect& WXUNUSED(rect),
128 int WXUNUSED(flags))
129 {
130 }
131
132 void
133 wxRendererXP::DrawSplitterSash(wxWindow *win,
134 wxDC& dc,
135 const wxSize& size,
136 wxCoord position,
137 wxOrientation orient,
138 int WXUNUSED(flags))
139 {
140 // I don't know if it is correct to use the rebar background for the
141 // splitter but it least this works ok in the default theme
142 wxUxThemeHandle hTheme(win, L"REBAR");
143 if ( hTheme )
144 {
145 RECT rect;
146 if ( orient == wxVERTICAL )
147 {
148 rect.left = position;
149 rect.right = position + SASH_WIDTH;
150 rect.top = 0;
151 rect.bottom = size.y;
152 }
153 else // wxHORIZONTAL
154 {
155 rect.left = 0;
156 rect.right = size.x;
157 rect.top = position;
158 rect.bottom = position + SASH_WIDTH;
159 }
160
161 wxUxThemeEngine::Get()->DrawThemeBackground
162 (
163 (WXHTHEME)hTheme,
164 dc.GetHDC(),
165 3 /* RP_BAND */,
166 0 /* no state */ ,
167 &rect,
168 NULL
169 );
170 }
171 }
172