MyGUI 3.5.3
MyGUI_Gui.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_GUI_H_
8#define MYGUI_GUI_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_Types.h"
12#include "MyGUI_Singleton.h"
13#include "MyGUI_XmlDocument.h"
14#include "MyGUI_IUnlinkWidget.h"
16#include "MyGUI_Widget.h"
18
19namespace MyGUI
20{
21
23
24 class MYGUI_EXPORT Gui : public WidgetContainer, public IUnlinkWidget, public MemberObsolete<Gui>
25 {
27 friend class WidgetManager;
28
29 public:
30 Gui();
31
38 void initialise(const std::string& _core = "MyGUI_Core.xml");
39
41 void shutdown();
42
43 // methods for creating widgets
52 Widget* createWidgetT(
53 std::string_view _type,
54 std::string_view _skin,
55 const IntCoord& _coord,
56 Align _align,
57 std::string_view _layer,
58 std::string_view _name = {});
60 Widget* createWidgetT(
61 std::string_view _type,
62 std::string_view _skin,
63 int _left,
64 int _top,
65 int _width,
66 int _height,
67 Align _align,
68 std::string_view _layer,
69 std::string_view _name = {});
71 Widget* createWidgetRealT(
72 std::string_view _type,
73 std::string_view _skin,
74 const FloatCoord& _coord,
75 Align _align,
76 std::string_view _layer,
77 std::string_view _name = {});
79 Widget* createWidgetRealT(
80 std::string_view _type,
81 std::string_view _skin,
82 float _left,
83 float _top,
84 float _width,
85 float _height,
86 Align _align,
87 std::string_view _layer,
88 std::string_view _name = {});
89
90 // templates for creating widgets by type
92 template<typename T>
93 T* createWidget(
94 std::string_view _skin,
95 const IntCoord& _coord,
96 Align _align,
97 std::string_view _layer,
98 std::string_view _name = {})
99 {
100 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
101 }
103 template<typename T>
104 T* createWidget(
105 std::string_view _skin,
106 int _left,
107 int _top,
108 int _width,
109 int _height,
110 Align _align,
111 std::string_view _layer,
112 std::string_view _name = {})
113 {
114 return static_cast<T*>(createWidgetT(
115 T::getClassTypeName(),
116 _skin,
117 IntCoord(_left, _top, _width, _height),
118 _align,
119 _layer,
120 _name));
121 }
123 template<typename T>
124 T* createWidgetReal(
125 std::string_view _skin,
126 const FloatCoord& _coord,
127 Align _align,
128 std::string_view _layer,
129 std::string_view _name = {})
130 {
131 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
132 }
134 template<typename T>
135 T* createWidgetReal(
136 std::string_view _skin,
137 float _left,
138 float _top,
139 float _width,
140 float _height,
141 Align _align,
142 std::string_view _layer,
143 std::string_view _name = {})
144 {
145 return static_cast<T*>(
146 createWidgetRealT(T::getClassTypeName(), _skin, _left, _top, _width, _height, _align, _layer, _name));
147 }
148
150 void destroyWidget(Widget* _widget);
151
153 void destroyWidgets(const VectorWidgetPtr& _widgets);
154
155#ifndef MYGUI_DONT_USE_OBSOLETE
156 using MemberObsolete<Gui>::destroyWidgets;
157 using MemberObsolete<Gui>::findWidgetT;
158 using MemberObsolete<Gui>::findWidget;
159#endif
160
164 Widget* findWidgetT(std::string_view _name, bool _throw = true) const;
165
169 template<typename T>
170 T* findWidget(std::string_view _name, bool _throw = true) const
171 {
172 Widget* widget = findWidgetT(_name, _throw);
173 if (nullptr == widget)
174 return nullptr;
175 return widget->castType<T>(_throw);
176 }
177
179 void destroyChildWidget(Widget* _widget);
180
182 void destroyAllChildWidget();
183
185 const VectorWidgetPtr& getRootWidgets() const;
186
190 void frameEvent(float _time) const;
191
196 void setDpiScale(float _value);
198 float getDpiScale() const;
199
200 /*events:*/
205 EventHandle_FrameEventDelegate eventFrameStart;
206
207 private:
208 void _unlinkWidget(Widget* _widget) override;
209
210 private:
211 // GUI manager singletons
212 InputManager* mInputManager{nullptr};
213 SubWidgetManager* mSubWidgetManager{nullptr};
214 LayerManager* mLayerManager{nullptr};
215 SkinManager* mSkinManager{nullptr};
216 WidgetManager* mWidgetManager{nullptr};
217 FontManager* mFontManager{nullptr};
218 ControllerManager* mControllerManager{nullptr};
219 PointerManager* mPointerManager{nullptr};
220 ClipboardManager* mClipboardManager{nullptr};
221 LayoutManager* mLayoutManager{nullptr};
222 LanguageManager* mLanguageManager{nullptr};
223 ResourceManager* mResourceManager{nullptr};
224 FactoryManager* mFactoryManager{nullptr};
225 ToolTipManager* mToolTipManager{nullptr};
226
227 float mDpiScale{1.0f};
228 bool mIsInitialise{false};
229 };
230
231} // namespace MyGUI
232
233#endif // MYGUI_GUI_H_
#define MYGUI_EXPORT
#define MYGUI_SINGLETON_DECLARATION(ClassName)
types::TCoord< float > FloatCoord
Definition MyGUI_Types.h:36
delegates::MultiDelegate< float > EventHandle_FrameEventDelegate
Definition MyGUI_Gui.h:22
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:35
std::vector< Widget * > VectorWidgetPtr