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

wftk::Rect Class Reference

Rectangle class. Has corners, fill, etc. More...

#include <rect.h>

List of all members.

Public Member Functions

 Rect ()
 Create an empty rectangle at (0, 0).
 Rect (int x_, int y_, int w_, int h_)
 Create a rectangle.
 Rect (const SDL_Rect &r)
 Copy a rectangle from an SDL_Rect.
bool isEmpty () const
 Returns true if the rectangle is empty.
bool isValid () const
 Returns true if the rectangle is valid (dimensions non-negative).
void setValid (bool val=true)
 Set the validity of the rectangle.
bool contains (const Point &p) const
 Returns true if the rectangle contains p.
bool contains (const Rect &r) const
 Returns true if the rectangle contains r.
void translate (int dx, int dy)
 move the rectangle by (dx, dy)
void translate (const Point &p)
 move the rectangle by p
void warp (const Point &newOrigin)
 move the rectangle, specifying new upperleft corner
void resize (int w_, int h_)
 this keeps the upper left corner and moves the lower right one
Rect unite (const Rect &r) const
 Return the smallest rectangle which contains both *this and r.
Rect intersect (const Rect &r) const
 Returns an invalid rectangle if *this and r don't intersect.
Point upperLeft () const
 Deprecated, use origin().
Point origin () const
 Return the upper left corner of the rectangle.
Uint16 width () const
 Return the width of the rectangle.
Uint16 height () const
 Return the height of the rectangle.

Static Public Attributes

static Rect invalid = Rect(0,0,-1,-1)
 An invalid rectangle.
static Rect empty = Rect(0,0,0,0)
 An empty (w == h == 0) rectangle.

Friends

bool operator== (const Rect &p, const Rect &q)
 Compare two rectangles for equality.
bool operator!= (const Rect &p, const Rect &q)
 Compare two rectangles.
bool operator< (const Rect &p, const Rect &q)
 binary predicate, for std::map only
std::ostream & operator<< (std::ostream &s, const Rect &p)
 Print a rectangle to a stream, formatted as (x,y,w,h).


Detailed Description

Rectangle class. Has corners, fill, etc.


The documentation for this class was generated from the following files:

Generated Tue Aug 9 18:40:27 2005.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.