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

Side by Side Diff: base/gfx/native_theme.h

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

Powered by Google App Engine
This is Rietveld 408576698