ScummVM API documentation
point.h
1
2/* ScummVM - Graphic Adventure Engine
3 *
4 * ScummVM is the legal property of its developers, whose names
5 * are too numerous to list here. Please refer to the COPYRIGHT
6 * file distributed with this source distribution.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef BAGEL_BOFLIB_POINT_H
24#define BAGEL_BOFLIB_POINT_H
25
26#include "bagel/afxwin.h"
27#include "bagel/boflib/stdinc.h"
28#include "bagel/boflib/object.h"
29
30namespace Bagel {
31
32class CBofPoint : public StPoint, public CBofObject {
33public:
34 // Constructors
35 CBofPoint();
36 CBofPoint(int initX, int initY);
37 CBofPoint(StPoint stPoint);
38 CBofPoint(const CBofPoint &cPoint);
39 CBofPoint(const StSize &stSize);
40 CBofPoint(const Common::Point &pt);
41
42 CBofPoint(const POINT &stPoint) {
43 setWinPoint(&stPoint);
44 }
45 virtual ~CBofPoint() {
46 }
47
48 void setWinPoint(const POINT *pPoint);
49 POINT GetWinPoint() const;
50
51 void operator=(const POINT &stPoint) {
52 setWinPoint(&stPoint);
53 }
54
55 operator const POINT() {
56 return GetWinPoint();
57 }
58
59
60 // Operations
61 void offset(int xOffset, int yOffset);
62 void offset(StPoint point);
63 void offset(StSize size);
64 void operator=(const StPoint &point);
65 void operator=(const CBofPoint &point);
66 bool operator==(StPoint point) const;
67 bool operator!=(StPoint point) const;
68 void operator+=(StSize size);
69 void operator-=(StSize size);
70 void operator+=(StPoint point);
71 void operator-=(StPoint point);
72
73 // Operators returning CBofPoint values
74 CBofPoint operator+(StSize size) const;
75 CBofPoint operator+(StPoint point) const;
76 CBofPoint operator-(StSize size) const;
77 CBofPoint operator-(StPoint point) const;
78 CBofPoint operator-() const;
79};
80
81// CBofPoint
82inline CBofPoint::CBofPoint() {
83 x = 0;
84 y = 0;
85}
86
87inline CBofPoint::CBofPoint(const int initX, const int initY) {
88 x = initX;
89 y = initY;
90}
91
92inline CBofPoint::CBofPoint(const StPoint stPoint) {
93 x = stPoint.x;
94 y = stPoint.y;
95}
96
97inline CBofPoint::CBofPoint(const StSize &stSize) {
98 x = stSize.cx;
99 y = stSize.cy;
100}
101
102inline CBofPoint::CBofPoint(const CBofPoint &cPoint) {
103 x = cPoint.x;
104 y = cPoint.y;
105}
106
107inline CBofPoint::CBofPoint(const Common::Point &pt) {
108 x = pt.x;
109 y = pt.y;
110}
111
112inline void CBofPoint::setWinPoint(const POINT *pPoint) {
113 assert(pPoint != nullptr);
114 assert(isValidObject(this));
115
116 x = pPoint->x;
117 y = pPoint->y;
118}
119
120inline POINT CBofPoint::GetWinPoint() const {
121 assert(isValidObject(this));
122
123 POINT stPoint;
124
125 stPoint.x = x;
126 stPoint.y = y;
127
128 return stPoint;
129}
130
131inline void CBofPoint::offset(int xOffset, int yOffset) {
132 // Make sure object is not used after it is destructed
133 assert(isValidObject(this));
134
135 x += xOffset;
136 y += yOffset;
137}
138
139inline void CBofPoint::offset(StPoint point) {
140 // Make sure object is not used after it is destructed
141 assert(isValidObject(this));
142
143 x += point.x;
144 y += point.y;
145}
146
147inline void CBofPoint::offset(StSize size) {
148 // Make sure object is not used after it is destructed
149 assert(isValidObject(this));
150
151 x += size.cx;
152 y += size.cy;
153}
154
155inline void CBofPoint::operator=(const StPoint &point) {
156 // Make sure object is not used after it is destructed
157 assert(isValidObject(this));
158
159 x = point.x;
160 y = point.y;
161}
162
163inline void CBofPoint::operator=(const CBofPoint &point) {
164 // Make sure object is not used after it is destructed
165 assert(isValidObject(this));
166
167 x = point.x;
168 y = point.y;
169}
170
171inline bool CBofPoint::operator==(StPoint point) const {
172 // Make sure object is not used after it is destructed
173 assert(isValidObject(this));
174
175 return (x == point.x && y == point.y);
176}
177
178inline bool CBofPoint::operator!=(StPoint point) const {
179 // Make sure object is not used after it is destructed
180 assert(isValidObject(this));
181
182 return (x != point.x || y != point.y);
183}
184
185inline void CBofPoint::operator+=(StSize size) {
186 // Make sure object is not used after it is destructed
187 assert(isValidObject(this));
188
189 x += size.cx;
190 y += size.cy;
191}
192
193inline void CBofPoint::operator+=(StPoint point) {
194 // Make sure object is not used after it is destructed
195 assert(isValidObject(this));
196
197 x += point.x;
198 y += point.y;
199}
200
201inline void CBofPoint::operator-=(StPoint point) {
202 // Make sure object is not used after it is destructed
203 assert(isValidObject(this));
204
205 x -= point.x;
206 y -= point.y;
207}
208
209inline void CBofPoint::operator-=(StSize size) {
210 // Make sure object is not used after it is destructed
211 assert(isValidObject(this));
212
213 x -= size.cx;
214 y -= size.cy;
215}
216
217inline CBofPoint CBofPoint::operator+(StSize size) const {
218 // Make sure object is not used after it is destructed
219 assert(isValidObject(this));
220
221 return CBofPoint(x + size.cx, y + size.cy);
222}
223
224inline CBofPoint CBofPoint::operator+(StPoint point) const {
225 // Make sure object is not used after it is destructed
226 assert(isValidObject(this));
227
228 return CBofPoint(x + point.x, y + point.y);
229}
230
231inline CBofPoint CBofPoint::operator-(StSize size) const {
232 // Make sure object is not used after it is destructed
233 assert(isValidObject(this));
234
235 return CBofPoint(x - size.cx, y - size.cy);
236}
237
238inline CBofPoint CBofPoint::operator-(StPoint point) const {
239 // Make sure object is not used after it is destructed
240 assert(isValidObject(this));
241
242 return CBofPoint(x - point.x, y - point.y);
243}
244
245inline CBofPoint CBofPoint::operator-() const {
246 // Make sure object is not used after it is destructed
247 assert(isValidObject(this));
248
249 return CBofPoint(-x, -y);
250}
251
252} // namespace Bagel
253
254#endif
Definition: object.h:28
Definition: point.h:32
Definition: stdinc.h:47
Definition: stdinc.h:42
T y
Definition: rect.h:49
T x
Definition: rect.h:48
Definition: rect.h:144
Definition: minwindef.h:161