1 #ifndef _d90c3428_278f_44c7_9400_f8b7e1bff0bd_ 2 #define _d90c3428_278f_44c7_9400_f8b7e1bff0bd_ 3 4 #include <MyGUI.h> 5 6 namespace tools 7 { 8 namespace utility 9 { 10 11 // это можно в методы гуи занести convertCoordToParentCoord(const MyGUI::IntCoord & _coord,MyGUI::Widget * _widget)12 inline MyGUI::IntCoord convertCoordToParentCoord(const MyGUI::IntCoord& _coord, MyGUI::Widget* _widget) 13 { 14 MyGUI::IntCoord coord = _coord; 15 MyGUI::Widget* parent = _widget->getParent(); 16 while (nullptr != parent) 17 { 18 coord = coord - parent->getPosition(); 19 // а может у нас и дедушка есть? а может и прадед... 20 parent = parent->getParent(); 21 } 22 return coord; 23 } 24 mapSet(MyGUI::VectorStringPairs & _map,const std::string & _key,const std::string & _value)25 inline void mapSet(MyGUI::VectorStringPairs& _map, const std::string& _key, const std::string& _value) 26 { 27 for (MyGUI::VectorStringPairs::iterator iter = _map.begin(); iter != _map.end(); ++iter) 28 { 29 if (iter->first == _key) 30 { 31 iter->second = _value; 32 return; 33 } 34 } 35 _map.push_back(MyGUI::PairString(_key, _value)); 36 } 37 mapFind(MyGUI::VectorStringPairs & _map,const std::string & _key)38 inline MyGUI::VectorStringPairs::iterator mapFind(MyGUI::VectorStringPairs& _map, const std::string& _key) 39 { 40 for (MyGUI::VectorStringPairs::iterator iter = _map.begin(); iter != _map.end(); ++iter) 41 { 42 if (iter->first == _key) 43 return iter; 44 } 45 return _map.end(); 46 } 47 mapErase(MyGUI::VectorStringPairs & _map,const std::string & _key)48 inline void mapErase(MyGUI::VectorStringPairs& _map, const std::string& _key) 49 { 50 for (MyGUI::VectorStringPairs::iterator iter = _map.begin(); iter != _map.end(); ++iter) 51 { 52 if (iter->first == _key) 53 { 54 _map.erase(iter); 55 return; 56 } 57 } 58 } 59 60 } 61 } 62 63 #endif 64