MyGUI 3.2.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

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
18 namespace MyGUI
19 {
20
21 typedef delegates::CMultiDelegate1<float> EventHandle_FrameEventDelegate;
22
23 class MYGUI_EXPORT Gui :
24 public Singleton<Gui>,
25 public IUnlinkWidget,
26 public MemberObsolete<Gui>
27 {
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:*/
150 EventHandle_FrameEventDelegate eventFrameStart;
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 virtual void _unlinkWidget(Widget* _widget);
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_
MyGUI::types::TCoord< int >
MyGUI::PointerManager
Definition: MyGUI_PointerManager.h:20
MyGUI::Widget
Widget properties. Widget_skin_childs Skin childs. Widget widget description should be here...
Definition: MyGUI_Widget.h:29
MyGUI::LayoutManager
Definition: MyGUI_LayoutManager.h:22
MyGUI::Gui::eventFrameStart
EventHandle_FrameEventDelegate eventFrameStart
Definition: MyGUI_Gui.h:150
MyGUI_Prerequest.h
MyGUI_Singleton.h
MyGUI::Gui::findWidget
T * findWidget(const std::string &_name, const std::string &_prefix, bool _throw=true)
Definition: MyGUI_Gui.h:126
MyGUI::LayerManager
Definition: MyGUI_LayerManager.h:22
MyGUI::InputManager
Definition: MyGUI_InputManager.h:27
MyGUI::LanguageManager
Definition: MyGUI_LanguageManager.h:20
MyGUI::ToolTipManager
Definition: MyGUI_ToolTipManager.h:17
MyGUI::Gui::createWidgetReal
T * createWidgetReal(const std::string &_skin, const FloatCoord &_coord, Align _align, const std::string &_layer, const std::string &_name="")
Definition: MyGUI_Gui.h:81
MyGUI::WidgetManager
Definition: MyGUI_WidgetManager.h:20
MyGUI::EventHandle_FrameEventDelegate
delegates::CMultiDelegate1< float > EventHandle_FrameEventDelegate
Definition: MyGUI_Gui.h:21
MyGUI::SubWidgetManager
Definition: MyGUI_SubWidgetManager.h:16
MyGUI_Types.h
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition: MyGUI_Types.h:35
MyGUI::PluginManager
Plugin manager. Load/unload and register plugins.
Definition: MyGUI_PluginManager.h:24
MyGUI::FactoryManager
Definition: MyGUI_FactoryManager.h:18
MyGUI::Enumerator
Definition: MyGUI_Enumerator.h:48
MyGUI_XmlDocument.h
MyGUI::Gui::findWidget
T * findWidget(const std::string &_name, bool _throw=true)
Definition: MyGUI_Gui.h:115
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI::DynLibManager
Manager of dynamic libraries.
Definition: MyGUI_DynLibManager.h:20
MyGUI::IUnlinkWidget
Definition: MyGUI_IUnlinkWidget.h:16
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:103
MyGUI::Gui::createWidget
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
MyGUI::Gui::createWidget
T * createWidget(const std::string &_skin, const IntCoord &_coord, Align _align, const std::string &_layer, const std::string &_name="")
Definition: MyGUI_Gui.h:69
MyGUI::VectorWidgetPtr
std::vector< Widget * > VectorWidgetPtr
Definition: MyGUI_WidgetDefines.h:19
MyGUI_BackwardCompatibility.h
MyGUI::ResourceManager
Definition: MyGUI_ResourceManager.h:21
MyGUI::IObject::castType
Type * castType(bool _throw=true)
Definition: MyGUI_IObject.h:18
MyGUI::WidgetStyle
Definition: MyGUI_WidgetStyle.h:16
MyGUI::Gui::createWidgetReal
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
MyGUI_Widget.h
MyGUI::ControllerManager
Definition: MyGUI_ControllerManager.h:20
MyGUI::MemberObsolete
Definition: MyGUI_DeprecatedTypes.h:13
MyGUI::SkinManager
Definition: MyGUI_SkinManager.h:21
MyGUI::Align
Definition: MyGUI_Align.h:19
MyGUI::Singleton
Definition: MyGUI_Singleton.h:20
MyGUI::delegates::CMultiDelegate1< float >
MyGUI_IUnlinkWidget.h
MYGUI_OBSOLETE
#define MYGUI_OBSOLETE(text)
Definition: MyGUI_Diagnostic.h:95
MyGUI::ClipboardManager
Definition: MyGUI_ClipboardManager.h:20
MyGUI::Gui
Definition: MyGUI_Gui.h:23
MyGUI::FontManager
Definition: MyGUI_FontManager.h:21