Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/ui/gtk/custom_button.h

Issue 9447096: gtk: Rename GtkThemeService to ThemeServiceGtk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_
6 #define CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ 6 #define CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_
7 #pragma once 7 #pragma once
8 8
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
15 #include "third_party/skia/include/core/SkColor.h" 15 #include "third_party/skia/include/core/SkColor.h"
16 #include "ui/base/animation/animation_delegate.h" 16 #include "ui/base/animation/animation_delegate.h"
17 #include "ui/base/animation/slide_animation.h" 17 #include "ui/base/animation/slide_animation.h"
18 #include "ui/base/gtk/gtk_signal.h" 18 #include "ui/base/gtk/gtk_signal.h"
19 #include "ui/base/gtk/owned_widget_gtk.h" 19 #include "ui/base/gtk/owned_widget_gtk.h"
20 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
21 21
22 class GtkThemeService; 22 class ThemeServiceGtk;
23 class SkBitmap; 23 class SkBitmap;
24 24
25 namespace gfx { 25 namespace gfx {
26 class CairoCachedSurface; 26 class CairoCachedSurface;
27 } 27 }
28 28
29 // These classes implement two kinds of custom-drawn buttons. They're 29 // These classes implement two kinds of custom-drawn buttons. They're
30 // used on the toolbar and the bookmarks bar. 30 // used on the toolbar and the bookmarks bar.
31 31
32 // CustomDrawButtonBase provides the base for building a custom drawn button. 32 // CustomDrawButtonBase provides the base for building a custom drawn button.
33 // It handles managing the pixbufs containing all the static images used to draw 33 // It handles managing the pixbufs containing all the static images used to draw
34 // the button. It also manages painting these pixbufs. 34 // the button. It also manages painting these pixbufs.
35 class CustomDrawButtonBase : public content::NotificationObserver { 35 class CustomDrawButtonBase : public content::NotificationObserver {
36 public: 36 public:
37 // If the images come from ResourceBundle rather than the theme provider, 37 // If the images come from ResourceBundle rather than the theme provider,
38 // pass in NULL for |theme_provider|. 38 // pass in NULL for |theme_provider|.
39 CustomDrawButtonBase(GtkThemeService* theme_provider, 39 CustomDrawButtonBase(ThemeServiceGtk* theme_provider,
40 int normal_id, 40 int normal_id,
41 int pressed_id, 41 int pressed_id,
42 int hover_id, 42 int hover_id,
43 int disabled_id); 43 int disabled_id);
44 44
45 virtual ~CustomDrawButtonBase(); 45 virtual ~CustomDrawButtonBase();
46 46
47 // Flip the image horizontally. Not to be used for RTL/LTR reasons. (In RTL 47 // Flip the image horizontally. Not to be used for RTL/LTR reasons. (In RTL
48 // mode, this will unflip the image.) 48 // mode, this will unflip the image.)
49 void set_flipped(bool flipped) { flipped_ = flipped; } 49 void set_flipped(bool flipped) { flipped_ = flipped; }
(...skipping 28 matching lines...) Expand all
78 78
79 // If non-negative, the state to paint the button. 79 // If non-negative, the state to paint the button.
80 int paint_override_; 80 int paint_override_;
81 81
82 // We need to remember the image ids that the user passes in and the theme 82 // We need to remember the image ids that the user passes in and the theme
83 // provider so we can reload images if the user changes theme. 83 // provider so we can reload images if the user changes theme.
84 int normal_id_; 84 int normal_id_;
85 int pressed_id_; 85 int pressed_id_;
86 int hover_id_; 86 int hover_id_;
87 int disabled_id_; 87 int disabled_id_;
88 GtkThemeService* theme_service_; 88 ThemeServiceGtk* theme_service_;
89 89
90 // Whether the button is flipped horizontally. Not used for RTL (we get 90 // Whether the button is flipped horizontally. Not used for RTL (we get
91 // flipped versions from the theme provider). Used for the flipped window 91 // flipped versions from the theme provider). Used for the flipped window
92 // buttons. 92 // buttons.
93 bool flipped_; 93 bool flipped_;
94 94
95 // Used to listen for theme change notifications. 95 // Used to listen for theme change notifications.
96 content::NotificationRegistrar registrar_; 96 content::NotificationRegistrar registrar_;
97 97
98 DISALLOW_COPY_AND_ASSIGN(CustomDrawButtonBase); 98 DISALLOW_COPY_AND_ASSIGN(CustomDrawButtonBase);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 public: 134 public:
135 // The constructor takes 4 resource ids. If a resource doesn't exist for a 135 // The constructor takes 4 resource ids. If a resource doesn't exist for a
136 // button, pass in 0. 136 // button, pass in 0.
137 CustomDrawButton(int normal_id, 137 CustomDrawButton(int normal_id,
138 int pressed_id, 138 int pressed_id,
139 int hover_id, 139 int hover_id,
140 int disabled_id); 140 int disabled_id);
141 141
142 // Same as above, but uses themed (and possibly tinted) images. |stock_id| and 142 // Same as above, but uses themed (and possibly tinted) images. |stock_id| and
143 // |stock_size| are used for GTK+ theme mode. 143 // |stock_size| are used for GTK+ theme mode.
144 CustomDrawButton(GtkThemeService* theme_provider, 144 CustomDrawButton(ThemeServiceGtk* theme_provider,
145 int normal_id, 145 int normal_id,
146 int pressed_id, 146 int pressed_id,
147 int hover_id, 147 int hover_id,
148 int disabled_id, 148 int disabled_id,
149 const char* stock_id, 149 const char* stock_id,
150 GtkIconSize stock_size); 150 GtkIconSize stock_size);
151 151
152 // As above, but uses an arbitrary GtkImage rather than a stock icon. This 152 // As above, but uses an arbitrary GtkImage rather than a stock icon. This
153 // constructor takes ownership of |native_widget|. 153 // constructor takes ownership of |native_widget|.
154 CustomDrawButton(GtkThemeService* theme_provider, 154 CustomDrawButton(ThemeServiceGtk* theme_provider,
155 int normal_id, 155 int normal_id,
156 int pressed_id, 156 int pressed_id,
157 int hover_id, 157 int hover_id,
158 int disabled_id, 158 int disabled_id,
159 GtkWidget* native_widget); 159 GtkWidget* native_widget);
160 160
161 virtual ~CustomDrawButton(); 161 virtual ~CustomDrawButton();
162 162
163 void Init(); 163 void Init();
164 164
(...skipping 24 matching lines...) Expand all
189 // Set the background details. 189 // Set the background details.
190 void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); 190 void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask);
191 191
192 // content::NotificationObserver implementation. 192 // content::NotificationObserver implementation.
193 virtual void Observe(int type, 193 virtual void Observe(int type,
194 const content::NotificationSource& source, 194 const content::NotificationSource& source,
195 const content::NotificationDetails& details) OVERRIDE; 195 const content::NotificationDetails& details) OVERRIDE;
196 196
197 // Returns a standard close button. Pass a |theme_provider| to use Gtk icons 197 // Returns a standard close button. Pass a |theme_provider| to use Gtk icons
198 // in Gtk rendering mode. 198 // in Gtk rendering mode.
199 static CustomDrawButton* CloseButton(GtkThemeService* theme_provider); 199 static CustomDrawButton* CloseButton(ThemeServiceGtk* theme_provider);
200 200
201 private: 201 private:
202 // Sets the button to themed or not. 202 // Sets the button to themed or not.
203 void SetBrowserTheme(); 203 void SetBrowserTheme();
204 204
205 // Whether to use the GTK+ theme. For this to be true, we have to be in GTK+ 205 // Whether to use the GTK+ theme. For this to be true, we have to be in GTK+
206 // theme mode and we must have a valid stock icon resource. 206 // theme mode and we must have a valid stock icon resource.
207 bool UseGtkTheme(); 207 bool UseGtkTheme();
208 208
209 // Callback for custom button expose, used to draw the custom graphics. 209 // Callback for custom button expose, used to draw the custom graphics.
210 CHROMEGTK_CALLBACK_1(CustomDrawButton, gboolean, OnCustomExpose, 210 CHROMEGTK_CALLBACK_1(CustomDrawButton, gboolean, OnCustomExpose,
211 GdkEventExpose*); 211 GdkEventExpose*);
212 212
213 // The actual button widget. 213 // The actual button widget.
214 ui::OwnedWidgetGtk widget_; 214 ui::OwnedWidgetGtk widget_;
215 215
216 CustomDrawButtonBase button_base_; 216 CustomDrawButtonBase button_base_;
217 217
218 CustomDrawHoverController hover_controller_; 218 CustomDrawHoverController hover_controller_;
219 219
220 // The widget to use when we are displaying in GTK+ theme mode. 220 // The widget to use when we are displaying in GTK+ theme mode.
221 ui::OwnedWidgetGtk native_widget_; 221 ui::OwnedWidgetGtk native_widget_;
222 222
223 // Our theme provider. 223 // Our theme provider.
224 GtkThemeService* theme_service_; 224 ThemeServiceGtk* theme_service_;
225 225
226 // True if we should never do gtk rendering. 226 // True if we should never do gtk rendering.
227 bool forcing_chrome_theme_; 227 bool forcing_chrome_theme_;
228 228
229 // Used to listen for theme change notifications. 229 // Used to listen for theme change notifications.
230 content::NotificationRegistrar registrar_; 230 content::NotificationRegistrar registrar_;
231 231
232 DISALLOW_COPY_AND_ASSIGN(CustomDrawButton); 232 DISALLOW_COPY_AND_ASSIGN(CustomDrawButton);
233 }; 233 };
234 234
235 #endif // CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ 235 #endif // CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/content_setting_bubble_gtk.cc ('k') | chrome/browser/ui/gtk/custom_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698