Wt::Rect Class Reference

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

#include <rect.h>

Inheritance diagram for Wt::Rect:

Inheritance graph
[legend]
Collaboration diagram for Wt::Rect:

Collaboration graph
[legend]
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)
void setRect (int x, int y, int w, int h)
 set's the rect's.
int width () const
int height () const
 Return the height of the rectangle.
int x () const
int y () const
int left () const
int top () const
int right () const
int bottom () const
void setX (int pos)
void setY (int pos)
void setWidth (int width)
void setHeight (int height)
void moveTopLeft (int x, int y)
 move the rectangle, specifying new upperleft corner
void moveBy (int dx, int dy)
 move the rectangle by (dx, dy)
void resize (int w, int h)
 this keeps the upper left corner and moves the lower right one
bool operator== (const SDLRect &other) const
 Compare two rectangles for equality.
bool operator!= (const SDLRect &other) const
 Compare two rectangles.
bool contains (int x, int y) const
 Returns true if the rectangle contains point (x, y).
bool contains (const SDLRect &r) const
 Returns true if the rectangle contains r.
bool intersects (const SDLRect &r) const
 Returns true if the rectangle overlaps with r.
 operator const SDL_Rect & () const
 operator SDL_Rect & ()
 operator const SDL_Rect * () const
 operator SDL_Rect * ()

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.

Definition at line 33 of file rect.h.


Member Enumeration Documentation

enum Wt::Rect::BorderCross [protected]

Enumerator:
Left 
Right 
Top 
Bottom 

Definition at line 163 of file rect.h.

00163                  {
00164         Left = 1 << 0,
00165         Right = 1 << 1,
00166         Top = 1 << 2,
00167         Bottom = 1 << 3
00168     } BorderCross;


Constructor & Destructor Documentation

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

Create an empty rectangle at (0, 0).

Definition at line 36 of file rect.h.

Referenced by align(), intersect(), operator<<(), operator=(), operator>>(), and unite().

00036            : SDLRect() {
00037         assert(sizeof(Rect) == sizeof(SDLRect));
00038     }

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

Create a rectangle.

Definition at line 40 of file rect.h.

00041             : SDLRect(x_, y_, w_, h_) {
00042         assert(sizeof(Rect) == sizeof(SDLRect));
00043     }

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

Definition at line 44 of file rect.h.

00045             : SDLRect(p.x(), p.y(), size.width(), size.height()) {
00046         assert(sizeof(Rect) == sizeof(SDLRect));
00047     }

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

Create a rectangle from a SDLRect.

Definition at line 49 of file rect.h.

00050             : SDLRect(sdlrect) {
00051         assert(sizeof(Rect) == sizeof(SDLRect));
00052     }

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

Definition at line 59 of file rect.h.

00059 {}


Member Function Documentation

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

Definition at line 131 of file rect.cpp.

References Wt::AlignAuto, Wt::AlignBottom, Wt::AlignCenter, Wt::AlignHCenter, Wt::AlignHorizontal_Mask, Wt::AlignJustify, Wt::AlignLeft, Wt::AlignRight, Wt::AlignTop, Wt::AlignVCenter, Wt::AlignVertical_Mask, Wt::Size::height(), Wt::SDLRect::height(), invalid, Rect(), size(), Wt::Size::width(), Wt::SDLRect::width(), Wt::SDLRect::x(), and Wt::SDLRect::y().

Referenced by Wt::PushButton::drawButtonLabel(), Wt::Label::drawContents(), Wt::Widget::erase(), Wt::BoxLayout::setGeometry(), Wt::GridLayout::setGeometry(), and Wt::CascadeLayout::setGeometry().

00131                                                                        {
00132     int xc = 0, yc = 0;
00133 
00134     if (alignment == AlignAuto)
00135         alignment = AlignCenter;
00136     else if (! (alignment & AlignHorizontal_Mask) )
00137         alignment |= AlignHCenter;
00138     else if (! (alignment & AlignVertical_Mask) )
00139         alignment |= AlignVCenter;
00140 
00141     switch (alignment & AlignHorizontal_Mask) {
00142     case AlignLeft:
00143         xc = container.x();
00144         break;
00145     case AlignRight:
00146         xc = container.x() + container.width() - size.width();
00147         break;
00148     case AlignHCenter:
00149         xc = container.x() + ((container.width() - size.width()) >> 1);
00150         break;
00151     case AlignJustify:
00152     default:
00153         //Error("Unimplemented Alignment flag %d\n", alignment);
00154         return invalid;
00155         break;
00156     }
00157 
00158     switch (alignment & AlignVertical_Mask) {
00159     case AlignTop:
00160         yc = container.y();
00161         break;
00162     case AlignBottom:
00163         yc = container.y() + container.height() - size.height();
00164         break;
00165     case AlignVCenter:
00166         yc = container.y() + ((container.height() - size.height()) >> 1);
00167         break;
00168     default:
00169         //Error("Unimplemented Alignment flag %d\n", alignment);
00170         return invalid;
00171         break;
00172     }
00173 
00174     return Rect(xc, yc, size.width(), size.height());
00175 }

Here is the call graph for this function:

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

Definition at line 63 of file rect.cpp.

References Bottom, Wt::SDLRect::bottom(), Left, Wt::SDLRect::left(), Right, Wt::SDLRect::right(), Top, Wt::SDLRect::top(), Wt::SDLRect::x(), and Wt::SDLRect::y().

Referenced by clipLine().

00063                                         {
00064     int border_cross = 0;
00065 
00066     border_cross |= (x < left()) ? Left : 0;
00067     border_cross |= (x > right()) ? Right : 0;
00068     border_cross |= (y < top()) ? Top : 0;
00069     border_cross |= (y > bottom()) ? Bottom : 0;
00070 
00071     return border_cross;
00072 }

Here is the call graph for this function:

int Wt::SDLRect::bottom (  )  const [inline, inherited]

Definition at line 98 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by borderCross(), Wt::Region::calc_extents(), clipLine(), Wt::SDLRect::contains(), Wt::Region::contains(), Wt::Painter::drawTiledPixmap(), intersect(), Wt::SDLRect::intersects(), Wt::CascadeLayout::setGeometry(), Wt::Region::unite(), and unite().

00098                        {
00099         return sdl_rect.y + sdl_rect.h - 1;
00100     }

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

Definition at line 118 of file rect.cpp.

References clipLine(), Wt::Point::setX(), Wt::Point::setY(), Wt::Point::x(), and Wt::Point::y().

00118                                               {
00119     int x1 = p1.x();
00120     int y1 = p1.y();
00121     int x2 = p2.x();
00122     int y2 = p2.y();
00123     bool clip = clipLine(x1, y1, x2, y2);
00124     p1.setX(x1);
00125     p1.setY(y1);
00126     p2.setX(x2);
00127     p2.setY(y2);
00128     return clip;
00129 }

Here is the call graph for this function:

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

Definition at line 74 of file rect.cpp.

References borderCross(), Wt::SDLRect::bottom(), Wt::SDLRect::left(), Left, Wt::SDLRect::right(), Right, Wt::SDLRect::top(), Top, Wt::SDLRect::x(), and Wt::SDLRect::y().

Referenced by clipLine(), and Wt::Painter::drawLine().

00074                                                             {
00075 
00076     int b1 = borderCross(x1, y1);
00077     int b2 = borderCross(x2, y2);
00078 
00079     while (b1 || b2) {
00080         int b;
00081         int x, y;
00082 
00083         if (b1 & b2) {
00084             // trivially reject
00085             return false;
00086         } else {
00087             b = (b1) ? b1 : b2;
00088         }
00089 
00090         if (b & Left) {
00091             x = left();
00092             y = y1 + (y2 - y1) * (x - x1) / (x2 - x1);
00093         } else if (b & Right) {
00094             x = right();
00095             y = y1 + (y2 - y1) * (x - x1) / (x2 - x1);
00096         } else if (b & Top) {
00097             y = top();
00098             x = x1 + (x2 - x1) * (y - y1) / (y2 - y1);
00099         } else { // if (b & Bottom) {
00100             y = bottom();
00101             x = x1 + (x2 - x1) * (y - y1) / (y2 - y1);
00102         }
00103 
00104         if (b == b1) {
00105             x1 = x;
00106             y1 = y;
00107             b1 = borderCross(x1, y1);
00108         } else {
00109             x2 = x;
00110             y2 = y;
00111             b2 = borderCross(x2, y2);
00112         }
00113     };
00114 
00115     return true;
00116 }

Here is the call graph for this function:

bool Wt::SDLRect::contains ( const SDLRect r  )  const [inline, inherited]

Returns true if the rectangle contains r.

Definition at line 164 of file sdlrect.h.

References Wt::SDLRect::bottom(), Wt::SDLRect::left(), Wt::SDLRect::right(), and Wt::SDLRect::top().

00164                                            {
00165         return left() <= r.left() && right() >= r.right() &&
00166                top() <= r.top() && bottom() >= r.bottom();
00167     }

Here is the call graph for this function:

bool Wt::SDLRect::contains ( int  x,
int  y 
) const [inline, inherited]

Returns true if the rectangle contains point (x, y).

Definition at line 158 of file sdlrect.h.

References Wt::SDLRect::sdl_rect, Wt::SDLRect::x(), and Wt::SDLRect::y().

00158                                       {
00159         return y >= sdl_rect.y && y < sdl_rect.y + sdl_rect.h
00160                && x >= sdl_rect.x && x < sdl_rect.x + sdl_rect.w;
00161     }

Here is the call graph for this function:

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

Returns true if the rectangle contains p.

Definition at line 76 of file rect.h.

References Wt::Point::x(), and Wt::Point::y().

Referenced by Wt::Widget::childAt(), Wt::Region::contains(), Wt::Painter::isClipped(), Wt::Window::Frame::mousePressEvent(), and Wt::Region::unite().

00076                                         {
00077         return contains(p.x(), p.y());
00078     }

Here is the call graph for this function:

int Wt::SDLRect::height (  )  const [inline, inherited]

Return the height of the rectangle.

Definition at line 77 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by align(), Wt::PixmapOf< Wt::SDLSurface >::blend(), Wt::PixmapOf< Wt::SDLSurface >::blitAlphaBlend(), Wt::PixmapOf< Wt::SDLSurface >::copy(), Wt::Painter::drawRect(), Wt::Painter::drawTiledPixmap(), Wt::Widget::height(), isEmpty(), isValid(), operator<<(), Wt::operator<<(), operator>>(), Wt::Widget::setGeometry(), Wt::GridLayout::setGeometry(), Wt::CascadeLayout::setGeometry(), Wt::SDLRect::setHeight(), setLeft(), setRight(), setTop(), size(), and Wt::SDLDisplay::update().

00077                        {
00078         return sdl_rect.h;
00079     }

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

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

Definition at line 48 of file rect.cpp.

References Wt::SDLRect::bottom(), invalid, isValid(), Wt::SDLRect::left(), Rect(), Wt::SDLRect::right(), and Wt::SDLRect::top().

Referenced by Wt::PixmapOf< Wt::SDLSurface >::blend(), Wt::PixmapOf< Wt::SDLSurface >::blitAlphaBlend(), operator &(), and operator &=().

00048                                         {
00049     if(!isValid() || !r.isValid())
00050         return invalid;
00051 
00052     int min_x = std::max(left(), r.left());
00053     int min_y = std::max(top(), r.top());
00054     int max_x = std::min(right(), r.right()) + 1;
00055     int max_y = std::min(bottom(), r.bottom()) + 1;
00056 
00057     if(min_x > max_x || min_y > max_y)
00058         return invalid;
00059 
00060     return Rect(min_x, min_y, max_x - min_x, max_y - min_y);
00061 }

Here is the call graph for this function:

bool Wt::SDLRect::intersects ( const SDLRect r  )  const [inline, inherited]

Returns true if the rectangle overlaps with r.

Definition at line 170 of file sdlrect.h.

References Wt::SDLRect::bottom(), Wt::SDLRect::left(), Wt::SDLRect::right(), and Wt::SDLRect::top().

Referenced by Wt::Region::contains(), Wt::Region::intersect(), and Wt::Region::subtract().

00170                                              {
00171         return (right() >= r.left() &&
00172                 left() <= r.right() &&
00173                 bottom() >= r.top() &&
00174                 top() <= r.bottom());
00175     }

Here is the call graph for this function:

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

Returns true if the rectangle is empty.

Definition at line 66 of file rect.h.

References Wt::SDLRect::height(), and Wt::SDLRect::width().

Referenced by Wt::PixmapOf< Wt::SDLSurface >::blend().

00066                          {
00067         return width() == 0 && height() == 0;
00068     }

Here is the call graph for this function:

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

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

Definition at line 70 of file rect.h.

References Wt::SDLRect::height(), and Wt::SDLRect::width().

Referenced by Wt::Region::calc_extents(), intersect(), and unite().

00070                          {
00071         return (width() > 0 && height() > 0);
00072     }

Here is the call graph for this function:

int Wt::SDLRect::left (  )  const [inline, inherited]

Definition at line 89 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by borderCross(), Wt::Region::calc_extents(), clipLine(), Wt::SDLRect::contains(), Wt::Region::contains(), Wt::Painter::drawRect(), Wt::Painter::drawTiledPixmap(), Wt::Widget::erase(), intersect(), Wt::SDLRect::intersects(), Wt::Widget::setGeometry(), Wt::CascadeLayout::setGeometry(), Wt::Region::unite(), and unite().

00089                      {
00090         return sdl_rect.x;
00091     }

void Wt::SDLRect::moveBy ( int  dx,
int  dy 
) [inline, inherited]

move the rectangle by (dx, dy)

Definition at line 133 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by Wt::Region::translate().

00133                                 {
00134         sdl_rect.x += dx;
00135         sdl_rect.y += dy;
00136     }

void Wt::SDLRect::moveTopLeft ( int  x,
int  y 
) [inline, inherited]

move the rectangle, specifying new upperleft corner

Definition at line 127 of file sdlrect.h.

References Wt::SDLRect::sdl_rect, Wt::SDLRect::x(), and Wt::SDLRect::y().

00127                                    {
00128         sdl_rect.x = x;
00129         sdl_rect.y = y;
00130     }

Here is the call graph for this function:

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

move the rectangle, specifying new upperleft corner

Definition at line 82 of file rect.h.

References Wt::Point::x(), and Wt::Point::y().

Referenced by Wt::Widget::move().

00082                                      {
00083         moveTopLeft(p.x(), p.y());
00084     }

Here is the call graph for this function:

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

Definition at line 151 of file rect.h.

References intersect().

00151                                             {
00152         return intersect(other);
00153     };

Here is the call graph for this function:

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

Definition at line 155 of file rect.h.

References intersect().

00155                                         {
00156         *this = intersect(other);
00157         return *this;
00158     };

Here is the call graph for this function:

Wt::SDLRect::operator const SDL_Rect & (  )  const [inline, inherited]

Definition at line 177 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

00177                                       {
00178         return sdl_rect;
00179     }

Wt::SDLRect::operator const SDL_Rect * (  )  const [inline, inherited]

Definition at line 185 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

00185                                       {
00186         return &sdl_rect;
00187     }

Wt::SDLRect::operator SDL_Rect & (  )  [inline, inherited]

Definition at line 181 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

00181                            {
00182         return sdl_rect;
00183     }

Wt::SDLRect::operator SDL_Rect * (  )  [inline, inherited]

Definition at line 189 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

00189                           {
00190         return &sdl_rect;
00191     }

bool Wt::SDLRect::operator!= ( const SDLRect other  )  const [inline, inherited]

Compare two rectangles.

Definition at line 153 of file sdlrect.h.

00153                                                 {
00154         return !(*this == other);
00155     }

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

subtract a margin (bigger rectangle)

Definition at line 129 of file rect.h.

References Wt::SDLRect::height(), Wt::SDLRect::setRect(), Wt::SDLRect::width(), Wt::SDLRect::x(), and Wt::SDLRect::y().

00129                                  {
00130         setRect(x() - margin, y() - margin,
00131                 width() + 2 * margin, height() + 2 * margin);
00132         return *this;
00133     }

Here is the call graph for this function:

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

subtract a margin (bigger rectangle)

Definition at line 123 of file rect.h.

References Wt::SDLRect::height(), Rect(), Wt::SDLRect::width(), Wt::SDLRect::x(), and Wt::SDLRect::y().

00123                                       {
00124         return Rect(x() - margin, y() - margin,
00125                     width() + 2 * margin, height() + 2 * margin);
00126     }

Here is the call graph for this function:

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

set's a rect from a SDLRect

Definition at line 54 of file rect.h.

References Rect().

00054                                       {
00055         *this = Rect(r);
00056         return *this;
00057     }

Here is the call graph for this function:

bool Wt::SDLRect::operator== ( const SDLRect other  )  const [inline, inherited]

Compare two rectangles for equality.

Definition at line 147 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

00147                                                 {
00148         return sdl_rect.x == other.sdl_rect.x && sdl_rect.y == other.sdl_rect.y
00149                && sdl_rect.w == other.sdl_rect.w && sdl_rect.h == other.sdl_rect.h;
00150     }

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

add a margin (smaller rectangle)

Definition at line 116 of file rect.h.

References Wt::SDLRect::height(), Wt::SDLRect::setRect(), Wt::SDLRect::width(), Wt::SDLRect::x(), and Wt::SDLRect::y().

00116                                  {
00117         setRect(x() + margin, y() + margin,
00118                 width() - 2 * margin, height() - 2 * margin);
00119         return *this;
00120     }

Here is the call graph for this function:

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

add a margin (smaller rectangle)

Definition at line 110 of file rect.h.

References Wt::SDLRect::height(), Rect(), Wt::SDLRect::width(), Wt::SDLRect::x(), and Wt::SDLRect::y().

00110                                       {
00111         return Rect(x() + margin, y() + margin,
00112                     width() - 2 * margin, height() - 2 * margin);
00113     }

Here is the call graph for this function:

void Wt::SDLRect::resize ( int  w,
int  h 
) [inline, inherited]

this keeps the upper left corner and moves the lower right one

Definition at line 139 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by setSize().

00139                               {
00140         if(w >= 0 && h >= 0) {
00141             sdl_rect.w = w;
00142             sdl_rect.h = h;
00143         }
00144     }

int Wt::SDLRect::right (  )  const [inline, inherited]

Definition at line 95 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by borderCross(), Wt::Region::calc_extents(), clipLine(), Wt::SDLRect::contains(), Wt::Region::contains(), Wt::Painter::drawTiledPixmap(), intersect(), Wt::SDLRect::intersects(), Wt::CascadeLayout::setGeometry(), Wt::Region::unite(), and unite().

00095                       {
00096         return sdl_rect.x + sdl_rect.w - 1;
00097     }

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

Definition at line 144 of file rect.h.

References Wt::SDLRect::setRect(), Wt::SDLRect::width(), Wt::SDLRect::x(), and Wt::SDLRect::y().

00144                            {
00145         setRect(x(), y(), width(), y2 - y() + 1);
00146     }

Here is the call graph for this function:

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

set's the rect's.

Definition at line 105 of file rect.h.

References Wt::SDLRect::setRect().

Referenced by Wt::Region::calc_extents(), and Wt::Region::unite().

00105                                                    {
00106         setRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
00107     }

Here is the call graph for this function:

void Wt::SDLRect::setHeight ( int  height  )  [inline, inherited]

Definition at line 122 of file sdlrect.h.

References Wt::SDLRect::height(), and Wt::SDLRect::sdl_rect.

Referenced by Wt::Label::drawContents(), and Wt::Painter::drawTiledPixmap().

00122                                {
00123         sdl_rect.h = height;
00124     }

Here is the call graph for this function:

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

Reimplemented from Wt::SDLRect.

Definition at line 135 of file rect.h.

References Wt::SDLRect::height(), Wt::SDLRect::setRect(), Wt::SDLRect::width(), Wt::SDLRect::x(), and Wt::SDLRect::y().

00135                          {
00136         setRect(x1, y(), x() - x1 + width(), height());
00137     }

Here is the call graph for this function:

void Wt::SDLRect::setRect ( int  x,
int  y,
int  w,
int  h 
) [inline, inherited]

set's the rect's.

Definition at line 59 of file sdlrect.h.

References Wt::SDLRect::sdl_rect, Wt::SDLRect::x(), and Wt::SDLRect::y().

Referenced by Wt::Region::calc_extents(), operator<<(), operator>>(), Wt::SDLRect::SDLRect(), setBottom(), setCoords(), setLeft(), setRight(), and setTop().

00059                                              {
00060         sdl_rect.x = x;
00061         sdl_rect.y = y;
00062         sdl_rect.w = (w> 0) ? w: 0;
00063         sdl_rect.h = (h> 0) ? h: 0;
00064     }

Here is the call graph for this function:

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

Definition at line 141 of file rect.h.

References Wt::SDLRect::height(), Wt::SDLRect::setRect(), Wt::SDLRect::x(), and Wt::SDLRect::y().

00141                           {
00142         setRect(x(), y(), x2 - x() + 1, height());
00143     }

Here is the call graph for this function:

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

set's the size of the rect.

Definition at line 101 of file rect.h.

References Wt::Size::height(), Wt::SDLRect::resize(), size(), and Wt::Size::width().

Referenced by Wt::Widget::resize(), and Wt::Layout::setGeometry().

00101                                    {
00102         resize(size.width(), size.height());
00103     }

Here is the call graph for this function:

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

Reimplemented from Wt::SDLRect.

Definition at line 138 of file rect.h.

References Wt::SDLRect::height(), Wt::SDLRect::setRect(), Wt::SDLRect::width(), Wt::SDLRect::x(), and Wt::SDLRect::y().

00138                         {
00139         setRect(x(), y1, width(), y() - y1 + height());
00140     }

Here is the call graph for this function:

void Wt::SDLRect::setWidth ( int  width  )  [inline, inherited]

Definition at line 118 of file sdlrect.h.

References Wt::SDLRect::sdl_rect, and Wt::SDLRect::width().

Referenced by Wt::Label::drawContents(), and Wt::Painter::drawTiledPixmap().

00118                              {
00119         sdl_rect.w = width;
00120     }

Here is the call graph for this function:

void Wt::SDLRect::setX ( int  pos  )  [inline, inherited]

Definition at line 102 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by Wt::Label::drawContents(), and Wt::Painter::drawTiledPixmap().

00102                        {
00103         sdl_rect.x = pos;
00104     }

void Wt::SDLRect::setY ( int  pos  )  [inline, inherited]

Definition at line 106 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by Wt::Label::drawContents(), and Wt::Painter::drawTiledPixmap().

00106                        {
00107         sdl_rect.y = pos;
00108     }

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

Return the width of the rectangle.

Definition at line 97 of file rect.h.

References Wt::SDLRect::height(), and Wt::SDLRect::width().

Referenced by align(), Wt::Painter::drawPixmap(), Wt::Window::frameSize(), Wt::Layout::setGeometry(), setSize(), and Wt::Widget::size().

00097                       {
00098         return Size(width(), height());
00099     }

Here is the call graph for this function:

int Wt::SDLRect::top (  )  const [inline, inherited]

Definition at line 92 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by borderCross(), Wt::Region::calc_extents(), clipLine(), Wt::SDLRect::contains(), Wt::Painter::drawRect(), Wt::Painter::drawTiledPixmap(), Wt::Widget::erase(), intersect(), Wt::SDLRect::intersects(), Wt::Region::regionOp(), Wt::Widget::setGeometry(), Wt::CascadeLayout::setGeometry(), Wt::Region::unite(), and unite().

00092                     {
00093         return sdl_rect.y;
00094     }

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

Return the topleft corner of the rectangle.

Definition at line 92 of file rect.h.

References Wt::SDLRect::x(), and Wt::SDLRect::y().

Referenced by Wt::Label::drawContents(), Wt::Painter::drawPixmap(), Wt::Painter::drawTiledPixmap(), Wt::Widget::mapFromGlobal(), Wt::Widget::mapFromParent(), Wt::Widget::mapToGlobal(), Wt::Widget::mapToParent(), Wt::Window::Frame::mousePressEvent(), and Wt::Window::pos().

00092                           {
00093         return Point(x(), y());
00094     }

Here is the call graph for this function:

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

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

Definition at line 30 of file rect.cpp.

References Wt::SDLRect::bottom(), invalid, isValid(), Wt::SDLRect::left(), Rect(), Wt::SDLRect::right(), and Wt::SDLRect::top().

00030                                     {
00031     if(!isValid() || !r.isValid())
00032         return invalid;
00033 
00034     int min_x = std::min(left(), r.left());
00035     int min_y = std::min(top(), r.top());
00036     int max_x = std::max(right(), r.right()) + 1;
00037     int max_y = std::max(bottom(), r.bottom()) + 1;
00038 
00039     assert(min_x <= max_x);
00040     assert(min_y <= max_y);
00041 
00042     return Rect(min_x, min_y, max_x - min_x, max_y - min_y);
00043 }

Here is the call graph for this function:

int Wt::SDLRect::width (  )  const [inline, inherited]

Definition at line 72 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by align(), Wt::PixmapOf< Wt::SDLSurface >::blend(), Wt::PixmapOf< Wt::SDLSurface >::blitAlphaBlend(), Wt::PixmapOf< Wt::SDLSurface >::copy(), Wt::Painter::drawRect(), Wt::Painter::drawTiledPixmap(), isEmpty(), isValid(), operator<<(), Wt::operator<<(), operator>>(), setBottom(), Wt::Widget::setGeometry(), Wt::GridLayout::setGeometry(), Wt::CascadeLayout::setGeometry(), setLeft(), setTop(), Wt::SDLRect::setWidth(), size(), Wt::SDLDisplay::update(), and Wt::Widget::width().

00072                       {
00073         return sdl_rect.w;
00074     }

int Wt::SDLRect::x (  )  const [inline, inherited]

Definition at line 81 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by align(), Wt::PixmapOf< Wt::SDLSurface >::blend(), Wt::PixmapOf< Wt::SDLSurface >::blitAlphaBlend(), borderCross(), clipLine(), Wt::SDLRect::contains(), Wt::Region::contains(), Wt::PushButton::drawButtonLabel(), Wt::SDLRect::moveTopLeft(), operator<<(), Wt::operator<<(), operator>>(), Wt::SDLRect::SDLRect(), setBottom(), Wt::GridLayout::setGeometry(), setLeft(), Wt::SDLRect::setRect(), setRight(), setTop(), topLeft(), Wt::SDLDisplay::update(), and Wt::Window::x().

00081                   {
00082         return sdl_rect.x;
00083     }

int Wt::SDLRect::y (  )  const [inline, inherited]

Definition at line 85 of file sdlrect.h.

References Wt::SDLRect::sdl_rect.

Referenced by align(), Wt::PixmapOf< Wt::SDLSurface >::blend(), Wt::PixmapOf< Wt::SDLSurface >::blitAlphaBlend(), borderCross(), clipLine(), Wt::SDLRect::contains(), Wt::Region::contains(), Wt::PushButton::drawButtonLabel(), Wt::SDLRect::moveTopLeft(), operator<<(), Wt::operator<<(), operator>>(), Wt::SDLRect::SDLRect(), setBottom(), Wt::GridLayout::setGeometry(), setLeft(), Wt::SDLRect::setRect(), setRight(), setTop(), topLeft(), Wt::SDLDisplay::update(), and Wt::Window::y().

00085                   {
00086         return sdl_rect.y;
00087     }


Member Data Documentation

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

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

Definition at line 64 of file rect.h.

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

An invalid rectangle.

Definition at line 62 of file rect.h.

Referenced by align(), intersect(), and unite().


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

Generated Fri Jul 28 19:31:21 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.