MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
menubutton.h
1 //© Copyright 2010 - 2013 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 _uimenubutton_h
41 #define _uimenubutton_h
42 
43 #include "UI/button.h"
44 
45 namespace Mezzanine
46 {
47  namespace UI
48  {
49  class MenuEntry;
50  ///////////////////////////////////////////////////////////////////////////////
51  /// @brief This is a button with additional data used to track the binding to a MenuEntry which can be serialized.
52  /// @details
53  ///////////////////////////////////////
54  class MenuButton : public Button
55  {
56  public:
57  /// @brief String containing the type name for this class: "MenuButton".
58  static const String TypeName;
59  protected:
60  friend class MenuButtonFactory;
61  /// @internal
62  /// @brief A pointer storing the MenuEntry this button is bound to.
64  //public:
65  /// @brief Blank constructor.
66  /// @param Parent The parent Screen that created this widget.
67  MenuButton(Screen* Parent);
68  /// @brief Standard initialization constructor.
69  /// @param RendName The name to be given to this renderable.
70  /// @param Parent The parent Screen that created this widget.
71  MenuButton(const String& RendName, Screen* Parent);
72  /// @brief Rect constructor.
73  /// @param RendName The name to be given to this renderable.
74  /// @param RendRect The rect describing this widget's transform relative to it's parent.
75  /// @param Parent The parent screen that created this renderable.
76  MenuButton(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
77  /// @brief XML constructor.
78  /// @param XMLNode The node of the xml document to construct from.
79  /// @param Parent The screen the created Button will belong to.
80  MenuButton(const XML::Node& XMLNode, Screen* Parent);
81  /// @brief Standard destructor.
82  virtual ~MenuButton();
83  public:
84  ///////////////////////////////////////////////////////////////////////////////
85  // Serialization
86 
87  /// @copydoc Renderable::ProtoSerializeProperties(XML::Node&) const
88  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
89  /// @copydoc Renderable::ProtoDeSerializeProperties(const XML::Node&)
90  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
91 
92  /// @copydoc Renderable::GetSerializableName()
93  static String GetSerializableName();
94 
95  ///////////////////////////////////////////////////////////////////////////////
96  // Internal Methods
97 
98  /// @internal
99  /// @brief Notifies this MenuButton that a MenuEntry is now using it as a push or pop button.
100  /// @param ToBeBound A pointer to the MenuEntry that this MenuButton will be bound to.
101  void _SetBoundMenu(MenuEntry* ToBeBound);
102  };//MenuButton
103 
104  ///////////////////////////////////////////////////////////////////////////////
105  /// @brief This is the factory implementation for MenuButton widgets.
106  /// @details
107  ///////////////////////////////////////
109  {
110  public:
111  /// @brief Class constructor.
113  /// @brief Class destructor.
114  virtual ~MenuButtonFactory() { }
115 
116  /// @copydoc WidgetFactory::GetWidgetTypeName() const
117  virtual String GetWidgetTypeName() const;
118 
119  /// @brief Creates a new MenuButton.
120  /// @param RendName The name to be given to the created MenuButton.
121  /// @param Parent The screen the created MenuButton will belong to.
122  /// @return Returns a pointer to the created MenuButton.
123  virtual MenuButton* CreateMenuButton(const String& RendName, Screen* Parent);
124  /// @brief Creates a new MenuButton.
125  /// @param RendName The name to be given to the created MenuButton.
126  /// @param RendRect The dimensions that will be assigned to the created MenuButton.
127  /// @param Parent The screen the created MenuButton will belong to.
128  /// @return Returns a pointer to the created MenuButton.
129  virtual MenuButton* CreateMenuButton(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
130  /// @brief Creates a new MenuButton.
131  /// @param XMLNode The node of the xml document to construct from.
132  /// @param Parent The screen the created MenuButton will belong to.
133  /// @return Returns a pointer to the created MenuButton.
134  virtual MenuButton* CreateMenuButton(const XML::Node& XMLNode, Screen* Parent);
135 
136  /// @copydoc WidgetFactory::CreateWidget(Screen*)
137  virtual Widget* CreateWidget(Screen* Parent);
138  /// @copydoc WidgetFactory::CreateWidget(const String&, const NameValuePairMap&, Screen*)
139  virtual Widget* CreateWidget(const String& RendName, const NameValuePairMap& Params, Screen* Parent);
140  /// @copydoc WidgetFactory::CreateWidget(const String&, const UnifiedRect&, const NameValuePairMap&, Screen*)
141  virtual Widget* CreateWidget(const String& RendName, const UnifiedRect& RendRect, const NameValuePairMap& Params, Screen* Parent);
142  /// @copydoc WidgetFactory::CreateWidget(const XML::Node&, Screen*)
143  virtual Widget* CreateWidget(const XML::Node& XMLNode, Screen* Parent);
144  /// @copydoc WidgetFactory::DestroyWidget(Widget*)
145  virtual void DestroyWidget(Widget* ToBeDestroyed);
146  };//MenuButtonFactory
147  }//UI
148 }//Mezzanine
149 
150 #endif