summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/custom_button.h
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-19 22:47:53 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-19 22:47:53 +0000
commit72cf811b3b85841866dddeb0605810f0bcd705e4 (patch)
tree0797f0bb3a08555fda2fed59e3a005f09e11db2d /chrome/browser/gtk/custom_button.h
parent812bfe6b685d7367cb9e255ec71b7b0b720e1235 (diff)
downloadchromium_src-72cf811b3b85841866dddeb0605810f0bcd705e4.zip
chromium_src-72cf811b3b85841866dddeb0605810f0bcd705e4.tar.gz
chromium_src-72cf811b3b85841866dddeb0605810f0bcd705e4.tar.bz2
Relocate custom button code to its own files, in anticipation of more changes.
(Next is to fix the menu buttons.) Review URL: http://codereview.chromium.org/20509 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/custom_button.h')
-rw-r--r--chrome/browser/gtk/custom_button.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/chrome/browser/gtk/custom_button.h b/chrome/browser/gtk/custom_button.h
new file mode 100644
index 0000000..d5f7721
--- /dev/null
+++ b/chrome/browser/gtk/custom_button.h
@@ -0,0 +1,44 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_GTK_CUSTOM_BUTTON_H_
+#define CHROME_BROWSER_GTK_CUSTOM_BUTTON_H_
+
+#include <gtk/gtk.h>
+
+#include <string>
+
+// These classes implement custom-drawn buttons. They're used on the toolbar
+// and the bookmarks bar.
+
+class CustomDrawButton {
+ public:
+ // The constructor takes 4 resource ids. If a resource doesn't exist for a
+ // button, pass in 0.
+ CustomDrawButton(int normal_id,
+ int active_id,
+ int highlight_id,
+ int depressed_id);
+ explicit CustomDrawButton(const std::string& filename);
+ ~CustomDrawButton();
+
+ GtkWidget* widget() const { return widget_; }
+
+ private:
+ // Load an image given a resource id.
+ GdkPixbuf* LoadImage(int resource_id);
+
+ // Callback for expose, used to draw the custom graphics.
+ static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e,
+ CustomDrawButton* obj);
+
+ // The actual button widget.
+ GtkWidget* widget_;
+
+ // We store one GdkPixbuf* for each possible state of the button;
+ // INSENSITIVE is the last available state;
+ GdkPixbuf* pixbufs_[GTK_STATE_INSENSITIVE + 1];
+};
+
+#endif // CHROME_BROWSER_GTK_CUSTOM_BUTTON_H_