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

Side by Side Diff: ui/native_theme/native_theme_win.h

Issue 239093007: Update Windows UI on system color changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase. Created 6 years, 8 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
OLDNEW
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 <map>
15 15
16 #include <windows.h> 16 #include <windows.h>
17 #include <uxtheme.h> 17 #include <uxtheme.h>
18 18
19 #include "base/basictypes.h" 19 #include "base/basictypes.h"
20 #include "base/compiler_specific.h" 20 #include "base/compiler_specific.h"
21 #include "third_party/skia/include/core/SkColor.h" 21 #include "third_party/skia/include/core/SkColor.h"
22 #include "ui/gfx/size.h" 22 #include "ui/gfx/size.h"
23 #include "ui/gfx/sys_color_change_listener.h"
24 #include "ui/native_theme/native_theme.h" 23 #include "ui/native_theme/native_theme.h"
25 24
26 class SkCanvas; 25 class SkCanvas;
27 26
28 namespace ui { 27 namespace ui {
29 28
30 // Windows implementation of native theme class. 29 // Windows implementation of native theme class.
31 // 30 //
32 // 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
33 // 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
34 // 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
35 // what kind of part to paint. 34 // what kind of part to paint.
36 class NATIVE_THEME_EXPORT NativeThemeWin : public NativeTheme, 35 class NATIVE_THEME_EXPORT NativeThemeWin : public NativeTheme {
37 public gfx::SysColorChangeListener {
38 public: 36 public:
39 enum ThemeName { 37 enum ThemeName {
40 BUTTON, 38 BUTTON,
41 LIST, 39 LIST,
42 MENU, 40 MENU,
43 MENULIST, 41 MENULIST,
44 SCROLLBAR, 42 SCROLLBAR,
45 STATUS, 43 STATUS,
46 TAB, 44 TAB,
47 TEXTFIELD, 45 TEXTFIELD,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 virtual gfx::Size GetPartSize(Part part, 105 virtual gfx::Size GetPartSize(Part part,
108 State state, 106 State state,
109 const ExtraParams& extra) const OVERRIDE; 107 const ExtraParams& extra) const OVERRIDE;
110 virtual void Paint(SkCanvas* canvas, 108 virtual void Paint(SkCanvas* canvas,
111 Part part, 109 Part part,
112 State state, 110 State state,
113 const gfx::Rect& rect, 111 const gfx::Rect& rect,
114 const ExtraParams& extra) const OVERRIDE; 112 const ExtraParams& extra) const OVERRIDE;
115 virtual SkColor GetSystemColor(ColorId color_id) const OVERRIDE; 113 virtual SkColor GetSystemColor(ColorId color_id) const OVERRIDE;
116 114
115 protected:
116 // gfx::SysColorChangeListener implementation:
117 virtual void OnSysColorChange() OVERRIDE;
118
117 private: 119 private:
118 NativeThemeWin(); 120 NativeThemeWin();
119 ~NativeThemeWin(); 121 ~NativeThemeWin();
120 122
121 // gfx::SysColorChangeListener implementation:
122 virtual void OnSysColorChange() OVERRIDE;
123
124 // Update the locally cached set of system colors. 123 // Update the locally cached set of system colors.
125 void UpdateSystemColors(); 124 void UpdateSystemColors();
126 125
127 // Paint directly to canvas' HDC. 126 // Paint directly to canvas' HDC.
128 void PaintDirect(SkCanvas* canvas, 127 void PaintDirect(SkCanvas* canvas,
129 Part part, 128 Part part,
130 State state, 129 State state,
131 const gfx::Rect& rect, 130 const gfx::Rect& rect,
132 const ExtraParams& extra) const; 131 const ExtraParams& extra) const;
133 132
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 SetThemeAppPropertiesPtr set_theme_properties_; 347 SetThemeAppPropertiesPtr set_theme_properties_;
349 IsThemeActivePtr is_theme_active_; 348 IsThemeActivePtr is_theme_active_;
350 GetThemeIntPtr get_theme_int_; 349 GetThemeIntPtr get_theme_int_;
351 350
352 // Handle to uxtheme.dll. 351 // Handle to uxtheme.dll.
353 HMODULE theme_dll_; 352 HMODULE theme_dll_;
354 353
355 // A cache of open theme handles. 354 // A cache of open theme handles.
356 mutable HANDLE theme_handles_[LAST]; 355 mutable HANDLE theme_handles_[LAST];
357 356
358 // The system color change listener and the updated cache of system colors. 357 // The cache of system colors.
359 gfx::ScopedSysColorChangeListener color_change_listener_;
360 mutable std::map<int, SkColor> system_colors_; 358 mutable std::map<int, SkColor> system_colors_;
361 359
362 // Is a high contrast theme active? 360 // Is a high contrast theme active?
363 mutable bool is_using_high_contrast_; 361 mutable bool is_using_high_contrast_;
364 362
365 // Is |is_using_high_contrast_| valid? 363 // Is |is_using_high_contrast_| valid?
366 mutable bool is_using_high_contrast_valid_; 364 mutable bool is_using_high_contrast_valid_;
367 365
368 DISALLOW_COPY_AND_ASSIGN(NativeThemeWin); 366 DISALLOW_COPY_AND_ASSIGN(NativeThemeWin);
369 }; 367 };
370 368
371 } // namespace ui 369 } // namespace ui
372 370
373 #endif // UI_NATIVE_THEME_NATIVE_THEME_WIN_H_ 371 #endif // UI_NATIVE_THEME_NATIVE_THEME_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698