Wt::Rect Class Reference

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

#include <rect.h>

Inherits Wt::SDLRect.

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 Point &p, const Size &size)
 Rect (const SDLRect &sdlrect)
 Create a rectangle from a SDLRect.
Rectoperator= (const SDLRect &r)
 set's a rect from a SDLRect
 ~Rect ()
bool isEmpty () const
 Returns true if the rectangle is empty.
bool isValid () const
 Returns true if the rectangle is valid (dimensions non-negative).
bool contains (const Point &p) const
 Returns true if the rectangle contains p.
void moveTopLeft (const Point &p)
 move the rectangle, specifying new upperleft corner
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 topLeft () const
 Return the topleft corner of the rectangle.
Size size () const
 Return the width of the rectangle.
void setSize (const Size &size)
 set's the size of the rect.
void setCoords (int x1, int y1, int x2, int y2)
 set's the rect's.
Rect operator>> (int margin) const
 add a margin (smaller rectangle)
Rectoperator>> (int margin)
 add a margin (smaller rectangle)
Rect operator<< (int margin) const
 subtract a margin (bigger rectangle)
Rectoperator<< (int margin)
 subtract a margin (bigger rectangle)
void setLeft (int x1)
void setTop (int y1)
void setRight (int x2)
void setBottom (int y2)
bool clipLine (int &x1, int &y1, int &x2, int &y2) const
bool clipLine (Point &p1, Point &p2) const
Rect operator & (const Rect &other) const
Rectoperator &= (const Rect &other)

Static Public Member Functions

static Rect align (const Rect &container, const Size &size, int alignment)

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.

Protected Types

 Left = 1 << 0
 Right = 1 << 1
 Top = 1 << 2
 Bottom = 1 << 3
enum  BorderCross { Left = 1 << 0, Right = 1 << 1, Top = 1 << 2, Bottom = 1 << 3 }

Protected Member Functions

int borderCross (int x, int y) const


Detailed Description

Rectangle class. Has corners, fill, etc.


Member Enumeration Documentation

enum Wt::Rect::BorderCross [protected]

Enumerator:
Left 
Right 
Top 
Bottom 


Constructor & Destructor Documentation

Wt::Rect::Rect (  )  [inline]

Create an empty rectangle at (0, 0).

Wt::Rect::Rect ( int  x_,
int  y_,
int  w_,
int  h_ 
) [inline]

Create a rectangle.

Wt::Rect::Rect ( const Point p,
const Size size 
) [inline]

Wt::Rect::Rect ( const SDLRect sdlrect  )  [inline]

Create a rectangle from a SDLRect.

Wt::Rect::~Rect (  )  [inline]


Member Function Documentation

Rect Wt::Rect::align ( const Rect container,
const Size size,
int  alignment 
) [static]

int Wt::Rect::borderCross ( int  x,
int  y 
) const [protected]

bool Wt::Rect::clipLine ( Point p1,
Point p2 
) const

bool Wt::Rect::clipLine ( int &  x1,
int &  y1,
int &  x2,
int &  y2 
) const

bool Wt::Rect::contains ( const Point p  )  const [inline]

Returns true if the rectangle contains p.

Rect Wt::Rect::intersect ( const Rect r  )  const

Returns an invalid rectangle if *this and r don't intersect.

bool Wt::Rect::isEmpty (  )  const [inline]

Returns true if the rectangle is empty.

bool Wt::Rect::isValid (  )  const [inline]

Returns true if the rectangle is valid (dimensions non-negative).

void Wt::Rect::moveTopLeft ( const Point p  )  [inline]

move the rectangle, specifying new upperleft corner

Rect Wt::Rect::operator & ( const Rect other  )  const [inline]

Rect& Wt::Rect::operator &= ( const Rect other  )  [inline]

Rect& Wt::Rect::operator<< ( int  margin  )  [inline]

subtract a margin (bigger rectangle)

Rect Wt::Rect::operator<< ( int  margin  )  const [inline]

subtract a margin (bigger rectangle)

Rect& Wt::Rect::operator= ( const SDLRect r  )  [inline]

set's a rect from a SDLRect

Rect& Wt::Rect::operator>> ( int  margin  )  [inline]

add a margin (smaller rectangle)

Rect Wt::Rect::operator>> ( int  margin  )  const [inline]

add a margin (smaller rectangle)

void Wt::Rect::setBottom ( int  y2  )  [inline]

void Wt::Rect::setCoords ( int  x1,
int  y1,
int  x2,
int  y2 
) [inline]

set's the rect's.

void Wt::Rect::setLeft ( int  x1  )  [inline]

Reimplemented from Wt::SDLRect.

void Wt::Rect::setRight ( int  x2  )  [inline]

void Wt::Rect::setSize ( const Size size  )  [inline]

set's the size of the rect.

void Wt::Rect::setTop ( int  y1  )  [inline]

Reimplemented from Wt::SDLRect.

Size Wt::Rect::size (  )  const [inline]

Return the width of the rectangle.

Point Wt::Rect::topLeft (  )  const [inline]

Return the topleft corner of the rectangle.

Rect Wt::Rect::unite ( const Rect r  )  const

Return the smallest rectangle which contains both *this and r.


Member Data Documentation

Rect Wt::Rect::empty = Rect(0, 0, 0, 0) [static]

An empty (w == h == 0) rectangle.

Rect Wt::Rect::invalid = Rect(0, 0, -1, -1) [static]

An invalid rectangle.


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

Generated Fri Jul 28 19:22:38 2006.
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.