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
3 // found in the LICENSE file.
5 #ifndef UI_BASE_THEME_PROVIDER_H_
6 #define UI_BASE_THEME_PROVIDER_H_
8 #include "base/basictypes.h"
9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/base/layout.h"
11 #include "ui/base/ui_base_export.h"
13 #if defined(OS_MACOSX)
23 #elif !defined(OS_WIN)
24 typedef struct _GdkColor GdkColor;
25 typedef struct _GdkPixbuf GdkPixbuf;
31 class RefCountedMemory;
40 ////////////////////////////////////////////////////////////////////////////////
44 // ThemeProvider is an abstract class that defines the API that should be
45 // implemented to provide bitmaps and color information for a given theme.
47 ////////////////////////////////////////////////////////////////////////////////
49 class UI_BASE_EXPORT ThemeProvider {
51 virtual ~ThemeProvider();
53 // Get the image specified by |id|. An implementation of ThemeProvider should
54 // have its own source of ids (e.g. an enum, or external resource bundle).
55 virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const = 0;
57 // Get the color specified by |id|.
58 virtual SkColor GetColor(int id) const = 0;
60 // Get the property (e.g. an alignment expressed in an enum, or a width or
61 // height) specified by |id|.
62 virtual int GetDisplayProperty(int id) const = 0;
64 // Whether we should use the native system frame (typically Aero glass) or
66 virtual bool ShouldUseNativeFrame() const = 0;
68 // Whether or not we have a certain image. Used for when the default theme
69 // doesn't provide a certain image, but custom themes might (badges, etc).
70 virtual bool HasCustomImage(int id) const = 0;
72 // Reads the image data from the theme file into the specified vector. Only
73 // valid for un-themed resources and the themed IDR_THEME_NTP_* in most
74 // implementations of ThemeProvider. Returns NULL on error.
75 virtual base::RefCountedMemory* GetRawData(
77 ui::ScaleFactor scale_factor) const = 0;
79 #if defined(OS_MACOSX) && !defined(TOOLKIT_VIEWS)
80 // Gets the NSImage with the specified |id|.
81 virtual NSImage* GetNSImageNamed(int id) const = 0;
83 // Gets the NSImage that GetNSImageNamed (above) would return, but returns it
84 // as a pattern color.
85 virtual NSColor* GetNSImageColorNamed(int id) const = 0;
87 // Gets the NSColor with the specified |id|.
88 virtual NSColor* GetNSColor(int id) const = 0;
90 // Gets the NSColor for tinting with the specified |id|.
91 virtual NSColor* GetNSColorTint(int id) const = 0;
93 // Gets the NSGradient with the specified |id|.
94 virtual NSGradient* GetNSGradient(int id) const = 0;
95 #elif defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) && !defined(OS_ANDROID)
96 // Gets the GdkPixbuf with the specified |id|. Returns a pointer to a shared
97 // instance of the GdkPixbuf. This shared GdkPixbuf is owned by the theme
98 // provider and should not be freed.
100 // The bitmap is assumed to exist. This function will log in release, and
101 // assert in debug mode if it does not. On failure, this will return a
102 // pointer to a shared empty placeholder bitmap so it will be visible what
105 // As above, but flips it in RTL locales.
106 virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const = 0;
112 #endif // UI_BASE_THEME_PROVIDER_H_