Spinning Topp Logo BlackTopp Studios
inc
checkbox.h
1 // © Copyright 2010 - 2016 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 _uicheckbox_h
41 #define _uicheckbox_h
42 
43 #include "datatypes.h"
44 #include "UI/button.h"
45 
46 namespace Mezzanine
47 {
48  namespace UI
49  {
50  class Button;
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @brief This is a simple widget for storing a bool value.
53  /// @details This class does not use a LayoutStrategy.
54  ///////////////////////////////////////
55  class MEZZ_LIB CheckBox : public Button
56  {
57  public:
58  /// @brief Enum describing extended widget states for the CheckBox widget.
60  {
61  WS_Selected = Widget::WS_Mezzanine_Reserved_1
62  };
63  /// @brief Enum describing additional pre-initialized RenderLayerGroups created by the Checkbox widget.
65  {
66  WG_SelectedNormal = Widget::WG_Mezzanine_Reserved_1,
67  WG_SelectedHovered = Widget::WG_Mezzanine_Reserved_2
68  };
69 
70  /// @brief String containing the type name for this class: "CheckBox".
71  static const String TypeName;
72  /// @brief Event name for when this checkbox is Selected.
73  static const String EventSelected;
74  /// @brief Event name for when this checkbox is Deselected.
75  static const String EventDeselected;
76  protected:
77  /// @internal
78  /// @brief Stores whether or not the current state of this CheckBox is locked.
80 
81  /// @internal
82  /// @brief Contains all the common necessary startup initializations for this class.
83  void ConstructCheckbox();
84  public:
85  /// @brief Blank constructor.
86  /// @param Parent The parent Screen that created this widget.
87  CheckBox(Screen* Parent);
88  /// @brief Standard initialization constructor.
89  /// @param RendName The name to be given to this renderable.
90  /// @param Parent The parent Screen that created this widget.
91  CheckBox(const String& RendName, Screen* Parent);
92  /// @brief Rect constructor.
93  /// @param RendName The name to be given to this renderable.
94  /// @param RendRect The rect describing this widget's transform relative to it's parent.
95  /// @param Parent The parent screen that created this renderable.
96  CheckBox(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
97  /// @brief XML constructor.
98  /// @param XMLNode The node of the xml document to construct from.
99  /// @param Parent The screen the created CheckBox will belong to.
100  CheckBox(const XML::Node& XMLNode, Screen* Parent);
101  /// @brief Class destructor.
102  virtual ~CheckBox();
103  //public:
104  ///////////////////////////////////////////////////////////////////////////////
105  // Utility Methods
106 
107  /// @brief Gets whether this checkbox is selected or not.
108  /// @return Returns a bool representing whether or not this checkbox is selected.
109  virtual Boole IsSelected();
110  /// @brief Gets wether this checkbox is locked into it's current state.
111  /// @return Returns true if this checkbox can't change it's state, false otherwise.
112  virtual Boole IsLocked();
113  /// @brief Manually select or deselect this checkbox.
114  /// @param Select The value to set the status of this checkbox.
115  virtual void ManualSelect(Boole Select);
116  /// @brief Locks (or unlocks) the current state of this checkbox.
117  /// @param Lock Whether or not to lock the current state of this checkbox.
118  virtual void SetSelectLock(Boole Lock);
119  /// @copydoc Widget::GetTypeName() const
120  virtual const String& GetTypeName() const;
121 
122  ///////////////////////////////////////////////////////////////////////////////
123  // Serialization
124 
125  /// @copydoc Renderable::ProtoSerializeProperties(XML::Node&) const
126  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
127  /// @copydoc Renderable::ProtoDeSerializeProperties(const XML::Node&)
128  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
129 
130  /// @copydoc Renderable::GetSerializableName()
131  static String GetSerializableName();
132 
133  ///////////////////////////////////////////////////////////////////////////////
134  // Internal Event Methods
135 
136  /// @copydoc Button::_OnActivate()
137  virtual void _OnActivate();
138  /// @copydoc Button::_OnDeactivate()
139  virtual void _OnDeactivate();
140  /// @brief Self logic to be executed when this checkbox is selected.
141  virtual void _OnSelected();
142  /// @brief Self logic to be executed when this checkbox is deselected.
143  virtual void _OnDeselected();
144  };//CheckBox
145 
146  ///////////////////////////////////////////////////////////////////////////////
147  /// @brief This is the factory implementation for CheckBox widgets.
148  /// @details
149  ///////////////////////////////////////
151  {
152  public:
153  /// @brief Class constructor.
155  /// @brief Class destructor.
156  virtual ~CheckBoxFactory() { }
157 
158  /// @copydoc WidgetFactory::GetWidgetTypeName() const
159  virtual String GetWidgetTypeName() const;
160 
161  /// @brief Creates a new CheckBox.
162  /// @param RendName The name to be given to the created CheckBox.
163  /// @param Parent The screen the created CheckBox will belong to.
164  /// @return Returns a pointer to the created CheckBox.
165  virtual CheckBox* CreateCheckBox(const String& RendName, Screen* Parent);
166  /// @brief Creates a new CheckBox.
167  /// @param RendName The name to be given to the created CheckBox.
168  /// @param RendRect The dimensions that will be assigned to the created CheckBox.
169  /// @param Parent The screen the created CheckBox will belong to.
170  /// @return Returns a pointer to the created CheckBox.
171  virtual CheckBox* CreateCheckBox(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
172  /// @brief Creates a new CheckBox.
173  /// @param XMLNode The node of the xml document to construct from.
174  /// @param Parent The screen the created CheckBox will belong to.
175  /// @return Returns a pointer to the created CheckBox.
176  virtual CheckBox* CreateCheckBox(const XML::Node& XMLNode, Screen* Parent);
177 
178  /// @copydoc WidgetFactory::CreateWidget(Screen*)
179  virtual Widget* CreateWidget(Screen* Parent);
180  /// @copydoc WidgetFactory::CreateWidget(const String&, const NameValuePairMap&, Screen*)
181  virtual Widget* CreateWidget(const String& RendName, const NameValuePairMap& Params, Screen* Parent);
182  /// @copydoc WidgetFactory::CreateWidget(const String&, const UnifiedRect&, const NameValuePairMap&, Screen*)
183  virtual Widget* CreateWidget(const String& RendName, const UnifiedRect& RendRect, const NameValuePairMap& Params, Screen* Parent);
184  /// @copydoc WidgetFactory::CreateWidget(const XML::Node&, Screen*)
185  virtual Widget* CreateWidget(const XML::Node& XMLNode, Screen* Parent);
186  /// @copydoc WidgetFactory::DestroyWidget(Widget*)
187  virtual void DestroyWidget(Widget* ToBeDestroyed);
188  };//CheckBoxFactory
189  }//UI
190 }//Mezzanine
191 
192 #endif
static const String TypeName
String containing the type name for this class: "CheckBox".
Definition: checkbox.h:71
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
Boole SelectLock
Stores whether or not the current state of this CheckBox is locked.
Definition: checkbox.h:79
All the definitions for datatypes as well as some basic conversion functions are defined here...
CheckBoxFactory()
Class constructor.
Definition: checkbox.h:154
static const String EventSelected
Event name for when this checkbox is Selected.
Definition: checkbox.h:73
This is the factory implementation for CheckBox widgets.
Definition: checkbox.h:150
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
This is the base class for all widgets.
Definition: widget.h:126
WidgetGroupIDExt
Enum describing additional pre-initialized RenderLayerGroups created by the Checkbox widget...
Definition: checkbox.h:64
static const String EventDeselected
Event name for when this checkbox is Deselected.
Definition: checkbox.h:75
WidgetStateExt
Enum describing extended widget states for the CheckBox widget.
Definition: checkbox.h:59
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
virtual ~CheckBoxFactory()
Class destructor.
Definition: checkbox.h:156
This class is a helper class, specifically for use as a button.
Definition: button.h:66
This is a simple widget for storing a bool value.
Definition: checkbox.h:55
std::map< String, String > NameValuePairMap
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Definition: datatypes.h:209
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
Definition: screen.h:142
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
This is a base class for factories that construct the widgets available to the UI subsystem...
Definition: widgetfactory.h:61