MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
checkbox.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 _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  /// @class CheckBox
53  /// @headerfile checkbox.h
54  /// @brief This is a simple widget for storing a bool value.
55  /// @details
56  ///////////////////////////////////////
57  class MEZZ_LIB CheckBox : public Button
58  {
59  public:
60  /// @enum WidgetStateExt
61  /// @brief Enum describing extended widget states for the CheckBox widget.
63  {
64  WS_Selected = 8
65  };
66 
67  /// @brief String containing the type name for this class: "CheckBox".
68  static const String TypeName;
69  /// @brief Event name for when this checkbox is Selected.
70  static const String EventSelected;
71  /// @brief Event name for when this checkbox is Deselected.
72  static const String EventDeselected;
73  protected:
74  friend class CheckBoxFactory;
75  /// @internal
76  /// @brief Stores whether or not the current state of this CheckBox is locked.
77  Boolean SelectLock;
78 
79  /// @internal
80  /// @brief Contains all the common necessary startup initializations for this class.
81  void ConstructCheckbox();
82  //public:
83  /// @brief Blank constructor.
84  /// @param Parent The parent Screen that created this widget.
85  CheckBox(Screen* Parent);
86  /// @brief Standard initialization constructor.
87  /// @param RendName The name to be given to this renderable.
88  /// @param Parent The parent Screen that created this widget.
89  CheckBox(const String& RendName, Screen* Parent);
90  /// @brief Rect constructor.
91  /// @param RendName The name to be given to this renderable.
92  /// @param RendRect The rect describing this widget's transform relative to it's parent.
93  /// @param Parent The parent screen that created this renderable.
94  CheckBox(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
95  /// @brief XML constructor.
96  /// @param XMLNode The node of the xml document to construct from.
97  /// @param Parent The screen the created CheckBox will belong to.
98  CheckBox(const XML::Node& XMLNode, Screen* Parent);
99  /// @brief Class destructor.
100  virtual ~CheckBox();
101  public:
102  ///////////////////////////////////////////////////////////////////////////////
103  // Utility Methods
104 
105  /// @brief Gets whether this checkbox is selected or not.
106  /// @return Returns a bool representing whether or not this checkbox is selected.
107  virtual Boolean IsSelected();
108  /// @brief Gets wether this checkbox is locked into it's current state.
109  /// @return Returns true if this checkbox can't change it's state, false otherwise.
110  virtual Boolean IsLocked();
111  /// @brief Manually select or deselect this checkbox.
112  /// @param Select The value to set the status of this checkbox.
113  virtual void ManualSelect(Boolean Select);
114  /// @brief Locks (or unlocks) the current state of this checkbox.
115  /// @param Lock Whether or not to lock the current state of this checkbox.
116  virtual void SetSelectLock(Boolean Lock);
117  /// @copydoc Widget::GetTypeName() const
118  virtual const String& GetTypeName() const;
119 
120  ///////////////////////////////////////////////////////////////////////////////
121  // Serialization
122 
123  /// @copydoc Renderable::ProtoSerializeProperties(XML::Node&) const
124  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
125  /// @copydoc Renderable::ProtoDeSerializeProperties(const XML::Node&)
126  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
127 
128  /// @copydoc Renderable::GetSerializableName()
129  static String GetSerializableName();
130 
131  ///////////////////////////////////////////////////////////////////////////////
132  // Internal Event Methods
133 
134  /// @copydoc Button::_OnActivate()
135  virtual void _OnActivate();
136  /// @copydoc Button::_OnDeactivate()
137  virtual void _OnDeactivate();
138  /// @brief Self logic to be executed when this checkbox is selected.
139  virtual void _OnSelected();
140  /// @brief Self logic to be executed when this checkbox is deselected.
141  virtual void _OnDeselected();
142  };//CheckBox
143 
144  ///////////////////////////////////////////////////////////////////////////////
145  /// @brief This is the factory implementation for CheckBox widgets.
146  /// @details
147  ///////////////////////////////////////
149  {
150  public:
151  /// @brief Class constructor.
153  /// @brief Class destructor.
154  virtual ~CheckBoxFactory() { }
155 
156  /// @copydoc WidgetFactory::GetWidgetTypeName() const
157  virtual String GetWidgetTypeName() const;
158 
159  /// @brief Creates a new CheckBox.
160  /// @param RendName The name to be given to the created CheckBox.
161  /// @param Parent The screen the created CheckBox will belong to.
162  /// @return Returns a pointer to the created CheckBox.
163  virtual CheckBox* CreateCheckBox(const String& RendName, Screen* Parent);
164  /// @brief Creates a new CheckBox.
165  /// @param RendName The name to be given to the created CheckBox.
166  /// @param RendRect The dimensions that will be assigned to the created CheckBox.
167  /// @param Parent The screen the created CheckBox will belong to.
168  /// @return Returns a pointer to the created CheckBox.
169  virtual CheckBox* CreateCheckBox(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
170  /// @brief Creates a new CheckBox.
171  /// @param XMLNode The node of the xml document to construct from.
172  /// @param Parent The screen the created CheckBox will belong to.
173  /// @return Returns a pointer to the created CheckBox.
174  virtual CheckBox* CreateCheckBox(const XML::Node& XMLNode, Screen* Parent);
175 
176  /// @copydoc WidgetFactory::CreateWidget(Screen*)
177  virtual Widget* CreateWidget(Screen* Parent);
178  /// @copydoc WidgetFactory::CreateWidget(const String&, const NameValuePairMap&, Screen*)
179  virtual Widget* CreateWidget(const String& RendName, const NameValuePairMap& Params, Screen* Parent);
180  /// @copydoc WidgetFactory::CreateWidget(const String&, const UnifiedRect&, const NameValuePairMap&, Screen*)
181  virtual Widget* CreateWidget(const String& RendName, const UnifiedRect& RendRect, const NameValuePairMap& Params, Screen* Parent);
182  /// @copydoc WidgetFactory::CreateWidget(const XML::Node&, Screen*)
183  virtual Widget* CreateWidget(const XML::Node& XMLNode, Screen* Parent);
184  /// @copydoc WidgetFactory::DestroyWidget(Widget*)
185  virtual void DestroyWidget(Widget* ToBeDestroyed);
186  };//CheckBoxFactory
187  }//UI
188 }//Mezzanine
189 
190 #endif