Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_GFX_NATIVE_THEME_H_ | 5 #ifndef UI_GFX_NATIVE_THEME_H_ |
| 6 #define UI_GFX_NATIVE_THEME_H_ | 6 #define UI_GFX_NATIVE_THEME_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 10 #include "ui/base/ui_export.h" | 10 #include "ui/base/ui_export.h" |
| 11 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 12 | 12 |
| 13 class SkCanvas; | 13 class SkCanvas; |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 | 16 |
| 17 namespace { | |
| 18 // Returned by GetSystemColor() in response to an invalid ColorId. | |
| 19 const SkColor kColorYouShouldNeverSee = SkColorSetRGB(255, 0, 128); | |
|
James Cook
2011/11/19 00:28:14
I wouldn't do this in a header file, even though t
benrg
2011/11/21 18:32:40
It seems silly to add a public method for code tha
| |
| 20 } | |
| 21 | |
| 17 class Rect; | 22 class Rect; |
| 18 class Size; | 23 class Size; |
| 19 | 24 |
| 20 // This class supports drawing UI controls (like buttons, text fields, lists, | 25 // This class supports drawing UI controls (like buttons, text fields, lists, |
| 21 // comboboxes, etc) that look like the native UI controls of the underlying | 26 // comboboxes, etc) that look like the native UI controls of the underlying |
| 22 // platform, such as Windows or Linux. | 27 // platform, such as Windows or Linux. It also supplies default colors for |
| 28 // dialog box backgrounds, etc., which are obtained from the system theme where | |
| 29 // possible. | |
| 23 // | 30 // |
| 24 // The supported control types are listed in the Part enum. These parts can be | 31 // The supported control types are listed in the Part enum. These parts can be |
| 25 // in any state given by the State enum, where the actual definititon of the | 32 // in any state given by the State enum, where the actual definition of the |
| 26 // state is part-specific. | 33 // state is part-specific. The supported colors are listed in the ColorId enum. |
| 27 // | 34 // |
| 28 // Some parts require more information than simply the state in order to be | 35 // Some parts require more information than simply the state in order to be |
| 29 // drawn correctly, and this information is given to the Paint() method via the | 36 // drawn correctly, and this information is given to the Paint() method via the |
| 30 // ExtraParams union. Each part that requires more information has its own | 37 // ExtraParams union. Each part that requires more information has its own |
| 31 // field in the union. | 38 // field in the union. |
| 32 // | 39 // |
| 33 // NativeTheme also supports getting the default size of a given part with | 40 // NativeTheme also supports getting the default size of a given part with |
| 34 // the GetPartSize() method. | 41 // the GetPartSize() method. |
| 35 class UI_EXPORT NativeTheme { | 42 class UI_EXPORT NativeTheme { |
| 36 public: | 43 public: |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 Part part, | 212 Part part, |
| 206 State state, | 213 State state, |
| 207 const gfx::Rect& rect, | 214 const gfx::Rect& rect, |
| 208 const ExtraParams& extra) const = 0; | 215 const ExtraParams& extra) const = 0; |
| 209 | 216 |
| 210 // Supports theme specific colors. | 217 // Supports theme specific colors. |
| 211 void SetScrollbarColors(unsigned inactive_color, | 218 void SetScrollbarColors(unsigned inactive_color, |
| 212 unsigned active_color, | 219 unsigned active_color, |
| 213 unsigned track_color) const; | 220 unsigned track_color) const; |
| 214 | 221 |
| 222 // Colors for GetSystemColor(). | |
| 223 enum ColorId { | |
| 224 kDialogBackgroundColorId | |
| 225 // TODO(benrg): move other hardcoded colors here. | |
| 226 }; | |
| 227 | |
| 228 // Return a color from the system theme. | |
| 229 virtual SkColor GetSystemColor(ColorId color_id) const = 0; | |
| 230 | |
| 215 // Returns a shared instance of the native theme. | 231 // Returns a shared instance of the native theme. |
| 216 // The returned object should not be deleted by the caller. This function | 232 // The returned object should not be deleted by the caller. This function |
| 217 // is not thread safe and should only be called from the UI thread. | 233 // is not thread safe and should only be called from the UI thread. |
| 218 // Each port of NativeTheme should provide its own implementation of this | 234 // Each port of NativeTheme should provide its own implementation of this |
| 219 // function, returning the port's subclass. | 235 // function, returning the port's subclass. |
| 220 static const NativeTheme* instance(); | 236 static const NativeTheme* instance(); |
| 221 | 237 |
| 222 protected: | 238 protected: |
| 223 NativeTheme() {} | 239 NativeTheme() {} |
| 224 virtual ~NativeTheme() {} | 240 virtual ~NativeTheme() {} |
| 225 | 241 |
| 226 static unsigned int thumb_inactive_color_; | 242 static unsigned int thumb_inactive_color_; |
| 227 static unsigned int thumb_active_color_; | 243 static unsigned int thumb_active_color_; |
| 228 static unsigned int track_color_; | 244 static unsigned int track_color_; |
| 229 | 245 |
| 230 DISALLOW_COPY_AND_ASSIGN(NativeTheme); | 246 DISALLOW_COPY_AND_ASSIGN(NativeTheme); |
| 231 }; | 247 }; |
| 232 | 248 |
| 233 } // namespace gfx | 249 } // namespace gfx |
| 234 | 250 |
| 235 #endif // UI_GFX_NATIVE_THEME_H_ | 251 #endif // UI_GFX_NATIVE_THEME_H_ |
| OLD | NEW |