OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_NATIVE_THEME_NATIVE_THEME_WIN_H_ | 5 #ifndef UI_NATIVE_THEME_NATIVE_THEME_WIN_H_ |
6 #define UI_NATIVE_THEME_NATIVE_THEME_WIN_H_ | 6 #define UI_NATIVE_THEME_NATIVE_THEME_WIN_H_ |
7 | 7 |
8 // A wrapper class for working with custom XP/Vista themes provided in | 8 // A wrapper class for working with custom XP/Vista themes provided in |
9 // uxtheme.dll. This is a singleton class that can be grabbed using | 9 // uxtheme.dll. This is a singleton class that can be grabbed using |
10 // NativeThemeWin::instance(). | 10 // NativeThemeWin::instance(). |
11 // For more information on visual style parts and states, see: | 11 // For more information on visual style parts and states, see: |
12 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/plat
form/commctls/userex/topics/partsandstates.asp | 12 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/plat
form/commctls/userex/topics/partsandstates.asp |
13 | 13 |
| 14 #include <map> |
| 15 |
14 #include <windows.h> | 16 #include <windows.h> |
15 #include <uxtheme.h> | 17 #include <uxtheme.h> |
16 | 18 |
17 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
18 #include "base/compiler_specific.h" | 20 #include "base/compiler_specific.h" |
19 #include "third_party/skia/include/core/SkColor.h" | 21 #include "third_party/skia/include/core/SkColor.h" |
20 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
| 23 #include "ui/gfx/sys_color_change_listener.h" |
21 #include "ui/native_theme/native_theme.h" | 24 #include "ui/native_theme/native_theme.h" |
22 | 25 |
23 class SkCanvas; | 26 class SkCanvas; |
24 | 27 |
25 namespace ui { | 28 namespace ui { |
26 | 29 |
27 // Windows implementation of native theme class. | 30 // Windows implementation of native theme class. |
28 // | 31 // |
29 // At the moment, this class in in transition from an older API that consists | 32 // At the moment, this class in in transition from an older API that consists |
30 // of several PaintXXX methods to an API, inherited from the NativeTheme base | 33 // of several PaintXXX methods to an API, inherited from the NativeTheme base |
31 // class, that consists of a single Paint() method with a argument to indicate | 34 // class, that consists of a single Paint() method with a argument to indicate |
32 // what kind of part to paint. | 35 // what kind of part to paint. |
33 class NATIVE_THEME_EXPORT NativeThemeWin : public NativeTheme { | 36 class NATIVE_THEME_EXPORT NativeThemeWin : public NativeTheme, |
| 37 public gfx::SysColorChangeListener { |
34 public: | 38 public: |
35 enum ThemeName { | 39 enum ThemeName { |
36 BUTTON, | 40 BUTTON, |
37 LIST, | 41 LIST, |
38 MENU, | 42 MENU, |
39 MENULIST, | 43 MENULIST, |
40 SCROLLBAR, | 44 SCROLLBAR, |
41 STATUS, | 45 STATUS, |
42 TAB, | 46 TAB, |
43 TEXTFIELD, | 47 TEXTFIELD, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 93 |
90 HRESULT PaintTextField(HDC hdc, | 94 HRESULT PaintTextField(HDC hdc, |
91 int part_id, | 95 int part_id, |
92 int state_id, | 96 int state_id, |
93 int classic_state, | 97 int classic_state, |
94 RECT* rect, | 98 RECT* rect, |
95 COLORREF color, | 99 COLORREF color, |
96 bool fill_content_area, | 100 bool fill_content_area, |
97 bool draw_edges) const; | 101 bool draw_edges) const; |
98 | 102 |
99 // NativeTheme Implementation: | 103 // NativeTheme implementation: |
100 virtual gfx::Size GetPartSize(Part part, | 104 virtual gfx::Size GetPartSize(Part part, |
101 State state, | 105 State state, |
102 const ExtraParams& extra) const OVERRIDE; | 106 const ExtraParams& extra) const OVERRIDE; |
103 virtual void Paint(SkCanvas* canvas, | 107 virtual void Paint(SkCanvas* canvas, |
104 Part part, | 108 Part part, |
105 State state, | 109 State state, |
106 const gfx::Rect& rect, | 110 const gfx::Rect& rect, |
107 const ExtraParams& extra) const OVERRIDE; | 111 const ExtraParams& extra) const OVERRIDE; |
108 virtual SkColor GetSystemColor(ColorId color_id) const OVERRIDE; | 112 virtual SkColor GetSystemColor(ColorId color_id) const OVERRIDE; |
109 | 113 |
110 private: | 114 private: |
111 NativeThemeWin(); | 115 NativeThemeWin(); |
112 ~NativeThemeWin(); | 116 ~NativeThemeWin(); |
113 | 117 |
| 118 // gfx::SysColorChangeListener implementation: |
| 119 virtual void OnSysColorChange() OVERRIDE; |
| 120 |
| 121 // Update the locally cached set of system colors. |
| 122 void UpdateSystemColors(); |
| 123 |
114 // Paint directly to canvas' HDC. | 124 // Paint directly to canvas' HDC. |
115 void PaintDirect(SkCanvas* canvas, | 125 void PaintDirect(SkCanvas* canvas, |
116 Part part, | 126 Part part, |
117 State state, | 127 State state, |
118 const gfx::Rect& rect, | 128 const gfx::Rect& rect, |
119 const ExtraParams& extra) const; | 129 const ExtraParams& extra) const; |
120 | 130 |
121 // Create a temporary HDC, paint to that, clean up the alpha values in the | 131 // Create a temporary HDC, paint to that, clean up the alpha values in the |
122 // temporary HDC, and then blit the result to canvas. This is to work around | 132 // temporary HDC, and then blit the result to canvas. This is to work around |
123 // the fact that Windows XP and some classic themes give bogus alpha values. | 133 // the fact that Windows XP and some classic themes give bogus alpha values. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 SetThemeAppPropertiesPtr set_theme_properties_; | 335 SetThemeAppPropertiesPtr set_theme_properties_; |
326 IsThemeActivePtr is_theme_active_; | 336 IsThemeActivePtr is_theme_active_; |
327 GetThemeIntPtr get_theme_int_; | 337 GetThemeIntPtr get_theme_int_; |
328 | 338 |
329 // Handle to uxtheme.dll. | 339 // Handle to uxtheme.dll. |
330 HMODULE theme_dll_; | 340 HMODULE theme_dll_; |
331 | 341 |
332 // A cache of open theme handles. | 342 // A cache of open theme handles. |
333 mutable HANDLE theme_handles_[LAST]; | 343 mutable HANDLE theme_handles_[LAST]; |
334 | 344 |
| 345 // The system color change listener and the updated cache of system colors. |
| 346 gfx::ScopedSysColorChangeListener color_change_listener_; |
| 347 mutable std::map<int, SkColor> system_colors_; |
| 348 |
335 DISALLOW_COPY_AND_ASSIGN(NativeThemeWin); | 349 DISALLOW_COPY_AND_ASSIGN(NativeThemeWin); |
336 }; | 350 }; |
337 | 351 |
338 } // namespace ui | 352 } // namespace ui |
339 | 353 |
340 #endif // UI_NATIVE_THEME_NATIVE_THEME_WIN_H_ | 354 #endif // UI_NATIVE_THEME_NATIVE_THEME_WIN_H_ |
OLD | NEW |