]>
Commit | Line | Data |
---|---|---|
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 | 35 | #include "wx/msw/uxtheme.h" |
03f01e63 | 36 | #include "wx/msw/private.h" |
8b97949e | 37 | |
9c7f49f5 | 38 | // ---------------------------------------------------------------------------- |
8b97949e | 39 | // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems |
9c7f49f5 VZ |
40 | // ---------------------------------------------------------------------------- |
41 | ||
38c4cb6a | 42 | class WXDLLEXPORT wxRendererMSW : public wxDelegateRendererNative |
9c7f49f5 | 43 | { |
2eb10e2a VZ |
44 | public: |
45 | wxRendererMSW() { } | |
46 | ||
8b97949e VZ |
47 | static wxRendererNative& Get(); |
48 | ||
7402677a VZ |
49 | virtual void DrawComboBoxDropButton(wxWindow *win, |
50 | wxDC& dc, | |
51 | const wxRect& rect, | |
52 | int flags = 0); | |
53 | ||
2eb10e2a VZ |
54 | private: |
55 | DECLARE_NO_COPY_CLASS(wxRendererMSW) | |
9c7f49f5 VZ |
56 | }; |
57 | ||
8b97949e VZ |
58 | // ---------------------------------------------------------------------------- |
59 | // wxRendererXP: wxRendererNative implementation for Windows XP and later | |
60 | // ---------------------------------------------------------------------------- | |
61 | ||
62 | class WXDLLEXPORT wxRendererXP : public wxDelegateRendererNative | |
63 | { | |
64 | public: | |
65 | wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { } | |
66 | ||
67 | static wxRendererNative& Get(); | |
68 | ||
69 | virtual void DrawSplitterBorder(wxWindow *win, | |
70 | wxDC& dc, | |
c4e6c15e VZ |
71 | const wxRect& rect, |
72 | int flags = 0); | |
8b97949e VZ |
73 | virtual void DrawSplitterSash(wxWindow *win, |
74 | wxDC& dc, | |
75 | const wxSize& size, | |
76 | wxCoord position, | |
c4e6c15e VZ |
77 | wxOrientation orient, |
78 | int flags = 0); | |
7402677a | 79 | |
c4e6c15e | 80 | virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win); |
8b97949e VZ |
81 | |
82 | private: | |
83 | DECLARE_NO_COPY_CLASS(wxRendererXP) | |
84 | }; | |
85 | ||
9c7f49f5 | 86 | // ============================================================================ |
8b97949e | 87 | // wxRendererNative and wxRendererMSW implementation |
9c7f49f5 VZ |
88 | // ============================================================================ |
89 | ||
90 | /* static */ | |
f0244295 | 91 | wxRendererNative& wxRendererNative::GetDefault() |
8b97949e VZ |
92 | { |
93 | wxUxThemeEngine *themeEngine = wxUxThemeEngine::Get(); | |
3afc693f VZ |
94 | return themeEngine && themeEngine->IsAppThemed() ? wxRendererXP::Get() |
95 | : wxRendererMSW::Get(); | |
8b97949e VZ |
96 | } |
97 | ||
98 | /* static */ | |
99 | wxRendererNative& wxRendererMSW::Get() | |
9c7f49f5 VZ |
100 | { |
101 | static wxRendererMSW s_rendererMSW; | |
102 | ||
103 | return s_rendererMSW; | |
104 | } | |
105 | ||
7402677a VZ |
106 | void |
107 | wxRendererMSW::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 | ||
8b97949e VZ |
127 | // ============================================================================ |
128 | // wxRendererXP implementation | |
129 | // ============================================================================ | |
130 | ||
131 | /* static */ | |
132 | wxRendererNative& 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... | |
144 | static const wxCoord SASH_WIDTH = 4; | |
145 | ||
c4e6c15e | 146 | wxSplitterRenderParams |
3c2544bb | 147 | wxRendererXP::GetSplitterParams(const wxWindow * win) |
8b97949e | 148 | { |
3c2544bb JS |
149 | if (win->GetWindowStyle() & wxSP_NO_XP_THEME) |
150 | return m_rendererNative.GetSplitterParams(win); | |
151 | else | |
152 | return wxSplitterRenderParams(SASH_WIDTH, 0, false); | |
8b97949e VZ |
153 | } |
154 | ||
155 | void | |
3c2544bb JS |
156 | wxRendererXP::DrawSplitterBorder(wxWindow * win, |
157 | wxDC& dc, | |
158 | const wxRect& rect, | |
159 | int flags) | |
8b97949e | 160 | { |
3c2544bb JS |
161 | if (win->GetWindowStyle() & wxSP_NO_XP_THEME) |
162 | { | |
163 | m_rendererNative.DrawSplitterBorder(win, dc, rect, flags); | |
164 | } | |
8b97949e VZ |
165 | } |
166 | ||
167 | void | |
168 | wxRendererXP::DrawSplitterSash(wxWindow *win, | |
169 | wxDC& dc, | |
170 | const wxSize& size, | |
171 | wxCoord position, | |
c4e6c15e | 172 | wxOrientation orient, |
3c2544bb | 173 | int flags) |
8b97949e | 174 | { |
6421119d | 175 | if ( !win->HasFlag(wxSP_NO_XP_THEME) ) |
8b97949e | 176 | { |
6421119d VZ |
177 | wxUxThemeHandle hTheme(win, L"WINDOW"); |
178 | if ( hTheme ) | |
8b97949e | 179 | { |
6421119d VZ |
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; | |
8b97949e | 206 | } |
8b97949e | 207 | } |
6421119d VZ |
208 | |
209 | m_rendererNative.DrawSplitterSash(win, dc, size, position, orient, flags); | |
8b97949e VZ |
210 | } |
211 |