togglebutton.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_GUICHAN_ADDON_TOGGLEBUTTON_H
00023 #define FIFE_GUICHAN_ADDON_TOGGLEBUTTON_H
00024
00025
00026 #include <string>
00027 #include <map>
00028
00029
00030 #include <guichan.hpp>
00031 #include <guichan/actionlistener.hpp>
00032
00033
00034
00035
00036
00037
00038 namespace gcn {
00047 class ToggleButton : public Button, public ActionListener {
00048 public:
00058 ToggleButton(Image *up_image = 0, Image *down_image = 0, Image *hover_image = 0, const std::string& caption = "", const std::string& group = "");
00059
00063 ~ToggleButton();
00064
00068 void draw(Graphics *graphics);
00069
00073 void adjustSize();
00074
00080 void setUpImage(Image* image);
00081
00087 void setDownImage(Image* image);
00088
00094 void setHoverImage(Image* image);
00095
00105 void setDownOffset(int x, int y);
00106
00114 int getDownXOffset() const;
00115
00123 int getDownYOffset() const;
00124
00131 bool isToggled() const;
00132
00140 void setToggled(bool toggled);
00141
00142
00151 void setGroup(const std::string &group);
00152
00159 const std::string &getGroup() const;
00160
00161 protected:
00162
00168 void action(const ActionEvent& actionEvent);
00169
00170 private:
00171
00172 Image *m_upImage;
00173
00174
00175 Image *m_downImage;
00176
00177
00178 Image *m_hoverImage;
00179
00180
00181
00182 int x_downoffset;
00183 int y_downoffset;
00184
00188 bool m_toggled;
00189
00190
00194 std::string m_group;
00195
00199 typedef std::multimap<std::string, ToggleButton *> GroupMap;
00200
00204 typedef GroupMap::iterator GroupIterator;
00205
00209 static GroupMap m_groupMap;
00210 };
00211
00212 }
00213
00214 #endif
00215