FIFE
2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 #ifndef FIFE_GUICHAN_ADDON_TOGGLEBUTTON_H 00023 #define FIFE_GUICHAN_ADDON_TOGGLEBUTTON_H 00024 00025 // Standard C++ library includes 00026 #include <string> 00027 #include <map> 00028 00029 // 3rd party library includes 00030 #include <guichan.hpp> 00031 #include <guichan/actionlistener.hpp> 00032 00033 // FIFE includes 00034 // These includes are split up in two parts, separated by one empty line 00035 // First block: files included from the FIFE root src directory 00036 // Second block: files included from the same folder 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 // From Guichan 0.8.1 00151 void setGroup(const std::string &group); 00152 00159 const std::string &getGroup() const; 00160 00161 protected: 00162 // Inherited from gcn::Widget 00168 void action(const ActionEvent& actionEvent); 00169 00170 private: 00171 // Image to be used when the button is not toggle 00172 Image *m_upImage; 00173 00174 // Image to be used when the button is toggled or pressed 00175 Image *m_downImage; 00176 00177 // Image to be used when the mouse cursor is over the image 00178 Image *m_hoverImage; 00179 00180 // Number of pixels the image/text will be offset from the top left 00181 // corner, when the button is pressed or toggled 00182 int x_downoffset; 00183 int y_downoffset; 00184 00188 bool m_toggled; 00189 00190 //-- From Guichan 0.8.1 -- 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 /* vim: set noexpandtab: set shiftwidth=2: set tabstop=2: */