MyGUI 3.4.1
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"
17
18namespace MyGUI
19{
20
22
24 public IUnlinkWidget,
25 public MemberObsolete<Gui>
26 {
28 friend class WidgetManager;
29
30 public:
31 Gui();
32
39 void initialise(const std::string& _core = "MyGUI_Core.xml");
40
41#ifndef MYGUI_DONT_USE_OBSOLETE
42 MYGUI_OBSOLETE(" is deprecated, use : void Gui::initialise(const std::string& _core) and set log filename in Platform")
43 void initialise(const std::string& _core, const std::string& _logFileName);
44#endif // MYGUI_DONT_USE_OBSOLETE
45
47 void shutdown();
48
49 // methods for creating widgets
58 Widget* createWidgetT(const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "");
60 Widget* createWidgetT(const std::string& _type, const std::string& _skin, int _left, int _top, int _width, int _height, Align _align, const std::string& _layer, const std::string& _name = "");
62 Widget* createWidgetRealT(const std::string& _type, const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "");
64 Widget* createWidgetRealT(const std::string& _type, const std::string& _skin, float _left, float _top, float _width, float _height, Align _align, const std::string& _layer, const std::string& _name = "");
65
66 // templates for creating widgets by type
68 template <typename T>
69 T* createWidget(const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
70 {
71 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
72 }
74 template <typename T>
75 T* createWidget(const std::string& _skin, int _left, int _top, int _width, int _height, Align _align, const std::string& _layer, const std::string& _name = "")
76 {
77 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, IntCoord(_left, _top, _width, _height), _align, _layer, _name));
78 }
80 template <typename T>
81 T* createWidgetReal(const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
82 {
83 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
84 }
86 template <typename T>
87 T* createWidgetReal(const std::string& _skin, float _left, float _top, float _width, float _height, Align _align, const std::string& _layer, const std::string& _name = "")
88 {
89 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _left, _top, _width, _height, _align, _layer, _name));
90 }
91
93 void destroyWidget(Widget* _widget);
94
96 void destroyWidgets(const VectorWidgetPtr& _widgets);
97
99 void destroyWidgets(EnumeratorWidgetPtr& _widgets);
100
104 Widget* findWidgetT(const std::string& _name, bool _throw = true);
105
109 Widget* findWidgetT(const std::string& _name, const std::string& _prefix, bool _throw = true);
110
114 template <typename T>
115 T* findWidget(const std::string& _name, bool _throw = true)
116 {
117 Widget* widget = findWidgetT(_name, _throw);
118 if (nullptr == widget) return nullptr;
119 return widget->castType<T>(_throw);
120 }
121
125 template <typename T>
126 T* findWidget(const std::string& _name, const std::string& _prefix, bool _throw = true)
127 {
128 return findWidget<T>(_prefix + _name, _throw);
129 }
130
132 void destroyChildWidget(Widget* _widget);
133
135 void destroyAllChildWidget();
136
138 EnumeratorWidgetPtr getEnumerator() const;
139
143 void frameEvent(float _time);
144
145 /*events:*/
151
152 /*internal:*/
153 void _linkChildWidget(Widget* _widget);
154 void _unlinkChildWidget(Widget* _widget);
155
156 private:
157 // создает виджет
158 Widget* baseCreateWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name);
159
160 // удяляет неудачника
161 void _destroyChildWidget(Widget* _widget);
162
163 // удаляет всех детей
164 void _destroyAllChildWidget();
165
166 void _unlinkWidget(Widget* _widget) override;
167
168 private:
169 // вектор всех детей виджетов
170 VectorWidgetPtr mWidgetChild;
171
172 // синглтоны гуя
173 InputManager* mInputManager;
174 SubWidgetManager* mSubWidgetManager;
175 LayerManager* mLayerManager;
176 SkinManager* mSkinManager;
177 WidgetManager* mWidgetManager;
178 FontManager* mFontManager;
179 ControllerManager* mControllerManager;
180 PointerManager* mPointerManager;
181 ClipboardManager* mClipboardManager;
182 LayoutManager* mLayoutManager;
183 DynLibManager* mDynLibManager;
184 PluginManager* mPluginManager;
185 LanguageManager* mLanguageManager;
186 ResourceManager* mResourceManager;
187 FactoryManager* mFactoryManager;
188 ToolTipManager* mToolTipManager;
189
190 bool mIsInitialise;
191 };
192
193} // namespace MyGUI
194
195#endif // MYGUI_GUI_H_
#define MYGUI_OBSOLETE(text)
#define MYGUI_EXPORT
#define MYGUI_SINGLETON_DECLARATION(ClassName)
Manager of dynamic libraries.
T * createWidgetReal(const std::string &_skin, const FloatCoord &_coord, Align _align, const std::string &_layer, const std::string &_name="")
Definition: MyGUI_Gui.h:81
T * createWidget(const std::string &_skin, int _left, int _top, int _width, int _height, Align _align, const std::string &_layer, const std::string &_name="")
Definition: MyGUI_Gui.h:75
T * createWidgetReal(const std::string &_skin, float _left, float _top, float _width, float _height, Align _align, const std::string &_layer, const std::string &_name="")
Definition: MyGUI_Gui.h:87
T * findWidget(const std::string &_name, bool _throw=true)
Definition: MyGUI_Gui.h:115
T * createWidget(const std::string &_skin, const IntCoord &_coord, Align _align, const std::string &_layer, const std::string &_name="")
Definition: MyGUI_Gui.h:69
T * findWidget(const std::string &_name, const std::string &_prefix, bool _throw=true)
Definition: MyGUI_Gui.h:126
EventHandle_FrameEventDelegate eventFrameStart
Definition: MyGUI_Gui.h:150
Type * castType(bool _throw=true)
Definition: MyGUI_IObject.h:18
Plugin manager. Load/unload and register plugins.
widget description should be here.
Definition: MyGUI_Widget.h:37
types::TCoord< int > IntCoord
Definition: MyGUI_Types.h:35
std::vector< Widget * > VectorWidgetPtr
delegates::CMultiDelegate1< float > EventHandle_FrameEventDelegate
Definition: MyGUI_Gui.h:21