Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_Rect Class Reference

A class for representing a rect using floating point coordinates. More...

List of all members.

Public Member Functions

Constructor / Destructor
 CP_Rect ()
 Constructor.
 CP_Rect (float infLeftCoord, float infTopCoord, float infRightCoord, float infBottomCoord)
 CP_Rect (const CP_Point &inLocation, const CP_Size &inSize)
 CP_Rect (const CP_Rect &inRect)
virtual ~CP_Rect ()
 Destructor.
Getters
float Left () const
float Top () const
float Right () const
float Bottom () const
float Width () const
float Height () const
float MinX () const
float MaxX () const
float MinY () const
float MaxY () const
float CenterX () const
float CenterY () const
CP_Point Center () const
Operators
CP_Rectoperator= (const CP_Rect &inFloatRect)
Setters
void Set (float infLeft, float infTop, float infRight, float infBottom)
void Set (const CP_Point &inTopLeft, const CP_Size &inSize)
void SetWidth (float inWidth)
void SetHeight (float inHeight)
void SetLeft (float inLeft)
void SetTop (float inTop)
void SetRight (float inRight)
void SetBottom (float inBottom)
Comparers
bool operator== (const CP_Rect &inRect) const
bool operator!= (const CP_Rect &inRect) const
Math
CP_Rectoperator+= (CP_Rect &inRect)
CP_Rectoperator-= (CP_Rect &inRect)
CP_Rectoperator *= (CP_Rect &inRect)
CP_Rectoperator/= (CP_Rect &inRect)
CP_Rect operator+ (CP_Rect &inRect) const
CP_Rect operator- (CP_Rect &inRect) const
CP_Rect operator * (CP_Rect &inRect) const
CP_Rect operator/ (CP_Rect &inRect) const
CP_Rectoperator+= (CP_Point &inPoint)
CP_Rectoperator-= (CP_Point &inPoint)
CP_Rectoperator *= (CP_Point &inPoint)
CP_Rectoperator/= (CP_Point &inPoint)
CP_Rect operator+ (CP_Point &inPoint) const
CP_Rect operator- (CP_Point &inPoint) const
CP_Rect operator * (CP_Point &inPoint) const
CP_Rect operator/ (CP_Point &inPoint) const
Movement
void Offset (float horAmt, float verAmt)
void Offset (const CP_Point &amt)
Sizers
void Expand (float horAmt, float verAmt)
void Expand (const CP_Rect &inAmount)
void Expand (const CP_Point &inAmount)
void Inset (float horAmt, float verAmt)
void Inset (const CP_Rect &inAmount)
void Inset (const CP_Point &inAmount)
Testers
bool IsEmpty () const
bool IsValid () const
bool Contains (const CP_Rect &inRect)
bool Contains (const CP_Point &inPoint)
Utility
void MakeEmpty ()
void MakeValid ()
CP_Point TopLeft () const
CP_Point BottomRight () const
CP_Point TopRight () const
CP_Point BottomLeft () const
CP_Size Size () const
bool Intersects (const CP_Rect &inRect)
CP_Rect Intersect (const CP_Rect &inRect) const
Constructor / Destructor
 CP_Rect (Rect inRect)
 Constructor.
Converters
 operator const Rect () const
 operator Rect * ()
 operator const Rect * () const
CP_Rectoperator= (Rect inRect)
void Set (Rect inRect)
Constructor / Destructor
 CP_Rect (RECT *inRect)
 Constructor.
Converters
 operator RECT * ()
 operator const RECT * () const
 operator const RECT () const
void Get (RECT &inOutRect)
void Set (RECT &inRect)

Protected Attributes

float fLeft
float fTop
float fRight
float fBottom


Detailed Description

This class is used to express all rectangles in CPLAT.


Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_Rect::CP_Rect  ) 
 

Constructor. This creates a rect with all coordinates at 0.

Exceptions:
none 

CP_Rect::CP_Rect float  infLeftCoord,
float  infTopCoord,
float  infRightCoord,
float  infBottomCoord
 

Constructor. This constructs the rect from the passed in floating point coordinates.

Parameters:
infLeftCoord fLeft as a floating point.
infTopCoord fTop as a floating point.
infRightCoord fRight as a floating point.
infBottomCoord fBottom as a floating point.
Exceptions:
none 

CP_Rect::CP_Rect const CP_Point inLocation,
const CP_Size inSize
 

Constructor. This constructs the rect from the passed in CP_Point and CP_Size.

Parameters:
infTopfLeft CP_Point specifing the fTop fLeft corner.
inSize CP_Size specifing the width and height.
Exceptions:
none 

CP_Rect::CP_Rect const CP_Rect inFloatRect  ) 
 

Copy constructor. Copies the coordinates from the passed in inFloatRect to this object.

Parameters:
inFloatRect Float rect to copy coordinates from.
Exceptions:
none 

CP_Rect::~CP_Rect  )  [virtual]
 

Destructor.

CP_Rect::CP_Rect Rect  inRect  ) 
 

bottom coordinate.

CP_Rect::CP_Rect RECT *  inRect  ) 
 

Windows - Constructor. Constructs this object from the passed in RECT.

Parameters:
inRect RECT to copy coordinates from.
Exceptions:
none 


Member Function Documentation

float CP_Rect::Left  )  const
 

Return the fLeft coordinate.

Exceptions:
none 
Returns:
float const Left coordinate

float CP_Rect::Top  )  const
 

Return the fTop coordinate.

Exceptions:
none 
Returns:
float const Top coordinate

float CP_Rect::Right  )  const
 

Return the fRight coordinate.

Exceptions:
none 
Returns:
float const Right coordinate

float CP_Rect::Bottom  )  const
 

Return the fBottom coordinate.

Exceptions:
none 
Returns:
float const Bottom coordinate

float CP_Rect::Width  )  const
 

Return the width of this rectangle.

Exceptions:
none 
Returns:
float const Width of rectangle.

float CP_Rect::Height  )  const
 

Return the height of this rectangle.

Exceptions:
none 
Returns:
float const Height of rectangle.

float CP_Rect::MinX  )  const
 

Returns the minimum horizontal dimenstion.

Exceptions:
none 
Returns:
float const The minimum of the left or right dimension.

float CP_Rect::MaxX  )  const
 

Returns the maximum horizontal dimenstion.

Exceptions:
none 
Returns:
float const The maximum of the left or right dimension.

float CP_Rect::MinY  )  const
 

Returns the minimum vertical dimenstion.

Exceptions:
none 
Returns:
float const The minimum of the top or bottom dimension.

float CP_Rect::MaxY  )  const
 

Returns the maximum vertical dimenstion.

Exceptions:
none 
Returns:
float const The maximum of the top or bottom dimension.

float CP_Rect::CenterX  )  const
 

Returns the horizontal center of this rect.

Exceptions:
none 
Returns:
float const The horizontal center.

float CP_Rect::CenterY  )  const
 

Returns the vertical center of this rect.

Exceptions:
none 
Returns:
float const The vertical center.

CP_Point CP_Rect::Center  )  const
 

Returns the center of this rect as a point.

Exceptions:
none 
Returns:
CP_Point const The center point of this rect.

CP_Rect & CP_Rect::operator= const CP_Rect inRect  ) 
 

Assignment operator. Sets the coordinates of this object to those of the passed in inRect.

Parameters:
inFloatRect Float rect to copy coordinates from.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourself.

void CP_Rect::Set float  inLeft,
float  inTop,
float  inRight,
float  inBottom
 

Sets the bounds of this rect from the passed in coordinates.

Parameters:
inLeft Left coordinate of this rect.
inTop Top coordinate of this rect.
inRight Right coordinate of this rect.
inBottom Bottom coordinate of this rect.
Exceptions:
none 
Returns:
void

void CP_Rect::Set const CP_Point inLocation,
const CP_Size inSize
 

Sets the coordinates of this rect from the passed in CP_Point and CP_Size.

Parameters:
inLocation CP_Point specifing the topCoord leftCoord corner.
inSize CP_Size specifing the width and height.
Exceptions:
none 
Returns:
void

void CP_Rect::SetWidth float  inWidth  ) 
 

Sets the width of the rect to the passed in width. The left dimension remains the same.

Parameters:
inWidth The width to make this rect.
Exceptions:
none 
Returns:
void

void CP_Rect::SetHeight float  inHeight  ) 
 

Sets the height of the rect to the passed in height. The top dimension remains the same.

Parameters:
inWidth The height to make this rect.
Exceptions:
none 
Returns:
void

void CP_Rect::SetLeft float  inLeft  ) 
 

Sets the left coordinates from the passed in float.

Parameters:
inLeft coordinate for the left side.
Exceptions:
none 
Returns:
void

void CP_Rect::SetTop float  inTop  ) 
 

Sets the top coordinates from the passed in float.

Parameters:
inTop coordinate for the top side.
Exceptions:
none 
Returns:
void

void CP_Rect::SetRight float  inRight  ) 
 

Sets the right coordinates from the passed in float.

Parameters:
inRight coordinate for the right side.
Exceptions:
none 
Returns:
void

void CP_Rect::SetBottom float  inBottom  ) 
 

Sets the bottom coordinates from the passed in float.

Parameters:
inBottom coordinate for the bottom side.
Exceptions:
none 
Returns:
void

bool CP_Rect::operator== const CP_Rect inRect  )  const
 

Equality operator. Return true if all 4 coordinates are the same as the passed in inRect.

Parameters:
inRect CP_Rect to compare against.
Exceptions:
none 
Returns:
bool const Returns true if all of the coordinates are the same.

bool CP_Rect::operator!= const CP_Rect inRect  )  const
 

Inequality operator. Return true if any of the 4 coordinates are the not the same as the passed in inRect.

Parameters:
inRect CP_Rect to compare against.
Exceptions:
none 
Returns:
bool const Returns true if any of the coordinates are not the same as the passed in rect.

CP_Rect & CP_Rect::operator+= CP_Rect inRect  ) 
 

Plus equal operator. Add the coordinates from the passeed in inRect to these coordinates.

Parameters:
inRect CP_Rect to add coordinates from.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect & CP_Rect::operator-= CP_Rect inRect  ) 
 

Minus equal operator. Subtract the coordinates from the passeed in inRect to these coordinates.

Parameters:
inRect CP_Rect to subtract coordinates from.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect & CP_Rect::operator *= CP_Rect inRect  ) 
 

Times equal operator. Multiply the coordinates from the passeed in inRect to these coordinates.

Parameters:
inRect CP_Rect to multiply coordinates by.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect & CP_Rect::operator/= CP_Rect inRect  ) 
 

Divide equal operator. Divide the coordinates from the passeed in inRect to these coordinates.

Parameters:
inRect CP_Rect to divide coordinates by.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect CP_Rect::operator+ CP_Rect inRect  )  const
 

Addition operator. Add the coordinates from the passeed in inRect to these coordinates.

Parameters:
inRect CP_Rect to add coordinates by.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect CP_Rect::operator- CP_Rect inRect  )  const
 

Minus operator. Subtract the coordinates from the passeed in inRect to these coordinates.

Parameters:
inRect CP_Rect to subtract coordinates by.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect CP_Rect::operator * CP_Rect inRect  )  const
 

Times operator. Multiply the coordinates from the passeed in inRect to these coordinates.

Parameters:
inRect CP_Rect to multiply coordinates by.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect CP_Rect::operator/ CP_Rect inRect  )  const
 

Divide operator. Divide the coordinates from the passeed in inRect to these coordinates.

Parameters:
inRect CP_Rect to divide coordinates by.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect & CP_Rect::operator+= CP_Point inPoint  ) 
 

Plus equal operator. Add the coordinates from the passeed in inPoint to these coordinates.

Parameters:
inPoint CP_Point to add against.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect & CP_Rect::operator-= CP_Point inPoint  ) 
 

Minus equal operator. Subtract the coordinates from the passeed in inPoint to these coordinates.

Parameters:
inPoint CP_Point to subtract against.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect & CP_Rect::operator *= CP_Point inPoint  ) 
 

Times equal operator. Multiply the coordinates from the passeed in inPoint to these coordinates.

Parameters:
inPoint CP_Point to multiple against.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect & CP_Rect::operator/= CP_Point inPoint  ) 
 

Divide equal operator. Divide the coordinates from the passeed in inPoint to these coordinates.

Parameters:
inPoint CP_Point to divide against.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect CP_Rect::operator+ CP_Point inPoint  )  const
 

Plus operator. Add the coordinates from the passeed in inPoint to these coordinates.

Parameters:
inPoint CP_Point to add against.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect CP_Rect::operator- CP_Point inPoint  )  const
 

Minus operator. Subtract the coordinates from the passeed in inPoint to these coordinates.

Parameters:
inPoint CP_Point to subtract against.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect CP_Rect::operator * CP_Point inPoint  )  const
 

Multiply operator. Multiply the coordinates from the passeed in inPoint to these coordinates.

Parameters:
inPoint CP_Point to multiple against.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

CP_Rect CP_Rect::operator/ CP_Point inPoint  )  const
 

Divide operator. Divide the coordinates from the passeed in inPoint to these coordinates.

Parameters:
inPoint CP_Point to divide against.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

void CP_Rect::Offset float  inHorAmount,
float  inVerAmount
 

Offset this rect by the passed in horinAmount and verinAmount.

Parameters:
inHorAmount Horizontal distance to move by.
inVerAmount Vertical distance to move by.
Exceptions:
none 
Returns:
void

void CP_Rect::Offset const CP_Point inAmount  ) 
 

Offset this rect by the passed in inAmount.

Parameters:
inAmount Distance to move by.
Exceptions:
none 
Returns:
void

void CP_Rect::Expand float  inHorAmount,
float  inVerAmount
 

Expand this rectangle by the passed in inHorAmount and inVerAmount.

Parameters:
inHorAmount Horizontal distance to move by.
inVerAmount Vertical distance to move by.
Exceptions:
none 
Returns:
void

void CP_Rect::Expand const CP_Rect inAmount  ) 
 

Expand this rectangle by the passed in amount contained in the CP_Rect inAmount. If the coordinates are negative, then the rect will be inset.

Parameters:
inAmount Distance to expand by.
Exceptions:
none 
Returns:
void

void CP_Rect::Expand const CP_Point inAmount  ) 
 

Expands this rect by the distance passed in the CP_Point. If the point contains negative numbers, then this rect is shrunk.

Parameters:
inAmount distance to expand this rect by.
Exceptions:
none 
Returns:
void

void CP_Rect::Inset float  inHorAmount,
float  inVerAmount
 

Inset (shrink) this rectangle by the passed in horinAmount and verinAmount.

Parameters:
inHorAmount Horizontal distance to shrink by.
inVerAmount Vertical distance to shrink by.
Exceptions:
none 
Returns:
void

void CP_Rect::Inset const CP_Rect inAmount  ) 
 

Inset (shrink) this rectangle by the passed in amount contained in the CP_Rect.

Parameters:
inAmount Distance to shrink by.
Exceptions:
none 
Returns:
oid

void CP_Rect::Inset const CP_Point inAmount  ) 
 

Inset (shrink) this rectangle by the passed in amount contained in the CP_Point.

Parameters:
inAmount Distance to shrink by.
Exceptions:
none 
Returns:
void

bool CP_Rect::IsEmpty  )  const
 

Return true if this rectangle is empty. All 4 coordinates equal 0.

Exceptions:
none 
Returns:
bool const Returns true if all 4 coordinates are 0.

bool CP_Rect::IsValid  )  const
 

Return true if this rectangles coordinates are valid. A valid rectangle is one where the left coordinate is less than or equal to the right. And the top is less than or equal to the bottom.

Exceptions:
none 
Returns:
bool const Returns true if this is a valid rect.

bool CP_Rect::Contains const CP_Rect inRect  ) 
 

Return true if this rectangle completely contains the passed in inRect. If the coordinates are equal, it is considered contained.

Exceptions:
none 
Returns:
bool const Returns true if the rect is totally contained.

bool CP_Rect::Contains const CP_Point inPoint  ) 
 

Return true if this rect contains the passed in point. If the coordinates are equal, it is considered contained.

Exceptions:
none 
Returns:
bool const Returns true if the point is totally contained.

void CP_Rect::MakeEmpty  ) 
 

Make the rectangle empty by setting all coordinates to 0.

Exceptions:
none 
Returns:
void

void CP_Rect::MakeValid  ) 
 

If this rectangle is invalid, then switch the coordinates to make sure it is valid. A valid rect is one where the left edge is less than or equal to the right coordinate. And the top is less than or equal to the bottom.

Exceptions:
none 
Returns:
void

CP_Point CP_Rect::TopLeft  )  const
 

Returns the top left points of the rect as a CP_Point.

Exceptions:
none 
Returns:
CP_Point Contains the top left corner of this rect.

CP_Point CP_Rect::BottomRight  )  const
 

Returns the bottom right points of the rect as a CP_Point.

Exceptions:
none 
Returns:
CP_Point Contains the bottom right corner of this rect.

CP_Point CP_Rect::TopRight  )  const
 

Returns the top right points of the rect as a CP_Point.

Exceptions:
none 
Returns:
CP_Point Contains the top right corner of this rect.

CP_Point CP_Rect::BottomLeft  )  const
 

Returns the bottom left points of the rect as a CP_Point.

Exceptions:
none 
Returns:
CP_Point Contains the bottom left corner of this rect.

CP_Size CP_Rect::Size  )  const
 

bool CP_Rect::Intersects const CP_Rect inRect  ) 
 

Set this rectangle to the intersection of these coordinates and the passed in inRect, return true if the result is a valid rectangle.

Parameters:
inRect CP_Rect to intersect with.
Exceptions:
none 
Returns:
bool The result rect is a valid rect.

CP_Rect CP_Rect::Intersect const CP_Rect inRect  )  const
 

Returns a CP_Rect object that is the intersection of this rect and the passed in rect.

Parameters:
inRect CP_Rect to intersect with.
Exceptions:
none 
Returns:
CP_Rect const The resulting intersection rect.

CP_Rect::operator const Rect  )  const
 

MacOS - operator Rect returns the coordinates of this object as a MacOS Rect. Const version.

Exceptions:
none 
Returns:
Rect const Rect with the coordinates from this object.

CP_Rect::operator Rect *  ) 
 

MacOS - operator Rect * returns the coordinates of this object as a MacOS Rect *.

Exceptions:
none 
Returns:
Rect * Rect with the coordinates from this object.

CP_Rect::operator const Rect *  )  const
 

MacOS - operator Rect * returns the coordinates of this object as a MacOS Rect *. Const version.

Exceptions:
none 
Returns:
Rect * const Rect with the coordinates from this object.

CP_Rect & CP_Rect::operator= Rect  inRect  ) 
 

MacOS - Assignment operator. Assigns the values to this object from the pssed in MacOS Rect.

Parameters:
inRect MacOS Rect with the coordinates from this object.
Exceptions:
none 
Returns:
CP_Rect& Returns a reference to ourselves.

void CP_Rect::Set Rect  inRect  ) 
 

MacOS - Constructor. Constructs this object from the passed in HIRect.

Parameters:
inRect Rect to copy coordinates from.
Exceptions:
none 

CP_Rect::operator RECT *  ) 
 

Windows - operator RECT * to return a Windows RECT * object that contains the coordinates of this rect.

Exceptions:
none 
Returns:
RECT * Windows RECT *.

CP_Rect::operator const RECT *  )  const
 

Windows - operator RECT * to return a Windows RECT * object that contains the coordinates of this rect.

Exceptions:
none 
Returns:
RECT * const Windows RECT *.

CP_Rect::operator const RECT  )  const
 

Windows - operator RECT to return a Windows RECT object that contains the coordinates of this rect.

Exceptions:
none 
Returns:
RECT const Windows RECT.

void CP_Rect::Get RECT &  inOutRect  ) 
 

Windows - Returns a Windows RECT in the passed in parameter.

Parameters:
inOutRect RECT to copy coordinates to.
Exceptions:
none 
Returns:
void

void CP_Rect::Set RECT &  inRect  ) 
 

Windows - Sets the coordines from the passed in Windows RECT.

Parameters:
inRect RECT to copy coordinates from.
Exceptions:
none 
Returns:
void


Member Data Documentation

float CP_Rect::fLeft [protected]
 

float CP_Rect::fTop [protected]
 

left coordinate.

float CP_Rect::fRight [protected]
 

top coordinate.

float CP_Rect::fBottom [protected]
 

right coordinate.


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:02:05 2005 for CPLAT by  doxygen 1.4.0