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
00033 namespace MyGUI
00034 {
00035
00036
00037 typedef delegates::CDelegate3<WidgetPtr, const std::string &, const std::string &> ParseDelegate;
00038
00039 class MYGUI_EXPORT WidgetManager
00040 {
00041 MYGUI_INSTANCE_HEADER(WidgetManager);
00042
00043 public:
00044
00045 typedef std::map<std::string, ParseDelegate> MapDelegate;
00046
00047 typedef std::set<IWidgetFactory*> SetWidgetFactory;
00048
00049 public:
00050 void initialise();
00051 void shutdown();
00052
00053 WidgetPtr createWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, WidgetPtr _parent, ICroppedRectangle * _cropeedParent, IWidgetCreator * _creator, const std::string& _name);
00054
00056 void destroyWidget(WidgetPtr _widget);
00058 void destroyWidgets(const VectorWidgetPtr &_widgets);
00060 void destroyWidgets(EnumeratorWidgetPtr _widgets);
00061
00063 void registerUnlinker(IUnlinkWidget * _unlink);
00065 void unregisterUnlinker(IUnlinkWidget * _unlink);
00067 void unlinkFromUnlinkers(WidgetPtr _widget);
00068
00069
00070 void addWidgetToUnlink(WidgetPtr _widget);
00071
00072
00073 void removeWidgetFromUnlink(WidgetPtr& _widget);
00074
00075
00076 #ifndef MYGUI_DONT_USE_OBSOLETE
00077
00078 MYGUI_OBSOLETE("use : void WidgetManager::destroyWidgets(VectorWidgetPtr &_widgets)")
00079 void destroyWidgetsVector(VectorWidgetPtr &_widgets) { destroyWidgets(_widgets); }
00080 MYGUI_OBSOLETE("")
00081 WidgetPtr findWidgetT(const std::string& _name, bool _throw = true);
00082 MYGUI_OBSOLETE("")
00083 WidgetPtr findWidgetT(const std::string& _name, const std::string& _prefix, bool _throw = true);
00084 MYGUI_OBSOLETE("")
00085 void registerFactory(IWidgetFactory * _factory);
00086 MYGUI_OBSOLETE("")
00087 void unregisterFactory(IWidgetFactory * _factory);
00088 MYGUI_OBSOLETE("use : void Widget::setProperty(const std::string &_key, const std::string &_value)")
00089 void parse(WidgetPtr _widget, const std::string &_key, const std::string &_value);
00090 MYGUI_OBSOLETE("")
00091 ParseDelegate& registerDelegate(const std::string& _key);
00092 MYGUI_OBSOLETE("")
00093 void unregisterDelegate(const std::string& _key);
00094
00095 template <typename T>
00096 MYGUI_OBSOLETE("")
00097 T* findWidget(const std::string& _name, bool _throw = true)
00098 {
00099 WidgetPtr widget = findWidgetT(_name, _throw);
00100 if (nullptr == widget) return nullptr;
00101 return widget->castType<T>(_throw);
00102 }
00103
00104 template <typename T>
00105 MYGUI_OBSOLETE("")
00106 T* findWidget(const std::string& _name, const std::string& _prefix, bool _throw = true)
00107 {
00108 return findWidget<T>(_prefix + _name, _throw);
00109 }
00110
00111 #endif // MYGUI_DONT_USE_OBSOLETE
00112
00113 protected:
00114 SetWidgetFactory mFactoryList;
00115
00116 MapDelegate mDelegates;
00117
00118
00119 VectorIUnlinkWidget mVectorIUnlinkWidget;
00120
00121
00122 VectorWidgetPtr mUnlinkWidgets;
00123 };
00124
00125 }
00126
00127 #endif // __MYGUI_WIDGET_MANAGER_H__