MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tabset.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 _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.
52  ///////////////////////////////////////
54  {
55  public:
56  /// @brief String containing the type name for this class: "TabSet".
57  static const String TypeName;
58  protected:
59  friend class TabSetFactory;
60  //public:
61  /// @brief Blank constructor.
62  /// @param Parent The parent Screen that created this widget.
63  TabSet(Screen* Parent);
64  /// @brief Standard initialization constructor.
65  /// @param RendName The name to be given to this renderable.
66  /// @param Parent The parent Screen that created this widget.
67  TabSet(const String& RendName, Screen* Parent);
68  /// @brief Rect constructor.
69  /// @param RendName The name to be given to this renderable.
70  /// @param RendRect The rect describing this widget's transform relative to it's parent.
71  /// @param Parent The parent screen that created this renderable.
72  TabSet(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
73  /// @brief XML constructor.
74  /// @param XMLNode The node of the xml document to construct from.
75  /// @param Parent The screen the created TabSet will belong to.
76  TabSet(const XML::Node& XMLNode, Screen* Parent);
77  /// @brief Class destructor.
78  virtual ~TabSet();
79  public:
80  ///////////////////////////////////////////////////////////////////////////////
81  // Utility Methods
82 
83  ///////////////////////////////////////////////////////////////////////////////
84  // Visibility and Priority Methods
85 
86  ///////////////////////////////////////////////////////////////////////////////
87  // TabSet Properties
88 
89  ///////////////////////////////////////////////////////////////////////////////
90  // TabSet Configuration
91 
92  ///////////////////////////////////////////////////////////////////////////////
93  // Serialization
94 
95  ///////////////////////////////////////////////////////////////////////////////
96  // Internal Event Methods
97 
98  ///////////////////////////////////////////////////////////////////////////////
99  // Internal Methods
100 
101  };//TabSet
102 
103  /*class Button;
104  typedef class EnclosedRenderableContainerWidget RenderableCollection;
105  ///////////////////////////////////////////////////////////////////////////////
106  /// @class RenderableSetData
107  /// @headerfile uitabset.h
108  /// @brief This is a helper class for the storage of Renderable Set's in a Tabset.
109  ///////////////////////////////////////
110  struct MEZZ_LIB RenderableSetData
111  {
112  /// @brief The name of the Accessor/Set Pair.
113  String Name;
114  /// @brief The text button allowing access to viewing the Set.
115  Button* Accessor;
116  /// @brief The collection of renderables to display.
117  RenderableCollection* Collection;
118 
119  /// @brief No initialization constructor.
120  RenderableSetData() : Accessor(NULL), Collection(NULL) {};
121  /// @brief Full initialization constructor.
122  RenderableSetData(ConstString& name, Button* access, RenderableCollection* set) : Name(name), Accessor(access), Collection(set) {};
123  };//RenderableSetData
124  ///////////////////////////////////////////////////////////////////////////////
125  /// @class TabSet
126  /// @headerfile uitabset.h
127  /// @brief This is a widget that stores sets of renderables but only displays one at a time.
128  /// @details This widget is useful for tabbed option displays.
129  ///////////////////////////////////////
130  class MEZZ_LIB TabSet : public Widget
131  {
132  protected:
133  friend class RenderableFactory;
134  Whole SetsAdded;
135  std::vector<RenderableSetData*> Sets;
136  Rect TemplateSetRect;
137  RenderableSetData* VisibleSet;
138  /// @brief Child specific update method.
139  virtual void UpdateImpl(bool Force = false);
140  /// @brief Child specific visibility method.
141  virtual void SetVisibleImpl(bool visible);
142  /// @brief Child specific mouse hover method.
143  virtual bool CheckMouseHoverImpl();
144  /// @internal
145  /// @brief Internal function for setting the location(position) of this widget.
146  virtual void SetLocation(const Vector2& Position);
147  /// @internal
148  /// @brief Internal function for setting the area(size) of this widget.
149  virtual void SetArea(const Vector2& Size);
150  //public:
151  /// @brief Class constructor.
152  /// @param name The Name for the Widget.
153  /// @param SetRect The Rect representing the position and size of all the Renderable Sets generated by this Widget.
154  /// @param parent The parent screen that created this widget.
155  TabSet(const String& name, const Rect& SetRect, Screen* parent);
156  /// @brief Class destructor.
157  virtual ~TabSet();
158  public:
159  ///////////////////////////////////////////////////////////////////////////////
160  // Creating and working with Renderable Sets
161  ///////////////////////////////////////
162  /// @brief Creates a new Set in this widget.
163  /// @details The names generated for the accessor and set will be [Name]+"Access" and [Name]+"Set".
164  /// @return Returns a RenderableSetData struct containing the newly created accessor and set.
165  /// @param Name The Name for the new Set.
166  /// @param AccessorRect The Rect representing the position and size of all the Renderable Sets generated by this Widget.
167  /// @param GlyphHeight The height(in relative units) desired for the text that will be displayed in the Accessor button.
168  /// @param Text The text to set in the TextButton.
169  virtual RenderableSetData* CreateRenderableSet(const String& Name, const Rect& AccessorRect, const Real& GlyphHeight, const String& Text);
170  /// @brief Gets a RenderableSetData by Index.
171  /// @return Returns a pointer to the RenderableSetData at the requested Index.
172  /// @param Index The index of the RenderableSetData to retrieve.
173  virtual RenderableSetData* GetRenderableSetData(const Whole& Index);
174  /// @brief Gets an RenderableSetData by Name.
175  /// @return Returns a pointer to the RenderableSetData of the requested Name.
176  /// @param SetDataName The name of the RenderableSetData to retrieve.
177  virtual RenderableSetData* GetRenderableSetData(const String& SetDataName);
178  /// @brief Gets a RenderableCollection by Index.
179  /// @return Returns a pointer to the RenderableSet at the requested Index.
180  /// @param Index The index of the RenderableSet to retrieve.
181  virtual RenderableCollection* GetRenderableCollection(const Whole& Index);
182  /// @brief Gets an RenderableCollection by Name.
183  /// @return Returns a pointer to the RenderableSet of the requested Name.
184  /// @param SetDataName The name of the RenderableSet to retrieve the collection from.
185  virtual RenderableCollection* GetRenderableCollection(const String& SetDataName);
186  /// @brief Gets a RenderableCollection by Accessor button.
187  /// @return Returns a pointer to the RenderableCollection associated with the provided Accessor.
188  /// @param Accessor The text button that provides access to the desired RenderableCollection.
189  virtual RenderableCollection* GetRenderableCollection(Button* Accessor);
190  /// @brief Gets an Accessor by Index.
191  /// @return Returns a pointer to the Accessor at the requested Index.
192  /// @param Index The index of the Accessor to retrieve.
193  virtual Button* GetAccessor(const Whole& Index);
194  /// @brief Gets an Accessor by Name.
195  /// @return Returns a pointer to the Accessor of the requested Name.
196  /// @param SetDataName The name of the RenderableSet to retrieve the accessor from.
197  virtual Button* GetAccessor(const String& SetDataName);
198  /// @brief Gets an Accessor by RenderableCollection.
199  /// @return Returns a pointer to the Accessor associated with the provided RenderableCollection.
200  /// @param Collection The Collection of renderables being provided access by the desired button.
201  virtual Button* GetAccessor(RenderableCollection* Collection);
202  /// @brief Gets the number of Sets stored in this TabSet.
203  /// @return Returns a Whole representing the number of RenderableSets being stored in this Widget.
204  virtual Whole GetNumRenderableSets();
205  /// @brief Destroys an existing RenderableSetData.
206  /// @param ToBeDestroyed The RenderableSetData that will be destroyed.
207  virtual void DestroyRenderableSet(RenderableSetData* ToBeDestroyed);
208  /// @brief Destroys all RenderableSetData's currently stored in this widget.
209  virtual void DestroyAllRenderableSets();
210  };//TabSet//*/
211  }//UI
212 }//Mezzanine
213 
214 #endif