MyGUI 3.2.0

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

- File List
- Globals

MyGUI_Gui.h
Go to the documentation of this file.
1
6 /*
7 This file is part of MyGUI.
8
9 MyGUI is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 MyGUI is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_GUI_H__
23 #define __MYGUI_GUI_H__
24
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_Types.h"
27 #include "MyGUI_Singleton.h"
28 #include "MyGUI_XmlDocument.h"
29 #include "MyGUI_IUnlinkWidget.h"
30 #include "MyGUI_Widget.h"
31 #include "MyGUI_BackwardCompatibility.h"
32
33 namespace MyGUI
34 {
35
36 typedef delegates::CMultiDelegate1<float> EventHandle_FrameEventDelegate;
37
38 class MYGUI_EXPORT Gui :
39 public Singleton<Gui>,
40 public IUnlinkWidget,
41 public MemberObsolete<Gui>
42 {
43 friend class WidgetManager;
44
45 public:
46 Gui();
47
54 void initialise(const std::string& _core = "MyGUI_Core.xml");
55
56 #ifndef MYGUI_DONT_USE_OBSOLETE
57 MYGUI_OBSOLETE(" is deprecated, use : void Gui::initialise(const std::string& _core) and set log filename in Platform")
58 void initialise(const std::string& _core, const std::string& _logFileName);
59 #endif // MYGUI_DONT_USE_OBSOLETE
60
62 void shutdown();
63
64 // methods for creating widgets
73 Widget* createWidgetT(const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "");
75 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 = "");
77 Widget* createWidgetRealT(const std::string& _type, const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "");
79 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 = "");
80
81 // templates for creating widgets by type
83 template <typename T>
84 T* createWidget(const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
85 {
86 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
87 }
89 template <typename T>
90 T* createWidget(const std::string& _skin, int _left, int _top, int _width, int _height, Align _align, const std::string& _layer, const std::string& _name = "")
91 {
92 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, IntCoord(_left, _top, _width, _height), _align, _layer, _name));
93 }
95 template <typename T>
96 T* createWidgetReal(const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
97 {
98 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
99 }
101 template <typename T>
102 T* createWidgetReal(const std::string& _skin, float _left, float _top, float _width, float _height, Align _align, const std::string& _layer, const std::string& _name = "")
103 {
104 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _left, _top, _width, _height, _align, _layer, _name));
105 }
106
108 void destroyWidget(Widget* _widget);
109
111 void destroyWidgets(const VectorWidgetPtr& _widgets);
112
114 void destroyWidgets(EnumeratorWidgetPtr& _widgets);
115
119 Widget* findWidgetT(const std::string& _name, bool _throw = true);
120
124 Widget* findWidgetT(const std::string& _name, const std::string& _prefix, bool _throw = true);
125
129 template <typename T>
130 T* findWidget(const std::string& _name, bool _throw = true)
131 {
132 Widget* widget = findWidgetT(_name, _throw);
133 if (nullptr == widget) return nullptr;
134 return widget->castType<T>(_throw);
135 }
136
140 template <typename T>
141 T* findWidget(const std::string& _name, const std::string& _prefix, bool _throw = true)
142 {
143 return findWidget<T>(_prefix + _name, _throw);
144 }
145
147 void destroyChildWidget(Widget* _widget);
148
150 void destroyAllChildWidget();
151
153 EnumeratorWidgetPtr getEnumerator() const;
154
158 void frameEvent(float _time);
159
160 /*events:*/
165 EventHandle_FrameEventDelegate
166 eventFrameStart;
167
168 /*internal:*/
169 void _linkChildWidget(Widget* _widget);
170 void _unlinkChildWidget(Widget* _widget);
171
172 private:
173 // создает виджет
174 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);
175
176 // удяляет неудачника
177 void _destroyChildWidget(Widget* _widget);
178
179 // удаляет всех детей
180 void _destroyAllChildWidget();
181
182 virtual void _unlinkWidget(Widget* _widget);
183
184 private:
185 // вектор всех детей виджетов
186 VectorWidgetPtr mWidgetChild;
187
188 // синглтоны гуя
189 InputManager* mInputManager;
190 SubWidgetManager* mSubWidgetManager;
191 LayerManager* mLayerManager;
192 SkinManager* mSkinManager;
193 WidgetManager* mWidgetManager;
194 FontManager* mFontManager;
195 ControllerManager* mControllerManager;
196 PointerManager* mPointerManager;
197 ClipboardManager* mClipboardManager;
198 LayoutManager* mLayoutManager;
199 DynLibManager* mDynLibManager;
200 PluginManager* mPluginManager;
201 LanguageManager* mLanguageManager;
202 ResourceManager* mResourceManager;
203 FactoryManager* mFactoryManager;
204 ToolTipManager* mToolTipManager;
205
206 bool mIsInitialise;
207 };
208
209 } // namespace MyGUI
210
211 #endif // __MYGUI_GUI_H__
MyGUI::types::TCoord< int >
MyGUI::PointerManager
Definition: MyGUI_PointerManager.h:35
MyGUI::Widget
Definition: MyGUI_Widget.h:41
MyGUI::LayoutManager
Definition: MyGUI_LayoutManager.h:37
MyGUI::Gui::eventFrameStart
EventHandle_FrameEventDelegate eventFrameStart
Definition: MyGUI_Gui.h:166
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:141
MyGUI::LayerManager
Definition: MyGUI_LayerManager.h:37
MyGUI::InputManager
Definition: MyGUI_InputManager.h:42
MyGUI::LanguageManager
Definition: MyGUI_LanguageManager.h:35
MyGUI::ToolTipManager
Definition: MyGUI_ToolTipManager.h:32
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:96
MyGUI::WidgetManager
Definition: MyGUI_WidgetManager.h:35
MyGUI::EventHandle_FrameEventDelegate
delegates::CMultiDelegate1< float > EventHandle_FrameEventDelegate
Definition: MyGUI_Gui.h:36
MyGUI::SubWidgetManager
Definition: MyGUI_SubWidgetManager.h:31
MyGUI_Types.h
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition: MyGUI_Types.h:50
MyGUI::PluginManager
Plugin manager. Load/unload and register plugins.
Definition: MyGUI_PluginManager.h:39
MyGUI::FactoryManager
Definition: MyGUI_FactoryManager.h:33
MyGUI::Enumerator
Definition: MyGUI_Enumerator.h:63
MyGUI_XmlDocument.h
MyGUI::Gui::findWidget
T * findWidget(const std::string &_name, bool _throw=true)
Definition: MyGUI_Gui.h:130
MyGUI::DynLibManager
Manager of dynamic libraries.
Definition: MyGUI_DynLibManager.h:35
MyGUI::IUnlinkWidget
Definition: MyGUI_IUnlinkWidget.h:31
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:120
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:90
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:84
MyGUI::VectorWidgetPtr
std::vector< Widget * > VectorWidgetPtr
Definition: MyGUI_WidgetDefines.h:33
MyGUI_BackwardCompatibility.h
MyGUI::ResourceManager
Definition: MyGUI_ResourceManager.h:36
MyGUI::IObject::castType
Type * castType(bool _throw=true)
Definition: MyGUI_IObject.h:33
MyGUI::WidgetStyle
Definition: MyGUI_WidgetStyle.h:31
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:102
MyGUI_Widget.h
MyGUI::ControllerManager
Definition: MyGUI_ControllerManager.h:35
MyGUI::MemberObsolete
Definition: MyGUI_DeprecatedTypes.h:28
MyGUI::SkinManager
Definition: MyGUI_SkinManager.h:36
MyGUI::Align
Definition: MyGUI_Align.h:34
MyGUI::Singleton
Definition: MyGUI_Singleton.h:35
MyGUI::delegates::CMultiDelegate1< float >
MyGUI_IUnlinkWidget.h
MYGUI_OBSOLETE
#define MYGUI_OBSOLETE(text)
Definition: MyGUI_Diagnostic.h:111
MyGUI::ClipboardManager
Definition: MyGUI_ClipboardManager.h:33
MyGUI::Gui
Definition: MyGUI_Gui.h:38
MyGUI::FontManager
Definition: MyGUI_FontManager.h:36