Public Member Functions | Public Attributes
GUI::Rect Class Reference

Class encapsulating operations on a Rectangle. More...

List of all members.

Public Member Functions

Point getPosition ()
 Return top-left postion of Rect as a Point.
float getWidth ()
 return width of Rect area
float getHeight ()
 return height of Rect area
Size getSize ()
 return the size of the Rect area
void setPosition (Point pt)
 set the position of the Rect (leaves size in tact)
void setWidth (float width)
 set the width of the Rect object
void setHeight (float height)
 set the height of the Rect object
void setSize (Size sze)
 set the size of the Rect area
Rect getIntersection (Rect rect)
 return a Rect that is the intersection of 'this' Rect with the Rect 'rect'
Rect offset (Point pt)
 Applies an offset the Rect object.
bool isPointInRect (Point pt)
 Return true if the given Point falls within this Rect.
Rect constrainSizeMax (Size sz)
 check the size of the Rect object and if it is bigger than sz, resize it so it isn't.
Rect constrainSizeMin (Size sz)
 check the size of the Rect object and if it is smaller than sz, resize it so it isn't.
Rect constrainSize (Size max_sz, Size min_sz)
 check the size of the Rect object and if it is bigger than max_sz or smaller than min_sz, resize it so it isn't.
bool operator= (const Rect &rhs)

Public Attributes

float top
float bottom
float left
float right

Detailed Description

Class encapsulating operations on a Rectangle.


Member Function Documentation

Rect GUI::Rect::getIntersection ( Rect  rect)

return a Rect that is the intersection of 'this' Rect with the Rect 'rect'

Note:
It can be assumed that if d_left == d_right, or d_top == d_bottom, or getWidth() == 0, or getHeight() == 0, then 'this' rect was totally outside 'rect'.
Rect GUI::Rect::offset ( Point  pt)

Applies an offset the Rect object.

Parameters:
ptPoint object containing the offsets to be applied to the Rect.
Returns:
this Rect after the offset is performed
bool GUI::Rect::isPointInRect ( Point  pt)

Return true if the given Point falls within this Rect.

Parameters:
ptPoint object describing the position to test.
Returns:
true if position pt is within this Rect's area, else false
Rect GUI::Rect::constrainSizeMax ( Size  sz)

check the size of the Rect object and if it is bigger than sz, resize it so it isn't.

Parameters:
szSize object that describes the maximum dimensions that this Rect should be limited to.
Returns:
'this' Rect object after the constrain operation
Rect GUI::Rect::constrainSizeMin ( Size  sz)

check the size of the Rect object and if it is smaller than sz, resize it so it isn't.

Parameters:
szSize object that describes the minimum dimensions that this Rect should be limited to.
Returns:
'this' Rect object after the constrain operation
Rect GUI::Rect::constrainSize ( Size  max_sz,
Size  min_sz 
)

check the size of the Rect object and if it is bigger than max_sz or smaller than min_sz, resize it so it isn't.

Parameters:
max_szSize object that describes the maximum dimensions that this Rect should be limited to.
min_szSize object that describes the minimum dimensions that this Rect should be limited to.
Returns:
'this' Rect object after the constrain operation