00001 #ifndef KDE__PAINTER_H
00002 #define KDE__PAINTER_H
00003
00004 #include <faith/point.h>
00005 #include <faith/color.h>
00006 #include <faith/application.h>
00007 #include <faith/rect.h>
00008 #include <faith/string.h>
00009 #include <faith/pen.h>
00010
00011 namespace Faith
00012 {
00013
00014 class PaintDevice;
00015 class Widget;
00016 class Font;
00017 class Image;
00018 class Pixmap;
00019
00020 namespace Internal
00021 {
00022 class Drawable;
00023 }
00024
00025
00035 class FAITH_CORE_EXPORT Painter
00036 {
00037 struct PainterPrivate;
00038 PainterPrivate *d;
00039 PaintDevice *mDest;
00040 mutable bool mInvalidated;
00041
00042 public:
00049 enum TextDirection
00050 {
00051 Auto,
00052 LTR,
00053 RTL
00054 };
00055
00061 Painter(PaintDevice *dest, const Widget *copyAttrib=0);
00062 Painter();
00063 ~Painter();
00064
00073 void save();
00078 void restore();
00079
00087 void begin(PaintDevice *dest, const Widget *copyAttrib=0);
00091 void end();
00092
00093 Point xForm(const Point &pt);
00094 Rect xForm(const Rect &pt);
00095
00099 Internal::Drawable *handle();
00100
00101 public:
00106 void drawLine(int ax, int ay, int bx, int by)
00107 { drawLine(Point(ax,ay), Point(bx, by)); }
00112 void drawLine(const Point &a, const Point &b);
00113
00122 void drawPolygon(const std::vector<Faith::Point> &points, int start=0, int count=-1);
00127 void drawPolygon(int count, const Faith::Point *points);
00128
00133 void drawText(const Point &p, const String &str, int pos=0, int len=-1, TextDirection dir=Auto);
00134
00138 void drawText(int x, int y, const String &str, int pos=0, int len=-1, TextDirection dir=Auto)
00139 {
00140 drawText(Point(x,y), str, pos, len, dir);
00141 }
00142
00147 void drawText(const Rect &rect, int textflags, const String &str, int pos=0, int len=-1);
00151 void drawText(int x, int y, int w, int h, int textflags, const String &str, int pos=0, int len=-1)
00152 {
00153 drawText(Rect(x,y,w,h), textflags, str, pos, len);
00154 }
00155
00159 void fillRect(const Rect &rect, const Color &color);
00160
00165 void fillRect(int x, int y, int w, int h, const Color &color)
00166 {
00167 fillRect(Rect(x, y, w, h), color);
00168 }
00169
00176 void drawImage(const Point &p, const Image &image, int fromx=0, int fromy=0, int w=-1, int h=-1);
00177
00181 void drawImage(int x, int y, const Image &image, int fromx=0, int fromy=0, int w=-1, int h=-1)
00182 {
00183 drawImage(Point(x, y), image, fromx, fromy, w,h);
00184 }
00185
00189 void drawImage(const Image &image, int fromx=0, int fromy=0, int w=-1, int h=-1)
00190 {
00191 drawImage(Point(0, 0), image, fromx, fromy, w,h);
00192 }
00193
00202 void drawPixmap(const Point &p, const Faith::Pixmap &pixmap, int fromx=0, int fromy=0, int w=-1, int h=-1);
00203
00207 void drawPixmap(int x, int y, const Faith::Pixmap &pixmap, int fromx=0, int fromy=0, int w=-1, int h=-1)
00208 {
00209 drawPixmap(Point(x, y), pixmap, fromx, fromy, w,h);
00210 }
00211
00215 void drawPixmap(const Faith::Pixmap &pixmap, int fromx=0, int fromy=0, int w=-1, int h=-1)
00216 {
00217 drawPixmap(Point(0, 0), pixmap, fromx, fromy, w,h);
00218 }
00219
00223 void drawPoint(const Point &pt);
00224
00228 void drawPoint(int x, int y)
00229 {
00230 drawPoint(Point(x,y));
00231 }
00232
00233 public:
00237 void setBackground(const Color &color);
00238
00243 Color background() const;
00244
00249 void setFont(const Font &font);
00253 Font font() const;
00254
00259 void setPen(const Pen &pen);
00263 Pen pen() const;
00264
00277 void setOrigin(const Point &point);
00278
00282 void setOrigin(int x, int y)
00283 { setOrigin(Faith::Point(x,y)); }
00284
00288 Point origin() const;
00289
00295 void setClipRectangle(const Rect &rectangle);
00296
00301 Rect clipRectangle() const;
00302
00306 void setClipping(bool c);
00307
00312 bool isClipping() const;
00313
00314 private:
00315 void updateGC() const;
00316 void invalidateGC();
00317 };
00318
00319 }
00320
00321 #endif
00322