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_H_ | 5 #ifndef UI_NATIVE_THEME_NATIVE_THEME_H_ |
| 6 #define UI_NATIVE_THEME_NATIVE_THEME_H_ | 6 #define UI_NATIVE_THEME_NATIVE_THEME_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | |
| 8 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 9 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 11 #include "ui/gfx/sys_color_change_listener.h" | |
| 10 #include "ui/native_theme/native_theme_export.h" | 12 #include "ui/native_theme/native_theme_export.h" |
| 11 | 13 |
| 12 class SkCanvas; | 14 class SkCanvas; |
| 13 | 15 |
| 14 namespace gfx { | 16 namespace gfx { |
| 15 class Rect; | 17 class Rect; |
| 16 class Size; | 18 class Size; |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace ui { | 21 namespace ui { |
| 20 | 22 |
| 21 // This class supports drawing UI controls (like buttons, text fields, lists, | 23 // This class supports drawing UI controls (like buttons, text fields, lists, |
| 22 // comboboxes, etc) that look like the native UI controls of the underlying | 24 // comboboxes, etc) that look like the native UI controls of the underlying |
| 23 // platform, such as Windows or Linux. It also supplies default colors for | 25 // platform, such as Windows or Linux. It also supplies default colors for |
| 24 // dialog box backgrounds, etc., which are obtained from the system theme where | 26 // dialog box backgrounds, etc., which are obtained from the system theme where |
| 25 // possible. | 27 // possible. |
| 26 // | 28 // |
| 27 // The supported control types are listed in the Part enum. These parts can be | 29 // The supported control types are listed in the Part enum. These parts can be |
| 28 // in any state given by the State enum, where the actual definition of the | 30 // in any state given by the State enum, where the actual definition of the |
| 29 // state is part-specific. The supported colors are listed in the ColorId enum. | 31 // state is part-specific. The supported colors are listed in the ColorId enum. |
| 30 // | 32 // |
| 31 // Some parts require more information than simply the state in order to be | 33 // Some parts require more information than simply the state in order to be |
| 32 // drawn correctly, and this information is given to the Paint() method via the | 34 // drawn correctly, and this information is given to the Paint() method via the |
| 33 // ExtraParams union. Each part that requires more information has its own | 35 // ExtraParams union. Each part that requires more information has its own |
| 34 // field in the union. | 36 // field in the union. |
| 35 // | 37 // |
| 36 // NativeTheme also supports getting the default size of a given part with | 38 // NativeTheme also supports getting the default size of a given part with |
| 37 // the GetPartSize() method. | 39 // the GetPartSize() method. |
| 38 class NATIVE_THEME_EXPORT NativeTheme { | 40 class NATIVE_THEME_EXPORT NativeTheme : public gfx::SysColorChangeListener { |
|
sky
2012/12/04 22:38:14
Since only windows actually implement OnSysColorCh
msw
2012/12/05 02:09:56
Done.
| |
| 39 public: | 41 public: |
| 40 // The part to be painted / sized. | 42 // The part to be painted / sized. |
| 41 enum Part { | 43 enum Part { |
| 42 kCheckbox, | 44 kCheckbox, |
| 43 kInnerSpinButton, | 45 kInnerSpinButton, |
| 44 kMenuList, | 46 kMenuList, |
| 45 kMenuCheck, | 47 kMenuCheck, |
| 46 kMenuCheckBackground, | 48 kMenuCheckBackground, |
| 47 kMenuPopupArrow, | 49 kMenuPopupArrow, |
| 48 kMenuPopupBackground, | 50 kMenuPopupBackground, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 kColorId_MenuSeparatorColor, | 238 kColorId_MenuSeparatorColor, |
| 237 kColorId_MenuBackgroundColor, | 239 kColorId_MenuBackgroundColor, |
| 238 kColorId_MenuBorderColor, | 240 kColorId_MenuBorderColor, |
| 239 // Label | 241 // Label |
| 240 kColorId_LabelEnabledColor, | 242 kColorId_LabelEnabledColor, |
| 241 kColorId_LabelDisabledColor, | 243 kColorId_LabelDisabledColor, |
| 242 kColorId_LabelBackgroundColor, | 244 kColorId_LabelBackgroundColor, |
| 243 // Textfield | 245 // Textfield |
| 244 kColorId_TextfieldDefaultColor, | 246 kColorId_TextfieldDefaultColor, |
| 245 kColorId_TextfieldDefaultBackground, | 247 kColorId_TextfieldDefaultBackground, |
| 248 kColorId_TextfieldReadOnlyColor, | |
| 249 kColorId_TextfieldReadOnlyBackground, | |
| 246 kColorId_TextfieldSelectionColor, | 250 kColorId_TextfieldSelectionColor, |
| 247 kColorId_TextfieldSelectionBackgroundFocused, | 251 kColorId_TextfieldSelectionBackgroundFocused, |
| 248 kColorId_TextfieldSelectionBackgroundUnfocused, | 252 kColorId_TextfieldSelectionBackgroundUnfocused, |
| 249 // TODO(benrg): move other hardcoded colors here. | 253 // TODO(benrg): move other hardcoded colors here. |
| 250 }; | 254 }; |
| 251 | 255 |
| 252 // Return a color from the system theme. | 256 // Return a color from the system theme. |
| 253 virtual SkColor GetSystemColor(ColorId color_id) const = 0; | 257 virtual SkColor GetSystemColor(ColorId color_id) const = 0; |
| 254 | 258 |
| 255 // Returns a shared instance of the native theme. | 259 // Returns a shared instance of the native theme. |
| 256 // The returned object should not be deleted by the caller. This function | 260 // The returned object should not be deleted by the caller. This function |
| 257 // is not thread safe and should only be called from the UI thread. | 261 // is not thread safe and should only be called from the UI thread. |
| 258 // Each port of NativeTheme should provide its own implementation of this | 262 // Each port of NativeTheme should provide its own implementation of this |
| 259 // function, returning the port's subclass. | 263 // function, returning the port's subclass. |
| 260 static NativeTheme* instance(); | 264 static NativeTheme* instance(); |
| 261 | 265 |
| 262 static bool IsNewMenuStyleEnabled(); | 266 static bool IsNewMenuStyleEnabled(); |
| 263 | 267 |
| 264 protected: | 268 protected: |
| 265 NativeTheme(); | 269 NativeTheme(); |
| 266 virtual ~NativeTheme() {} | 270 virtual ~NativeTheme(); |
| 271 | |
| 272 // gfx::SysColorChangeListener implementation: | |
| 273 virtual void OnSysColorChange() OVERRIDE; | |
| 274 | |
| 275 gfx::ScopedSysColorChangeListener color_change_listener_; | |
| 267 | 276 |
| 268 unsigned int thumb_inactive_color_; | 277 unsigned int thumb_inactive_color_; |
| 269 unsigned int thumb_active_color_; | 278 unsigned int thumb_active_color_; |
| 270 unsigned int track_color_; | 279 unsigned int track_color_; |
| 271 | 280 |
| 272 DISALLOW_COPY_AND_ASSIGN(NativeTheme); | 281 DISALLOW_COPY_AND_ASSIGN(NativeTheme); |
| 273 }; | 282 }; |
| 274 | 283 |
| 275 } // namespace ui | 284 } // namespace ui |
| 276 | 285 |
| 277 #endif // UI_NATIVE_THEME_NATIVE_THEME_H_ | 286 #endif // UI_NATIVE_THEME_NATIVE_THEME_H_ |
| OLD | NEW |