diff options
author | Paweł Kołodziejski | 2002-08-24 15:31:37 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2002-08-24 15:31:37 +0000 |
commit | 9f993a1d29120120b3d9c08d56ca1990f4222ae5 (patch) | |
tree | 751e3cfdc133f1abf27d6ff35b9b6a2c329bf3a0 /scumm/smush/rect.cpp | |
parent | fa181fcd8b6956821f4f8585f3124e9cf0214303 (diff) | |
download | scummvm-rg350-9f993a1d29120120b3d9c08d56ca1990f4222ae5.tar.gz scummvm-rg350-9f993a1d29120120b3d9c08d56ca1990f4222ae5.tar.bz2 scummvm-rg350-9f993a1d29120120b3d9c08d56ca1990f4222ae5.zip |
synced with scummvm
svn-id: r4821
Diffstat (limited to 'scumm/smush/rect.cpp')
-rw-r--r-- | scumm/smush/rect.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/scumm/smush/rect.cpp b/scumm/smush/rect.cpp new file mode 100644 index 0000000000..deb1d5b35f --- /dev/null +++ b/scumm/smush/rect.cpp @@ -0,0 +1,62 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001/2002 The ScummVM project + * + * 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 2 + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ + +#include <stdafx.h> +#include "rect.h" + +Rect::Rect() : _topLeft(0, 0), _bottomRight(0,0) { +} + +Rect::Rect(int x, int y) : _topLeft(0, 0), _bottomRight(x, y) { + check(); +} + +Rect::Rect(int x1, int y1, int x2, int y2) : _topLeft(x1, y1), _bottomRight(x2, y2) { + check(); +} + +Rect::Rect(const Rect & r) : _topLeft(r._topLeft), _bottomRight(r._bottomRight) { +} + +Rect & Rect::operator=(const Rect & r) { + _topLeft = r._topLeft; + _bottomRight = r._bottomRight; + return *this; +} + +bool Rect::operator==(const Rect & r) const { + return _topLeft == r._topLeft && _bottomRight == r._bottomRight; +} + +void Rect::check() { + if ((_topLeft.getX() < 0) || (_bottomRight.getX() < _topLeft.getX()) || (_topLeft.getY() < 0) || (_bottomRight.getY() < _topLeft.getY())) { + error("Invalid rect"); + } +} + +bool Rect::isInside(int x, int y) const { + return _topLeft.getX() >= x && _bottomRight.getX() < x && _topLeft.getY() >= y && _bottomRight.getY() < y; +} + +bool Rect::isInside(const Point & p) const { + return (left() <= p.getX()) && (right() > p.getX()) && (top() <= p.getY()) && (bottom() > p.getY()); +} + |