File: Common.h

package info (click to toggle)
mygui 3.4.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 38,800 kB
  • sloc: cpp: 122,825; ansic: 30,231; xml: 15,792; cs: 12,601; tcl: 776; python: 397; makefile: 38
file content (63 lines) | stat: -rw-r--r-- 1,561 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef _d90c3428_278f_44c7_9400_f8b7e1bff0bd_
#define _d90c3428_278f_44c7_9400_f8b7e1bff0bd_

#include <MyGUI.h>

namespace tools
{
	namespace utility
	{

		// это можно в методы гуи занести
		inline MyGUI::IntCoord convertCoordToParentCoord(const MyGUI::IntCoord& _coord, MyGUI::Widget* _widget)
		{
			MyGUI::IntCoord coord = _coord;
			MyGUI::Widget* parent = _widget->getParent();
			while (nullptr != parent)
			{
				coord = coord - parent->getPosition();
				// а может у нас и дедушка есть? а может и прадед...
				parent = parent->getParent();
			}
			return coord;
		}

		inline void mapSet(MyGUI::VectorStringPairs& _map, const std::string& _key, const std::string& _value)
		{
			for (MyGUI::VectorStringPairs::iterator iter = _map.begin(); iter != _map.end(); ++iter)
			{
				if (iter->first == _key)
				{
					iter->second = _value;
					return;
				}
			}
			_map.push_back(MyGUI::PairString(_key, _value));
		}

		inline MyGUI::VectorStringPairs::iterator mapFind(MyGUI::VectorStringPairs& _map, const std::string& _key)
		{
			for (MyGUI::VectorStringPairs::iterator iter = _map.begin(); iter != _map.end(); ++iter)
			{
				if (iter->first == _key)
					return iter;
			}
			return _map.end();
		}

		inline void mapErase(MyGUI::VectorStringPairs& _map, const std::string& _key)
		{
			for (MyGUI::VectorStringPairs::iterator iter = _map.begin(); iter != _map.end(); ++iter)
			{
				if (iter->first == _key)
				{
					_map.erase(iter);
					return;
				}
			}
		}

	}
}

#endif