Woopsi 1.3
Nintendo DS Gui Framework
Public Member Functions | Static Public Member Functions | Public Attributes
WoopsiUI::Rect Class Reference

#include <libwoopsi/include/rect.h>

List of all members.

Public Member Functions

 Rect ()
 Rect (s16 x, s16 y, s32 width, s32 height)
 Rect (const Rect &rect)
s16 getX () const
s16 getY () const
s32 getWidth () const
s32 getHeight () const
void setX (s16 x)
void setY (s16 y)
void setWidth (s32 width)
void setHeight (s32 height)
void setX2 (s16 x2)
void setY2 (s16 y2)
s16 getX2 () const
s16 getY2 () const
bool hasDimensions () const
void getIntersect (const Rect &rect, Rect &dest) const
void getAddition (const Rect &rect, Rect &dest) const
void clipToIntersect (const Rect &rect)
void expandToInclude (const Rect &rect)
bool intersects (const Rect &rect) const
bool contains (s16 x, s16 y) const
void copyTo (Rect &dest) const
bool splitIntersection (const Rect &rect, Rect &intersection, WoopsiArray< Rect > *remainderRects) const
Rect operator& (const Rect &rect)
Rect operator+ (const Rect &rect)
bool operator== (const Rect &rect)
bool operator!= (const Rect &rect)

Static Public Member Functions

static Rect fromCoordinates (s16 x1, s16 y1, s16 x2, s16 y2)

Public Attributes

s16 x
s16 y
s32 width
s32 height

Detailed Description

Class describing a rectangle.


Constructor & Destructor Documentation

WoopsiUI::Rect::Rect ( )

Constructor.

WoopsiUI::Rect::Rect ( s16  x,
s16  y,
s32  width,
s32  height 
)

Constructor.

Parameters:
xThe x co-ordinate of the rect.
yThe y co-ordinate of the rect.
widthThe width of the rect.
heightThe height of the rect.
WoopsiUI::Rect::Rect ( const Rect rect)

Copy constructor.

Parameters:
rectRect to copy.

Member Function Documentation

void WoopsiUI::Rect::clipToIntersect ( const Rect rect)

Clips this rect to the region that intersects the supplied rect.

bool WoopsiUI::Rect::contains ( s16  x,
s16  y 
) const

Check if the rect contains the supplied point.

Parameters:
xX co-ord of the point.
yY co-ord of the point.
Returns:
True if the rect contains the point; false if not.
void WoopsiUI::Rect::copyTo ( Rect dest) const

Copy the properties of this rect to the destination rect.

Parameters:
destDestination rect to copy to.
void WoopsiUI::Rect::expandToInclude ( const Rect rect)

Expands this rect so that it includes the area described by the supplied rect.

static Rect WoopsiUI::Rect::fromCoordinates ( s16  x1,
s16  y1,
s16  x2,
s16  y2 
) [static]

Create a rect object from the supplied co-ordinates.

Parameters:
x1The x co-ordinate of the rect's top-left corner.
y1The y co-ordinate of the rect's top-left corner.
x2The x co-ordinate of the rect's bottom-right corner.
y2The y co-ordinate of the rect's bottom-right corner.
Returns:
A new rect.
void WoopsiUI::Rect::getAddition ( const Rect rect,
Rect dest 
) const

Populates dest with a rectangle representating the smallest rectangle that contains this rectangle and rect.

Parameters:
rectThe rectangle to add to this.
destThe destination rectangle.
s32 WoopsiUI::Rect::getHeight ( ) const [inline]

Get the rect's height.

Returns:
The rect's height.
void WoopsiUI::Rect::getIntersect ( const Rect rect,
Rect dest 
) const

Populates dest with a rectangle representating the intersection of this rectangle and rect.

Parameters:
rectThe rectangle to intersect with this.
destThe destination rectangle.
s32 WoopsiUI::Rect::getWidth ( ) const [inline]

Get the rect's width.

Returns:
The rect's width.
s16 WoopsiUI::Rect::getX ( ) const [inline]

Get the rect's x co-ordinate.

Returns:
The rect's x co-ordinate.
s16 WoopsiUI::Rect::getX2 ( ) const [inline]

Get the x co-ordinate of the rect's bottom-right corner.

Returns:
The x co-ordinate of the rect's bottom-right corner.
s16 WoopsiUI::Rect::getY ( ) const [inline]

Get the rect's y co-ordinate.

Returns:
The rect's y co-ordinate.
s16 WoopsiUI::Rect::getY2 ( ) const [inline]

Get the y co-ordinate of the rect's bottom-right corner.

Returns:
The y co-ordinate of the rect's bottom-right corner.
bool WoopsiUI::Rect::hasDimensions ( ) const

Determines if the rectangle has two dimensions; in other words, does it have both height and width? Negative width or height is considered not to be valid.

Returns:
True if the rect has height and width; false if not.
bool WoopsiUI::Rect::intersects ( const Rect rect) const

Check if the supplied rect intersects this.

Parameters:
rectRect to check for intersection with this.
Returns:
True if the rect intersects this; false if not.
bool WoopsiUI::Rect::operator!= ( const Rect rect)

Overloaded != operator. Checks if the dimensions of the supplied rect are not the same as this rect.

Parameters:
rectThe rect to compare with this.
Returns:
True if the dimensions are not equal; false if they are.
Rect WoopsiUI::Rect::operator& ( const Rect rect)

Overloaded & operator. Returns the intersect of this rectangle and the rectangle passed as the "rect" argument".

Parameters:
rectThe rectangle to intersect with this.
Returns:
The intersect of this rect with the argument.
Rect WoopsiUI::Rect::operator+ ( const Rect rect)

Overloaded + operator. Returns the smallest rectangle that can contain this rectangle and the rectangle passed as the "rect" argument.

Parameters:
rectThe rectangle to add to this.
Returns:
The smallest rect that contains this and the argument.
bool WoopsiUI::Rect::operator== ( const Rect rect)

Overloaded == operator. Checks if the dimensions of the supplied rect are the same as this rect.

Parameters:
rectThe rect to compare with this.
Returns:
True if the dimensions are equal; false if not.
void WoopsiUI::Rect::setHeight ( s32  height) [inline]

Set the rect's height.

Parameters:
heightThe new height.
void WoopsiUI::Rect::setWidth ( s32  width) [inline]

Set the rect's width.

Parameters:
widthThe new width.
void WoopsiUI::Rect::setX ( s16  x) [inline]

Set the rect's x co-ordinate.

Parameters:
xThe new x co-ordinate.
void WoopsiUI::Rect::setX2 ( s16  x2)

Set the x co-ordinate of the rect's bottom-right corner. If x2 is less than the rect's current x co-ordinate the method automatically adjusts the co-ords so that the rect's width is never negative. Changing this property will change the width of the rect.

Parameters:
x2The x co-ordinate of the rect's bottom-right corner.
void WoopsiUI::Rect::setY ( s16  y) [inline]

Set the rect's y co-ordinate.

Parameters:
yThe new y co-ordinate.
void WoopsiUI::Rect::setY2 ( s16  y2)

Set the y co-ordinate of the rect's bottom-right corner. If y2 is less than the rect's current y co-ordinate the method automatically adjusts the co-ords so that the rect's height is never negative. Changing this property will change the height of the rect.

Parameters:
y2The y co-ordinate of the rect's bottom-right corner.
bool WoopsiUI::Rect::splitIntersection ( const Rect rect,
Rect intersection,
WoopsiArray< Rect > *  remainderRects 
) const

Determines if the supplied rect intersects this and, if so, divides the supplied rect into the intersected region (stored in "intersection") and the rectangular regions that do not intersect (stored in "remainderRects").

Parameters:
rectRectangle to check for intersection.
intersectionWill contain the dimensions of the intersect once the function ends.
remainderRectsWill contain the list of non-intersecting regions of rect.
Returns:
True if there is an intersection; false if not.

Member Data Documentation

Height of the rectangle.

Width of the rectangle.

X co-ordinate of the rectangle.

Y co-ordinate of the rectangle.


The documentation for this class was generated from the following file:
 All Classes Functions Variables Enumerations Enumerator