Spinning Topp Logo BlackTopp Studios
inc
tabset.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 _uitabset_h
41 #define _uitabset_h
42 
43 #include "UI/stackedcontainer.h"
44 
45 namespace Mezzanine
46 {
47  namespace UI
48  {
49  ///////////////////////////////////////////////////////////////////////////////
50  /// @brief This is a widget that stores sets of renderables but only displays one at a time.
51  /// @details This widget is useful for tabbed option displays. @n @n
52  /// This class uses the base LayoutStrategy.
53  ///////////////////////////////////////
55  {
56  public:
57  /// @brief Convenience typedef for objects that will be used to represent tabs in this TabSet.
59  /// @brief Container class for storing @ref TabbedSubSet instances stored by this class.
60  typedef std::map<TabbedSubSet*,UInt16> TabbedSubSetContainer;
61  /// @brief Iterator type for @ref TabbedSubSet instances stored by this class.
62  typedef TabbedSubSetContainer::iterator TabbedSubSetIterator;
63  /// @brief Const Iterator type for @ref TabbedSubSet instances stored stored by this class.
64  typedef TabbedSubSetContainer::const_iterator ConstTabbedSubSetIterator;
65 
66  /// @brief String containing the type name for this class: "TabSet".
67  static const String TypeName;
68  protected:
69  /// @internal
70  /// @brief A container storing all the bindings to
71  TabbedSubSetContainer SubSetBindings;
72  /// @internal
73  /// @brief A pointer to the only visible child of this TabSet.
74  TabbedSubSet* VisibleChild;
75 
76  /// @copydoc Renderable::ProtoSerializeImpl(XML::Node&) const
77  virtual void ProtoSerializeImpl(XML::Node& SelfRoot) const;
78  /// @copydoc Renderable::ProtoDeSerializeImpl(const XML::Node&)
79  virtual void ProtoDeSerializeImpl(const XML::Node& SelfRoot);
80  public:
81  /// @brief Blank constructor.
82  /// @param Parent The parent Screen that created this widget.
83  TabSet(Screen* Parent);
84  /// @brief Standard initialization constructor.
85  /// @param RendName The name to be given to this renderable.
86  /// @param Parent The parent Screen that created this widget.
87  TabSet(const String& RendName, Screen* Parent);
88  /// @brief Rect constructor.
89  /// @param RendName The name to be given to this renderable.
90  /// @param RendRect The rect describing this widget's transform relative to it's parent.
91  /// @param Parent The parent screen that created this renderable.
92  TabSet(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
93  /// @brief XML constructor.
94  /// @param XMLNode The node of the xml document to construct from.
95  /// @param Parent The screen the created TabSet will belong to.
96  TabSet(const XML::Node& XMLNode, Screen* Parent);
97  /// @brief Class destructor.
98  virtual ~TabSet();
99  //public:
100  ///////////////////////////////////////////////////////////////////////////////
101  // Utility Methods
102 
103  /// @brief Makes a child TabbedSubSet in this TabSet visible.
104  /// @warning This method makes no attempt to verify the provided TabbedSubSet is a part of this TabSet.
105  /// @param MakeVisible A pointer to the TabbedSubSet to be made visible.
106  virtual void SetVisibleSubSet(TabbedSubSet* MakeVisible);
107  /// @brief Makes a child TabbedSubSet in this TabSet visible.
108  /// @param Binding A UInt16 that is the ZOrder of the TabbedSubSet to be made visible, or makes all subsets hidden of the ZOrder does not exist.
109  virtual void SetVisibleSubSet(const UInt16 Binding);
110  /// @brief Gets a pointer to the TabbedSubSet that is currently visible within this TabSet.
111  /// @return Returns a pointer to the child subset that is currently visible.
112  virtual TabbedSubSet* GetVisibleSubSet() const;
113 
114  /// @copydoc Widget::GetTypeName() const
115  virtual const String& GetTypeName() const;
116 
117  ///////////////////////////////////////////////////////////////////////////////
118  // Visibility and Priority Methods
119 
120  /// @copydoc Renderable::SetVisible(Boole)
121  virtual void SetVisible(Boole CanSee);
122  /// @copydoc Renderable::Show()
123  virtual void Show();
124  /// @copydoc Renderable::Hide()
125  virtual void Hide();
126 
127  ///////////////////////////////////////////////////////////////////////////////
128  // TabSet Properties
129 
130  ///////////////////////////////////////////////////////////////////////////////
131  // TabSet Configuration
132 
133  /// @copydoc StackedContainer::SetButtonConfig(const UInt16, StackButton*)
134  /// @note The UInt16 passed into this method should represent the ZOrder of the TabbedSubSet it will make visible.
135  virtual void SetButtonConfig(const UInt16 Config, StackButton* ConfigButton);
136  /// @copydoc StackedContainer::GetButtonConfig(const StackButton*) const
137  /// @note This method will return the ZOrder of the TabbedSubSet it will make visible. This will return 0 if the button is invalid.
138  virtual UInt16 GetButtonConfig(const StackButton* ConfigButton) const;
139 
140  /// @brief Removes a button from the configuration of this TabSet.
141  /// @param ConfigButton A pointer to the button to be removed from this TabSets configuration.
142  virtual void RemoveButtonConfig(StackButton* ConfigButton);
143 
144  /// @brief Creates a new TabbedSubSet for this TabSet.
145  /// @note The ZOrder given to the created TabbedSubSet will be used as an ID for setting the visible child of this TabSet.
146  /// Ideally ZOrder "0" should not be used since it is returned in the event of an error condition when querying for a button configuration.
147  /// @param Name The name to be given to the TabbedSubSet.
148  /// @param ChildZOrder The ZOrder to be assigned to the TabbedSubSet.
149  /// @return Returns a pointer to the created TabbedSubSet.
150  virtual TabbedSubSet* CreateTabbedSubSet(const String& Name, const UInt16 ChildZOrder);
151 
152  ///////////////////////////////////////////////////////////////////////////////
153  // Serialization
154 
155  /// @copydoc Renderable::ProtoSerializeProperties(XML::Node&) const
156  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
157  /// @brief Convert the Button Bindings of this class to an XML::Node ready for serialization.
158  /// @param SelfRoot The root node containing all the serialized data for this instance.
159  virtual void ProtoSerializeButtonBindings(XML::Node& SelfRoot) const;
160 
161  /// @copydoc Renderable::ProtoDeSerializeProperties(const XML::Node&)
162  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
163  /// @brief Take the data stored in an XML Node and overwrite the Button Bindings of this object with it.
164  /// @param SelfRoot An XML::Node containing the data to populate this class with.
165  virtual void ProtoDeSerializeButtonBindings(const XML::Node& SelfRoot);
166 
167  /// @copydoc Renderable::GetSerializableName()
168  static String GetSerializableName();
169 
170  ///////////////////////////////////////////////////////////////////////////////
171  // Internal Event Methods
172 
173  ///////////////////////////////////////////////////////////////////////////////
174  // Internal Methods
175 
176  /// @copydoc StackedContainer::_NotifyButtonSelected(StackButton*)
177  virtual void _NotifyButtonSelected(StackButton* Selected);
178  };//TabSet
179 
180  ///////////////////////////////////////////////////////////////////////////////
181  /// @brief This is the factory implementation for TabSet widgets.
182  /// @details
183  ///////////////////////////////////////
185  {
186  public:
187  /// @brief Class constructor.
189  /// @brief Class destructor.
190  virtual ~TabSetFactory() { }
191 
192  /// @copydoc WidgetFactory::GetWidgetTypeName() const
193  virtual String GetWidgetTypeName() const;
194 
195  /// @brief Creates a new TabSet.
196  /// @param RendName The name to be given to the created TabSet.
197  /// @param Parent The screen the created TabSet will belong to.
198  /// @return Returns a pointer to the created TabSet.
199  virtual TabSet* CreateTabSet(const String& RendName, Screen* Parent);
200  /// @brief Creates a new TabSet.
201  /// @param RendName The name to be given to the created TabSet.
202  /// @param RendRect The dimensions that will be assigned to the created TabSet.
203  /// @param Parent The screen the created TabSet will belong to.
204  /// @return Returns a pointer to the created TabSet.
205  virtual TabSet* CreateTabSet(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
206  /// @brief Creates a new TabSet.
207  /// @param XMLNode The node of the xml document to construct from.
208  /// @param Parent The screen the created TabSet will belong to.
209  /// @return Returns a pointer to the created TabSet.
210  virtual TabSet* CreateTabSet(const XML::Node& XMLNode, Screen* Parent);
211 
212  /// @copydoc WidgetFactory::CreateWidget(Screen*)
213  virtual Widget* CreateWidget(Screen* Parent);
214  /// @copydoc WidgetFactory::CreateWidget(const String&, const NameValuePairMap&, Screen*)
215  virtual Widget* CreateWidget(const String& RendName, const NameValuePairMap& Params, Screen* Parent);
216  /// @copydoc WidgetFactory::CreateWidget(const String&, const UnifiedRect&, const NameValuePairMap&, Screen*)
217  virtual Widget* CreateWidget(const String& RendName, const UnifiedRect& RendRect, const NameValuePairMap& Params, Screen* Parent);
218  /// @copydoc WidgetFactory::CreateWidget(const XML::Node&, Screen*)
219  virtual Widget* CreateWidget(const XML::Node& XMLNode, Screen* Parent);
220  /// @copydoc WidgetFactory::DestroyWidget(Widget*)
221  virtual void DestroyWidget(Widget* ToBeDestroyed);
222  };//TabSetFactory
223  }//UI
224 }//Mezzanine
225 
226 #endif
TabbedSubSet * VisibleChild
A pointer to the only visible child of this TabSet.
Definition: tabset.h:74
static const String TypeName
String containing the type name for this class: "TabSet".
Definition: tabset.h:67
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
Widget TabbedSubSet
Convenience typedef for objects that will be used to represent tabs in this TabSet.
Definition: tabset.h:58
This is a button with additional data used to track the binding to a StackedContainer which can be se...
Definition: stackbutton.h:54
virtual ~TabSetFactory()
Class destructor.
Definition: tabset.h:190
This is a widget that stores sets of renderables but only displays one at a time. ...
Definition: tabset.h:54
TabSetFactory()
Class constructor.
Definition: tabset.h:188
std::map< TabbedSubSet *, UInt16 > TabbedSubSetContainer
Container class for storing TabbedSubSet instances stored by this class.
Definition: tabset.h:60
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
This is the base class for containers that stack their children one on top of the other...
This is the base class for all widgets.
Definition: widget.h:126
This is the factory implementation for TabSet widgets.
Definition: tabset.h:184
TabbedSubSetContainer::iterator TabbedSubSetIterator
Iterator type for TabbedSubSet instances stored by this class.
Definition: tabset.h:62
TabbedSubSetContainer::const_iterator ConstTabbedSubSetIterator
Const Iterator type for TabbedSubSet instances stored stored by this class.
Definition: tabset.h:64
#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
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
TabbedSubSetContainer SubSetBindings
A container storing all the bindings to.
Definition: tabset.h:71