OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef APP_THEME_PROVIDER_H_ | |
6 #define APP_THEME_PROVIDER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "third_party/skia/include/core/SkColor.h" | |
11 | |
12 #if defined(OS_MACOSX) | |
13 #ifdef __OBJC__ | |
14 @class NSColor; | |
15 @class NSGradient; | |
16 @class NSImage; | |
17 #else | |
18 class NSColor; | |
19 class NSGradient; | |
20 class NSImage; | |
21 #endif // __OBJC__ | |
22 #elif !defined(OS_WIN) | |
23 typedef struct _GdkColor GdkColor; | |
24 typedef struct _GdkPixbuf GdkPixbuf; | |
25 #endif // OS_* | |
26 | |
27 class Profile; | |
28 class RefCountedMemory; | |
29 class SkBitmap; | |
30 | |
31 //////////////////////////////////////////////////////////////////////////////// | |
32 // | |
33 // ThemeProvider | |
34 // | |
35 // ThemeProvider is an abstract class that defines the API that should be | |
36 // implemented to provide bitmaps and color information for a given theme. | |
37 // | |
38 //////////////////////////////////////////////////////////////////////////////// | |
39 | |
40 class ThemeProvider { | |
41 public: | |
42 virtual ~ThemeProvider(); | |
43 | |
44 // Initialize the provider with the passed in profile. | |
45 virtual void Init(Profile* profile) = 0; | |
46 | |
47 // Get the bitmap specified by |id|. An implementation of ThemeProvider should | |
48 // have its own source of ids (e.g. an enum, or external resource bundle). | |
49 virtual SkBitmap* GetBitmapNamed(int id) const = 0; | |
50 | |
51 // Get the color specified by |id|. | |
52 virtual SkColor GetColor(int id) const = 0; | |
53 | |
54 // Get the property (e.g. an alignment expressed in an enum, or a width or | |
55 // height) specified by |id|. | |
56 virtual bool GetDisplayProperty(int id, int* result) const = 0; | |
57 | |
58 // Whether we should use the native system frame (typically Aero glass) or | |
59 // a custom frame. | |
60 virtual bool ShouldUseNativeFrame() const = 0; | |
61 | |
62 // Whether or not we have a certain image. Used for when the default theme | |
63 // doesn't provide a certain image, but custom themes might (badges, etc). | |
64 virtual bool HasCustomImage(int id) const = 0; | |
65 | |
66 // Reads the image data from the theme file into the specified vector. Only | |
67 // valid for un-themed resources and the themed IDR_THEME_NTP_* in most | |
68 // implementations of ThemeProvider. Returns NULL on error. | |
69 virtual RefCountedMemory* GetRawData(int id) const = 0; | |
70 | |
71 #if defined(OS_MACOSX) | |
72 // Gets the NSImage with the specified |id|. | |
73 // | |
74 // The bitmap is not assumed to exist. If a theme does not provide an image, | |
75 // if |allow_default| is true, then the default image will be returned, else | |
76 // this function will return nil. | |
77 virtual NSImage* GetNSImageNamed(int id, bool allow_default) const = 0; | |
78 | |
79 // Gets the NSImage that GetNSImageNamed (above) would return, but returns it | |
80 // as a pattern color. | |
81 virtual NSColor* GetNSImageColorNamed(int id, bool allow_default) const = 0; | |
82 | |
83 // Gets the NSColor with the specified |id|. | |
84 // | |
85 // The color is not assumed to exist. If a theme does not provide an color, if | |
86 // |allow_default| is true, then the default color will be returned, else this | |
87 // function will return nil. | |
88 virtual NSColor* GetNSColor(int id, bool allow_default) const = 0; | |
89 | |
90 // Gets the NSColor for tinting with the specified |id|. | |
91 // | |
92 // The tint is not assumed to exist. If a theme does not provide a tint with | |
93 // that id, if |allow_default| is true, then the default tint will be | |
94 // returned, else this function will return nil. | |
95 virtual NSColor* GetNSColorTint(int id, bool allow_default) const = 0; | |
96 | |
97 // Gets the NSGradient with the specified |id|. | |
98 virtual NSGradient* GetNSGradient(int id) const = 0; | |
99 #elif defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) | |
100 // Gets the GdkPixbuf with the specified |id|. Returns a pointer to a shared | |
101 // instance of the GdkPixbuf. This shared GdkPixbuf is owned by the theme | |
102 // provider and should not be freed. | |
103 // | |
104 // The bitmap is assumed to exist. This function will log in release, and | |
105 // assert in debug mode if it does not. On failure, this will return a | |
106 // pointer to a shared empty placeholder bitmap so it will be visible what | |
107 // is missing. | |
108 virtual GdkPixbuf* GetPixbufNamed(int id) const = 0; | |
109 | |
110 // As above, but flips it in RTL locales. | |
111 virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const = 0; | |
112 #endif | |
113 }; | |
114 | |
115 #endif // APP_THEME_PROVIDER_H_ | |
OLD | NEW |