1 #ifndef _2430e622_7ed5_481e_91df_1a6805bc9e49_ 2 #define _2430e622_7ed5_481e_91df_1a6805bc9e49_ 3 4 #include <sstream> 5 #include "WidgetContainer.h" 6 7 namespace tools 8 { 9 10 typedef MyGUI::delegates::CMultiDelegate0 Event_ChangeWidgets; 11 typedef MyGUI::delegates::CMultiDelegate3<MyGUI::Widget*, const MyGUI::IntCoord&, const std::string&> Event_ChangeWidgetCoord; 12 13 typedef std::vector<WidgetContainer*> VectorWidgetContainer; 14 typedef MyGUI::Enumerator<VectorWidgetContainer> EnumeratorWidgetContainer; 15 16 class EditorWidgets : 17 public MyGUI::Singleton<EditorWidgets>, 18 public MyGUI::IUnlinkWidget 19 { 20 public: 21 EditorWidgets(); 22 23 void initialise(); 24 void shutdown(); 25 26 bool load(const MyGUI::UString& _fileName); 27 bool save(const MyGUI::UString& _fileName); 28 void clear(); 29 30 void loadxmlDocument(MyGUI::xml::Document* doc, bool _testMode = false); 31 MyGUI::xml::Document* savexmlDocument(); 32 WidgetContainer* find(MyGUI::Widget* _widget); 33 WidgetContainer* find(const std::string& _name); 34 void add(WidgetContainer* _container); 35 void remove(MyGUI::Widget* _widget); 36 void remove(WidgetContainer* _container); 37 38 bool tryToApplyProperty(MyGUI::Widget* _widget, const std::string& _key, const std::string& _value, bool _testMode = false); 39 void onSetWidgetCoord(MyGUI::Widget* _widget, const MyGUI::IntCoord& _value, const std::string& _owner); 40 41 void invalidateWidgets(); 42 EnumeratorWidgetContainer getWidgets(); 43 44 std::string getSkinReplace(const std::string& _skinName); 45 46 const MyGUI::UString& getCurrentFileName() const; 47 const MyGUI::UString& getCurrentItemName() const; 48 49 Event_ChangeWidgets eventChangeWidgets; 50 Event_ChangeWidgetCoord eventChangeWidgetCoord; 51 52 virtual void _unlinkWidget(MyGUI::Widget* _widget); 53 54 MyGUI::MapString& getCodeGeneratorSettings(); 55 56 private: 57 WidgetContainer* _find(MyGUI::Widget* _widget, const std::string& _name, std::vector<WidgetContainer*> _widgets); 58 59 void parseWidget(MyGUI::xml::ElementEnumerator& _widget, MyGUI::Widget* _parent, bool _testMode = false); 60 void serialiseWidget(WidgetContainer* _container, MyGUI::xml::ElementPtr _node, bool _compatibility = false); 61 62 void loadIgnoreParameters(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version); 63 void loadSkinReplace(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version); 64 65 void notifyFrameStarted(float _time); 66 67 void destroyAllWidgets(); 68 69 bool isSkinExist(const std::string& _skinName); 70 bool checkTemplate(const std::string& _skinName); 71 72 bool loadFromProject(const MyGUI::UString& _fileName, size_t _index); 73 bool saveToProject(const MyGUI::UString& _fileName, size_t _index); 74 75 bool unbind(WidgetContainer* _container); 76 77 void loadWidgetsFromXmlNode(MyGUI::xml::ElementPtr _root, bool _testMode = false); 78 void saveWidgetsToXmlNode(MyGUI::xml::ElementPtr _root, bool _compatibility = false); 79 80 void loadCodeGeneratorSettings(MyGUI::xml::ElementPtr _sectorNode); 81 void saveCodeGeneratorSettings(MyGUI::xml::ElementPtr _rootNode); 82 83 private: 84 bool mWidgetsChanged; 85 typedef std::vector<std::string> VectorString; 86 VectorString mIgnoreParameters; 87 VectorWidgetContainer mWidgets; 88 89 MyGUI::MapString mSkinReplaces; 90 91 MyGUI::UString mCurrentFileName; 92 MyGUI::UString mCurrentItemName; 93 94 MyGUI::MapString mCodeGeneratorSettings; 95 }; 96 97 } 98 99 #endif 100