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/observer_list.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" |
10 #include "ui/native_theme/native_theme_export.h" | 11 #include "ui/native_theme/native_theme_export.h" |
11 | 12 |
12 class SkCanvas; | 13 class SkCanvas; |
13 | 14 |
14 namespace gfx { | 15 namespace gfx { |
15 class Rect; | 16 class Rect; |
16 class Size; | 17 class Size; |
17 } | 18 } |
18 | 19 |
19 namespace ui { | 20 namespace ui { |
20 | 21 |
| 22 class NativeThemeObserver; |
| 23 |
21 // This class supports drawing UI controls (like buttons, text fields, lists, | 24 // This class supports drawing UI controls (like buttons, text fields, lists, |
22 // comboboxes, etc) that look like the native UI controls of the underlying | 25 // 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 | 26 // 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 | 27 // dialog box backgrounds, etc., which are obtained from the system theme where |
25 // possible. | 28 // possible. |
26 // | 29 // |
27 // The supported control types are listed in the Part enum. These parts can be | 30 // 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 | 31 // 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. | 32 // state is part-specific. The supported colors are listed in the ColorId enum. |
30 // | 33 // |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // Return a color from the system theme. | 307 // Return a color from the system theme. |
305 virtual SkColor GetSystemColor(ColorId color_id) const = 0; | 308 virtual SkColor GetSystemColor(ColorId color_id) const = 0; |
306 | 309 |
307 // Returns a shared instance of the native theme. | 310 // Returns a shared instance of the native theme. |
308 // The returned object should not be deleted by the caller. This function | 311 // The returned object should not be deleted by the caller. This function |
309 // is not thread safe and should only be called from the UI thread. | 312 // is not thread safe and should only be called from the UI thread. |
310 // Each port of NativeTheme should provide its own implementation of this | 313 // Each port of NativeTheme should provide its own implementation of this |
311 // function, returning the port's subclass. | 314 // function, returning the port's subclass. |
312 static NativeTheme* instance(); | 315 static NativeTheme* instance(); |
313 | 316 |
| 317 // Add or remove observers to be notified when the native theme changes. |
| 318 void AddObserver(NativeThemeObserver* observer); |
| 319 void RemoveObserver(NativeThemeObserver* observer); |
| 320 |
314 protected: | 321 protected: |
| 322 // Notify observers of native theme changes. |
| 323 void NotifyObservers(); |
| 324 |
315 NativeTheme(); | 325 NativeTheme(); |
316 virtual ~NativeTheme(); | 326 virtual ~NativeTheme(); |
317 | 327 |
318 unsigned int thumb_inactive_color_; | 328 unsigned int thumb_inactive_color_; |
319 unsigned int thumb_active_color_; | 329 unsigned int thumb_active_color_; |
320 unsigned int track_color_; | 330 unsigned int track_color_; |
321 | 331 |
| 332 private: |
| 333 // Observers to notify when the native theme changes. |
| 334 ObserverList<NativeThemeObserver> native_theme_observers_; |
| 335 |
322 DISALLOW_COPY_AND_ASSIGN(NativeTheme); | 336 DISALLOW_COPY_AND_ASSIGN(NativeTheme); |
323 }; | 337 }; |
324 | 338 |
325 } // namespace ui | 339 } // namespace ui |
326 | 340 |
327 #endif // UI_NATIVE_THEME_NATIVE_THEME_H_ | 341 #endif // UI_NATIVE_THEME_NATIVE_THEME_H_ |
OLD | NEW |