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

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

Issue 150176: GTK: First draft of using native themes, partially based on evan's CL 118358. (Closed)
Patch Set: And the codereview tool is back. Created 11 years, 5 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_GTK_CUSTOM_BUTTON_H_ 5 #ifndef CHROME_BROWSER_GTK_CUSTOM_BUTTON_H_
6 #define CHROME_BROWSER_GTK_CUSTOM_BUTTON_H_ 6 #define CHROME_BROWSER_GTK_CUSTOM_BUTTON_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 27 matching lines...) Expand all
38 // INSENSITIVE is the last available state; 38 // INSENSITIVE is the last available state;
39 GdkPixbuf* pixbufs_[GTK_STATE_INSENSITIVE + 1]; 39 GdkPixbuf* pixbufs_[GTK_STATE_INSENSITIVE + 1];
40 40
41 // If non-negative, the state to paint the button. 41 // If non-negative, the state to paint the button.
42 int paint_override_; 42 int paint_override_;
43 43
44 DISALLOW_COPY_AND_ASSIGN(CustomDrawButtonBase); 44 DISALLOW_COPY_AND_ASSIGN(CustomDrawButtonBase);
45 }; 45 };
46 46
47 // CustomDrawButton is a plain button where all its various states are drawn 47 // CustomDrawButton is a plain button where all its various states are drawn
48 // with static images. 48 // with static images. In GTK rendering mode, it will show the standard button
49 // with GTK |stock_id|.
49 class CustomDrawButton { 50 class CustomDrawButton {
50 public: 51 public:
51 // The constructor takes 4 resource ids. If a resource doesn't exist for a 52 // The constructor takes 4 resource ids. If a resource doesn't exist for a
52 // button, pass in 0. 53 // button, pass in 0.
53 CustomDrawButton(int normal_id, 54 CustomDrawButton(int normal_id,
54 int active_id, 55 int active_id,
55 int highlight_id, 56 int highlight_id,
56 int depressed_id); 57 int depressed_id,
58 const char* stock_id);
57 explicit CustomDrawButton(const std::string& filename); 59 explicit CustomDrawButton(const std::string& filename);
58 ~CustomDrawButton(); 60 ~CustomDrawButton();
59 61
60 GtkWidget* widget() const { return widget_.get(); } 62 GtkWidget* widget() const { return widget_.get(); }
61 63
62 gfx::Rect bounds() const { 64 gfx::Rect bounds() const {
63 return gfx::Rect(widget_->allocation.x, 65 return gfx::Rect(widget_->allocation.x,
64 widget_->allocation.y, 66 widget_->allocation.y,
65 widget_->allocation.width, 67 widget_->allocation.width,
66 widget_->allocation.height); 68 widget_->allocation.height);
67 } 69 }
68 70
69 int width() const { return widget_->allocation.width; } 71 int width() const { return widget_->allocation.width; }
70 int height() const { return widget_->allocation.height; } 72 int height() const { return widget_->allocation.height; }
71 73
74 // Sets properties on the GtkButton returned by widget(). By default, the
75 // button is very boring. This will either give it an image from the
76 // |gtk_stock_name_| if |use_gtk| is true or will use the chrome frame
77 // images.
78 void SetUseSystemTheme(bool use_gtk);
79
72 // Set the state to draw. We will paint the widget as if it were in this 80 // Set the state to draw. We will paint the widget as if it were in this
73 // state. 81 // state.
74 void SetPaintOverride(GtkStateType state); 82 void SetPaintOverride(GtkStateType state);
75 83
76 // Resume normal drawing of the widget's state. 84 // Resume normal drawing of the widget's state.
77 void UnsetPaintOverride(); 85 void UnsetPaintOverride();
78 86
79 // Returns a standard close button. 87 // Returns a standard close button.
80 static CustomDrawButton* CloseButton(); 88 static CustomDrawButton* CloseButton();
81 89
82 private: 90 private:
83 // Callback for expose, used to draw the custom graphics. 91 // Callback for custom button expose, used to draw the custom graphics.
84 static gboolean OnExpose(GtkWidget* widget, 92 static gboolean OnCustomExpose(GtkWidget* widget,
85 GdkEventExpose* e, 93 GdkEventExpose* e,
86 CustomDrawButton* obj); 94 CustomDrawButton* obj);
87 95
88 // The actual button widget. 96 // The actual button widget.
89 OwnedWidgetGtk widget_; 97 OwnedWidgetGtk widget_;
90 98
91 CustomDrawButtonBase button_base_; 99 CustomDrawButtonBase button_base_;
92 100
101 // The stock icon name.
102 const char* gtk_stock_name_;
103
104 // Whether we have an expose signal handler we may need to remove.
105 bool has_expose_signal_handler_;
106
93 DISALLOW_COPY_AND_ASSIGN(CustomDrawButton); 107 DISALLOW_COPY_AND_ASSIGN(CustomDrawButton);
94 }; 108 };
95 109
96 #endif // CHROME_BROWSER_GTK_CUSTOM_BUTTON_H_ 110 #endif // CHROME_BROWSER_GTK_CUSTOM_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698