Mercurial > mm7
annotate NewUI/Core/UIControl.h @ 1905:4cae2d58cfb4
Слияние
author | Ritor1 |
---|---|
date | Mon, 21 Oct 2013 17:24:10 +0600 |
parents | 6788e58c1715 |
children | 62a27b2cfcc2 |
rev | line source |
---|---|
1815 | 1 #pragma once |
2 #include <list> | |
1824
6788e58c1715
adding <algorithm> to uicontrol to fix build issue with vs2008
Grumpy7
parents:
1815
diff
changeset
|
3 #include <algorithm> |
1815 | 4 |
5 class UIControl | |
6 { | |
7 public: | |
8 virtual void Show() = 0; | |
9 | |
10 virtual bool Focused() = 0; | |
11 | |
12 // Events | |
13 virtual bool OnKey(int key) | |
14 { | |
15 for (auto i = children.begin(); i != children.end(); ++i) | |
16 if ((*i)->OnKey(key)) | |
17 return true; | |
18 return false; | |
19 } | |
20 | |
21 virtual bool OnMouseLeftClick(int x, int y) | |
22 { | |
23 for (auto i = children.begin(); i != children.end(); ++i) | |
24 if ((*i)->OnMouseLeftClick(x, y)) | |
25 return true; | |
26 return false; | |
27 } | |
28 | |
29 virtual bool OnMouseRightClick(int x, int y) | |
30 { | |
31 for (auto i = children.begin(); i != children.end(); ++i) | |
32 if ((*i)->OnMouseRightClick(x, y)) | |
33 return true; | |
34 return false; | |
35 } | |
36 | |
37 virtual bool OnMouseEnter() | |
38 { | |
39 for (auto i = children.begin(); i != children.end(); ++i) | |
40 if ((*i)->OnMouseEnter()) | |
41 return true; | |
42 return false; | |
43 } | |
44 | |
45 virtual bool OnMouseLeave() | |
46 { | |
47 for (auto i = children.begin(); i != children.end(); ++i) | |
48 if ((*i)->OnMouseLeave()) | |
49 return true; | |
50 return false; | |
51 } | |
52 | |
53 // Container | |
54 virtual bool AddControl(UIControl *ctrl) | |
55 { | |
56 if (std::find(children.begin(), children.end(), ctrl) == children.end()) | |
57 { | |
58 children.push_back(ctrl); | |
59 return true; | |
60 } | |
61 return false; | |
62 } | |
63 | |
64 virtual bool RemoveControl(UIControl *ctrl) | |
65 { | |
66 auto i = std::find(children.begin(), children.end(), ctrl); | |
67 | |
68 children.remove(ctrl); | |
69 if (i != children.end()) | |
70 return true; | |
71 return false; | |
72 } | |
73 | |
74 protected: | |
75 std::list<UIControl *> children; | |
76 }; |