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