Wt::Painter Class Reference

class that allows drawing graphics primitives onto a Pixmap More...

#include <painter.h>

Collaboration diagram for Wt::Painter:

Collaboration graph
[legend]
List of all members.

Public Types

 CopyROP
 OrROP
 dst = src
 AndROP
 dst = src | dst
 XorROP
 dst = src ^ dst
enum  RasterOp { CopyROP, OrROP, AndROP, XorROP }

Public Member Functions

 Painter (const Pixmap *pixmap=0, bool clipping=true)
 constructor - binds this Painter to the pixmap
 ~Painter ()
bool begin (const Pixmap *pixmap, bool clipping=true)
bool begin ()
bool end ()
Pixmappixmap () const
bool isActive () const
const Fontfont () const
void setFont (const Font &font)
const Penpen () const
void setPen (const Pen &pen)
const Brushbrush () const
void setBrush (const Brush &brush)
const ColorbackgroundColor () const
void setBackgroundColor (const Color &color)
void save ()
void restore ()
void flush ()
RasterOp rasterOp () const
void setRasterOp (RasterOp raster_op)
void setClipping (bool enable)
bool clipping () const
bool hasClipping () const
void drawPoint (int x, int y)
void drawPoint (const Point &p)
void drawPoints (const PointArray &points, int start=0, int end=-1)
void drawHorizontalLine (int x1, int x2, int y)
void drawVerticalLine (int x, int y1, int y2)
void drawLine (int x1, int y1, int x2, int y2)
void drawLine (const Point &p1, const Point &p2)
void fillRect (const Rect &r, const Brush &brush)
void fillRect (int x, int y, int w, int h, const Brush &brush)
void fillRegion (const Region &r, const Brush &brush)
void blendRect (const Rect &r, const Brush &brush)
void blendRect (int x, int y, int w, int h, const Brush &brush)
void blendRegion (const Region &r, const Brush &brush)
void eraseRect (const Rect &r)
void eraseRect (int x, int y, int w, int h)
void eraseRegion (const Region &r)
void drawRect (int x, int y, int w, int h)
void drawRect (const Rect &r)
void drawLineSegments (const PointArray &points, int start=0, int end=-1)
void drawPolyline (const PointArray &points, int start=0, int end=-1)
void drawPolygon (const PointArray &points, int start=0, int end=-1)
void drawPixmap (const Point &p, const Pixmap &src, const Rect &sr)
void drawPixmap (const Point &p, const Pixmap &src)
void drawPixmap (int x, int y, const Pixmap &src, int sx=0, int sy=0, int sw=-1, int sh=-1)
void drawPixmap (const Rect &r, const Pixmap &src)
void drawTiledPixmap (const Rect &r, const Pixmap &src, const Point &sp)
void drawTiledPixmap (const Rect &r, const Pixmap &src)
void drawTiledPixmap (int x, int y, int w, int h, const Pixmap &src, int sx=0, int sy=0)
void drawText (int x, int y, const std::string &text, int len=-1)
void drawText (const Point &p, const std::string &text, int len=-1)
void drawText (int x, int y, const std::string &text, int pos, int len)
void drawText (const Point &p, const std::string &text, int pos, int len)
Rect boundingRect (const std::string &text, int pos=0, int len=-1)

Protected Member Functions

bool isClipped (int x, int y) const
bool isClipped (const Point &p) const
void rop (int pixeladdr, int pixel)

Private Attributes

bool active_
Pixmappixmap_
std::stack< Statestate_stack
State state

Classes

class  State

Detailed Description

class that allows drawing graphics primitives onto a Pixmap

Definition at line 95 of file painter.h.


Member Enumeration Documentation

enum Wt::Painter::RasterOp

Enumerator:
CopyROP 
OrROP  dst = src
AndROP  dst = src | dst
XorROP  dst = src ^ dst

Definition at line 156 of file painter.h.

00156                  {
00157         CopyROP,    /// dst = src
00158         OrROP,      /// dst = src | dst
00159         AndROP,     /// dst = src & dst
00160         XorROP      /// dst = src ^ dst
00161     } RasterOp;


Constructor & Destructor Documentation

Wt::Painter::Painter ( const Pixmap pixmap = 0,
bool  clipping = true 
)

constructor - binds this Painter to the pixmap

Definition at line 34 of file painter.cpp.

References begin(), and pixmap_.

00034                                                     :
00035         active_(false),
00036 pixmap_(const_cast<Pixmap *>(pixmap)) {
00037     begin(pixmap_, clipping);
00038 }

Here is the call graph for this function:

Wt::Painter::~Painter (  ) 

Definition at line 40 of file painter.cpp.

References end().

00040                   {
00041     end();
00042 }

Here is the call graph for this function:


Member Function Documentation

const Color& Wt::Painter::backgroundColor (  )  const [inline]

Definition at line 135 of file painter.h.

References Wt::Painter::State::bg_color, and state.

Referenced by Wt::Widget::backgroundColor(), and Wt::Widget::setBackgroundColor().

00135                                          {
00136         return state.bg_color;
00137     }

bool Wt::Painter::begin (  ) 

Definition at line 57 of file painter.cpp.

References pixmap_.

Referenced by Painter().

00057                     {
00058     return begin(pixmap_);
00059 }

bool Wt::Painter::begin ( const Pixmap pixmap,
bool  clipping = true 
)

Definition at line 44 of file painter.cpp.

References active_, pixmap(), pixmap_, and setClipping().

Referenced by Wt::Widget::erase(), and Wt::Widget::paintEvent().

00044                                                        {
00045     bool status = false;
00046     if (!active_) {
00047         pixmap_ = const_cast<Pixmap *>(pixmap);
00048         if (pixmap_ && *pixmap_) {
00049             setClipping(clipping);
00050             active_ = true;
00051             status = true;
00052         }
00053     }
00054     return status;
00055 }

Here is the call graph for this function:

void Wt::Painter::blendRect ( int  x,
int  y,
int  w,
int  h,
const Brush brush 
)

Definition at line 310 of file painter.cpp.

References blendRect(), and brush().

00310                                                                       {
00311     blendRect(Rect(x, y, w, h), brush);
00312 }

Here is the call graph for this function:

void Wt::Painter::blendRect ( const Rect r,
const Brush brush 
)

Definition at line 303 of file painter.cpp.

References Wt::PixmapOf< SDLPixmap >::blend(), brush(), Wt::Brush::color(), Wt::Brush::NoBrush, pixmap_, and Wt::Brush::style().

Referenced by blendRect(), and Wt::PushButton::drawButton().

00303                                                          {
00304     if (brush.style() == Brush::NoBrush)
00305         return;
00306 
00307     pixmap_->blend(r, brush.color());
00308 }

Here is the call graph for this function:

void Wt::Painter::blendRegion ( const Region r,
const Brush brush 
)

Definition at line 314 of file painter.cpp.

References Wt::PixmapOf< SDLPixmap >::blend(), brush(), Wt::Brush::color(), Wt::Brush::NoBrush, pixmap_, and Wt::Brush::style().

00314                                                              {
00315     if (brush.style() == Brush::NoBrush)
00316         return;
00317 
00318     pixmap_->blend(r, brush.color());
00319 }

Here is the call graph for this function:

Rect Wt::Painter::boundingRect ( const std::string &  text,
int  pos = 0,
int  len = -1 
)

Definition at line 468 of file painter.cpp.

References Wt::Font::boundingRect(), Wt::Painter::State::font, and state.

00468                                                                   {
00469     len = (len - 1) ? text.length() : len;
00470     return state.font.boundingRect(text.substr(pos, len));
00471 }

Here is the call graph for this function:

const Brush& Wt::Painter::brush (  )  const [inline]

Definition at line 127 of file painter.h.

References Wt::Painter::State::brush, and state.

Referenced by blendRect(), blendRegion(), fillRect(), fillRegion(), and setBrush().

00127                                 {
00128         return state.brush;
00129     }

bool Wt::Painter::clipping (  )  const [inline]

Definition at line 175 of file painter.h.

References Wt::Painter::State::clipping, and state.

Referenced by hasClipping().

00175                           {
00176         return state.clipping;
00177     }

void Wt::Painter::drawHorizontalLine ( int  x1,
int  x2,
int  y 
)

Definition at line 143 of file painter.cpp.

References Wt::Painter::State::clipping, Wt::Pen::color(), isActive(), Wt::Painter::State::pen, pixmap_, rop(), and state.

Referenced by Wt::Frame::drawFrame(), drawLine(), and drawRect().

00143                                                       {
00144     if(!isActive() || y < 0 || y >= pixmap_->height())
00145         return;
00146 
00147     int w = pixmap_->width();
00148 
00149     if (state.clipping) {
00150         x1 = std::max(0, x1);
00151         x1 = std::min(x1, w - 1);
00152         x2 = std::max(0, x2);
00153         x2 = std::min(x2, w - 1);
00154     }
00155 
00156     if (x1 > x2)
00157         std::swap(x1, x2);
00158 
00159     int pixel = pixmap_->pixelFormat().mapToPixelValue(state.pen.color());
00160     int pixel_offset = pixmap_->pixelOffset(x1, y);
00161     int skip = pixmap_->pixelFormat().bytesPerPixel();
00162 
00163     pixmap_->lock()
00164     ;
00165     while(x1 <= x2) {
00166         rop(pixel_offset, pixel);
00167         x1++;
00168         pixel_offset += skip;
00169     }
00170     pixmap_->unlock();
00171 
00172 }

Here is the call graph for this function:

void Wt::Painter::drawLine ( const Point p1,
const Point p2 
)

Definition at line 281 of file painter.cpp.

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

00281                                                        {
00282     drawLine(p1.x(), p1.y(), p2.x(), p2.y());
00283 }

Here is the call graph for this function:

void Wt::Painter::drawLine ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 204 of file painter.cpp.

References Wt::Rect::clipLine(), Wt::Painter::State::clipping, Wt::Pen::color(), drawHorizontalLine(), drawVerticalLine(), isActive(), Wt::Painter::State::pen, pixmap_, Wt::PixmapOf< SDLPixmap >::rect(), rop(), and state.

Referenced by drawLine(), drawLineSegments(), drawPolygon(), and drawPolyline().

00204                                                      {
00205     if(!isActive())
00206         return;
00207 
00208     int dx, dy, sdx, sdy, x, y, px, py;
00209 
00210     dx = x2 - x1;
00211     dy = y2 - y1;
00212 
00213     //check if we may optimize to either vLine or hLine ...
00214     if(dx == 0) {
00215         //this is a vertical line, call vLine and return
00216         drawVerticalLine(x1, y1, y2);
00217         return;
00218     }
00219     if(dy == 0) {
00220         //this is a horizontal line, call hLine and return
00221         drawHorizontalLine(x1, x2, y1);
00222         return;
00223     }
00224 
00225     // if clipping is enabled x1, y1, x2, y2 are the clipped values
00226     if (state.clipping && !pixmap_->rect().clipLine(x1, y1, x2, y2)) {
00227         dx = x2 - x1;
00228         dy = y2 - y1;
00229         return;
00230     }
00231 
00232     // here comes the hard job ... bresenham:
00233 
00234     sdx = (dx < 0) ? -1 : 1;
00235     sdy = (dy < 0) ? -1 : 1;
00236 
00237     dx = sdx * dx + 1;
00238     dy = sdy * dy + 1;
00239 
00240     x = y = 0;
00241 
00242     px = x1;
00243     py = y1;
00244 
00245     // map the color to the appropriate bit pattern to write ...
00246     int pixel = pixmap_->pixelFormat().mapToPixelValue(state.pen.color());
00247     int pixel_offset;
00248 
00249     /// \todo the calculation of the pixel_offset could be reduced to addings ...
00250     /// no multiplies are needed in fact
00251     pixmap_->lock()
00252     ;
00253     if (dx >= dy) {
00254         for (x = 0; x < dx; x++) {
00255             pixel_offset = pixmap_->pixelOffset(px, py);
00256             rop(pixel_offset, pixel);
00257 
00258             y += dy;
00259             if (y >= dx) {
00260                 y -= dx;
00261                 py += sdy;
00262             }
00263             px += sdx;
00264         }
00265     } else {
00266         for (y = 0; y < dy; y++) {
00267             pixel_offset = pixmap_->pixelOffset(px, py);
00268             rop(pixel_offset, pixel);
00269 
00270             x += dx;
00271             if (x >= dy) {
00272                 x -= dy;
00273                 px += sdx;
00274             }
00275             py += sdy;
00276         }
00277     }
00278     pixmap_->unlock();
00279 }

Here is the call graph for this function:

void Wt::Painter::drawLineSegments ( const PointArray points,
int  start = 0,
int  end = -1 
)

Definition at line 351 of file painter.cpp.

References drawLine(), and end().

00351                                                                            {
00352     int i;
00353     end = (end > 0) ? end : points.size();
00354 
00355     for (i = start; i < end - 1; i += 2) {
00356         drawLine(points[i], points[i + 1]);
00357     }
00358 }

Here is the call graph for this function:

void Wt::Painter::drawPixmap ( const Rect r,
const Pixmap src 
)

Definition at line 394 of file painter.cpp.

References Wt::PixmapOf< SDLPixmap >::blit(), pixmap_, Wt::PixmapOf< SDLPixmap >::scale(), Wt::Rect::size(), and Wt::Rect::topLeft().

00394                                                          {
00395     pixmap_->blit(r.topLeft(), src.scale(r.size()));
00396 }

Here is the call graph for this function:

void Wt::Painter::drawPixmap ( int  x,
int  y,
const Pixmap src,
int  sx = 0,
int  sy = 0,
int  sw = -1,
int  sh = -1 
)

Definition at line 390 of file painter.cpp.

References Wt::PixmapOf< SDLPixmap >::blit(), and pixmap_.

00390                                                                                         {
00391     pixmap_->blit(x, y, src, Rect(sx, sy, sw, sh));
00392 }

Here is the call graph for this function:

void Wt::Painter::drawPixmap ( const Point p,
const Pixmap src 
)

Definition at line 386 of file painter.cpp.

References Wt::PixmapOf< SDLPixmap >::blit(), pixmap_, Wt::Point::x(), and Wt::Point::y().

00386                                                           {
00387     pixmap_->blit(p.x(), p.y(), src);
00388 }

Here is the call graph for this function:

void Wt::Painter::drawPixmap ( const Point p,
const Pixmap src,
const Rect sr 
)

Definition at line 382 of file painter.cpp.

References Wt::PixmapOf< SDLPixmap >::blit(), and pixmap_.

Referenced by Wt::PushButton::drawButton(), Wt::Label::drawContents(), and Wt::Widget::erase().

00382                                                                           {
00383     pixmap_->blit(p.x(), p.y(), src, sr);
00384 }

Here is the call graph for this function:

void Wt::Painter::drawPoint ( const Point p  ) 

Definition at line 121 of file painter.cpp.

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

00121                                       {
00122     drawPoint(p.x(), p.y());
00123 }

Here is the call graph for this function:

void Wt::Painter::drawPoint ( int  x,
int  y 
)

Definition at line 109 of file painter.cpp.

References Wt::Pen::color(), isClipped(), Wt::Painter::State::pen, pixmap_, rop(), and state.

Referenced by drawPoint().

00109                                     {
00110     if (!isClipped(x, y)) {
00111         int pixel_offset = pixmap_->pixelOffset(x, y);
00112         int pixel = pixmap_->pixelFormat().mapToPixelValue(state.pen.color());
00113 
00114         pixmap_->lock()
00115         ;
00116         rop(pixel_offset, pixel);
00117         pixmap_->unlock();
00118     }
00119 }

Here is the call graph for this function:

void Wt::Painter::drawPoints ( const PointArray points,
int  start = 0,
int  end = -1 
)

Definition at line 125 of file painter.cpp.

References Wt::Pen::color(), end(), isClipped(), Wt::Painter::State::pen, pixmap_, rop(), and state.

00125                                                                      {
00126     int i;
00127     int pixel = pixmap_->pixelFormat().mapToPixelValue(state.pen.color());
00128 
00129     end = (end > 0) ? end : points.size();
00130 
00131     pixmap_->lock()
00132     ;
00133     for (i = start; i < end; i++) {
00134         const Point& p = points[i];
00135         if (!isClipped(p)) {
00136             int pixel_offset = pixmap_->pixelOffset(p.x(), p.y());
00137             rop(pixel_offset, pixel);
00138         }
00139     }
00140     pixmap_->unlock();
00141 }

Here is the call graph for this function:

void Wt::Painter::drawPolygon ( const PointArray points,
int  start = 0,
int  end = -1 
)

Definition at line 369 of file painter.cpp.

References Wt::Painter::State::brush, drawLine(), end(), Wt::Brush::NoBrush, state, and Wt::Brush::style().

00369                                                                       {
00370     int i;
00371     end = (end > 0) ? end : points.size();
00372 
00373     for (i = start; i < end; i++) {
00374         drawLine(points[i], points[i + 1 % end]);
00375     }
00376 
00377     if (state.brush.style() != Brush::NoBrush) {
00378         /// \todo we have to actually fill the damn thing
00379     }
00380 }

Here is the call graph for this function:

void Wt::Painter::drawPolyline ( const PointArray points,
int  start = 0,
int  end = -1 
)

Definition at line 360 of file painter.cpp.

References drawLine(), and end().

00360                                                                        {
00361     int i;
00362     end = (end > 0) ? end : points.size();
00363 
00364     for (i = start; i < end; i++) {
00365         drawLine(points[i], points[i + 1]);
00366     }
00367 }

Here is the call graph for this function:

void Wt::Painter::drawRect ( const Rect r  ) 

Definition at line 347 of file painter.cpp.

References drawRect(), Wt::SDLRect::height(), Wt::SDLRect::left(), Wt::SDLRect::top(), and Wt::SDLRect::width().

00347                                      {
00348     drawRect(r.left(), r.top(), r.width(), r.height());
00349 }

Here is the call graph for this function:

void Wt::Painter::drawRect ( int  x,
int  y,
int  w,
int  h 
)

Definition at line 333 of file painter.cpp.

References Wt::Painter::State::brush, drawHorizontalLine(), drawVerticalLine(), fillRect(), Wt::Brush::NoBrush, state, and Wt::Brush::style().

Referenced by drawRect().

00333                                                  {
00334     int x2 = x + w - 1;
00335     int y2 = y + h - 1;
00336 
00337     drawHorizontalLine(x, x2, y);
00338     drawVerticalLine(x, y, y2);
00339     drawHorizontalLine(x, x2, y2);
00340     drawVerticalLine(x2, y, y2);
00341 
00342     if (state.brush.style() != Brush::NoBrush) {
00343         fillRect(x + 1, y + 1, w - 1, h - 1, state.brush);
00344     }
00345 }

Here is the call graph for this function:

void Wt::Painter::drawText ( const Point p,
const std::string &  text,
int  pos,
int  len 
)

Definition at line 456 of file painter.cpp.

References drawText().

00457                                                                 {
00458     len = (len - 1) ? text.length() : len;
00459     const std::string& t = text.substr(pos, len);
00460     drawText(p, t);
00461 }

Here is the call graph for this function:

void Wt::Painter::drawText ( int  x,
int  y,
const std::string &  text,
int  pos,
int  len 
)

Definition at line 463 of file painter.cpp.

References drawText().

00464                                                                 {
00465     drawText(Point(x, y), text, pos, len);
00466 }

Here is the call graph for this function:

void Wt::Painter::drawText ( const Point p,
const std::string &  text,
int  len = -1 
)

Definition at line 441 of file painter.cpp.

References Wt::SDLColor::alpha(), Wt::Font::ascent(), Wt::Painter::State::bg_color, Wt::PixmapOf< SDLPixmap >::blit(), Wt::PixmapOf< SDLPixmap >::blitAlphaCopy(), Wt::Font::blitText(), Wt::Painter::State::font, pixmap_, state, and Wt::SDLColor::Transparent.

00441                                                                      {
00442     const std::string& t = (len == -1) ? text : text.substr(0, len);
00443     const Point p1 = p - Point(0, state.font.ascent());
00444 
00445     if (state.bg_color.alpha() != Color::Transparent) {
00446         pixmap_->blit(p1, state.font.blitText(t));
00447     } else {
00448         pixmap_->blitAlphaCopy(p1, state.font.blitText(t));
00449     }
00450 }

Here is the call graph for this function:

void Wt::Painter::drawText ( int  x,
int  y,
const std::string &  text,
int  len = -1 
)

Todo:
missing functionality: paragraphs, multi line text, text aligining (low priority)

Definition at line 452 of file painter.cpp.

Referenced by Wt::PushButton::drawButtonLabel(), Wt::Label::drawContents(), Wt::Widget::drawText(), and drawText().

00452                                                                    {
00453     drawText(Point(x, y), text, len);
00454 }

void Wt::Painter::drawTiledPixmap ( int  x,
int  y,
int  w,
int  h,
const Pixmap src,
int  sx = 0,
int  sy = 0 
)

Definition at line 436 of file painter.cpp.

References drawTiledPixmap().

00437                                                                  {
00438     drawTiledPixmap(Rect(x, y, w, h), src, Point(sx, sy));
00439 }

Here is the call graph for this function:

void Wt::Painter::drawTiledPixmap ( const Rect r,
const Pixmap src 
)

Definition at line 432 of file painter.cpp.

References drawTiledPixmap().

00432                                                               {
00433     drawTiledPixmap(r, src, Point(0, 0));
00434 }

Here is the call graph for this function:

void Wt::Painter::drawTiledPixmap ( const Rect r,
const Pixmap src,
const Point sp 
)

Definition at line 398 of file painter.cpp.

References Wt::PixmapOf< SDLPixmap >::blit(), Wt::SDLRect::bottom(), Wt::SDLRect::height(), Wt::SDLRect::left(), pixmap_, Wt::SDLRect::right(), Wt::SDLRect::setHeight(), Wt::SDLRect::setWidth(), Wt::SDLRect::setX(), Wt::SDLRect::setY(), Wt::SDLRect::top(), Wt::Rect::topLeft(), trace, Wt::SDLRect::width(), Wt::Point::x(), and Wt::Point::y().

Referenced by drawTiledPixmap(), and Wt::Widget::updateBackground().

00399                                                                   {
00400 
00401     int src_w = src.width();
00402     int src_h = src.height();
00403     int dst_w = r.width();
00404     int dst_h = r.height();
00405     int x, y, w;
00406     int h = src_h - sp.y();
00407     Rect dst_rect(0, 0, 0, h);
00408     Rect src_rect(sp, Size(0, h));
00409 
00410     trace("painter") << "Tiling a " << Size(src_w, src_h)
00411     << " background onto a " << Size(dst_w, dst_h) << " surface" << std::endl;
00412 
00413     for(y = r.top(); y <= r.bottom(); y += h) {
00414         dst_rect.setY(y);
00415         w = src_w - sp.x();
00416         dst_rect.setWidth(w);
00417         src_rect.setWidth(w);
00418         for(x = r.left(); x <= r.right(); x += w) {
00419             dst_rect.setX(x);
00420             trace("painter")  << "Blitting tile at " << dst_rect.topLeft() << std::endl;
00421             pixmap_->blit(dst_rect.topLeft(), src, src_rect);
00422             w = src_w;
00423             dst_rect.setWidth(w);
00424             src_rect.setWidth(w);
00425         }
00426         h = src_h;
00427         dst_rect.setHeight(h);
00428         src_rect.setHeight(h);
00429     }
00430 }

Here is the call graph for this function:

void Wt::Painter::drawVerticalLine ( int  x,
int  y1,
int  y2 
)

Definition at line 174 of file painter.cpp.

References Wt::Painter::State::clipping, Wt::Pen::color(), isActive(), Wt::Painter::State::pen, pixmap_, rop(), and state.

Referenced by Wt::Frame::drawFrame(), drawLine(), and drawRect().

00174                                                     {
00175     if(!isActive() || x < 0 || x >= pixmap_->width())
00176         return;
00177 
00178     int h = pixmap_->height();
00179 
00180     if (state.clipping) {
00181         y1 = std::max(0, y1);
00182         y1 = std::min(y1, h - 1);
00183         y2 = std::max(0, y2);
00184         y2 = std::min(y2, h - 1);
00185     }
00186 
00187     if (y1 > y2)
00188         std::swap(y1, y2);
00189 
00190     int pixel = pixmap_->pixelFormat().mapToPixelValue(state.pen.color());
00191     int pixel_offset = pixmap_->pixelOffset(x, y1);
00192     int skip = pixmap_->bytesPerLine();
00193 
00194     pixmap_->lock()
00195     ;
00196     while(y1 <= y2) {
00197         rop(pixel_offset, pixel);
00198         y1++;
00199         pixel_offset += skip;
00200     }
00201     pixmap_->unlock();
00202 }

Here is the call graph for this function:

bool Wt::Painter::end (  ) 

Definition at line 61 of file painter.cpp.

References active_, restore(), and state_stack.

Referenced by drawLineSegments(), drawPoints(), drawPolygon(), drawPolyline(), Wt::Widget::erase(), Wt::Widget::paintEvent(), and ~Painter().

00061                   {
00062     bool status = false;
00063     if (active_) {
00064         while (!state_stack.empty()) {
00065             restore();
00066         }
00067         active_ = false;
00068         status = true;
00069     }
00070     return status;
00071 }

Here is the call graph for this function:

void Wt::Painter::eraseRect ( int  x,
int  y,
int  w,
int  h 
)

Definition at line 325 of file painter.cpp.

References eraseRect().

00325                                                   {
00326     eraseRect(Rect(x, y, w, h));
00327 }

Here is the call graph for this function:

void Wt::Painter::eraseRect ( const Rect r  ) 

Definition at line 321 of file painter.cpp.

References Wt::Painter::State::bg_color, fillRect(), and state.

Referenced by Wt::Widget::erase(), and eraseRect().

00321                                      {
00322     fillRect(r, state.bg_color);
00323 }

Here is the call graph for this function:

void Wt::Painter::eraseRegion ( const Region r  ) 

Definition at line 329 of file painter.cpp.

References Wt::Painter::State::bg_color, fillRegion(), and state.

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

00329                                          {
00330     fillRegion(r, state.bg_color);
00331 }

Here is the call graph for this function:

void Wt::Painter::fillRect ( int  x,
int  y,
int  w,
int  h,
const Brush brush 
)

Definition at line 292 of file painter.cpp.

References brush(), and fillRect().

00292                                                                      {
00293     fillRect(Rect(x, y, w, h), brush);
00294 }

Here is the call graph for this function:

void Wt::Painter::fillRect ( const Rect r,
const Brush brush 
)

Definition at line 285 of file painter.cpp.

References brush(), Wt::Brush::color(), Wt::PixmapOf< SDLPixmap >::fill(), Wt::Brush::NoBrush, pixmap_, and Wt::Brush::style().

Referenced by drawRect(), eraseRect(), and fillRect().

00285                                                         {
00286     if (brush.style() == Brush::NoBrush)
00287         return;
00288 
00289     pixmap_->fill(r, brush.color());
00290 }

Here is the call graph for this function:

void Wt::Painter::fillRegion ( const Region r,
const Brush brush 
)

Definition at line 296 of file painter.cpp.

References brush(), Wt::Brush::color(), Wt::PixmapOf< SDLPixmap >::fill(), Wt::Brush::NoBrush, pixmap_, and Wt::Brush::style().

Referenced by eraseRegion().

00296                                                             {
00297     if (brush.style() == Brush::NoBrush)
00298         return;
00299 
00300     pixmap_->fill(r, brush.color());
00301 }

Here is the call graph for this function:

void Wt::Painter::flush (  )  [inline]

Definition at line 154 of file painter.h.

00154 {}

const Font& Wt::Painter::font (  )  const [inline]

Definition at line 110 of file painter.h.

References Wt::Painter::State::font, and state.

Referenced by Wt::Widget::font(), and setFont().

00110                              {
00111         return state.font;
00112     }

bool Wt::Painter::hasClipping (  )  const [inline]

Deprecated:

Definition at line 180 of file painter.h.

References clipping().

00180                              {
00181         return clipping();
00182     }

Here is the call graph for this function:

bool Wt::Painter::isActive (  )  const

Definition at line 73 of file painter.cpp.

References active_.

Referenced by drawHorizontalLine(), drawLine(), drawVerticalLine(), and isClipped().

00073                               {
00074     return active_;
00075 }

bool Wt::Painter::isClipped ( const Point p  )  const [protected]

Definition at line 81 of file painter.cpp.

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

00081                                             {
00082     return isClipped(p.x(), p.y());
00083 }

Here is the call graph for this function:

bool Wt::Painter::isClipped ( int  x,
int  y 
) const [protected]

Definition at line 77 of file painter.cpp.

References Wt::Painter::State::clipping, Wt::Rect::contains(), isActive(), pixmap_, Wt::PixmapOf< SDLPixmap >::rect(), and state.

Referenced by drawPoint(), drawPoints(), and isClipped().

00077                                           {
00078     return !isActive() || (state.clipping && !pixmap_->rect().contains(x, y));
00079 }

Here is the call graph for this function:

const Pen& Wt::Painter::pen (  )  const [inline]

Definition at line 118 of file painter.h.

References Wt::Painter::State::pen, and state.

Referenced by Wt::Widget::foregroundColor(), Wt::Widget::setForegroundColor(), and setPen().

00118                            {
00119         return state.pen;
00120     }

Pixmap* Wt::Painter::pixmap (  )  const [inline]

Definition at line 105 of file painter.h.

References pixmap_.

Referenced by begin().

00105                            {
00106         return pixmap_;
00107     }

RasterOp Wt::Painter::rasterOp (  )  const [inline]

Definition at line 163 of file painter.h.

References Wt::Painter::State::raster_op, and state.

00163                               {
00164         return state.raster_op;
00165     }

void Wt::Painter::restore (  )  [inline]

Definition at line 148 of file painter.h.

References state, and state_stack.

Referenced by Wt::PushButton::drawButtonLabel(), Wt::Frame::drawFrame(), and end().

00148                    {
00149         assert(!state_stack.empty());
00150         state = state_stack.top();
00151         state_stack.pop();
00152     }

void Wt::Painter::rop ( int  pixeladdr,
int  pixel 
) [protected]

Definition at line 85 of file painter.cpp.

References AndROP, CopyROP, OrROP, Wt::PixmapOf< SDLPixmap >::pixel(), pixmap_, Wt::Painter::State::raster_op, Wt::PixmapOf< SDLPixmap >::setPixel(), state, Warn, and XorROP.

Referenced by drawHorizontalLine(), drawLine(), drawPoint(), drawPoints(), and drawVerticalLine().

00085                                              {
00086     switch(state.raster_op) {
00087     case CopyROP:
00088         pixmap_->setPixel(pixel_offset, pixel);
00089         break;
00090     case XorROP:
00091         pixel = pixel ^ pixmap_->pixel(pixel_offset);
00092         pixmap_->setPixel(pixel_offset, pixel);
00093         break;
00094     case AndROP:
00095         pixel = pixel & pixmap_->pixel(pixel_offset);
00096         pixmap_->setPixel(pixel_offset, pixel);
00097         break;
00098     case OrROP:
00099         pixel = pixel | pixmap_->pixel(pixel_offset);
00100         pixmap_->setPixel(pixel_offset, pixel);
00101         break;
00102     default:
00103         Warn("Unknown Raster Operation %d\n", state.raster_op);
00104         pixmap_->setPixel(pixel_offset, pixel);
00105         break;
00106     }
00107 }

Here is the call graph for this function:

void Wt::Painter::save (  )  [inline]

Definition at line 144 of file painter.h.

References state, and state_stack.

Referenced by Wt::PushButton::drawButtonLabel(), and Wt::Frame::drawFrame().

00144                 {
00145         state_stack.push(state);
00146     }

void Wt::Painter::setBackgroundColor ( const Color color  )  [inline]

Definition at line 139 of file painter.h.

References Wt::Painter::State::bg_color, Wt::Painter::State::font, Wt::Font::setBackgroundColor(), and state.

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

00139                                                 {
00140         state.bg_color = color;
00141         state.font.setBackgroundColor(color);
00142     }

Here is the call graph for this function:

void Wt::Painter::setBrush ( const Brush brush  )  [inline]

Definition at line 131 of file painter.h.

References brush(), Wt::Painter::State::brush, and state.

00131                                       {
00132         state.brush = brush;
00133     }

Here is the call graph for this function:

void Wt::Painter::setClipping ( bool  enable  )  [inline]

Definition at line 171 of file painter.h.

References Wt::Painter::State::clipping, and state.

Referenced by begin().

00171                                   {
00172         state.clipping = enable;
00173     }

void Wt::Painter::setFont ( const Font font  )  [inline]

Definition at line 114 of file painter.h.

References font(), Wt::Painter::State::font, and state.

Referenced by Wt::Widget::reparent(), Wt::Widget::setFont(), and Wt::Widget::Widget().

00114                                    {
00115         state.font = font;
00116     }

Here is the call graph for this function:

void Wt::Painter::setPen ( const Pen pen  )  [inline]

Definition at line 122 of file painter.h.

References Wt::Pen::color(), Wt::Painter::State::font, pen(), Wt::Painter::State::pen, Wt::Font::setForegroundColor(), and state.

Referenced by Wt::PushButton::drawButtonLabel(), Wt::Frame::drawFrame(), and Wt::Widget::setForegroundColor().

00122                                 {
00123         state.pen = pen;
00124         state.font.setForegroundColor(pen.color());
00125     }

Here is the call graph for this function:

void Wt::Painter::setRasterOp ( RasterOp  raster_op  )  [inline]

Definition at line 167 of file painter.h.

References Wt::Painter::State::raster_op, and state.

00167                                          {
00168         state.raster_op = raster_op;
00169     }


Member Data Documentation

bool Wt::Painter::active_ [private]

Definition at line 237 of file painter.h.

Referenced by begin(), end(), and isActive().

Pixmap* Wt::Painter::pixmap_ [private]

Definition at line 238 of file painter.h.

Referenced by begin(), blendRect(), blendRegion(), drawHorizontalLine(), drawLine(), drawPixmap(), drawPoint(), drawPoints(), drawText(), drawTiledPixmap(), drawVerticalLine(), fillRect(), fillRegion(), isClipped(), Painter(), pixmap(), and rop().

State Wt::Painter::state [private]

Definition at line 258 of file painter.h.

Referenced by backgroundColor(), boundingRect(), brush(), clipping(), drawHorizontalLine(), drawLine(), drawPoint(), drawPoints(), drawPolygon(), drawRect(), drawText(), drawVerticalLine(), eraseRect(), eraseRegion(), font(), isClipped(), pen(), rasterOp(), restore(), rop(), save(), setBackgroundColor(), setBrush(), setClipping(), setFont(), setPen(), and setRasterOp().

std::stack<State> Wt::Painter::state_stack [private]

Definition at line 257 of file painter.h.

Referenced by end(), restore(), and save().


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

Generated Fri Jul 28 19:30:51 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.