[1809] | 1 | /************************************************************************
|
---|
| 2 | filename: CEGUIRadioButton.h
|
---|
| 3 | created: 13/4/2004
|
---|
| 4 | author: Paul D Turner
|
---|
| 5 |
|
---|
| 6 | purpose: Interface to base class for RadioButton widget
|
---|
| 7 | *************************************************************************/
|
---|
| 8 | /*************************************************************************
|
---|
| 9 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
| 10 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
| 11 |
|
---|
| 12 | This library is free software; you can redistribute it and/or
|
---|
| 13 | modify it under the terms of the GNU Lesser General Public
|
---|
| 14 | License as published by the Free Software Foundation; either
|
---|
| 15 | version 2.1 of the License, or (at your option) any later version.
|
---|
| 16 |
|
---|
| 17 | This library is distributed in the hope that it will be useful,
|
---|
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | Lesser General Public License for more details.
|
---|
| 21 |
|
---|
| 22 | You should have received a copy of the GNU Lesser General Public
|
---|
| 23 | License along with this library; if not, write to the Free Software
|
---|
| 24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 25 | *************************************************************************/
|
---|
| 26 | #ifndef _CEGUIRadioButton_h_
|
---|
| 27 | #define _CEGUIRadioButton_h_
|
---|
| 28 |
|
---|
| 29 | #include "CEGUIBase.h"
|
---|
| 30 | #include "elements/CEGUIButtonBase.h"
|
---|
| 31 | #include "elements/CEGUIRadioButtonProperties.h"
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | #if defined(_MSC_VER)
|
---|
| 35 | # pragma warning(push)
|
---|
| 36 | # pragma warning(disable : 4251)
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | // Start of CEGUI namespace section
|
---|
| 41 | namespace CEGUI
|
---|
| 42 | {
|
---|
| 43 | /*!
|
---|
| 44 | \brief
|
---|
| 45 | Base class to provide the logic for Radio Button widgets.
|
---|
| 46 |
|
---|
| 47 | */
|
---|
| 48 | class CEGUIEXPORT RadioButton : public ButtonBase
|
---|
| 49 | {
|
---|
| 50 | public:
|
---|
| 51 | static const String EventNamespace; //!< Namespace for global events
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | /*************************************************************************
|
---|
| 55 | Event name constants
|
---|
| 56 | *************************************************************************/
|
---|
| 57 | // generated internally by Window
|
---|
| 58 | static const String EventSelectStateChanged; //!< The selected state of the widget has changed.
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | /*************************************************************************
|
---|
| 62 | Accessor Functions
|
---|
| 63 | *************************************************************************/
|
---|
| 64 | /*!
|
---|
| 65 | \brief
|
---|
| 66 | return true if the radio button is selected (has the checkmark)
|
---|
| 67 |
|
---|
| 68 | \return
|
---|
| 69 | true if this widget is selected, false if the widget is not selected.
|
---|
| 70 | */
|
---|
| 71 | bool isSelected(void) const {return d_selected;}
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | /*!
|
---|
| 75 | \brief
|
---|
| 76 | return the groupID assigned to this radio button
|
---|
| 77 |
|
---|
| 78 | \return
|
---|
| 79 | ulong value that identifies the Radio Button group this widget belongs to.
|
---|
| 80 | */
|
---|
| 81 | ulong getGroupID(void) const {return d_groupID;}
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | /*!
|
---|
| 85 | \brief
|
---|
| 86 | Return a pointer to the RadioButton object within the same group as this RadioButton, that
|
---|
| 87 | is currently selected.
|
---|
| 88 |
|
---|
| 89 | \return
|
---|
| 90 | Pointer to the RadioButton object that is the RadioButton within the same group as this RadioButton,
|
---|
| 91 | and is attached to the same parent window as this RadioButton, that is currently selected.
|
---|
| 92 | Returns NULL if no button within the group is selected, or if 'this' is not attached to a parent window.
|
---|
| 93 | */
|
---|
| 94 | RadioButton* getSelectedButtonInGroup(void) const;
|
---|
| 95 |
|
---|
| 96 |
|
---|
| 97 | /*************************************************************************
|
---|
| 98 | Manipulator Functions
|
---|
| 99 | *************************************************************************/
|
---|
| 100 | /*!
|
---|
| 101 | \brief
|
---|
| 102 | set whether the radio button is selected or not
|
---|
| 103 |
|
---|
| 104 | \param select
|
---|
| 105 | true to put the radio button in the selected state, false to put the radio button in the
|
---|
| 106 | deselected state. If changing to the selected state, any previously selected radio button
|
---|
| 107 | within the same group is automatically deselected.
|
---|
| 108 |
|
---|
| 109 | \return
|
---|
| 110 | Nothing.
|
---|
| 111 | */
|
---|
| 112 | void setSelected(bool select);
|
---|
| 113 |
|
---|
| 114 |
|
---|
| 115 | /*!
|
---|
| 116 | \brief
|
---|
| 117 | set the groupID for this radio button
|
---|
| 118 |
|
---|
| 119 | \param group
|
---|
| 120 | ulong value specifying the radio button group that this widget belongs to.
|
---|
| 121 |
|
---|
| 122 | \return
|
---|
| 123 | Nothing.
|
---|
| 124 | */
|
---|
| 125 | void setGroupID(ulong group);
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 | /*************************************************************************
|
---|
| 129 | Construction / Destruction
|
---|
| 130 | *************************************************************************/
|
---|
| 131 | RadioButton(const String& type, const String& name);
|
---|
| 132 | virtual ~RadioButton(void);
|
---|
| 133 |
|
---|
| 134 |
|
---|
| 135 | protected:
|
---|
| 136 | /*************************************************************************
|
---|
| 137 | Implementation Functions
|
---|
| 138 | *************************************************************************/
|
---|
| 139 | /*!
|
---|
| 140 | \brief
|
---|
| 141 | Add radio button specific events
|
---|
| 142 | */
|
---|
| 143 | void addRadioButtonEvents(void);
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | /*!
|
---|
| 147 | \brief
|
---|
| 148 | Deselect any selected radio buttons attached to the same parent within the same group
|
---|
| 149 | (but not do not deselect 'this').
|
---|
| 150 | */
|
---|
| 151 | void deselectOtherButtonsInGroup(void) const;
|
---|
| 152 |
|
---|
| 153 |
|
---|
| 154 | /*!
|
---|
| 155 | \brief
|
---|
| 156 | Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
|
---|
| 157 |
|
---|
| 158 | \param class_name
|
---|
| 159 | The class name that is to be checked.
|
---|
| 160 |
|
---|
| 161 | \return
|
---|
| 162 | true if this window was inherited from \a class_name. false if not.
|
---|
| 163 | */
|
---|
| 164 | virtual bool testClassName_impl(const String& class_name) const
|
---|
| 165 | {
|
---|
| 166 | if (class_name==(const utf8*)"RadioButton") return true;
|
---|
| 167 | return ButtonBase::testClassName_impl(class_name);
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 |
|
---|
| 171 | /*************************************************************************
|
---|
| 172 | New Radio Button Events
|
---|
| 173 | *************************************************************************/
|
---|
| 174 | /*!
|
---|
| 175 | \brief
|
---|
| 176 | event triggered internally when the select state of the button changes.
|
---|
| 177 | */
|
---|
| 178 | virtual void onSelectStateChanged(WindowEventArgs& e);
|
---|
| 179 |
|
---|
| 180 |
|
---|
| 181 | /*************************************************************************
|
---|
| 182 | Overridden Event handlers
|
---|
| 183 | *************************************************************************/
|
---|
| 184 | virtual void onMouseButtonUp(MouseEventArgs& e);
|
---|
| 185 |
|
---|
| 186 |
|
---|
| 187 | /*************************************************************************
|
---|
| 188 | Implementation Data
|
---|
| 189 | *************************************************************************/
|
---|
| 190 | bool d_selected; // true when radio button is selected (has checkmark)
|
---|
| 191 | ulong d_groupID; // radio button group ID
|
---|
| 192 |
|
---|
| 193 |
|
---|
| 194 | private:
|
---|
| 195 | /*************************************************************************
|
---|
| 196 | Static Properties for this class
|
---|
| 197 | *************************************************************************/
|
---|
| 198 | static RadioButtonProperties::Selected d_selectedProperty;
|
---|
| 199 | static RadioButtonProperties::GroupID d_groupIDProperty;
|
---|
| 200 |
|
---|
| 201 |
|
---|
| 202 | /*************************************************************************
|
---|
| 203 | Private methods
|
---|
| 204 | *************************************************************************/
|
---|
| 205 | void addRadioButtonProperties(void);
|
---|
| 206 | };
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 | } // End of CEGUI namespace section
|
---|
| 210 |
|
---|
| 211 | #if defined(_MSC_VER)
|
---|
| 212 | # pragma warning(pop)
|
---|
| 213 | #endif
|
---|
| 214 |
|
---|
| 215 | #endif // end of guard _CEGUIRadioButton_h_
|
---|