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.
24 /*************** point ****************************/
28 //memset(this, 0, sizeof(*this));
35 Point::Point(const Point
& pnt
)
39 //memcpy(this, &pnt, sizeof(*this));
42 Point
& Point::operator=(const Point
& pnt
)
46 //memcpy(this, &pnt, sizeof(*this));
50 bool Point::operator==(const Point
& pnt
)
52 if (( x
== pnt
.x
) && ( y
== pnt
.y
)) {
56 //return !memcmp( this, &pnt, sizeof(*this));
59 bool Point::operator!=(const Point
& pnt
)
61 if (( x
== pnt
.x
) && ( y
== pnt
.y
)) {
67 Point::Point(short x
, short y
)
73 ieDword
Point::asDword() const
75 return ((y
& 0xFFFF) << 16) | (x
& 0xFFFF);
78 void Point::fromDword(ieDword val
)
84 bool Point::isnull() const
92 bool Point::isempty() const
100 bool Point::PointInside(const Point
&p
) const
102 if (( p
.x
< 0 ) || ( p
.x
> x
)) {
105 if (( p
.y
< 0 ) || ( p
.y
> y
)) {
111 /*************** region ****************************/
117 Region::~Region(void)
121 Region::Region(const Region
& rgn
)
129 Region
& Region::operator=(const Region
& rgn
)
138 bool Region::operator==(const Region
& rgn
)
140 if (( x
== rgn
.x
) && ( y
== rgn
.y
) && ( w
== rgn
.w
) && ( h
== rgn
.h
)) {
146 bool Region::operator!=(const Region
& rgn
)
148 if (( x
!= rgn
.x
) || ( y
!= rgn
.y
) || ( w
!= rgn
.w
) || ( h
!= rgn
.h
)) {
154 Region::Region(int x
, int y
, int w
, int h
)
162 Region::Region(const Point
&p
, int w
, int h
)
170 bool Region::PointInside(const Point
&p
) const
172 if (( p
.x
< x
) || ( p
.x
> ( x
+ w
) )) {
175 if (( p
.y
< y
) || ( p
.y
> ( y
+ h
) )) {
181 bool Region::PointInside(unsigned short XPos
, unsigned short YPos
) const
183 if (( XPos
< x
) || ( XPos
> ( x
+ w
) )) {
186 if (( YPos
< y
) || ( YPos
> ( y
+ h
) )) {
192 bool Region::InsideRegion(const Region
& rgn
) const
194 if (x
> ( rgn
.x
+ rgn
.w
)) {
197 if (( x
+ w
) < rgn
.x
) {
200 if (y
> ( rgn
.y
+ rgn
.h
)) {
203 if (( y
+ h
) < rgn
.y
) {
209 void Region::Normalize()