Crazy Eddie's GUI System  0.8.7
CEGUI::Rect< T > Class Template Reference

Class encapsulating operations on a Rectangle. More...

+ Inheritance diagram for CEGUI::Rect< T >:
+ Collaboration diagram for CEGUI::Rect< T >:

Public Types

typedef T value_type
 

Public Member Functions

 Rect (const T &left, const T &top, const T &right, const T &bottom)
 
 Rect (const Vector2< T > &min, const Vector2< T > &max)
 
 Rect (const Vector2< T > &pos, const Size< T > &size)
 
 Rect (const Rect &r)
 
Rectoperator= (const Rect &rhs)
 
void left (const T &v)
 
const T & left () const
 
void top (const T &v)
 
const T & top () const
 
void right (const T &v)
 
const T & right () const
 
void bottom (const T &v)
 
const T & bottom () const
 
void setPosition (const Vector2< T > &min)
 set the position of the Rect (leaves size in tact)
 
const Vector2< T > & getPosition () const
 Return top-left position of Rect as a Vector2<T>
 
void setSize (const Size< T > &size)
 
Size< T > getSize () const
 return the size of the Rect area
 
void setWidth (const T &w)
 
getWidth () const
 return width of Rect area
 
void setHeight (const T &h)
 
getHeight () const
 return height of Rect area
 
Rect getIntersection (const Rect &rect) const
 return a Rect that is the intersection of 'this' Rect with the Rect 'rect' More...
 
void offset (const Vector2< T > &v)
 Applies an offset the Rect object. More...
 
bool isPointInRect (const Vector2< T > &v) const
 Return true if the given Vector2 falls within this Rect. More...
 
void constrainSizeMax (const Size< T > &size)
 check the size of the Rect object and if it is bigger than sz, resize it so it isn't. More...
 
void constrainSizeMin (const Size< T > &size)
 check the size of the Rect object and if it is smaller than sz, resize it so it isn't. More...
 
void constrainSize (const Size< T > &max_sz, const Size< T > &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. More...
 
bool operator== (const Rect &rhs) const
 
bool operator!= (const Rect &rhs) const
 
Rect operator* (T scalar) const
 
const Rectoperator*= (T scalar)
 
Rect operator+ (const Rect &r) const
 

Static Public Member Functions

static Rect zero ()
 finger saving alias for zero sized, zero positioned rect
 

Public Attributes

Vector2< T > d_min
 
Vector2< T > d_max
 

Friends

std::ostream & operator<< (std::ostream &s, const Rect &v)
 

Detailed Description

template<typename T>
class CEGUI::Rect< T >

Class encapsulating operations on a Rectangle.

Member Function Documentation

template<typename T>
void CEGUI::Rect< T >::constrainSize ( const Size< T > &  max_sz,
const Size< T > &  min_sz 
)
inline

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
template<typename T>
void CEGUI::Rect< T >::constrainSizeMax ( const Size< T > &  size)
inline

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
template<typename T>
void CEGUI::Rect< T >::constrainSizeMin ( const Size< T > &  size)
inline

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
template<typename T>
Rect CEGUI::Rect< T >::getIntersection ( const Rect< T > &  rect) const
inline

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'.
template<typename T>
bool CEGUI::Rect< T >::isPointInRect ( const Vector2< T > &  v) const
inline

Return true if the given Vector2 falls within this Rect.

Parameters
ptVector2 object describing the position to test.
Returns
true if position pt is within this Rect's area, else false
template<typename T>
void CEGUI::Rect< T >::offset ( const Vector2< T > &  v)
inline

Applies an offset the Rect object.

Parameters
ptVector2 object containing the offsets to be applied to the Rect.
Returns
this Rect after the offset is performed