Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: gfx/native_theme_win.h

Issue 6246027: Move src/gfx/ to src/ui/gfx... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gfx/native_theme_linux.cc ('k') | gfx/native_theme_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // A wrapper class for working with custom XP/Vista themes provided in 5 // A wrapper class for working with custom XP/Vista themes provided in
6 // uxtheme.dll. This is a singleton class that can be grabbed using 6 // uxtheme.dll. This is a singleton class that can be grabbed using
7 // NativeTheme::instance(). 7 // NativeTheme::instance().
8 // For more information on visual style parts and states, see: 8 // For more information on visual style parts and states, see:
9 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/plat form/commctls/userex/topics/partsandstates.asp 9 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/plat form/commctls/userex/topics/partsandstates.asp
10 10
11 #ifndef APP_GFX_NATIVE_THEME_WIN_H_ 11 #ifndef APP_GFX_NATIVE_THEME_WIN_H_
12 #define APP_GFX_NATIVE_THEME_WIN_H_ 12 #define APP_GFX_NATIVE_THEME_WIN_H_
13 #pragma once 13 #pragma once
14 14
15 #include <windows.h> 15 #include "ui/gfx/native_theme_win.h"
16 #include <uxtheme.h> 16 // TODO(sail): remove this file once all includes have been updated.
17 #include "base/basictypes.h"
18 #include "gfx/size.h"
19 #include "third_party/skia/include/core/SkColor.h"
20
21 namespace skia {
22 class PlatformCanvas;
23 } // namespace skia
24
25 namespace gfx {
26
27 // TODO: Define class member enums to replace part_id and state_id parameters
28 // that are currently defined in <vssym32.h>. Afterward, classic_state should
29 // be removed and class users wouldn't need to include <vssym32.h> anymore.
30 // This would enable HOT state on non-themed UI (like when RDP'ing) and would
31 // simplify usage.
32 // TODO: This class should probably be changed to be platform independent at
33 // the same time.
34 class NativeTheme {
35 public:
36 enum ThemeName {
37 BUTTON,
38 LIST,
39 MENU,
40 MENULIST,
41 SCROLLBAR,
42 STATUS,
43 TAB,
44 TEXTFIELD,
45 TRACKBAR,
46 WINDOW,
47 PROGRESS,
48 SPIN,
49 LAST
50 };
51
52 // This enumeration is used within PaintMenuArrow in order to indicate the
53 // direction the menu arrow should point to.
54 enum MenuArrowDirection {
55 LEFT_POINTING_ARROW,
56 RIGHT_POINTING_ARROW
57 };
58
59 enum ControlState {
60 CONTROL_NORMAL,
61 CONTROL_HIGHLIGHTED,
62 CONTROL_DISABLED
63 };
64
65 typedef HRESULT (WINAPI* DrawThemeBackgroundPtr)(HANDLE theme,
66 HDC hdc,
67 int part_id,
68 int state_id,
69 const RECT* rect,
70 const RECT* clip_rect);
71 typedef HRESULT (WINAPI* DrawThemeBackgroundExPtr)(HANDLE theme,
72 HDC hdc,
73 int part_id,
74 int state_id,
75 const RECT* rect,
76 const DTBGOPTS* opts);
77 typedef HRESULT (WINAPI* GetThemeColorPtr)(HANDLE hTheme,
78 int part_id,
79 int state_id,
80 int prop_id,
81 COLORREF* color);
82 typedef HRESULT (WINAPI* GetThemeContentRectPtr)(HANDLE hTheme,
83 HDC hdc,
84 int part_id,
85 int state_id,
86 const RECT* rect,
87 RECT* content_rect);
88 typedef HRESULT (WINAPI* GetThemePartSizePtr)(HANDLE hTheme,
89 HDC hdc,
90 int part_id,
91 int state_id,
92 RECT* rect,
93 int ts,
94 SIZE* size);
95 typedef HANDLE (WINAPI* OpenThemeDataPtr)(HWND window,
96 LPCWSTR class_list);
97 typedef HRESULT (WINAPI* CloseThemeDataPtr)(HANDLE theme);
98
99 typedef void (WINAPI* SetThemeAppPropertiesPtr) (DWORD flags);
100 typedef BOOL (WINAPI* IsThemeActivePtr)();
101 typedef HRESULT (WINAPI* GetThemeIntPtr)(HANDLE hTheme,
102 int part_id,
103 int state_id,
104 int prop_id,
105 int *value);
106
107 HRESULT PaintButton(HDC hdc,
108 int part_id,
109 int state_id,
110 int classic_state,
111 RECT* rect) const;
112
113 HRESULT PaintDialogBackground(HDC dc, bool active, RECT* rect) const;
114
115 HRESULT PaintListBackground(HDC dc, bool enabled, RECT* rect) const;
116
117 // |arrow_direction| determines whether the arrow is pointing to the left or
118 // to the right. In RTL locales, sub-menus open from right to left and
119 // therefore the menu arrow should point to the left and not to the right.
120 HRESULT PaintMenuArrow(ThemeName theme,
121 HDC hdc,
122 int part_id,
123 int state_id,
124 RECT* rect,
125 MenuArrowDirection arrow_direction,
126 ControlState state) const;
127
128 HRESULT PaintMenuBackground(ThemeName theme,
129 HDC hdc,
130 int part_id,
131 int state_id,
132 RECT* rect) const;
133
134 HRESULT PaintMenuCheck(ThemeName theme,
135 HDC hdc,
136 int part_id,
137 int state_id,
138 RECT* rect,
139 ControlState state) const;
140
141 HRESULT PaintMenuCheckBackground(ThemeName theme,
142 HDC hdc,
143 int part_id,
144 int state_id,
145 RECT* rect) const;
146
147 HRESULT PaintMenuGutter(HDC hdc,
148 int part_id,
149 int state_id,
150 RECT* rect) const;
151
152 HRESULT PaintMenuItemBackground(ThemeName theme,
153 HDC hdc,
154 int part_id,
155 int state_id,
156 bool selected,
157 RECT* rect) const;
158
159 HRESULT PaintMenuList(HDC hdc,
160 int part_id,
161 int state_id,
162 int classic_state,
163 RECT* rect) const;
164
165 HRESULT PaintMenuSeparator(HDC hdc,
166 int part_id,
167 int state_id,
168 RECT* rect) const;
169
170 // Paints a scrollbar arrow. |classic_state| should have the appropriate
171 // classic part number ORed in already.
172 HRESULT PaintScrollbarArrow(HDC hdc,
173 int state_id,
174 int classic_state,
175 RECT* rect) const;
176
177 // Paints a scrollbar track section. |align_rect| is only used in classic
178 // mode, and makes sure the checkerboard pattern in |target_rect| is aligned
179 // with one presumed to be in |align_rect|.
180 HRESULT PaintScrollbarTrack(HDC hdc,
181 int part_id,
182 int state_id,
183 int classic_state,
184 RECT* target_rect,
185 RECT* align_rect,
186 skia::PlatformCanvas* canvas) const;
187
188 // Paints a scrollbar thumb or gripper.
189 HRESULT PaintScrollbarThumb(HDC hdc,
190 int part_id,
191 int state_id,
192 int classic_state,
193 RECT* rect) const;
194
195 HRESULT PaintSpinButton(HDC hdc,
196 int part_id,
197 int state_id,
198 int classic_state,
199 RECT* rect) const;
200
201 HRESULT PaintStatusGripper(HDC hdc,
202 int part_id,
203 int state_id,
204 int classic_state,
205 RECT* rect) const;
206
207 HRESULT PaintTabPanelBackground(HDC dc, RECT* rect) const;
208
209 HRESULT PaintTextField(HDC hdc,
210 int part_id,
211 int state_id,
212 int classic_state,
213 RECT* rect,
214 COLORREF color,
215 bool fill_content_area,
216 bool draw_edges) const;
217
218 HRESULT PaintTrackbar(HDC hdc,
219 int part_id,
220 int state_id,
221 int classic_state,
222 RECT* rect,
223 skia::PlatformCanvas* canvas) const;
224
225 HRESULT PaintProgressBar(HDC hdc,
226 RECT* bar_rect,
227 RECT* value_rect,
228 bool determinate,
229 double animated_seconds,
230 skia::PlatformCanvas* canvas) const;
231
232 bool IsThemingActive() const;
233
234 HRESULT GetThemePartSize(ThemeName themeName,
235 HDC hdc,
236 int part_id,
237 int state_id,
238 RECT* rect,
239 int ts,
240 SIZE* size) const;
241
242 HRESULT GetThemeColor(ThemeName theme,
243 int part_id,
244 int state_id,
245 int prop_id,
246 SkColor* color) const;
247
248 // Get the theme color if theming is enabled. If theming is unsupported
249 // for this part, use Win32's GetSysColor to find the color specified
250 // by default_sys_color.
251 SkColor GetThemeColorWithDefault(ThemeName theme,
252 int part_id,
253 int state_id,
254 int prop_id,
255 int default_sys_color) const;
256
257 HRESULT GetThemeInt(ThemeName theme,
258 int part_id,
259 int state_id,
260 int prop_id,
261 int *result) const;
262
263 // Get the thickness of the border associated with the specified theme,
264 // defaulting to GetSystemMetrics edge size if themes are disabled.
265 // In Classic Windows, borders are typically 2px; on XP+, they are 1px.
266 Size GetThemeBorderSize(ThemeName theme) const;
267
268 // Disables all theming for top-level windows in the entire process, from
269 // when this method is called until the process exits. All the other
270 // methods in this class will continue to work, but their output will ignore
271 // the user's theme. This is meant for use when running tests that require
272 // consistent visual results.
273 void DisableTheming() const;
274
275 // Closes cached theme handles so we can unload the DLL or update our UI
276 // for a theme change.
277 void CloseHandles() const;
278
279 // Returns true if classic theme is in use.
280 bool IsClassicTheme(ThemeName name) const;
281
282 // Gets our singleton instance.
283 static const NativeTheme* instance();
284
285 private:
286 NativeTheme();
287 ~NativeTheme();
288
289 HRESULT PaintFrameControl(HDC hdc,
290 RECT* rect,
291 UINT type,
292 UINT state,
293 ControlState control_state) const;
294
295 // Returns a handle to the theme data.
296 HANDLE GetThemeHandle(ThemeName theme_name) const;
297
298 // Function pointers into uxtheme.dll.
299 DrawThemeBackgroundPtr draw_theme_;
300 DrawThemeBackgroundExPtr draw_theme_ex_;
301 GetThemeColorPtr get_theme_color_;
302 GetThemeContentRectPtr get_theme_content_rect_;
303 GetThemePartSizePtr get_theme_part_size_;
304 OpenThemeDataPtr open_theme_;
305 CloseThemeDataPtr close_theme_;
306 SetThemeAppPropertiesPtr set_theme_properties_;
307 IsThemeActivePtr is_theme_active_;
308 GetThemeIntPtr get_theme_int_;
309
310 // Handle to uxtheme.dll.
311 HMODULE theme_dll_;
312
313 // A cache of open theme handles.
314 mutable HANDLE theme_handles_[LAST];
315
316 DISALLOW_COPY_AND_ASSIGN(NativeTheme);
317 };
318
319 } // namespace gfx
320 17
321 #endif // APP_GFX_NATIVE_THEME_WIN_H_ 18 #endif // APP_GFX_NATIVE_THEME_WIN_H_
OLDNEW
« no previous file with comments | « gfx/native_theme_linux.cc ('k') | gfx/native_theme_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698