Wt::SDLRect Class Reference

#include <sdlrect.h>

Inheritance diagram for Wt::SDLRect:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SDLRect ()
 Create an empty rectangle at (0, 0).
 SDLRect (int x, int y, int w, int h)
 Create a rectangle.
 SDLRect (const SDL_Rect &sdl_rect)
 Create a rectangle from a SDL_Rect.
void setRect (int x, int y, int w, int h)
 set's the rect's.
SDLRectoperator= (const SDL_Rect &r)
 assign operator
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 setLeft (int pos)
void setTop (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 * ()

Private Attributes

SDL_Rect sdl_rect

Detailed Description

Note:
don't change object size to keep SDL_Color compatibility. th means:

Definition at line 38 of file sdlrect.h.


Constructor & Destructor Documentation

Wt::SDLRect::SDLRect (  )  [inline]

Create an empty rectangle at (0, 0).

Definition at line 41 of file sdlrect.h.

References setRect().

00041               {
00042         assert(sizeof(SDLRect) == sizeof(SDL_Rect));
00043         setRect(0, 0, 0, 0);
00044     }

Here is the call graph for this function:

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

Create a rectangle.

Definition at line 47 of file sdlrect.h.

References setRect(), x(), and y().

00047                                         {
00048         assert(sizeof(SDLRect) == sizeof(SDL_Rect));
00049         setRect(x, y, w, h);
00050     }

Here is the call graph for this function:

Wt::SDLRect::SDLRect ( const SDL_Rect &  sdl_rect  )  [inline]

Create a rectangle from a SDL_Rect.

Definition at line 53 of file sdlrect.h.

00054             : sdl_rect(sdl_rect) {
00055         assert(sizeof(SDLRect) == sizeof(SDL_Rect));
00056     }


Member Function Documentation

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

Definition at line 98 of file sdlrect.h.

References sdl_rect.

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

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

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

Returns true if the rectangle contains r.

Definition at line 164 of file sdlrect.h.

References bottom(), left(), right(), and 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]

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

Definition at line 158 of file sdlrect.h.

References sdl_rect, x(), and 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:

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

Return the height of the rectangle.

Definition at line 77 of file sdlrect.h.

References sdl_rect.

Referenced by Wt::Rect::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(), Wt::Rect::isEmpty(), Wt::Rect::isValid(), Wt::Rect::operator<<(), Wt::operator<<(), Wt::Rect::operator>>(), Wt::Widget::setGeometry(), Wt::GridLayout::setGeometry(), Wt::CascadeLayout::setGeometry(), setHeight(), Wt::Rect::setLeft(), Wt::Rect::setRight(), Wt::Rect::setTop(), Wt::Rect::size(), and Wt::SDLDisplay::update().

00077                        {
00078         return sdl_rect.h;
00079     }

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

Returns true if the rectangle overlaps with r.

Definition at line 170 of file sdlrect.h.

References bottom(), left(), right(), and 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:

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

Definition at line 89 of file sdlrect.h.

References sdl_rect.

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

00089                      {
00090         return sdl_rect.x;
00091     }

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

move the rectangle by (dx, dy)

Definition at line 133 of file sdlrect.h.

References 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]

move the rectangle, specifying new upperleft corner

Definition at line 127 of file sdlrect.h.

References sdl_rect, x(), and y().

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

Here is the call graph for this function:

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

Definition at line 177 of file sdlrect.h.

References sdl_rect.

00177                                       {
00178         return sdl_rect;
00179     }

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

Definition at line 185 of file sdlrect.h.

References sdl_rect.

00185                                       {
00186         return &sdl_rect;
00187     }

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

Definition at line 181 of file sdlrect.h.

References sdl_rect.

00181                            {
00182         return sdl_rect;
00183     }

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

Definition at line 189 of file sdlrect.h.

References sdl_rect.

00189                           {
00190         return &sdl_rect;
00191     }

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

Compare two rectangles.

Definition at line 153 of file sdlrect.h.

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

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

assign operator

Definition at line 67 of file sdlrect.h.

References sdl_rect.

00067                                           {
00068         sdl_rect = r;
00069         return *this;
00070     }

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

Compare two rectangles for equality.

Definition at line 147 of file sdlrect.h.

References 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     }

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

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

Definition at line 139 of file sdlrect.h.

References sdl_rect.

Referenced by Wt::Rect::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]

Definition at line 95 of file sdlrect.h.

References sdl_rect.

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

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

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

Definition at line 122 of file sdlrect.h.

References height(), and 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::SDLRect::setLeft ( int  pos  )  [inline]

Reimplemented in Wt::Rect.

Definition at line 110 of file sdlrect.h.

References sdl_rect.

00110                           {
00111         sdl_rect.x = pos;
00112     }

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

set's the rect's.

Definition at line 59 of file sdlrect.h.

References sdl_rect, x(), and y().

Referenced by Wt::Region::calc_extents(), Wt::Rect::operator<<(), Wt::Rect::operator>>(), SDLRect(), Wt::Rect::setBottom(), Wt::Rect::setCoords(), Wt::Rect::setLeft(), Wt::Rect::setRight(), and Wt::Rect::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::SDLRect::setTop ( int  pos  )  [inline]

Reimplemented in Wt::Rect.

Definition at line 114 of file sdlrect.h.

References sdl_rect.

00114                          {
00115         sdl_rect.y = pos;
00116     }

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

Definition at line 118 of file sdlrect.h.

References sdl_rect, and 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]

Definition at line 102 of file sdlrect.h.

References 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]

Definition at line 106 of file sdlrect.h.

References sdl_rect.

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

00106                        {
00107         sdl_rect.y = pos;
00108     }

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

Definition at line 92 of file sdlrect.h.

References sdl_rect.

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

00092                     {
00093         return sdl_rect.y;
00094     }

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

Definition at line 72 of file sdlrect.h.

References sdl_rect.

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

00072                       {
00073         return sdl_rect.w;
00074     }

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

Definition at line 81 of file sdlrect.h.

References sdl_rect.

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

00081                   {
00082         return sdl_rect.x;
00083     }

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

Definition at line 85 of file sdlrect.h.

References sdl_rect.

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

00085                   {
00086         return sdl_rect.y;
00087     }


Member Data Documentation

SDL_Rect Wt::SDLRect::sdl_rect [private]

Definition at line 194 of file sdlrect.h.

Referenced by bottom(), contains(), height(), left(), moveBy(), moveTopLeft(), operator const SDL_Rect &(), operator const SDL_Rect *(), operator SDL_Rect &(), operator SDL_Rect *(), operator=(), operator==(), resize(), right(), setHeight(), setLeft(), setRect(), setTop(), setWidth(), setX(), setY(), top(), width(), x(), and y().


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

Generated Fri Jul 28 19:32:52 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.