00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MYGUI_WIDGET_MANAGER_H__
00024 #define __MYGUI_WIDGET_MANAGER_H__
00025
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Instance.h"
00028 #include "MyGUI_IWidgetCreator.h"
00029 #include "MyGUI_IUnlinkWidget.h"
00030 #include "MyGUI_ICroppedRectangle.h"
00031 #include "MyGUI_Widget.h"
00032 #include <set>
00033
00034 namespace MyGUI
00035 {
00036
00037
00038 typedef delegates::CDelegate3<Widget*, const std::string &, const std::string &> ParseDelegate;
00039
00040 class MYGUI_EXPORT WidgetManager
00041 {
00042 MYGUI_INSTANCE_HEADER( WidgetManager )
00043
00044 public:
00045
00046 typedef std::map<std::string, ParseDelegate> MapDelegate;
00047
00048 typedef std::set<IWidgetFactory*> SetWidgetFactory;
00049
00050 public:
00051 void initialise();
00052 void shutdown();
00053
00054 Widget* createWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, Widget* _parent, ICroppedRectangle * _cropeedParent, IWidgetCreator * _creator, const std::string& _name);
00055
00057 void destroyWidget(Widget* _widget);
00059 void destroyWidgets(const VectorWidgetPtr &_widgets);
00061 void destroyWidgets(EnumeratorWidgetPtr _widgets);
00062
00064 void registerUnlinker(IUnlinkWidget * _unlink);
00066 void unregisterUnlinker(IUnlinkWidget * _unlink);
00068 void unlinkFromUnlinkers(Widget* _widget);
00069
00070
00071 void addWidgetToUnlink(Widget* _widget);
00072
00073
00074 void removeWidgetFromUnlink(Widget*& _widget);
00075
00076 bool isFactoryExist(const std::string& _type);
00077
00078
00079 void _oldParse(Widget* _widget, const std::string &_key, const std::string &_value);
00080
00081
00082 #ifndef MYGUI_DONT_USE_OBSOLETE
00083
00084 MYGUI_OBSOLETE("use : void WidgetManager::destroyWidgets(VectorWidgetPtr &_widgets)")
00085 void destroyWidgetsVector(VectorWidgetPtr &_widgets) { destroyWidgets(_widgets); }
00086 MYGUI_OBSOLETE("")
00087 Widget* findWidgetT(const std::string& _name, bool _throw = true);
00088 MYGUI_OBSOLETE("")
00089 Widget* findWidgetT(const std::string& _name, const std::string& _prefix, bool _throw = true);
00090 MYGUI_OBSOLETE("")
00091 void registerFactory(IWidgetFactory * _factory);
00092 MYGUI_OBSOLETE("")
00093 void unregisterFactory(IWidgetFactory * _factory);
00094 MYGUI_OBSOLETE("use : void Widget::setProperty(const std::string &_key, const std::string &_value)")
00095 void parse(Widget* _widget, const std::string &_key, const std::string &_value);
00096 MYGUI_OBSOLETE("")
00097 ParseDelegate& registerDelegate(const std::string& _key);
00098 MYGUI_OBSOLETE("")
00099 void unregisterDelegate(const std::string& _key);
00100
00101 template <typename T>
00102 MYGUI_OBSOLETE("")
00103 T* findWidget(const std::string& _name, bool _throw = true)
00104 {
00105 Widget* widget = findWidgetT(_name, _throw);
00106 if (nullptr == widget) return nullptr;
00107 return widget->castType<T>(_throw);
00108 }
00109
00110 template <typename T>
00111 MYGUI_OBSOLETE("")
00112 T* findWidget(const std::string& _name, const std::string& _prefix, bool _throw = true)
00113 {
00114 return findWidget<T>(_prefix + _name, _throw);
00115 }
00116
00117 #endif // MYGUI_DONT_USE_OBSOLETE
00118
00119 protected:
00120 SetWidgetFactory mFactoryList;
00121
00122 MapDelegate mDelegates;
00123
00124
00125 VectorIUnlinkWidget mVectorIUnlinkWidget;
00126
00127
00128 VectorWidgetPtr mUnlinkWidgets;
00129 };
00130
00131 }
00132
00133 #endif // __MYGUI_WIDGET_MANAGER_H__