From b985de6e83790bd02bd63e3ed47a3a79592b08da Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 Feb 2012 20:34:46 +0300 Subject: Add image support for buttons. --- src/gui/widgets/button.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/gui/widgets/button.h') diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 560e46377..6585d9850 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -28,8 +28,12 @@ #include class GraphicsVertexes; +class Image; +class ImageSet; class ImageRect; +const std::string BUTTON_PLAY = "buttonplay.png"; + /** * Button widget. Same as the Guichan button but with custom look. * @@ -50,6 +54,23 @@ class Button : public gcn::Button, public gcn::WidgetListener Button(const std::string &caption, const std::string &actionEventId, gcn::ActionListener *listener); + /** + * Constructor, sets the caption of the button to the given string and + * adds the given action listener. + */ + Button(const std::string &caption, const std::string &imageName, + int imageWidth, int imageHeight, + const std::string &actionEventId, + gcn::ActionListener *listener); + + /** + * Constructor, sets the caption of the button to the given string and + * adds the given action listener. + */ + Button(const std::string &imageName, int imageWidth, int imageHeight, + const std::string &actionEventId, + gcn::ActionListener *listener); + /** * Destructor. */ @@ -86,6 +107,12 @@ class Button : public gcn::Button, public gcn::WidgetListener void widgetMoved(const gcn::Event &event); + void loadImage(const std::string &imageName); + + void adjustSize(); + + void setCaption(const std::string& caption); + private: void init(); @@ -103,6 +130,10 @@ class Button : public gcn::Button, public gcn::WidgetListener int mYOffset; gcn::Color mEnabledColor; gcn::Color mDisabledColor; + Image **mImages; + ImageSet *mImageSet; + int mImageWidth; + int mImageHeight; }; #endif -- cgit v1.2.3-60-g2f50