1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 /*************** point ****************************/
27 //memset(this, 0, sizeof(*this));
34 Point::Point(const Point
& pnt
)
38 //memcpy(this, &pnt, sizeof(*this));
41 Point
& Point::operator=(const Point
& pnt
)
45 //memcpy(this, &pnt, sizeof(*this));
49 bool Point::operator==(const Point
& pnt
)
51 if (( x
== pnt
.x
) && ( y
== pnt
.y
)) {
55 //return !memcmp( this, &pnt, sizeof(*this));
58 bool Point::operator!=(const Point
& pnt
)
60 if (( x
== pnt
.x
) && ( y
== pnt
.y
)) {
66 Point::Point(short x
, short y
)
72 ieDword
Point::asDword() const
74 return ((y
& 0xFFFF) << 16) | (x
& 0xFFFF);
77 void Point::fromDword(ieDword val
)
83 bool Point::isnull() const
91 bool Point::isempty() const
99 bool Point::PointInside(const Point
&p
) const
101 if (( p
.x
< 0 ) || ( p
.x
> x
)) {
104 if (( p
.y
< 0 ) || ( p
.y
> y
)) {
110 /*************** region ****************************/
116 Region::~Region(void)
120 Region::Region(const Region
& rgn
)
128 Region
& Region::operator=(const Region
& rgn
)
137 bool Region::operator==(const Region
& rgn
)
139 if (( x
== rgn
.x
) && ( y
== rgn
.y
) && ( w
== rgn
.w
) && ( h
== rgn
.h
)) {
145 bool Region::operator!=(const Region
& rgn
)
147 if (( x
!= rgn
.x
) || ( y
!= rgn
.y
) || ( w
!= rgn
.w
) || ( h
!= rgn
.h
)) {
153 Region::Region(int x
, int y
, int w
, int h
)
161 Region::Region(const Point
&p
, int w
, int h
)
169 bool Region::PointInside(const Point
&p
) const
171 if (( p
.x
< x
) || ( p
.x
> ( x
+ w
) )) {
174 if (( p
.y
< y
) || ( p
.y
> ( y
+ h
) )) {
180 bool Region::PointInside(unsigned short XPos
, unsigned short YPos
) const
182 if (( XPos
< x
) || ( XPos
> ( x
+ w
) )) {
185 if (( YPos
< y
) || ( YPos
> ( y
+ h
) )) {
191 bool Region::InsideRegion(const Region
& rgn
) const
193 if (x
> ( rgn
.x
+ rgn
.w
)) {
196 if (( x
+ w
) < rgn
.x
) {
199 if (y
> ( rgn
.y
+ rgn
.h
)) {
202 if (( y
+ h
) < rgn
.y
) {
208 void Region::Normalize()