Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

SDLmm::SRect Class Reference

This enhanced version of SDL_Rect includes a number of handy short-hand constructors. Since the class is derived from the SDL_Rect struct, it can be used in any context where an SDL_Rect is valid. More...

#include <sdlmm_srect.h>

Inheritance diagram for SDLmm::SRect::

SDL_Rect List of all members.

Public Methods

 SRect ()
 Default constructor which creates an empty SRect (xywh variables set to sero). More...

 SRect (const SRect &rect)
 This is the copy constructor. Simply initializes the value of an SRect to that of another SRect. More...

 SRect (const SDL_Rect &rect)
 Constructor which initializes the class from an SDL_Rect struct. More...

 SRect (const SPoint &point)
 Constructor which initializes the class from an SPoint object. More...

 SRect (const SPoint &upper_left_point, const SPoint &bottom_right_point)
 Construct an object using the given upper left and bottom right corners. More...

 SRect (const SPoint &point, Uint16 nw, Uint16 nh)
 Constructor which initializes the class from an SPoint object and integer values. More...

 SRect (Sint16 nx, Sint16 ny, Uint16 nw, Uint16 nh)
 Constructor which initializes the class from integer values. More...

 SRect (Uint16 nw, Uint16 nh)
 Constructor which initializes the width and height from integer values. More...

SRect& operator= (const SDL_Rect &rect)
 Set the value of an SRect to that of an existing SDL_Rect or SRect. More...

bool operator== (const SDL_Rect &rect) const
 Compare two rectangles for equality. More...

void Move (const SPoint &point)
 Move the position of the rectangle. More...

bool Contains (const SPoint &point) const
 Is the point in the rectangle? More...

SPoint GetUpperLeft () const
 Get the coordinates for the upper left corner of the SRect. More...

SPoint GetUpperRight () const
 Get the coordinates for the upper right corner of the SRect. More...

SPoint GetBottomLeft () const
 Get the coordinates for the bottom left corner of the SRect. More...

SPoint GetBottomRight () const
 Get the coordinates for the bottom right corner of the SRect. More...


Detailed Description

This enhanced version of SDL_Rect includes a number of handy short-hand constructors. Since the class is derived from the SDL_Rect struct, it can be used in any context where an SDL_Rect is valid.

Todo:
Extend the class with useful utility functions in regards to rectangles like intersections.
Author:
David Hedbor <david@hedbor.org>

Definition at line 43 of file sdlmm_srect.h.


Constructor & Destructor Documentation

SDLmm::SRect::SRect ( )
 

Default constructor which creates an empty SRect (xywh variables set to sero).

Definition at line 30 of file sdlmm_srect.cpp.

SDLmm::SRect::SRect ( const SRect & rect )
 

This is the copy constructor. Simply initializes the value of an SRect to that of another SRect.

Parameters:
rect   an existing SRect object.

Definition at line 34 of file sdlmm_srect.cpp.

SDLmm::SRect::SRect ( const SDL_Rect & rect )
 

Constructor which initializes the class from an SDL_Rect struct.

Parameters:
rect   an existing SDL_Rect struct.

Definition at line 39 of file sdlmm_srect.cpp.

SDLmm::SRect::SRect ( const SPoint & point )
 

Constructor which initializes the class from an SPoint object.

The x and y values will be initialized with the x/y values of the SPoint. h and w will be set to zero.

Parameters:
point   reference to an existing SPoint object.

Definition at line 53 of file sdlmm_srect.cpp.

SDLmm::SRect::SRect ( const SPoint & upper_left_point,
const SPoint & bottom_right_point )
 

Construct an object using the given upper left and bottom right corners.

Parameters:
upper_left_point   SPoint for the upper right corner of the rectangle
bottom_right_point   SPoint for the bottom right corner of the rectangle

Definition at line 62 of file sdlmm_srect.cpp.

SDLmm::SRect::SRect ( const SPoint & point,
Uint16 nw,
Uint16 nh )
 

Constructor which initializes the class from an SPoint object and integer values.

The x and y values will be initialized with the x/y values of the SPoint and the dimensions from nw and nh.

Parameters:
nw, nh   the width and height of the rectangle
point   reference to an existing SPoint object for the upper right corner.

Definition at line 57 of file sdlmm_srect.cpp.

SDLmm::SRect::SRect ( Sint16 nx,
Sint16 ny,
Uint16 nw,
Uint16 nh )
 

Constructor which initializes the class from integer values.

Parameters:
nx, ny   position of the upper left corner of the rectangle
nw, nh   the width and height of the rectangle

Definition at line 44 of file sdlmm_srect.cpp.

SDLmm::SRect::SRect ( Uint16 nw,
Uint16 nh )
 

Constructor which initializes the width and height from integer values.

The x/y coordinates for the upper left corner will be set to zero.

Parameters:
nw, nh   the width and height of the rectangle

Definition at line 48 of file sdlmm_srect.cpp.


Member Function Documentation

bool SDLmm::SRect::Contains ( const SPoint & point ) const [inline]
 

Is the point in the rectangle?

Definition at line 125 of file sdlmm_srect.h.

SPoint SDLmm::SRect::GetBottomLeft ( ) const [inline]
 

Get the coordinates for the bottom left corner of the SRect.

Returns:
SPoint object

Definition at line 138 of file sdlmm_srect.h.

SPoint SDLmm::SRect::GetBottomRight ( ) const [inline]
 

Get the coordinates for the bottom right corner of the SRect.

Returns:
SPoint object

Definition at line 141 of file sdlmm_srect.h.

SPoint SDLmm::SRect::GetUpperLeft ( ) const [inline]
 

Get the coordinates for the upper left corner of the SRect.

Returns:
SPoint object

Definition at line 132 of file sdlmm_srect.h.

SPoint SDLmm::SRect::GetUpperRight ( ) const [inline]
 

Get the coordinates for the upper right corner of the SRect.

Returns:
SPoint object

Definition at line 135 of file sdlmm_srect.h.

void SDLmm::SRect::Move ( const SPoint & point ) [inline]
 

Move the position of the rectangle.

Parameters:
point   difference to move by.

Definition at line 120 of file sdlmm_srect.h.

SRect & SDLmm::SRect::operator= ( const SDL_Rect & rect ) [inline]
 

Set the value of an SRect to that of an existing SDL_Rect or SRect.

Definition at line 100 of file sdlmm_srect.h.

bool SDLmm::SRect::operator== ( const SDL_Rect & rect ) const [inline]
 

Compare two rectangles for equality.

Returns:
true if x / y coordinates and h / w are identical in both rectangles.

Definition at line 111 of file sdlmm_srect.h.


The documentation for this class was generated from the following files:
Documentation automatically generated by doxygen written by Dimitri van Heesch. Project hosted at
Hosted by SourceForge