00001 /************************************************************************ 00002 filename: CEGUIRadioButton.h 00003 created: 13/4/2004 00004 author: Paul D Turner 00005 00006 purpose: Interface to base class for RadioButton widget 00007 *************************************************************************/ 00008 /************************************************************************* 00009 Crazy Eddie's GUI System (http://www.cegui.org.uk) 00010 Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk) 00011 00012 This library is free software; you can redistribute it and/or 00013 modify it under the terms of the GNU Lesser General Public 00014 License as published by the Free Software Foundation; either 00015 version 2.1 of the License, or (at your option) any later version. 00016 00017 This library is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 Lesser General Public License for more details. 00021 00022 You should have received a copy of the GNU Lesser General Public 00023 License along with this library; if not, write to the Free Software 00024 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 *************************************************************************/ 00026 #ifndef _CEGUIRadioButton_h_ 00027 #define _CEGUIRadioButton_h_ 00028 00029 #include "CEGUIBase.h" 00030 #include "elements/CEGUIButtonBase.h" 00031 #include "elements/CEGUIRadioButtonProperties.h" 00032 00033 00034 #if defined(_MSC_VER) 00035 # pragma warning(push) 00036 # pragma warning(disable : 4251) 00037 #endif 00038 00039 00040 // Start of CEGUI namespace section 00041 namespace CEGUI 00042 { 00048 class CEGUIBASE_API RadioButton : public ButtonBase 00049 { 00050 public: 00051 static const String EventNamespace; 00052 00053 00054 /************************************************************************* 00055 Event name constants 00056 *************************************************************************/ 00057 // generated internally by Window 00058 static const String EventSelectStateChanged; 00059 00060 00061 /************************************************************************* 00062 Accessor Functions 00063 *************************************************************************/ 00071 bool isSelected(void) const {return d_selected;} 00072 00073 00081 ulong getGroupID(void) const {return d_groupID;} 00082 00083 00094 RadioButton* getSelectedButtonInGroup(void) const; 00095 00096 00097 /************************************************************************* 00098 Manipulator Functions 00099 *************************************************************************/ 00112 void setSelected(bool select); 00113 00114 00125 void setGroupID(ulong group); 00126 00127 00128 /************************************************************************* 00129 Construction / Destruction 00130 *************************************************************************/ 00131 RadioButton(const String& type, const String& name); 00132 virtual ~RadioButton(void); 00133 00134 00135 protected: 00136 /************************************************************************* 00137 Implementation Functions 00138 *************************************************************************/ 00143 void addRadioButtonEvents(void); 00144 00145 00151 void deselectOtherButtonsInGroup(void) const; 00152 00153 00154 /************************************************************************* 00155 New Radio Button Events 00156 *************************************************************************/ 00161 virtual void onSelectStateChanged(WindowEventArgs& e); 00162 00163 00164 /************************************************************************* 00165 Overridden Event handlers 00166 *************************************************************************/ 00167 virtual void onMouseButtonUp(MouseEventArgs& e); 00168 00169 00170 /************************************************************************* 00171 Implementation Data 00172 *************************************************************************/ 00173 bool d_selected; // true when radio button is selected (has checkmark) 00174 ulong d_groupID; // radio button group ID 00175 00176 00177 private: 00178 /************************************************************************* 00179 Static Properties for this class 00180 *************************************************************************/ 00181 static RadioButtonProperties::Selected d_selectedProperty; 00182 static RadioButtonProperties::GroupID d_groupIDProperty; 00183 00184 00185 /************************************************************************* 00186 Private methods 00187 *************************************************************************/ 00188 void addRadioButtonProperties(void); 00189 }; 00190 00191 00192 } // End of CEGUI namespace section 00193 00194 #if defined(_MSC_VER) 00195 # pragma warning(pop) 00196 #endif 00197 00198 #endif // end of guard _CEGUIRadioButton_h_