forked from arbruijn/d2x-xl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rectangle.h
69 lines (57 loc) · 1.62 KB
/
rectangle.h
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
64
65
66
67
68
69
#ifndef RECTANGLE_H
#define RECTANGLE_H
//------------------------------------------------------------------------------
class CRectangle {
public:
int m_x, m_y, m_w, m_h;
CRectangle (int x = 0, int y = 0, int w = 0, int h = 0, int t = 0) : m_x (x), m_y (y), m_w (w), m_h (h) {}
void Setup (int x, int y, int w, int h) {
m_x = x;
m_y = y;
m_w = w;
m_h = h;
}
inline CRectangle& operator= (CRectangle const other) {
m_x = other.m_x;
m_y = other.m_y;
m_w = other.m_w;
m_h = other.m_h;
return *this;
}
inline CRectangle& operator+= (CRectangle const other) {
m_x += other.m_x;
m_y += other.m_y;
m_w += other.m_w;
m_h += other.m_h;
return *this;
}
inline CRectangle& operator-= (CRectangle const other) {
m_x -= other.m_x;
m_y -= other.m_y;
m_w -= other.m_w;
m_h -= other.m_h;
return *this;
}
inline CRectangle operator+ (CRectangle const other) {
CRectangle rc = *this;
rc += other;
return rc;
}
inline CRectangle operator- (CRectangle const other) {
CRectangle rc = *this;
rc -= other;
return rc;
}
inline int Left (void) { return m_x; }
inline int Top (void) { return m_y; }
inline int Right (void) { return m_x + m_w - 1; }
inline int Bottom (void) { return m_y + m_h - 1; }
inline int Width (void) { return m_w; }
inline int Height (void) { return m_h; }
inline void SetLeft (int x) { m_x = x; }
inline void SetTop (int y) { m_y = y; }
inline void SetWidth (int w) { m_w = w; }
inline void SetHeight (int h) { m_h = h; }
};
//------------------------------------------------------------------------------
#endif