MyGUI
3.2.1
|
00001 /* 00002 * This source file is part of MyGUI. For the latest info, see http://mygui.info/ 00003 * Distributed under the MIT License 00004 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 00005 */ 00006 00007 #ifndef __MYGUI_GUI_H__ 00008 #define __MYGUI_GUI_H__ 00009 00010 #include "MyGUI_Prerequest.h" 00011 #include "MyGUI_Types.h" 00012 #include "MyGUI_Singleton.h" 00013 #include "MyGUI_XmlDocument.h" 00014 #include "MyGUI_IUnlinkWidget.h" 00015 #include "MyGUI_Widget.h" 00016 #include "MyGUI_BackwardCompatibility.h" 00017 00018 namespace MyGUI 00019 { 00020 00021 typedef delegates::CMultiDelegate1<float> EventHandle_FrameEventDelegate; 00022 00023 class MYGUI_EXPORT Gui : 00024 public Singleton<Gui>, 00025 public IUnlinkWidget, 00026 public MemberObsolete<Gui> 00027 { 00028 friend class WidgetManager; 00029 00030 public: 00031 Gui(); 00032 00039 void initialise(const std::string& _core = "MyGUI_Core.xml"); 00040 00041 #ifndef MYGUI_DONT_USE_OBSOLETE 00042 MYGUI_OBSOLETE(" is deprecated, use : void Gui::initialise(const std::string& _core) and set log filename in Platform") 00043 void initialise(const std::string& _core, const std::string& _logFileName); 00044 #endif // MYGUI_DONT_USE_OBSOLETE 00045 00047 void shutdown(); 00048 00049 // methods for creating widgets 00058 Widget* createWidgetT(const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = ""); 00060 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 = ""); 00062 Widget* createWidgetRealT(const std::string& _type, const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = ""); 00064 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 = ""); 00065 00066 // templates for creating widgets by type 00068 template <typename T> 00069 T* createWidget(const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "") 00070 { 00071 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name)); 00072 } 00074 template <typename T> 00075 T* createWidget(const std::string& _skin, int _left, int _top, int _width, int _height, Align _align, const std::string& _layer, const std::string& _name = "") 00076 { 00077 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, IntCoord(_left, _top, _width, _height), _align, _layer, _name)); 00078 } 00080 template <typename T> 00081 T* createWidgetReal(const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "") 00082 { 00083 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name)); 00084 } 00086 template <typename T> 00087 T* createWidgetReal(const std::string& _skin, float _left, float _top, float _width, float _height, Align _align, const std::string& _layer, const std::string& _name = "") 00088 { 00089 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _left, _top, _width, _height, _align, _layer, _name)); 00090 } 00091 00093 void destroyWidget(Widget* _widget); 00094 00096 void destroyWidgets(const VectorWidgetPtr& _widgets); 00097 00099 void destroyWidgets(EnumeratorWidgetPtr& _widgets); 00100 00104 Widget* findWidgetT(const std::string& _name, bool _throw = true); 00105 00109 Widget* findWidgetT(const std::string& _name, const std::string& _prefix, bool _throw = true); 00110 00114 template <typename T> 00115 T* findWidget(const std::string& _name, bool _throw = true) 00116 { 00117 Widget* widget = findWidgetT(_name, _throw); 00118 if (nullptr == widget) return nullptr; 00119 return widget->castType<T>(_throw); 00120 } 00121 00125 template <typename T> 00126 T* findWidget(const std::string& _name, const std::string& _prefix, bool _throw = true) 00127 { 00128 return findWidget<T>(_prefix + _name, _throw); 00129 } 00130 00132 void destroyChildWidget(Widget* _widget); 00133 00135 void destroyAllChildWidget(); 00136 00138 EnumeratorWidgetPtr getEnumerator() const; 00139 00143 void frameEvent(float _time); 00144 00145 /*events:*/ 00150 EventHandle_FrameEventDelegate eventFrameStart; 00151 00152 /*internal:*/ 00153 void _linkChildWidget(Widget* _widget); 00154 void _unlinkChildWidget(Widget* _widget); 00155 00156 private: 00157 // создает виджет 00158 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); 00159 00160 // удяляет неудачника 00161 void _destroyChildWidget(Widget* _widget); 00162 00163 // удаляет всех детей 00164 void _destroyAllChildWidget(); 00165 00166 virtual void _unlinkWidget(Widget* _widget); 00167 00168 private: 00169 // вектор всех детей виджетов 00170 VectorWidgetPtr mWidgetChild; 00171 00172 // синглтоны гуя 00173 InputManager* mInputManager; 00174 SubWidgetManager* mSubWidgetManager; 00175 LayerManager* mLayerManager; 00176 SkinManager* mSkinManager; 00177 WidgetManager* mWidgetManager; 00178 FontManager* mFontManager; 00179 ControllerManager* mControllerManager; 00180 PointerManager* mPointerManager; 00181 ClipboardManager* mClipboardManager; 00182 LayoutManager* mLayoutManager; 00183 DynLibManager* mDynLibManager; 00184 PluginManager* mPluginManager; 00185 LanguageManager* mLanguageManager; 00186 ResourceManager* mResourceManager; 00187 FactoryManager* mFactoryManager; 00188 ToolTipManager* mToolTipManager; 00189 00190 bool mIsInitialise; 00191 }; 00192 00193 } // namespace MyGUI 00194 00195 #endif // __MYGUI_GUI_H__