MyGUI: MyGUI_Gui.h Source File

MyGUI 3.4.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"
15#include "MyGUI_Widget.h"
16#include "MyGUI_BackwardCompatibility.h"
17
18namespace MyGUI
19{
20
21 using EventHandle_FrameEventDelegate = delegates::MultiDelegate<float>;
22
23 class MYGUI_EXPORT Gui : public IUnlinkWidget, public MemberObsolete<Gui>
24 {
25 MYGUI_SINGLETON_DECLARATION(Gui);
26 friend class WidgetManager;
27
28 public:
29 Gui();
30
37 void initialise(const std::string& _core = "MyGUI_Core.xml");
38
39#ifndef MYGUI_DONT_USE_OBSOLETE
40 MYGUI_OBSOLETE(
41 " is deprecated, use : void Gui::initialise(const std::string& _core) and set log filename in Platform")
42 void initialise(const std::string& _core, std::string_view _logFileName);
43#endif // MYGUI_DONT_USE_OBSOLETE
44
46 void shutdown();
47
48 // methods for creating widgets
57 Widget* createWidgetT(
58 std::string_view _type,
59 std::string_view _skin,
60 const IntCoord& _coord,
61 Align _align,
62 std::string_view _layer,
63 std::string_view _name = {});
65 Widget* createWidgetT(
66 std::string_view _type,
67 std::string_view _skin,
68 int _left,
69 int _top,
70 int _width,
71 int _height,
72 Align _align,
73 std::string_view _layer,
74 std::string_view _name = {});
76 Widget* createWidgetRealT(
77 std::string_view _type,
78 std::string_view _skin,
79 const FloatCoord& _coord,
80 Align _align,
81 std::string_view _layer,
82 std::string_view _name = {});
84 Widget* createWidgetRealT(
85 std::string_view _type,
86 std::string_view _skin,
87 float _left,
88 float _top,
89 float _width,
90 float _height,
91 Align _align,
92 std::string_view _layer,
93 std::string_view _name = {});
94
95 // templates for creating widgets by type
97 template<typename T>
98 T* createWidget(
99 std::string_view _skin,
100 const IntCoord& _coord,
101 Align _align,
102 std::string_view _layer,
103 std::string_view _name = {})
104 {
105 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
106 }
107
108 template<typename T>
109 T* createWidget(
110 std::string_view _skin,
111 int _left,
112 int _top,
113 int _width,
114 int _height,
115 Align _align,
116 std::string_view _layer,
117 std::string_view _name = {})
118 {
119 return static_cast<T*>(createWidgetT(
120 T::getClassTypeName(),
121 _skin,
122 IntCoord(_left, _top, _width, _height),
123 _align,
124 _layer,
125 _name));
126 }
127
128 template<typename T>
129 T* createWidgetReal(
130 std::string_view _skin,
131 const FloatCoord& _coord,
132 Align _align,
133 std::string_view _layer,
134 std::string_view _name = {})
135 {
136 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
137 }
138
139 template<typename T>
140 T* createWidgetReal(
141 std::string_view _skin,
142 float _left,
143 float _top,
144 float _width,
145 float _height,
146 Align _align,
147 std::string_view _layer,
148 std::string_view _name = {})
149 {
150 return static_cast<T*>(
151 createWidgetRealT(T::getClassTypeName(), _skin, _left, _top, _width, _height, _align, _layer, _name));
152 }
153
155 void destroyWidget(Widget* _widget);
156
158 void destroyWidgets(const VectorWidgetPtr& _widgets);
159
161 void destroyWidgets(EnumeratorWidgetPtr& _widgets);
162
166 Widget* findWidgetT(std::string_view _name, bool _throw = true) const;
167
171 Widget* findWidgetT(std::string_view _name, std::string_view _prefix, bool _throw = true) const;
172
176 template<typename T>
177 T* findWidget(std::string_view _name, bool _throw = true) const
178 {
179 Widget* widget = findWidgetT(_name, _throw);
180 if (nullptr == widget)
181 return nullptr;
182 return widget->castType<T>(_throw);
183 }
184
188 template<typename T>
189 T* findWidget(std::string_view _name, std::string_view _prefix, bool _throw = true) const
190 {
191 std::string name{_prefix};
192 name += _name;
193 return findWidget<T>(name, _throw);
194 }
195
197 void destroyChildWidget(Widget* _widget);
198
200 void destroyAllChildWidget();
201
203 EnumeratorWidgetPtr getEnumerator() const;
204
208 void frameEvent(float _time) const;
209
210 /*events:*/
215 EventHandle_FrameEventDelegate eventFrameStart;
216
217 /*internal:*/
218 void _linkChildWidget(Widget* _widget);
219 void _unlinkChildWidget(Widget* _widget);
220
221 private:
222 // создает виджет
223 Widget* baseCreateWidget(
224 WidgetStyle _style,
225 std::string_view _type,
226 std::string_view _skin,
227 const IntCoord& _coord,
228 Align _align,
229 std::string_view _layer,
230 std::string_view _name);
231
232 // удяляет неудачника
233 void _destroyChildWidget(Widget* _widget);
234
235 // удаляет всех детей
236 void _destroyAllChildWidget();
237
238 void _unlinkWidget(Widget* _widget) override;
239
240 private:
241 // вектор всех детей виджетов
242 VectorWidgetPtr mWidgetChild;
243
244 // синглтоны гуя
245 InputManager* mInputManager{nullptr};
246 SubWidgetManager* mSubWidgetManager{nullptr};
247 LayerManager* mLayerManager{nullptr};
248 SkinManager* mSkinManager{nullptr};
249 WidgetManager* mWidgetManager{nullptr};
250 FontManager* mFontManager{nullptr};
251 ControllerManager* mControllerManager{nullptr};
252 PointerManager* mPointerManager{nullptr};
253 ClipboardManager* mClipboardManager{nullptr};
254 LayoutManager* mLayoutManager{nullptr};
255 DynLibManager* mDynLibManager{nullptr};
256 PluginManager* mPluginManager{nullptr};
257 LanguageManager* mLanguageManager{nullptr};
258 ResourceManager* mResourceManager{nullptr};
259 FactoryManager* mFactoryManager{nullptr};
260 ToolTipManager* mToolTipManager{nullptr};
261
262 bool mIsInitialise{false};
263 };
264
265} // namespace MyGUI
266
267#endif // MYGUI_GUI_H_
MyGUI_BackwardCompatibility.h
MYGUI_OBSOLETE
#define MYGUI_OBSOLETE(text)
Definition MyGUI_Diagnostic.h:68
MyGUI_IUnlinkWidget.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MyGUI_Singleton.h
MYGUI_SINGLETON_DECLARATION
#define MYGUI_SINGLETON_DECLARATION(ClassName)
Definition MyGUI_Singleton.h:112
MyGUI_Types.h
MyGUI_Widget.h
MyGUI_XmlDocument.h
MyGUI::Gui::_unlinkChildWidget
void _unlinkChildWidget(Widget *_widget)
Definition MyGUI_Gui.cpp:268
MyGUI::Gui::shutdown
void shutdown()
Definition MyGUI_Gui.cpp:104
MyGUI::Gui::initialise
void initialise(const std::string &_core="MyGUI_Core.xml")
Definition MyGUI_Gui.cpp:41
MyGUI::Gui::_linkChildWidget
void _linkChildWidget(Widget *_widget)
Definition MyGUI_Gui.cpp:261
MyGUI::Gui::createWidgetReal
T * createWidgetReal(std::string_view _skin, float _left, float _top, float _width, float _height, Align _align, std::string_view _layer, std::string_view _name={})
Definition MyGUI_Gui.h:140
MyGUI::Gui::createWidget
T * createWidget(std::string_view _skin, const IntCoord &_coord, Align _align, std::string_view _layer, std::string_view _name={})
Definition MyGUI_Gui.h:98
MyGUI::Gui::WidgetManager
friend class WidgetManager
Definition MyGUI_Gui.h:26
MyGUI::Gui::findWidget
T * findWidget(std::string_view _name, std::string_view _prefix, bool _throw=true) const
Definition MyGUI_Gui.h:189
MyGUI::Gui::findWidget
T * findWidget(std::string_view _name, bool _throw=true) const
Definition MyGUI_Gui.h:177
MyGUI::Gui::findWidgetT
Widget * findWidgetT(std::string_view _name, bool _throw=true) const
Definition MyGUI_Gui.cpp:178
MyGUI::Gui::Gui
Gui(const Gui &)=delete
MyGUI::Gui::createWidgetReal
T * createWidgetReal(std::string_view _skin, const FloatCoord &_coord, Align _align, std::string_view _layer, std::string_view _name={})
Definition MyGUI_Gui.h:129
MyGUI::Gui::createWidget
T * createWidget(std::string_view _skin, int _left, int _top, int _width, int _height, Align _align, std::string_view _layer, std::string_view _name={})
Definition MyGUI_Gui.h:109
MyGUI::Gui::createWidgetT
Widget * createWidgetT(std::string_view _type, std::string_view _skin, const IntCoord &_coord, Align _align, std::string_view _layer, std::string_view _name={})
Definition MyGUI_Gui.cpp:275
MyGUI::Gui::eventFrameStart
EventHandle_FrameEventDelegate eventFrameStart
Definition MyGUI_Gui.h:215
MyGUI::IObject::castType
Type * castType(bool _throw=true)
Definition MyGUI_IObject.h:18
MyGUI::IUnlinkWidget
Definition MyGUI_IUnlinkWidget.h:17
MyGUI::InputManager
Definition MyGUI_InputManager.h:27
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::SubWidgetManager
Definition MyGUI_SubWidgetManager.h:17
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:40
MyGUI::delegates::MultiDelegate
Definition MyGUI_Delegate.h:190
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::FloatCoord
types::TCoord< float > FloatCoord
Definition MyGUI_Types.h:37
MyGUI::EnumeratorWidgetPtr
Enumerator< VectorWidgetPtr > EnumeratorWidgetPtr
Definition MyGUI_WidgetDefines.h:22
MyGUI::EventHandle_FrameEventDelegate
delegates::MultiDelegate< float > EventHandle_FrameEventDelegate
Definition MyGUI_Gui.h:21
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
MyGUI::VectorWidgetPtr
std::vector< Widget * > VectorWidgetPtr
Definition MyGUI_WidgetDefines.h:20
MyGUI::Align
Definition MyGUI_Align.h:20
MyGUI::WidgetStyle
Definition MyGUI_WidgetStyle.h:19