Spinning Topp Logo BlackTopp Studios
inc
dropdownlist.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 _uidropdownlist_h
41 #define _uidropdownlist_h
42 
43 #include "UI/widget.h"
44 //#include "UI/listbox.h"
45 
46 namespace Mezzanine
47 {
48  namespace UI
49  {
50  class ListBox;
51  class CheckBox;
52  ///////////////////////////////////////////////////////////////////////////////
53  /// @brief This is a widget that displays one selection from a list that can have it's visibility toggled.
54  /// @details This class uses a HorizontalLayoutStrategy.
55  /// @remarks It is not uncommon to have a DropDownList in close proximity to other renderables that could overlap with
56  /// the ListBox child of a DropDownList. When this happens be mindful of the ZOrders of sibling renderables. If the
57  /// DropDownList has the highest ZOrder among it's surrounding renderables then the ListBox will behave as expected.
58  ///////////////////////////////////////
59  class MEZZ_LIB DropDownList : public Widget
60  {
61  public:
62  /// @brief String containing the type name for this class: "DropDownList".
63  static const String TypeName;
64  protected:
65  /// @internal
66  /// @brief A pointer to a copy of the ListItem that is the current selection.
68  /// @internal
69  /// @brief A pointer to the CheckBox that will toggle the visibility of the Selection List.
71  /// @internal
72  /// @brief A pointer to the ListBox holding all possible selections.
74 
75  /// @internal
76  /// @brief Convenience method for the construction of a DropDownList.
77  /// @param Style An enum value representing how the scrollbar child of thie ListBox will be constructed. See @ref UI::ScrollbarStyle enum for more info.
78  virtual void ConstructDropDownList(const UI::ScrollbarStyle& Style);
79  public:
80  /// @brief Blank constructor.
81  /// @param Parent The parent Screen that created this widget.
82  DropDownList(Screen* Parent);
83  /// @brief Standard initialization constructor.
84  /// @param RendName The name to be given to this renderable.
85  /// @param Style An enum value representing how the scrollbar child of the ListBox will be constructed. See @ref UI::ScrollbarStyle enum for more info.
86  /// @param Parent The parent Screen that created this widget.
87  DropDownList(const String& RendName, const UI::ScrollbarStyle& Style, 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 Style An enum value representing how the scrollbar child of the ListBox will be constructed. See @ref UI::ScrollbarStyle enum for more info.
92  /// @param Parent The parent screen that created this renderable.
93  DropDownList(const String& RendName, const UnifiedRect& RendRect, const UI::ScrollbarStyle& Style, Screen* Parent);
94  /// @brief XML constructor.
95  /// @param XMLNode The node of the xml document to construct from.
96  /// @param Parent The screen the created ListBox will belong to.
97  DropDownList(const XML::Node& XMLNode, Screen* Parent);
98  /// @brief Class destructor.
99  virtual ~DropDownList();
100  //public:
101  ///////////////////////////////////////////////////////////////////////////////
102  // Utility Methods
103 
104  /// @copydoc Widget::GetTypeName() const
105  virtual const String& GetTypeName() const;
106 
107  /// @copydoc QuadRenderable::UpdateDimensions(const Rect&, const Rect&)
108  virtual void UpdateDimensions(const Rect& OldSelfRect, const Rect& NewSelfRect);
109  /// @brief Configures the selection display of this DropDownList to match the new selection.
110  /// @param NewSelection A pointer to the item that was selected in the ListBox.
111  virtual void UpdateCurrentSelection(Widget* NewSelection);
112 
113  /// @brief Gets the text being displayed by the current selection.
114  /// @return Returns a String containing the text being displayed by this lists SelectionDisplay.
115  virtual String GetSelectionText() 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  // DropDownList Properties
129 
130  ///////////////////////////////////////////////////////////////////////////////
131  // DropDownList Configuration
132 
133  /// @brief Gets the Widget displaying the current selection.
134  /// @return Returns a pointer to the Widget responsible for the display of the selected list item.
135  virtual Widget* GetSelectionDisplay() const;
136  /// @brief Gets the CheckBox that toggles the selection list visibility.
137  /// @return Returns a pointer to the CheckBox responsible for toggling the selection list visibility.
138  virtual CheckBox* GetListToggle() const;
139  /// @brief Gets the ListBox containing all the list options.
140  /// @return Returns a pointer to the ListBox containing all selectable items.
141  virtual ListBox* GetSelectionList() const;
142 
143  ///////////////////////////////////////////////////////////////////////////////
144  // Serialization
145 
146  /// @copydoc Renderable::ProtoSerializeProperties(XML::Node&) const
147  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
148  /// @copydoc QuadRenderable::ProtoSerializeChildQuads(XML::Node&) const
149  virtual void ProtoSerializeChildQuads(XML::Node& SelfRoot) const;
150 
151  /// @copydoc Renderable::ProtoDeSerializeProperties(const XML::Node&)
152  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
153  /// @copydoc QuadRenderable::ProtoDeSerializeChildQuads(const XML::Node&)
154  virtual void ProtoDeSerializeChildQuads(const XML::Node& SelfRoot);
155 
156  /// @copydoc Renderable::GetSerializableName()
157  static String GetSerializableName();
158 
159  ///////////////////////////////////////////////////////////////////////////////
160  // Internal Event Methods
161 
162  ///////////////////////////////////////////////////////////////////////////////
163  // Internal Methods
164 
165  /// @copydoc EventSubscriber::_NotifyEvent(EventArgumentsPtr)
166  virtual void _NotifyEvent(EventArgumentsPtr Args);
167  };//DropDownList
168 
169  ///////////////////////////////////////////////////////////////////////////////
170  /// @brief This is the factory implementation for DropDownList widgets.
171  /// @details
172  ///////////////////////////////////////
174  {
175  public:
176  /// @brief Class constructor.
178  /// @brief Class destructor.
179  virtual ~DropDownListFactory() { }
180 
181  /// @copydoc WidgetFactory::GetWidgetTypeName() const
182  virtual String GetWidgetTypeName() const;
183 
184  /// @brief Creates a new DropDownList.
185  /// @param RendName The name to be given to the created DropDownList.
186  /// @param Style An enum value representing how the scrollbar child of the ListBox will be constructed. See @ref UI::ScrollbarStyle enum for more info.
187  /// @param Parent The screen the created DropDownList will belong to.
188  /// @return Returns a pointer to the created DropDownList.
189  virtual DropDownList* CreateDropDownList(const String& RendName, const UI::ScrollbarStyle& Style, Screen* Parent);
190  /// @brief Creates a new DropDownList.
191  /// @param RendName The name to be given to the created DropDownList.
192  /// @param RendRect The dimensions that will be assigned to the created DropDownList.
193  /// @param Style An enum value representing how the scrollbar child of the ListBox will be constructed. See @ref UI::ScrollbarStyle enum for more info.
194  /// @param Parent The screen the created DropDownList will belong to.
195  /// @return Returns a pointer to the created DropDownList.
196  virtual DropDownList* CreateDropDownList(const String& RendName, const UnifiedRect& RendRect, const UI::ScrollbarStyle& Style, Screen* Parent);
197  /// @brief Creates a new DropDownList.
198  /// @param XMLNode The node of the xml document to construct from.
199  /// @param Parent The screen the created DropDownList will belong to.
200  /// @return Returns a pointer to the created DropDownList.
201  virtual DropDownList* CreateDropDownList(const XML::Node& XMLNode, Screen* Parent);
202 
203  /// @copydoc WidgetFactory::CreateWidget(Screen*)
204  virtual Widget* CreateWidget(Screen* Parent);
205  /// @copydoc WidgetFactory::CreateWidget(const String&, const NameValuePairMap&, Screen*)
206  virtual Widget* CreateWidget(const String& RendName, const NameValuePairMap& Params, Screen* Parent);
207  /// @copydoc WidgetFactory::CreateWidget(const String&, const UnifiedRect&, const NameValuePairMap&, Screen*)
208  virtual Widget* CreateWidget(const String& RendName, const UnifiedRect& RendRect, const NameValuePairMap& Params, Screen* Parent);
209  /// @copydoc WidgetFactory::CreateWidget(const XML::Node&, Screen*)
210  virtual Widget* CreateWidget(const XML::Node& XMLNode, Screen* Parent);
211  /// @copydoc WidgetFactory::DestroyWidget(Widget*)
212  virtual void DestroyWidget(Widget* ToBeDestroyed);
213  };//DropDownListFactory
214  }//UI
215 }//Mezzanine
216 
217 #endif
This is the factory implementation for DropDownList widgets.
Definition: dropdownlist.h:173
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
virtual ~DropDownListFactory()
Class destructor.
Definition: dropdownlist.h:179
A simple reference counting pointer.
Definition: countedptr.h:70
This class represents a box shaped area on the screen.
Definition: rect.h:55
ScrollbarStyle
Used by the scrollbar class to determine what styling should be used for the scrollbar.
CheckBox * ListToggle
A pointer to the CheckBox that will toggle the visibility of the Selection List.
Definition: dropdownlist.h:70
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
static const String TypeName
String containing the type name for this class: "DropDownList".
Definition: dropdownlist.h:63
This is the base class for all widgets.
Definition: widget.h:126
ListBox * SelectionList
A pointer to the ListBox holding all possible selections.
Definition: dropdownlist.h:73
Widget * SelectionDisplay
A pointer to a copy of the ListItem that is the current selection.
Definition: dropdownlist.h:67
DropDownListFactory()
Class constructor.
Definition: dropdownlist.h:177
#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
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
This is a widget that displays one selection from a list that can have it's visibility toggled...
Definition: dropdownlist.h:59
This is a widget for displaying a list of captions in a box.
Definition: listbox.h:63