MyGUI  3.2.0
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"
32 
33 namespace MyGUI
34 {
35 
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:*/
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__