mx::Rect Struct Reference

#include <mxtype.h>

List of all members.

Public Member Functions

 Rect ()
 Rect (SDL_Rect &rc)
 Rect (SDL_Rect *rc)
 Rect (int x, int y, int width, int height)
 Rect (const Rect &r)
 Rect (const Point &p, const Size &s)
const int width () const
const int height () const
const int x () const
const int y () const
const bool pointInRect (Point p) const
 operator SDL_Rect ()

Public Attributes

Point point
Size rsize


Detailed Description

Rectangle structure, holds a Point and a Size, for x,y,width,height

Definition at line 63 of file mxtype.h.


Constructor & Destructor Documentation

mx::Rect::Rect (  )  [inline]

default constructor

Definition at line 69 of file mxtype.h.

00069 { }

mx::Rect::Rect ( SDL_Rect &  rc  )  [inline]

Constructor

Parameters:
rc takes a SDL_Rect and fills in point and rsize

Definition at line 73 of file mxtype.h.

00073 : point(rc.x, rc.y) , rsize(rc.w, rc.h) {}

mx::Rect::Rect ( SDL_Rect *  rc  )  [inline]

Constructor

Parameters:
rc takes a Pointer to a SDL_Rect and sets point and rsize

Definition at line 77 of file mxtype.h.

References point, and rsize.

00078                 {
00079                         if(rc == 0) return;
00080                         point = mx::Point(rc->x, rc->y);
00081                         rsize = mx::Size(rc->w, rc->h);
00082                 }

mx::Rect::Rect ( int  x,
int  y,
int  width,
int  height 
) [inline]

Constructor sets the rect from four integer's.

Parameters:
x x coordinate
y y coordinate
width width size
height height size

Definition at line 90 of file mxtype.h.

00090 : point(x,y), rsize(width, height) {}

mx::Rect::Rect ( const Rect r  )  [inline]

Copy constructor sets this Rect's values from another Rect

Parameters:
r Rectangle to set from

Definition at line 94 of file mxtype.h.

00094 : point(r.point), rsize(r.rsize)  {}

mx::Rect::Rect ( const Point p,
const Size s 
) [inline]

Constructor taking a Point and a Size

Parameters:
p Point for X,Y
s for Size width,height

Definition at line 99 of file mxtype.h.

00099 : point(p), rsize(s) {}


Member Function Documentation

const int mx::Rect::height (  )  const [inline]

height of the Rect

Returns:
returns height

Definition at line 108 of file mxtype.h.

References mx::Size::height, and rsize.

Referenced by mx::mxSurface::copySurface().

00108 { return rsize.height; }

mx::Rect::operator SDL_Rect (  )  [inline]

operator SDL_Rect so Rect can be used as a SDL_Rect in expressions

Returns:
returns SDL_Rect

Definition at line 130 of file mxtype.h.

References mx::Size::height, point, rsize, mx::Size::width, mx::Point::x, and mx::Point::y.

00130                                      {
00131                         SDL_Rect rc = { point.x, point.y, rsize.width, rsize.height };
00132                         return rc;
00133                 }

const bool mx::Rect::pointInRect ( Point  p  )  const [inline]

is this Point inside this Rect ?

Parameters:
p the Point
Returns:
true if it is, false if is not

Definition at line 122 of file mxtype.h.

References mx::Size::height, point, rsize, mx::Size::width, mx::Point::x, and mx::Point::y.

00123                 {
00124                         if(p.x >= point.x && p.x <= point.x+rsize.width && p.y >= point.y && p.y <= point.y+rsize.height) return true;
00125                         return false;
00126                 }

const int mx::Rect::width (  )  const [inline]

width of the Rect

Returns:
returns width

Definition at line 104 of file mxtype.h.

References rsize, and mx::Size::width.

Referenced by mx::mxSurface::copySurface().

00104 { return rsize.width; }

const int mx::Rect::x (  )  const [inline]

x of the Rect

Returns:
returns the x coordinate

Definition at line 112 of file mxtype.h.

References point, and mx::Point::x.

Referenced by mx::mxSurface::copySurface().

00112 { return point.x; }

const int mx::Rect::y (  )  const [inline]

y of the Rect

Returns:
returns the y coordinate

Definition at line 116 of file mxtype.h.

References point, and mx::Point::y.

Referenced by mx::mxSurface::copySurface().

00116 { return point.y; }


Member Data Documentation

Point variable for X,Y

Definition at line 65 of file mxtype.h.

Referenced by operator SDL_Rect(), pointInRect(), Rect(), x(), and y().

Size variable for size width,height

Definition at line 67 of file mxtype.h.

Referenced by height(), operator SDL_Rect(), pointInRect(), Rect(), and width().


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

Generated on Wed Jun 10 14:52:02 2009 for libmx by  doxygen 1.5.8