Woopsi 1.0 GUI Framework for Nintendo DS Homebrew

- Main Page
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes

# WoopsiUI::Rect Class Reference

`#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:

  x | The x co-ordinate of the rect.
  y | The y co-ordinate of the rect.
  width | The width of the rect.
  height | The height of the rect.

WoopsiUI::Rect::Rect | ( | const Rect & | rect | ) |

Copy constructor.

Parameters:

  rect | Rect 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:

  x | X co-ord of the point.
  y | Y 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:

  dest | Destination 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:

  x1 | The x co-ordinate of the rect's top-left corner.
  y1 | The y co-ordinate of the rect's top-left corner.
  x2 | The x co-ordinate of the rect's bottom-right corner.
  y2 | The 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:

  rect | The rectangle to add to this.
  dest | The 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:

  rect | The rectangle to intersect with this.
  dest | The 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:

  rect | Rect 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:

  rect | The 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:

  rect | The 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:

  rect | The 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:

  rect | The 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:

  height | The new height.

void WoopsiUI::Rect::setWidth | ( | s32 | width | ) | `[inline]`

Set the rect's width.

Parameters:

  width | The new width.

void WoopsiUI::Rect::setX | ( | s16 | x | ) | `[inline]`

Set the rect's x co-ordinate.

Parameters:

  x | The 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:

  x2 | The 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:

  y | The 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:

  y2 | The 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:

  rect | Rectangle to check for intersection.
  intersection | Will contain the dimensions of the intersect once the function ends.
  remainderRects | Will contain the list of non-intersecting regions of rect.

Returns:
  True if there is an intersection; false if not.

## Member Data Documentation

s32 WoopsiUI::Rect::height

Height of the rectangle.

s32 WoopsiUI::Rect::width

Width of the rectangle.

s16 WoopsiUI::Rect::x

X co-ordinate of the rectangle.

s16 WoopsiUI::Rect::y

Y co-ordinate of the rectangle.

The documentation for this class was generated from the following file:

- rect.h