MezzanineEngine
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Mezzanine
src
UI
radiobutton.h
1
// © Copyright 2010 - 2014 BlackTopp Studios Inc.
2
/* This file is part of The Mezzanine Engine.
3
4
The Mezzanine Engine is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
The Mezzanine Engine is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
/* The original authors have included a copy of the license specified above in the
18
'Docs' folder. See 'gpl.txt'
19
*/
20
/* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21
Build professional software and charge for their product.
22
23
However there are some practical restrictions, so if your project involves
24
any of the following you should contact us and we will try to work something
25
out:
26
- DRM or Copy Protection of any kind(except Copyrights)
27
- Software Patents You Do Not Wish to Freely License
28
- Any Kind of Linking to Non-GPL licensed Works
29
- Are Currently In Violation of Another Copyright Holder's GPL License
30
- If You want to change our code and not add a few hundred MB of stuff to
31
your distribution
32
33
These and other limitations could cause serious legal problems if you ignore
34
them, so it is best to simply contact us or the Free Software Foundation, if
35
you have any questions.
36
37
Joseph Toppi - toppij@gmail.com
38
John Blackwood - makoenergy02@gmail.com
39
*/
40
#ifndef _uiradiobutton_h
41
#define _uiradiobutton_h
42
43
#include "UI/checkbox.h"
44
45
namespace
Mezzanine
46
{
47
namespace
UI
48
{
49
class
RadioButton;
50
///////////////////////////////////////////////////////////////////////////////
51
/// @brief This is a class designed to facilitate operations across an entire group of RadioButtons.
52
/// @details
53
///////////////////////////////////////
54
class
RadioButtonGroup
55
{
56
public
:
57
/// @brief Basic container type for RadioButton storage by this class.
58
typedef
std::vector<RadioButton*>
RadioButtonContainer
;
59
/// @brief Iterator type for RadioButton instances stored by this class.
60
typedef
RadioButtonContainer::iterator
RadioButtonIterator
;
61
/// @brief Const Iterator type for RadioButton instances stored by this class.
62
typedef
RadioButtonContainer::const_iterator
ConstRadioButtonIterator
;
63
protected
:
64
/// @internal
65
/// @brief A container storing all the RadioButtons belonging to this group.
66
RadioButtonContainer
GroupButtons
;
67
/// @internal
68
/// @brief A pointer to the RadioButton that is the current selection, or NULL if none are selected.
69
RadioButton
*
CurrentSelection
;
70
public
:
71
/// @brief Class constructor.
72
RadioButtonGroup
();
73
/// @brief Class destructor.
74
~RadioButtonGroup
();
75
76
///////////////////////////////////////////////////////////////////////////////
77
// Utility Methods
78
79
/// @brief Adds a RadioButton to this group.
80
/// @param ToAdd A pointer to the RadioButton to be added to this group.
81
void
AddButtonToGroup
(
RadioButton
* ToAdd);
82
/// @brief Gets the number of buttons in this group.
83
/// @return Returns a Whole representing the number of buttons that belong to this group.
84
Whole
GetNumButtons
()
const
;
85
/// @brief Removes a RadioButton from this group.
86
/// @param ToRemove A pointer to the RadioButton to be removed from this group.
87
void
RemoveButtonFromGroup
(
RadioButton
* ToRemove);
88
89
/// @brief Makes a RadioButton in this group the selection, deselecting all other RadioButtons in the group.
90
/// @note You can pass in NULL to ensure none of the RadioButtons in this group are selected.
91
/// @param ToSelect A pointer to the RadioButton in this group that will be selected.
92
void
SelectButton
(
RadioButton
* ToSelect);
93
/// @brief Deselects all but one (or just all) button(s) in this group
94
/// @note You can pass in NULL to deselect all buttons in this group.
95
/// @param Exclude The Button that will be excluded from forced deselection.
96
void
DeselectOtherButtons
(
RadioButton
* Exclude);
97
98
/// @brief Gets an iterator to the first RadioButton.
99
/// @return Returns an iterator to the first RadioButton being stored by this renderable.
100
RadioButtonIterator
RadioButtonBegin
();
101
/// @brief Gets an iterator to one passed the last RadioButton.
102
/// @return Returns an iterator to one passed the last RadioButton being stored by this renderable.
103
RadioButtonIterator
RadioButtonEnd
();
104
/// @brief Gets a const iterator to the first RadioButton.
105
/// @return Returns a const iterator to the first RadioButton being stored by this renderable.
106
ConstRadioButtonIterator
RadioButtonBegin
()
const
;
107
/// @brief Gets an iterator to one passed the last RadioButton.
108
/// @return Returns an iterator to one passed the last RadioButton being stored by this renderable.
109
ConstRadioButtonIterator
RadioButtonEnd
()
const
;
110
111
///////////////////////////////////////////////////////////////////////////////
112
// Internal Methods
113
114
/// @internal
115
/// @brief Notifies this group a button has been selected.
116
void
_NotifyButtonSelected
(
RadioButton
* Selected);
117
};
//RadioButtonGroup
118
119
///////////////////////////////////////////////////////////////////////////////
120
/// @brief This is a simple widget where only one of it's selections can be selected at a time.
121
/// @details
122
///////////////////////////////////////
123
class
RadioButton
:
public
CheckBox
124
{
125
public
:
126
/// @brief String containing the type name for this class: "RadioButton".
127
static
const
String
TypeName
;
128
protected
:
129
friend
class
RadioButtonFactory
;
130
/// @internal
131
/// @brief A pointer to the group this RadioButton belongs to.
132
RadioButtonGroup
*
ButtonGroup
;
133
134
/// @copydoc Renderable::ProtoSerializeImpl(XML::Node&) const
135
virtual
void
ProtoSerializeImpl
(
XML::Node
& SelfRoot)
const
;
136
/// @copydoc Renderable::ProtoDeSerializeImpl(const XML::Node&)
137
virtual
void
ProtoDeSerializeImpl
(
const
XML::Node
& SelfRoot);
138
//public:
139
/// @brief Blank constructor.
140
/// @param Parent The parent Screen that created this widget.
141
RadioButton
(
Screen
* Parent);
142
/// @brief Standard initialization constructor.
143
/// @param RendName The name to be given to this renderable.
144
/// @param Parent The parent Screen that created this widget.
145
RadioButton
(
const
String
& RendName,
Screen
* Parent);
146
/// @brief Rect constructor.
147
/// @param RendName The name to be given to this renderable.
148
/// @param RendRect The rect describing this widget's transform relative to it's parent.
149
/// @param Parent The parent screen that created this renderable.
150
RadioButton
(
const
String
& RendName,
const
UnifiedRect
& RendRect,
Screen
* Parent);
151
/// @brief XML constructor.
152
/// @param XMLNode The node of the xml document to construct from.
153
/// @param Parent The screen the created RadioButton will belong to.
154
RadioButton
(
const
XML::Node
& XMLNode,
Screen
* Parent);
155
/// @brief Class destructor.
156
virtual
~RadioButton
();
157
public
:
158
///////////////////////////////////////////////////////////////////////////////
159
// Utility Methods
160
161
///////////////////////////////////////////////////////////////////////////////
162
// RadioButton Properties
163
164
///////////////////////////////////////////////////////////////////////////////
165
// RadioButton Configuration
166
167
/// @brief Adds this RadioButton to the same RadioButtonGroup as the specified RadioButton.
168
/// @param GroupButton The RadioButton to get the button group from and add this button to.
169
virtual
void
AddToButtonGroup
(
RadioButton
* GroupButton);
170
/// @brief Removes this RadioButton from the RadioButtonGroup it currently belongs to.
171
virtual
void
RemoveFromButtonGroup
();
172
173
///////////////////////////////////////////////////////////////////////////////
174
// Serialization
175
176
/// @brief Convert the Group Buttons of this class to an XML::Node ready for serialization.
177
/// @param SelfRoot The root node containing all the serialized data for this instance.
178
virtual
void
ProtoSerializeGroupButtons
(
XML::Node
& SelfRoot)
const
;
179
/// @copydoc Renderable::ProtoSerializeProperties(XML::Node&) const
180
virtual
void
ProtoSerializeProperties
(
XML::Node
& SelfRoot)
const
;
181
182
/// @brief Take the data stored in an XML Node and overwrite the Group Buttons of this object with it.
183
/// @param SelfRoot An XML::Node containing the data to populate this class with.
184
virtual
void
ProtoDeSerializeGroupButtons
(
const
XML::Node
& SelfRoot);
185
/// @copydoc Renderable::ProtoDeSerializeProperties(const XML::Node&)
186
virtual
void
ProtoDeSerializeProperties
(
const
XML::Node
& SelfRoot);
187
188
/// @copydoc Renderable::GetSerializableName()
189
static
String
GetSerializableName
();
190
191
///////////////////////////////////////////////////////////////////////////////
192
// Internal Event Methods
193
194
/// @copydoc Checkbox::_OnSelected()
195
virtual
void
_OnSelected
();
196
/// @copydoc Checkbox::_OnDeselected()
197
virtual
void
_OnDeselected
();
198
199
///////////////////////////////////////////////////////////////////////////////
200
// Internal Methods
201
202
/// @internal
203
/// @brief Gets the RadioButtonGroup this button belongs to.
204
/// @return Returns a pointer to the RadioButtonGroup that this button belongs to, or NULL if it doesn't have a group.
205
virtual
RadioButtonGroup
*
_GetButtonGroup
()
const
;
206
};
//RadioButton
207
208
///////////////////////////////////////////////////////////////////////////////
209
/// @brief This is the factory implementation for RadioButton widgets.
210
/// @details
211
///////////////////////////////////////
212
class
MEZZ_LIB
RadioButtonFactory
:
public
WidgetFactory
213
{
214
public
:
215
/// @brief Class constructor.
216
RadioButtonFactory
() { }
217
/// @brief Class destructor.
218
virtual
~RadioButtonFactory
() { }
219
220
/// @copydoc WidgetFactory::GetWidgetTypeName() const
221
virtual
String
GetWidgetTypeName()
const
;
222
223
/// @brief Creates a new RadioButton.
224
/// @param RendName The name to be given to the created RadioButton.
225
/// @param Parent The screen the created RadioButton will belong to.
226
/// @return Returns a pointer to the created RadioButton.
227
virtual
RadioButton
* CreateRadioButton(
const
String
& RendName,
Screen
* Parent);
228
/// @brief Creates a new RadioButton.
229
/// @param RendName The name to be given to the created RadioButton.
230
/// @param RendRect The dimensions that will be assigned to the created RadioButton.
231
/// @param Parent The screen the created RadioButton will belong to.
232
/// @return Returns a pointer to the created RadioButton.
233
virtual
RadioButton
* CreateRadioButton(
const
String
& RendName,
const
UnifiedRect
& RendRect,
Screen
* Parent);
234
/// @brief Creates a new RadioButton.
235
/// @param XMLNode The node of the xml document to construct from.
236
/// @param Parent The screen the created RadioButton will belong to.
237
/// @return Returns a pointer to the created RadioButton.
238
virtual
RadioButton
* CreateRadioButton(
const
XML::Node
& XMLNode,
Screen
* Parent);
239
240
/// @copydoc WidgetFactory::CreateWidget(Screen*)
241
virtual
Widget
* CreateWidget(
Screen
* Parent);
242
/// @copydoc WidgetFactory::CreateWidget(const String&, const NameValuePairMap&, Screen*)
243
virtual
Widget
* CreateWidget(
const
String
& RendName,
const
NameValuePairMap
& Params,
Screen
* Parent);
244
/// @copydoc WidgetFactory::CreateWidget(const String&, const UnifiedRect&, const NameValuePairMap&, Screen*)
245
virtual
Widget
* CreateWidget(
const
String
& RendName,
const
UnifiedRect
& RendRect,
const
NameValuePairMap
& Params,
Screen
* Parent);
246
/// @copydoc WidgetFactory::CreateWidget(const XML::Node&, Screen*)
247
virtual
Widget
* CreateWidget(
const
XML::Node
& XMLNode,
Screen
* Parent);
248
/// @copydoc WidgetFactory::DestroyWidget(Widget*)
249
virtual
void
DestroyWidget(
Widget
* ToBeDestroyed);
250
};
//RadioButtonFactory
251
}
//UI
252
}
//Mezzanine
253
254
#endif
Generated on Mon Jan 6 2014 20:58:06 for MezzanineEngine by
1.8.4