author | KUDr |
Sun, 18 Feb 2007 14:17:28 +0000 | |
branch | cpp_gui |
changeset 6258 | a2f86b8fd99b |
child 6259 | 0f36789984b1 |
permissions | -rw-r--r-- |
6258
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
1 |
/* $Id$ */ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
2 |
#ifndef RECT_H |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
3 |
#define RECT_H |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
4 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
5 |
/** Template based point */ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
6 |
template <typename T> struct PointT { |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
7 |
T x, y; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
8 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
9 |
PointT(T x_a = 0, T y_a = 0) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
10 |
: x(x_a), y(y_a) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
11 |
{} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
12 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
13 |
template <typename Ta> PointT(const PointT<Ta> &src) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
14 |
: x((T)src.x), y((T)src.y) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
15 |
{} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
16 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
17 |
PointT& operator =(const PointT &src) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
18 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
19 |
x = (T)src.x; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
20 |
y = (T)src.y; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
21 |
return *this; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
22 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
23 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
24 |
PointT operator -() const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
25 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
26 |
return PointT(-x, -y); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
27 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
28 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
29 |
void DoMove(T dx, T dy) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
30 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
31 |
x += dx; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
32 |
y += dy; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
33 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
34 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
35 |
void DoMove(const PointT &offset) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
36 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
37 |
DoMove((T)offset.x, (T)offset.y); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
38 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
39 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
40 |
PointT operator +(const PointT &offset) const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
41 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
42 |
PointT pt; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
43 |
pt.DoMove(offset); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
44 |
return pt; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
45 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
46 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
47 |
PointT operator -(const PointT &offset) const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
48 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
49 |
PointT pt; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
50 |
pt.DoMove(-offset); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
51 |
return pt; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
52 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
53 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
54 |
PointT& operator +=(const PointT &offset) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
55 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
56 |
DoMove(offset); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
57 |
return *this; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
58 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
59 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
60 |
PointT& operator -=(const PointT &offset) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
61 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
62 |
DoMove(-offset); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
63 |
return *this; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
64 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
65 |
}; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
66 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
67 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
68 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
69 |
/** Template based rectangle */ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
70 |
template <typename T> struct RectT |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
71 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
72 |
PointT<T> top_left, bottom_right; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
73 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
74 |
RectT(T left = 0, T top = 0, T right = 0, T bottom = 0) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
75 |
: top_left(left, top), bottom_right(right, bottom) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
76 |
{} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
77 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
78 |
template <typename Ta> RectT(const RectT<Ta> &src) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
79 |
: top_left(src.top_left), bottom_right(src.bottom_right) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
80 |
{} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
81 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
82 |
T Left() const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
83 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
84 |
return top_left.x; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
85 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
86 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
87 |
T Top() const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
88 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
89 |
return top_left.y; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
90 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
91 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
92 |
T Right() const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
93 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
94 |
return bottom_right.x; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
95 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
96 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
97 |
T Bottom() const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
98 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
99 |
return bottom_right.y; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
100 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
101 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
102 |
T Width() const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
103 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
104 |
return bottom_right.x - top_left.x + 1; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
105 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
106 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
107 |
T Height() const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
108 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
109 |
return bottom_right.y - top_left.y + 1; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
110 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
111 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
112 |
const PointT<T>& TopLeft() const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
113 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
114 |
return top_left; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
115 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
116 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
117 |
const PointT<T>& BottomRight() const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
118 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
119 |
return bottom_right; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
120 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
121 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
122 |
void SetLeft(T val) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
123 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
124 |
top_left.x = val; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
125 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
126 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
127 |
void SetTop(T val) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
128 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
129 |
top_left.y = val; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
130 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
131 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
132 |
void SetRight(T val) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
133 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
134 |
bottom_right.x = val; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
135 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
136 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
137 |
void SetBottom(T val) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
138 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
139 |
bottom_right.y = val; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
140 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
141 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
142 |
void SetWidth(T val) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
143 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
144 |
bottom_right.x = top_left.x + val - 1; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
145 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
146 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
147 |
void SetHeight(T val) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
148 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
149 |
bottom_right.y = top_left.y + val - 1; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
150 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
151 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
152 |
void SetTopLeft(const PointT<T> &pt) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
153 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
154 |
top_left = pt; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
155 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
156 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
157 |
void SetBottomRight(const PointT<T> &pt) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
158 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
159 |
bottom_right = pt; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
160 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
161 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
162 |
bool PtInRect(const PointT<T> &pt) const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
163 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
164 |
return (top_left.x <= pt.x && pt.x <= bottom_right.x && top_left.y <= pt.y && pt.y <= bottom_right.y); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
165 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
166 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
167 |
RectT& operator =(const RectT &src) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
168 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
169 |
top_left = src.top_left; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
170 |
bottom_right = src.bottom_right; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
171 |
return *this; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
172 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
173 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
174 |
void DoMove(T dx, T dy) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
175 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
176 |
DoMove(PointT<T>(dx, dy)); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
177 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
178 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
179 |
void DoMove(const PointT<T> &offset) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
180 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
181 |
top_left.DoMove(offset); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
182 |
bottom_right.DoMove(offset); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
183 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
184 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
185 |
RectT operator +(const PointT<T> &offset) const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
186 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
187 |
RectT r; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
188 |
r.DoMove(offset); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
189 |
return r; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
190 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
191 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
192 |
RectT operator -(const PointT<T> &offset) const |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
193 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
194 |
RectT r; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
195 |
r.DoMove(-offset); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
196 |
return r; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
197 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
198 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
199 |
RectT& operator +=(const PointT<T> &offset) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
200 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
201 |
DoMove(offset); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
202 |
return *this; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
203 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
204 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
205 |
RectT& operator -=(const PointT<T> &offset) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
206 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
207 |
DoMove(-offset); |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
208 |
return *this; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
209 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
210 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
211 |
void DoUnion(const PointT<T> &pt) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
212 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
213 |
if (pt.x < top_left.x) { |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
214 |
top_left.x = pt.x; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
215 |
} else if (pt.x > bottom_right.x) { |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
216 |
bottom_right.x = pt.x; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
217 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
218 |
if (pt.y < top_left.y) { |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
219 |
top_left.y = pt.y; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
220 |
} else if (pt.y > bottom_right.y) { |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
221 |
bottom_right.y = pt.y; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
222 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
223 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
224 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
225 |
void DoUnion(const RectT &rc) |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
226 |
{ |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
227 |
if (rc.top_left.x < top_left.x) { |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
228 |
top_left.x = rc.top_left.x; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
229 |
} else if (rc.bottom_right.x > bottom_right.x) { |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
230 |
bottom_right.x = rc.bottom_right.x; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
231 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
232 |
if (rc.top_left.y < top_left.y) { |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
233 |
top_left.y = rc.top_left.y; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
234 |
} else if (rc.bottom_right.y > bottom_right.y) { |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
235 |
bottom_right.y = rc.bottom_right.y; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
236 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
237 |
} |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
238 |
}; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
239 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
240 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
241 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
242 |
typedef PointT<int16> Point16; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
243 |
typedef PointT<int32> Point32; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
244 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
245 |
typedef RectT<int16> Rect16; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
246 |
typedef RectT<int32> Rect32; |
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
247 |
|
a2f86b8fd99b
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff
changeset
|
248 |
#endif /*RECT_H*/ |