mirror of
https://github.com/scummvm/scummvm.git
synced 2025-04-02 10:52:32 -04:00
138 lines
3.3 KiB
C++
138 lines
3.3 KiB
C++
|
|
/* ScummVM - Graphic Adventure Engine
|
|
*
|
|
* ScummVM is the legal property of its developers, whose names
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
* file distributed with this source distribution.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
#ifndef BAGEL_BOFLIB_SIZE_H
|
|
#define BAGEL_BOFLIB_SIZE_H
|
|
|
|
#include "bagel/boflib/stdinc.h"
|
|
#include "bagel/boflib/object.h"
|
|
|
|
namespace Bagel {
|
|
|
|
class CBofSize : public StSize, public CBofObject {
|
|
public:
|
|
// Constructors
|
|
CBofSize();
|
|
CBofSize(int initCX, int initCY);
|
|
CBofSize(const StSize &stSize);
|
|
CBofSize(const CBofSize &cSize);
|
|
CBofSize(StPoint stPoint);
|
|
|
|
// Operations
|
|
void operator=(const CBofSize &cSize);
|
|
bool operator==(StSize size);
|
|
bool operator!=(StSize size);
|
|
void operator+=(StSize size);
|
|
void operator-=(StSize size);
|
|
|
|
// Operators returning CBofSize values
|
|
CBofSize operator+(StSize size);
|
|
CBofSize operator-(StSize size);
|
|
CBofSize operator-();
|
|
};
|
|
|
|
// CBofSize
|
|
inline CBofSize::CBofSize() {
|
|
cx = cy = 0;
|
|
}
|
|
|
|
inline CBofSize::CBofSize(int initCX, int initCY) {
|
|
cx = initCX;
|
|
cy = initCY;
|
|
}
|
|
|
|
inline CBofSize::CBofSize(const StSize &stSize) {
|
|
cx = stSize.cx;
|
|
cy = stSize.cy;
|
|
}
|
|
|
|
inline CBofSize::CBofSize(const CBofSize &cSize) {
|
|
cx = cSize.cx;
|
|
cy = cSize.cy;
|
|
}
|
|
|
|
inline CBofSize::CBofSize(StPoint stPoint) {
|
|
cx = stPoint.x;
|
|
cy = stPoint.y;
|
|
}
|
|
|
|
inline void CBofSize::operator=(const CBofSize &cSize) {
|
|
cx = cSize.cx;
|
|
cy = cSize.cy;
|
|
}
|
|
|
|
inline bool CBofSize::operator==(StSize size) {
|
|
// Make sure object is not used after it is destructed
|
|
assert(isValidObject(this));
|
|
|
|
return (cx == size.cx && cy == size.cy);
|
|
}
|
|
|
|
inline bool CBofSize::operator!=(StSize size) {
|
|
// Make sure object is not used after it is destructed
|
|
assert(isValidObject(this));
|
|
|
|
return (cx != size.cx || cy != size.cy);
|
|
}
|
|
|
|
inline void CBofSize::operator+=(StSize size) {
|
|
// Make sure object is not used after it is destructed
|
|
assert(isValidObject(this));
|
|
|
|
cx += size.cx;
|
|
cy += size.cy;
|
|
}
|
|
|
|
inline void CBofSize::operator-=(StSize size) {
|
|
// Make sure object is not used after it is destructed
|
|
assert(isValidObject(this));
|
|
|
|
cx -= size.cx;
|
|
cy -= size.cy;
|
|
}
|
|
|
|
inline CBofSize CBofSize::operator+(StSize size) {
|
|
// Make sure object is not used after it is destructed
|
|
assert(isValidObject(this));
|
|
|
|
return CBofSize(cx + size.cx, cy + size.cy);
|
|
}
|
|
|
|
inline CBofSize CBofSize::operator-(StSize size) {
|
|
// Make sure object is not used after it is destructed
|
|
assert(isValidObject(this));
|
|
|
|
return CBofSize(cx - size.cx, cy - size.cy);
|
|
}
|
|
|
|
inline CBofSize CBofSize::operator-() {
|
|
// Make sure object is not used after it is destructed
|
|
assert(isValidObject(this));
|
|
|
|
return CBofSize(-cx, -cy);
|
|
}
|
|
|
|
#define CSize CBofSize
|
|
|
|
} // namespace Bagel
|
|
|
|
#endif
|