diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-20 19:15:02 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-20 19:15:02 +0000 |
commit | e6ba540ce15f791b531cd7ac712e7a5880edf38e (patch) | |
tree | 622999398c8e4d2e46e47cf37d726f25b3382ca2 /chrome/browser/gtk/custom_button.h | |
parent | 7a679c414e9812d4139d3afde9d98c4efe8f5bb8 (diff) | |
download | chromium_src-e6ba540ce15f791b531cd7ac712e7a5880edf38e.zip chromium_src-e6ba540ce15f791b531cd7ac712e7a5880edf38e.tar.gz chromium_src-e6ba540ce15f791b531cd7ac712e7a5880edf38e.tar.bz2 |
Draw custom menu buttons properly.
This is an iterative process towards code to be proud of; the previous
code of mine was horrible, this is less bad, and my next attempt at it
will be pretty, I promise.
Review URL: http://codereview.chromium.org/28001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10111 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/custom_button.h')
-rw-r--r-- | chrome/browser/gtk/custom_button.h | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/chrome/browser/gtk/custom_button.h b/chrome/browser/gtk/custom_button.h index d5f7721..8951aaf 100644 --- a/chrome/browser/gtk/custom_button.h +++ b/chrome/browser/gtk/custom_button.h @@ -9,9 +9,15 @@ #include <string> -// These classes implement custom-drawn buttons. They're used on the toolbar -// and the bookmarks bar. +#include "base/scoped_ptr.h" +class NineBox; + +// These classes implement two kinds of custom-drawn buttons. They're +// used on the toolbar and the bookmarks bar. + +// CustomDrawButton is a plain button where all its various states are drawn +// with static images. class CustomDrawButton { public: // The constructor takes 4 resource ids. If a resource doesn't exist for a @@ -26,9 +32,6 @@ class 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); @@ -41,4 +44,27 @@ class CustomDrawButton { GdkPixbuf* pixbufs_[GTK_STATE_INSENSITIVE + 1]; }; +// CustomContainerButton wraps another widget and uses a NineBox of +// images to draw a highlight around the edges when you mouse over it. +class CustomContainerButton { + public: + CustomContainerButton(); + ~CustomContainerButton(); + + GtkWidget* widget() const { return widget_; } + + private: + // Callback for expose, used to draw the custom graphics. + static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, + CustomContainerButton* obj); + + // The button widget. + GtkWidget* widget_; + + // The theme graphics for when the mouse is over the button. + scoped_ptr<NineBox> nine_box_prelight_; + // The theme graphics for when the button is clicked. + scoped_ptr<NineBox> nine_box_active_; +}; + #endif // CHROME_BROWSER_GTK_CUSTOM_BUTTON_H_ |