blob: 22f70a0025ccf89520a37fb19a237eb17719609c [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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.
4
5#ifndef UI_BASE_THEME_PROVIDER_H_
6#define UI_BASE_THEME_PROVIDER_H_
7
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_export.h"
12
13#if defined(OS_MACOSX)
14#ifdef __OBJC__
15@class NSColor;
16@class NSGradient;
17@class NSImage;
18#else
19class NSColor;
20class NSGradient;
21class NSImage;
22#endif // __OBJC__
23#elif !defined(OS_WIN)
24typedef struct _GdkColor GdkColor;
25typedef struct _GdkPixbuf GdkPixbuf;
26#endif // OS_*
27
28class SkBitmap;
29
30namespace base {
31class RefCountedMemory;
32}
33
34namespace gfx {
35class ImageSkia;
36}
37
38namespace ui {
39
40////////////////////////////////////////////////////////////////////////////////
41//
42// ThemeProvider
43//
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.
46//
47////////////////////////////////////////////////////////////////////////////////
48
49class UI_EXPORT ThemeProvider {
50 public:
51 virtual ~ThemeProvider();
52
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;
56
57 // Get the color specified by |id|.
58 virtual SkColor GetColor(int id) const = 0;
59
60 // Get the property (e.g. an alignment expressed in an enum, or a width or
61 // height) specified by |id|.
62 virtual bool GetDisplayProperty(int id, int* result) const = 0;
63
64 // Whether we should use the native system frame (typically Aero glass) or
65 // a custom frame.
66 virtual bool ShouldUseNativeFrame() const = 0;
67
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;
71
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(
76 int id,
77 ui::ScaleFactor scale_factor) const = 0;
78
79#if defined(OS_MACOSX) && !defined(TOOLKIT_VIEWS)
80 // Gets the NSImage with the specified |id|.
Ben Murdochbb1529c2013-08-08 10:24:53 +010081 virtual NSImage* GetNSImageNamed(int id) const = 0;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000082
83 // Gets the NSImage that GetNSImageNamed (above) would return, but returns it
84 // as a pattern color.
Ben Murdochbb1529c2013-08-08 10:24:53 +010085 virtual NSColor* GetNSImageColorNamed(int id) const = 0;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000086
87 // Gets the NSColor with the specified |id|.
Ben Murdochbb1529c2013-08-08 10:24:53 +010088 virtual NSColor* GetNSColor(int id) const = 0;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000089
90 // Gets the NSColor for tinting with the specified |id|.
Ben Murdochbb1529c2013-08-08 10:24:53 +010091 virtual NSColor* GetNSColorTint(int id) const = 0;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000092
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.
99 //
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
103 // is missing.
104
105 // As above, but flips it in RTL locales.
106 virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const = 0;
107#endif
108};
109
110} // namespace ui
111
112#endif // UI_BASE_THEME_PROVIDER_H_