ScummVM API documentation
size.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_SIZE_H
24 #define BAGEL_BOFLIB_SIZE_H
25 
26 #include "bagel/boflib/stdinc.h"
27 #include "bagel/boflib/object.h"
28 
29 namespace Bagel {
30 
31 class CBofSize : public StSize, public CBofObject {
32 public:
33  // Constructors
34  CBofSize();
35  CBofSize(int initCX, int initCY);
36  CBofSize(const StSize &stSize);
37  CBofSize(const CBofSize &cSize);
38  CBofSize(StPoint stPoint);
39 
40  // Operations
41  void operator=(const CBofSize &cSize);
42  bool operator==(StSize size);
43  bool operator!=(StSize size);
44  void operator+=(StSize size);
45  void operator-=(StSize size);
46 
47  // Operators returning CBofSize values
48  CBofSize operator+(StSize size);
49  CBofSize operator-(StSize size);
50  CBofSize operator-();
51 };
52 
53 // CBofSize
54 inline CBofSize::CBofSize() {
55  cx = cy = 0;
56 }
57 
58 inline CBofSize::CBofSize(int initCX, int initCY) {
59  cx = initCX;
60  cy = initCY;
61 }
62 
63 inline CBofSize::CBofSize(const StSize &stSize) {
64  cx = stSize.cx;
65  cy = stSize.cy;
66 }
67 
68 inline CBofSize::CBofSize(const CBofSize &cSize) {
69  cx = cSize.cx;
70  cy = cSize.cy;
71 }
72 
73 inline CBofSize::CBofSize(StPoint stPoint) {
74  cx = stPoint.x;
75  cy = stPoint.y;
76 }
77 
78 inline void CBofSize::operator=(const CBofSize &cSize) {
79  cx = cSize.cx;
80  cy = cSize.cy;
81 }
82 
83 inline bool CBofSize::operator==(StSize size) {
84  // Make sure object is not used after it is destructed
85  assert(isValidObject(this));
86 
87  return (cx == size.cx && cy == size.cy);
88 }
89 
90 inline bool CBofSize::operator!=(StSize size) {
91  // Make sure object is not used after it is destructed
92  assert(isValidObject(this));
93 
94  return (cx != size.cx || cy != size.cy);
95 }
96 
97 inline void CBofSize::operator+=(StSize size) {
98  // Make sure object is not used after it is destructed
99  assert(isValidObject(this));
100 
101  cx += size.cx;
102  cy += size.cy;
103 }
104 
105 inline void CBofSize::operator-=(StSize size) {
106  // Make sure object is not used after it is destructed
107  assert(isValidObject(this));
108 
109  cx -= size.cx;
110  cy -= size.cy;
111 }
112 
113 inline CBofSize CBofSize::operator+(StSize size) {
114  // Make sure object is not used after it is destructed
115  assert(isValidObject(this));
116 
117  return CBofSize(cx + size.cx, cy + size.cy);
118 }
119 
120 inline CBofSize CBofSize::operator-(StSize size) {
121  // Make sure object is not used after it is destructed
122  assert(isValidObject(this));
123 
124  return CBofSize(cx - size.cx, cy - size.cy);
125 }
126 
127 inline CBofSize CBofSize::operator-() {
128  // Make sure object is not used after it is destructed
129  assert(isValidObject(this));
130 
131  return CBofSize(-cx, -cy);
132 }
133 
134 #define CSize CBofSize
135 
136 } // namespace Bagel
137 
138 #endif
Definition: object.h:28
Definition: size.h:31
Definition: stdinc.h:40
Definition: bagel.h:31
Definition: stdinc.h:45