MyGUI
3.2.0
|
00001 00006 /* 00007 This file is part of MyGUI. 00008 00009 MyGUI is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 MyGUI is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #ifndef __MYGUI_GUI_H__ 00023 #define __MYGUI_GUI_H__ 00024 00025 #include "MyGUI_Prerequest.h" 00026 #include "MyGUI_Types.h" 00027 #include "MyGUI_Singleton.h" 00028 #include "MyGUI_XmlDocument.h" 00029 #include "MyGUI_IUnlinkWidget.h" 00030 #include "MyGUI_Widget.h" 00031 #include "MyGUI_BackwardCompatibility.h" 00032 00033 namespace MyGUI 00034 { 00035 00036 typedef delegates::CMultiDelegate1<float> EventHandle_FrameEventDelegate; 00037 00038 class MYGUI_EXPORT Gui : 00039 public Singleton<Gui>, 00040 public IUnlinkWidget, 00041 public MemberObsolete<Gui> 00042 { 00043 friend class WidgetManager; 00044 00045 public: 00046 Gui(); 00047 00054 void initialise(const std::string& _core = "MyGUI_Core.xml"); 00055 00056 #ifndef MYGUI_DONT_USE_OBSOLETE 00057 MYGUI_OBSOLETE(" is deprecated, use : void Gui::initialise(const std::string& _core) and set log filename in Platform") 00058 void initialise(const std::string& _core, const std::string& _logFileName); 00059 #endif // MYGUI_DONT_USE_OBSOLETE 00060 00062 void shutdown(); 00063 00064 // methods for creating widgets 00073 Widget* createWidgetT(const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = ""); 00075 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 = ""); 00077 Widget* createWidgetRealT(const std::string& _type, const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = ""); 00079 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 = ""); 00080 00081 // templates for creating widgets by type 00083 template <typename T> 00084 T* createWidget(const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "") 00085 { 00086 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name)); 00087 } 00089 template <typename T> 00090 T* createWidget(const std::string& _skin, int _left, int _top, int _width, int _height, Align _align, const std::string& _layer, const std::string& _name = "") 00091 { 00092 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, IntCoord(_left, _top, _width, _height), _align, _layer, _name)); 00093 } 00095 template <typename T> 00096 T* createWidgetReal(const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "") 00097 { 00098 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name)); 00099 } 00101 template <typename T> 00102 T* createWidgetReal(const std::string& _skin, float _left, float _top, float _width, float _height, Align _align, const std::string& _layer, const std::string& _name = "") 00103 { 00104 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _left, _top, _width, _height, _align, _layer, _name)); 00105 } 00106 00108 void destroyWidget(Widget* _widget); 00109 00111 void destroyWidgets(const VectorWidgetPtr& _widgets); 00112 00114 void destroyWidgets(EnumeratorWidgetPtr& _widgets); 00115 00119 Widget* findWidgetT(const std::string& _name, bool _throw = true); 00120 00124 Widget* findWidgetT(const std::string& _name, const std::string& _prefix, bool _throw = true); 00125 00129 template <typename T> 00130 T* findWidget(const std::string& _name, bool _throw = true) 00131 { 00132 Widget* widget = findWidgetT(_name, _throw); 00133 if (nullptr == widget) return nullptr; 00134 return widget->castType<T>(_throw); 00135 } 00136 00140 template <typename T> 00141 T* findWidget(const std::string& _name, const std::string& _prefix, bool _throw = true) 00142 { 00143 return findWidget<T>(_prefix + _name, _throw); 00144 } 00145 00147 void destroyChildWidget(Widget* _widget); 00148 00150 void destroyAllChildWidget(); 00151 00153 EnumeratorWidgetPtr getEnumerator() const; 00154 00158 void frameEvent(float _time); 00159 00160 /*events:*/ 00165 EventHandle_FrameEventDelegate 00166 eventFrameStart; 00167 00168 /*internal:*/ 00169 void _linkChildWidget(Widget* _widget); 00170 void _unlinkChildWidget(Widget* _widget); 00171 00172 private: 00173 // создает виджет 00174 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); 00175 00176 // удяляет неудачника 00177 void _destroyChildWidget(Widget* _widget); 00178 00179 // удаляет всех детей 00180 void _destroyAllChildWidget(); 00181 00182 virtual void _unlinkWidget(Widget* _widget); 00183 00184 private: 00185 // вектор всех детей виджетов 00186 VectorWidgetPtr mWidgetChild; 00187 00188 // синглтоны гуя 00189 InputManager* mInputManager; 00190 SubWidgetManager* mSubWidgetManager; 00191 LayerManager* mLayerManager; 00192 SkinManager* mSkinManager; 00193 WidgetManager* mWidgetManager; 00194 FontManager* mFontManager; 00195 ControllerManager* mControllerManager; 00196 PointerManager* mPointerManager; 00197 ClipboardManager* mClipboardManager; 00198 LayoutManager* mLayoutManager; 00199 DynLibManager* mDynLibManager; 00200 PluginManager* mPluginManager; 00201 LanguageManager* mLanguageManager; 00202 ResourceManager* mResourceManager; 00203 FactoryManager* mFactoryManager; 00204 ToolTipManager* mToolTipManager; 00205 00206 bool mIsInitialise; 00207 }; 00208 00209 } // namespace MyGUI 00210 00211 #endif // __MYGUI_GUI_H__