Chromium Code Reviews| 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> | |
| 14 #include <windows.h> | 15 #include <windows.h> |
|
msw - DO NOT USE
2012/12/07 19:10:37
Hmm, including uxtheme.h before windows.h causes b
| |
| 15 #include <uxtheme.h> | 16 #include <uxtheme.h> |
| 16 | 17 |
| 17 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
| 18 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
| 19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
| 20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 22 #include "ui/gfx/sys_color_change_listener.h" | |
| 21 #include "ui/native_theme/native_theme.h" | 23 #include "ui/native_theme/native_theme.h" |
| 22 | 24 |
| 23 class SkCanvas; | 25 class SkCanvas; |
| 24 | 26 |
| 25 namespace ui { | 27 namespace ui { |
| 26 | 28 |
| 27 // Windows implementation of native theme class. | 29 // Windows implementation of native theme class. |
| 28 // | 30 // |
| 29 // At the moment, this class in in transition from an older API that consists | 31 // 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 | 32 // 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 | 33 // class, that consists of a single Paint() method with a argument to indicate |
| 32 // what kind of part to paint. | 34 // what kind of part to paint. |
| 33 class NATIVE_THEME_EXPORT NativeThemeWin : public NativeTheme { | 35 class NATIVE_THEME_EXPORT NativeThemeWin : public NativeTheme, |
| 36 public gfx::SysColorChangeListener { | |
| 34 public: | 37 public: |
| 35 enum ThemeName { | 38 enum ThemeName { |
| 36 BUTTON, | 39 BUTTON, |
| 37 LIST, | 40 LIST, |
| 38 MENU, | 41 MENU, |
| 39 MENULIST, | 42 MENULIST, |
| 40 SCROLLBAR, | 43 SCROLLBAR, |
| 41 STATUS, | 44 STATUS, |
| 42 TAB, | 45 TAB, |
| 43 TEXTFIELD, | 46 TEXTFIELD, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 | 92 |
| 90 HRESULT PaintTextField(HDC hdc, | 93 HRESULT PaintTextField(HDC hdc, |
| 91 int part_id, | 94 int part_id, |
| 92 int state_id, | 95 int state_id, |
| 93 int classic_state, | 96 int classic_state, |
| 94 RECT* rect, | 97 RECT* rect, |
| 95 COLORREF color, | 98 COLORREF color, |
| 96 bool fill_content_area, | 99 bool fill_content_area, |
| 97 bool draw_edges) const; | 100 bool draw_edges) const; |
| 98 | 101 |
| 99 // NativeTheme Implementation: | 102 // NativeTheme implementation: |
| 100 virtual gfx::Size GetPartSize(Part part, | 103 virtual gfx::Size GetPartSize(Part part, |
| 101 State state, | 104 State state, |
| 102 const ExtraParams& extra) const OVERRIDE; | 105 const ExtraParams& extra) const OVERRIDE; |
| 103 virtual void Paint(SkCanvas* canvas, | 106 virtual void Paint(SkCanvas* canvas, |
| 104 Part part, | 107 Part part, |
| 105 State state, | 108 State state, |
| 106 const gfx::Rect& rect, | 109 const gfx::Rect& rect, |
| 107 const ExtraParams& extra) const OVERRIDE; | 110 const ExtraParams& extra) const OVERRIDE; |
| 108 virtual SkColor GetSystemColor(ColorId color_id) const OVERRIDE; | 111 virtual SkColor GetSystemColor(ColorId color_id) const OVERRIDE; |
| 109 | 112 |
| 110 private: | 113 private: |
| 111 NativeThemeWin(); | 114 NativeThemeWin(); |
| 112 ~NativeThemeWin(); | 115 ~NativeThemeWin(); |
| 113 | 116 |
| 117 // gfx::SysColorChangeListener implementation: | |
| 118 virtual void OnSysColorChange() OVERRIDE; | |
| 119 | |
| 120 // Update the locally cached set of system colors. | |
| 121 void UpdateSystemColors(); | |
| 122 | |
| 114 // Paint directly to canvas' HDC. | 123 // Paint directly to canvas' HDC. |
| 115 void PaintDirect(SkCanvas* canvas, | 124 void PaintDirect(SkCanvas* canvas, |
| 116 Part part, | 125 Part part, |
| 117 State state, | 126 State state, |
| 118 const gfx::Rect& rect, | 127 const gfx::Rect& rect, |
| 119 const ExtraParams& extra) const; | 128 const ExtraParams& extra) const; |
| 120 | 129 |
| 121 // Create a temporary HDC, paint to that, clean up the alpha values in the | 130 // 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 | 131 // 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. | 132 // 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_; | 334 SetThemeAppPropertiesPtr set_theme_properties_; |
| 326 IsThemeActivePtr is_theme_active_; | 335 IsThemeActivePtr is_theme_active_; |
| 327 GetThemeIntPtr get_theme_int_; | 336 GetThemeIntPtr get_theme_int_; |
| 328 | 337 |
| 329 // Handle to uxtheme.dll. | 338 // Handle to uxtheme.dll. |
| 330 HMODULE theme_dll_; | 339 HMODULE theme_dll_; |
| 331 | 340 |
| 332 // A cache of open theme handles. | 341 // A cache of open theme handles. |
| 333 mutable HANDLE theme_handles_[LAST]; | 342 mutable HANDLE theme_handles_[LAST]; |
| 334 | 343 |
| 344 // The system color change listener and the updated cache of system colors. | |
| 345 gfx::ScopedSysColorChangeListener color_change_listener_; | |
| 346 mutable std::map<int, SkColor> system_colors_; | |
| 347 | |
| 335 DISALLOW_COPY_AND_ASSIGN(NativeThemeWin); | 348 DISALLOW_COPY_AND_ASSIGN(NativeThemeWin); |
| 336 }; | 349 }; |
| 337 | 350 |
| 338 } // namespace ui | 351 } // namespace ui |
| 339 | 352 |
| 340 #endif // UI_NATIVE_THEME_NATIVE_THEME_WIN_H_ | 353 #endif // UI_NATIVE_THEME_NATIVE_THEME_WIN_H_ |
| OLD | NEW |