qpainter.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QPAINTER_H
00043 #define QPAINTER_H
00044 
00045 #include <QtCore/qnamespace.h>
00046 #include <QtCore/qrect.h>
00047 #include <QtCore/qpoint.h>
00048 #include <QtCore/qscopedpointer.h>
00049 #include <QtGui/qpixmap.h>
00050 #include <QtGui/qimage.h>
00051 #include <QtGui/qtextoption.h>
00052 #include <QtGui/qdrawutil.h>
00053 
00054 #ifndef QT_INCLUDE_COMPAT
00055 #include <QtGui/qpolygon.h>
00056 #include <QtGui/qpen.h>
00057 #include <QtGui/qbrush.h>
00058 #include <QtGui/qmatrix.h>
00059 #include <QtGui/qtransform.h>
00060 #include <QtGui/qfontinfo.h>
00061 #include <QtGui/qfontmetrics.h>
00062 #endif
00063 
00064 QT_BEGIN_HEADER
00065 
00066 QT_BEGIN_NAMESPACE
00067 
00068 QT_MODULE(Gui)
00069 
00070 class QBrush;
00071 class QFontInfo;
00072 class QFontMetrics;
00073 class QPaintDevice;
00074 class QPainterPath;
00075 class QPainterPrivate;
00076 class QPen;
00077 class QPolygon;
00078 class QTextItem;
00079 class QMatrix;
00080 class QTransform;
00081 class QStaticText;
00082 
00083 class QPainterPrivateDeleter;
00084 
00085 class Q_GUI_EXPORT QPainter
00086 {
00087     Q_DECLARE_PRIVATE(QPainter)
00088     Q_GADGET
00089     Q_FLAGS(RenderHint RenderHints)
00090 
00091 public:
00092     enum RenderHint {
00093         Antialiasing = 0x01,
00094         TextAntialiasing = 0x02,
00095         SmoothPixmapTransform = 0x04,
00096         HighQualityAntialiasing = 0x08,
00097         NonCosmeticDefaultPen = 0x10
00098     };
00099 
00100     Q_DECLARE_FLAGS(RenderHints, RenderHint)
00101 
00102     class PixmapFragment {
00103     public:
00104         qreal x;
00105         qreal y;
00106         qreal sourceLeft;
00107         qreal sourceTop;
00108         qreal width;
00109         qreal height;
00110         qreal scaleX;
00111         qreal scaleY;
00112         qreal rotation;
00113         qreal opacity;
00114         static PixmapFragment Q_GUI_EXPORT create(const QPointF &pos, const QRectF &sourceRect,
00115                                             qreal scaleX = 1, qreal scaleY = 1,
00116                                             qreal rotation = 0, qreal opacity = 1);
00117     };
00118 
00119     enum PixmapFragmentHint {
00120         OpaqueHint = 0x01
00121     };
00122 
00123     Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)
00124 
00125     QPainter();
00126     explicit QPainter(QPaintDevice *);
00127     ~QPainter();
00128 
00129     QPaintDevice *device() const;
00130 
00131     bool begin(QPaintDevice *);
00132     bool end();
00133     bool isActive() const;
00134 
00135     void initFrom(const QWidget *widget);
00136 
00137     enum CompositionMode {
00138         CompositionMode_SourceOver,
00139         CompositionMode_DestinationOver,
00140         CompositionMode_Clear,
00141         CompositionMode_Source,
00142         CompositionMode_Destination,
00143         CompositionMode_SourceIn,
00144         CompositionMode_DestinationIn,
00145         CompositionMode_SourceOut,
00146         CompositionMode_DestinationOut,
00147         CompositionMode_SourceAtop,
00148         CompositionMode_DestinationAtop,
00149         CompositionMode_Xor,
00150 
00151         //svg 1.2 blend modes
00152         CompositionMode_Plus,
00153         CompositionMode_Multiply,
00154         CompositionMode_Screen,
00155         CompositionMode_Overlay,
00156         CompositionMode_Darken,
00157         CompositionMode_Lighten,
00158         CompositionMode_ColorDodge,
00159         CompositionMode_ColorBurn,
00160         CompositionMode_HardLight,
00161         CompositionMode_SoftLight,
00162         CompositionMode_Difference,
00163         CompositionMode_Exclusion,
00164 
00165         // ROPs
00166         RasterOp_SourceOrDestination,
00167         RasterOp_SourceAndDestination,
00168         RasterOp_SourceXorDestination,
00169         RasterOp_NotSourceAndNotDestination,
00170         RasterOp_NotSourceOrNotDestination,
00171         RasterOp_NotSourceXorDestination,
00172         RasterOp_NotSource,
00173         RasterOp_NotSourceAndDestination,
00174         RasterOp_SourceAndNotDestination
00175     };
00176     void setCompositionMode(CompositionMode mode);
00177     CompositionMode compositionMode() const;
00178 
00179     const QFont &font() const;
00180     void setFont(const QFont &f);
00181 
00182     QFontMetrics fontMetrics() const;
00183     QFontInfo fontInfo() const;
00184 
00185     void setPen(const QColor &color);
00186     void setPen(const QPen &pen);
00187     void setPen(Qt::PenStyle style);
00188     const QPen &pen() const;
00189 
00190     void setBrush(const QBrush &brush);
00191     void setBrush(Qt::BrushStyle style);
00192     const QBrush &brush() const;
00193 
00194     // attributes/modes
00195     void setBackgroundMode(Qt::BGMode mode);
00196     Qt::BGMode backgroundMode() const;
00197 
00198     QPoint brushOrigin() const;
00199     inline void setBrushOrigin(int x, int y);
00200     inline void setBrushOrigin(const QPoint &);
00201     void setBrushOrigin(const QPointF &);
00202 
00203     void setBackground(const QBrush &bg);
00204     const QBrush &background() const;
00205 
00206     qreal opacity() const;
00207     void setOpacity(qreal opacity);
00208 
00209     // Clip functions
00210     QRegion clipRegion() const;
00211     QPainterPath clipPath() const;
00212 
00213     void setClipRect(const QRectF &, Qt::ClipOperation op = Qt::ReplaceClip);
00214     void setClipRect(const QRect &, Qt::ClipOperation op = Qt::ReplaceClip);
00215     inline void setClipRect(int x, int y, int w, int h, Qt::ClipOperation op = Qt::ReplaceClip);
00216 
00217     void setClipRegion(const QRegion &, Qt::ClipOperation op = Qt::ReplaceClip);
00218 
00219     void setClipPath(const QPainterPath &path, Qt::ClipOperation op = Qt::ReplaceClip);
00220 
00221     void setClipping(bool enable);
00222     bool hasClipping() const;
00223 
00224     void save();
00225     void restore();
00226 
00227     // XForm functions
00228     void setMatrix(const QMatrix &matrix, bool combine = false);
00229     const QMatrix &matrix() const;
00230     const QMatrix &deviceMatrix() const;
00231     void resetMatrix();
00232 
00233     void setTransform(const QTransform &transform, bool combine = false);
00234     const QTransform &transform() const;
00235     const QTransform &deviceTransform() const;
00236     void resetTransform();
00237 
00238     void setWorldMatrix(const QMatrix &matrix, bool combine = false);
00239     const QMatrix &worldMatrix() const;
00240 
00241     void setWorldTransform(const QTransform &matrix, bool combine = false);
00242     const QTransform &worldTransform() const;
00243 
00244     QMatrix combinedMatrix() const;
00245     QTransform combinedTransform() const;
00246 
00247     void setMatrixEnabled(bool enabled);
00248     bool matrixEnabled() const;
00249 
00250     void setWorldMatrixEnabled(bool enabled);
00251     bool worldMatrixEnabled() const;
00252 
00253     void scale(qreal sx, qreal sy);
00254     void shear(qreal sh, qreal sv);
00255     void rotate(qreal a);
00256 
00257     void translate(const QPointF &offset);
00258     inline void translate(const QPoint &offset);
00259     inline void translate(qreal dx, qreal dy);
00260 
00261     QRect window() const;
00262     void setWindow(const QRect &window);
00263     inline void setWindow(int x, int y, int w, int h);
00264 
00265     QRect viewport() const;
00266     void setViewport(const QRect &viewport);
00267     inline void setViewport(int x, int y, int w, int h);
00268 
00269     void setViewTransformEnabled(bool enable);
00270     bool viewTransformEnabled() const;
00271 
00272     // drawing functions
00273     void strokePath(const QPainterPath &path, const QPen &pen);
00274     void fillPath(const QPainterPath &path, const QBrush &brush);
00275     void drawPath(const QPainterPath &path);
00276 
00277     inline void drawPoint(const QPointF &pt);
00278     inline void drawPoint(const QPoint &p);
00279     inline void drawPoint(int x, int y);
00280 
00281     void drawPoints(const QPointF *points, int pointCount);
00282     inline void drawPoints(const QPolygonF &points);
00283     void drawPoints(const QPoint *points, int pointCount);
00284     inline void drawPoints(const QPolygon &points);
00285 
00286     inline void drawLine(const QLineF &line);
00287     inline void drawLine(const QLine &line);
00288     inline void drawLine(int x1, int y1, int x2, int y2);
00289     inline void drawLine(const QPoint &p1, const QPoint &p2);
00290     inline void drawLine(const QPointF &p1, const QPointF &p2);
00291 
00292     void drawLines(const QLineF *lines, int lineCount);
00293     inline void drawLines(const QVector<QLineF> &lines);
00294     void drawLines(const QPointF *pointPairs, int lineCount);
00295     inline void drawLines(const QVector<QPointF> &pointPairs);
00296     void drawLines(const QLine *lines, int lineCount);
00297     inline void drawLines(const QVector<QLine> &lines);
00298     void drawLines(const QPoint *pointPairs, int lineCount);
00299     inline void drawLines(const QVector<QPoint> &pointPairs);
00300 
00301     inline void drawRect(const QRectF &rect);
00302     inline void drawRect(int x1, int y1, int w, int h);
00303     inline void drawRect(const QRect &rect);
00304 
00305     void drawRects(const QRectF *rects, int rectCount);
00306     inline void drawRects(const QVector<QRectF> &rectangles);
00307     void drawRects(const QRect *rects, int rectCount);
00308     inline void drawRects(const QVector<QRect> &rectangles);
00309 
00310     void drawEllipse(const QRectF &r);
00311     void drawEllipse(const QRect &r);
00312     inline void drawEllipse(int x, int y, int w, int h);
00313 
00314     inline void drawEllipse(const QPointF &center, qreal rx, qreal ry);
00315     inline void drawEllipse(const QPoint &center, int rx, int ry);
00316 
00317     void drawPolyline(const QPointF *points, int pointCount);
00318     inline void drawPolyline(const QPolygonF &polyline);
00319     void drawPolyline(const QPoint *points, int pointCount);
00320     inline void drawPolyline(const QPolygon &polygon);
00321 
00322     void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill);
00323     inline void drawPolygon(const QPolygonF &polygon, Qt::FillRule fillRule = Qt::OddEvenFill);
00324     void drawPolygon(const QPoint *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill);
00325     inline void drawPolygon(const QPolygon &polygon, Qt::FillRule fillRule = Qt::OddEvenFill);
00326 
00327     void drawConvexPolygon(const QPointF *points, int pointCount);
00328     inline void drawConvexPolygon(const QPolygonF &polygon);
00329     void drawConvexPolygon(const QPoint *points, int pointCount);
00330     inline void drawConvexPolygon(const QPolygon &polygon);
00331 
00332     void drawArc(const QRectF &rect, int a, int alen);
00333     inline void drawArc(const QRect &, int a, int alen);
00334     inline void drawArc(int x, int y, int w, int h, int a, int alen);
00335 
00336     void drawPie(const QRectF &rect, int a, int alen);
00337     inline void drawPie(int x, int y, int w, int h, int a, int alen);
00338     inline void drawPie(const QRect &, int a, int alen);
00339 
00340     void drawChord(const QRectF &rect, int a, int alen);
00341     inline void drawChord(int x, int y, int w, int h, int a, int alen);
00342     inline void drawChord(const QRect &, int a, int alen);
00343 
00344     void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius,
00345                          Qt::SizeMode mode = Qt::AbsoluteSize);
00346     inline void drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius,
00347                                 Qt::SizeMode mode = Qt::AbsoluteSize);
00348     inline void drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius,
00349                                 Qt::SizeMode mode = Qt::AbsoluteSize);
00350 
00351     void drawRoundRect(const QRectF &r, int xround = 25, int yround = 25);
00352     inline void drawRoundRect(int x, int y, int w, int h, int = 25, int = 25);
00353     inline void drawRoundRect(const QRect &r, int xround = 25, int yround = 25);
00354 
00355     void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset = QPointF());
00356     inline void drawTiledPixmap(int x, int y, int w, int h, const QPixmap &, int sx=0, int sy=0);
00357     inline void drawTiledPixmap(const QRect &, const QPixmap &, const QPoint & = QPoint());
00358 #ifndef QT_NO_PICTURE
00359     void drawPicture(const QPointF &p, const QPicture &picture);
00360     inline void drawPicture(int x, int y, const QPicture &picture);
00361     inline void drawPicture(const QPoint &p, const QPicture &picture);
00362 #endif
00363 
00364     void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect);
00365     inline void drawPixmap(const QRect &targetRect, const QPixmap &pixmap, const QRect &sourceRect);
00366     inline void drawPixmap(int x, int y, int w, int h, const QPixmap &pm,
00367                            int sx, int sy, int sw, int sh);
00368     inline void drawPixmap(int x, int y, const QPixmap &pm,
00369                            int sx, int sy, int sw, int sh);
00370     inline void drawPixmap(const QPointF &p, const QPixmap &pm, const QRectF &sr);
00371     inline void drawPixmap(const QPoint &p, const QPixmap &pm, const QRect &sr);
00372     void drawPixmap(const QPointF &p, const QPixmap &pm);
00373     inline void drawPixmap(const QPoint &p, const QPixmap &pm);
00374     inline void drawPixmap(int x, int y, const QPixmap &pm);
00375     inline void drawPixmap(const QRect &r, const QPixmap &pm);
00376     inline void drawPixmap(int x, int y, int w, int h, const QPixmap &pm);
00377 
00378     void drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount,
00379                              const QPixmap &pixmap, PixmapFragmentHints hints = 0);
00380 
00381     void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect,
00382                    Qt::ImageConversionFlags flags = Qt::AutoColor);
00383     inline void drawImage(const QRect &targetRect, const QImage &image, const QRect &sourceRect,
00384                           Qt::ImageConversionFlags flags = Qt::AutoColor);
00385     inline void drawImage(const QPointF &p, const QImage &image, const QRectF &sr,
00386                           Qt::ImageConversionFlags flags = Qt::AutoColor);
00387     inline void drawImage(const QPoint &p, const QImage &image, const QRect &sr,
00388                           Qt::ImageConversionFlags flags = Qt::AutoColor);
00389     inline void drawImage(const QRectF &r, const QImage &image);
00390     inline void drawImage(const QRect &r, const QImage &image);
00391     void drawImage(const QPointF &p, const QImage &image);
00392     inline void drawImage(const QPoint &p, const QImage &image);
00393     inline void drawImage(int x, int y, const QImage &image, int sx = 0, int sy = 0,
00394                           int sw = -1, int sh = -1, Qt::ImageConversionFlags flags = Qt::AutoColor);
00395 
00396     void setLayoutDirection(Qt::LayoutDirection direction);
00397     Qt::LayoutDirection layoutDirection() const;
00398 
00399     void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText);
00400     inline void drawStaticText(const QPoint &topLeftPosition, const QStaticText &staticText);
00401     inline void drawStaticText(int left, int top, const QStaticText &staticText);
00402 
00403     void drawText(const QPointF &p, const QString &s);
00404     inline void drawText(const QPoint &p, const QString &s);
00405     inline void drawText(int x, int y, const QString &s);
00406 
00407     void drawText(const QPointF &p, const QString &str, int tf, int justificationPadding);
00408 
00409     void drawText(const QRectF &r, int flags, const QString &text, QRectF *br=0);
00410     void drawText(const QRect &r, int flags, const QString &text, QRect *br=0);
00411     inline void drawText(int x, int y, int w, int h, int flags, const QString &text, QRect *br=0);
00412 
00413     void drawText(const QRectF &r, const QString &text, const QTextOption &o = QTextOption());
00414 
00415     QRectF boundingRect(const QRectF &rect, int flags, const QString &text);
00416     QRect boundingRect(const QRect &rect, int flags, const QString &text);
00417     inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text);
00418 
00419     QRectF boundingRect(const QRectF &rect, const QString &text, const QTextOption &o = QTextOption());
00420 
00421     void drawTextItem(const QPointF &p, const QTextItem &ti);
00422     inline void drawTextItem(int x, int y, const QTextItem &ti);
00423     inline void drawTextItem(const QPoint &p, const QTextItem &ti);
00424 
00425     void fillRect(const QRectF &, const QBrush &);
00426     inline void fillRect(int x, int y, int w, int h, const QBrush &);
00427     void fillRect(const QRect &, const QBrush &);
00428 
00429     void fillRect(const QRectF &, const QColor &color);
00430     inline void fillRect(int x, int y, int w, int h, const QColor &color);
00431     void fillRect(const QRect &, const QColor &color);
00432 
00433     inline void fillRect(int x, int y, int w, int h, Qt::GlobalColor c);
00434     inline void fillRect(const QRect &r, Qt::GlobalColor c);
00435     inline void fillRect(const QRectF &r, Qt::GlobalColor c);
00436 
00437     inline void fillRect(int x, int y, int w, int h, Qt::BrushStyle style);
00438     inline void fillRect(const QRect &r, Qt::BrushStyle style);
00439     inline void fillRect(const QRectF &r, Qt::BrushStyle style);
00440 
00441     void eraseRect(const QRectF &);
00442     inline void eraseRect(int x, int y, int w, int h);
00443     inline void eraseRect(const QRect &);
00444 
00445     void setRenderHint(RenderHint hint, bool on = true);
00446     void setRenderHints(RenderHints hints, bool on = true);
00447     RenderHints renderHints() const;
00448     inline bool testRenderHint(RenderHint hint) const { return renderHints() & hint; }
00449 
00450     QPaintEngine *paintEngine() const;
00451 
00452     static void setRedirected(const QPaintDevice *device, QPaintDevice *replacement,
00453                               const QPoint& offset = QPoint());
00454     static QPaintDevice *redirected(const QPaintDevice *device, QPoint *offset = 0);
00455     static void restoreRedirected(const QPaintDevice *device);
00456 
00457     void beginNativePainting();
00458     void endNativePainting();
00459 
00460 #ifdef QT3_SUPPORT
00461 
00462     inline QT3_SUPPORT void setBackgroundColor(const QColor &color) { setBackground(color); }
00463     inline QT3_SUPPORT const QColor &backgroundColor() const { return background().color(); }
00464 
00465     inline QT3_SUPPORT void drawText(int x, int y, const QString &s, int pos, int len)
00466         { drawText(x, y, s.mid(pos, len)); }
00467     inline QT3_SUPPORT void drawText(const QPoint &p, const QString &s, int pos, int len)
00468         { drawText(p, s.mid(pos, len)); }
00469     inline QT3_SUPPORT void drawText(int x, int y, const QString &s, int len)
00470         { drawText(x, y, s.left(len)); }
00471     inline QT3_SUPPORT void drawText(const QPoint &p, const QString &s, int len)
00472         { drawText(p, s.left(len)); }
00473     inline QT3_SUPPORT void drawText(const QRect &r, int flags, const QString &str, int len, QRect *br=0)
00474         { drawText(r, flags, str.left(len), br); }
00475     inline QT3_SUPPORT void drawText(int x, int y, int w, int h, int flags, const QString &text, int len, QRect *br=0)
00476         { drawText(QRect(x, y, w, h), flags, text.left(len), br); }
00477     inline QT3_SUPPORT QRect boundingRect(const QRect &rect, int flags, const QString &text, int len)
00478         { return boundingRect(rect, flags, text.left(len)); }
00479     inline QT3_SUPPORT QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text, int len)
00480         { return boundingRect(QRect(x, y, w, h), flags, text.left(len)); }
00481 
00482     inline QT3_SUPPORT bool begin(QPaintDevice *pdev, const QWidget *init)
00483         { bool ret = begin(pdev); initFrom(init); return ret; }
00484     QT3_SUPPORT void drawPoints(const QPolygon &pa, int index, int npoints = -1)
00485     { drawPoints(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
00486 
00487     QT3_SUPPORT void drawCubicBezier(const QPolygon &pa, int index = 0);
00488 
00489     QT3_SUPPORT void drawLineSegments(const QPolygon &points, int index = 0, int nlines = -1);
00490 
00491     inline QT3_SUPPORT void drawPolyline(const QPolygon &pa, int index, int npoints = -1)
00492     { drawPolyline(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
00493 
00494     inline QT3_SUPPORT void drawPolygon(const QPolygon &pa, bool winding, int index = 0, int npoints = -1)
00495     { drawPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints,
00496                   winding ? Qt::WindingFill : Qt::OddEvenFill); }
00497 
00498     inline QT3_SUPPORT void drawPolygon(const QPolygonF &polygon, bool winding, int index = 0,
00499                                       int npoints = -1)
00500     { drawPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints,
00501                   winding ? Qt::WindingFill : Qt::OddEvenFill); }
00502 
00503     inline QT3_SUPPORT void drawConvexPolygon(const QPolygonF &polygon, int index, int npoints = -1)
00504     { drawConvexPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints); }
00505     inline QT3_SUPPORT void drawConvexPolygon(const QPolygon &pa, int index, int npoints = -1)
00506     { drawConvexPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
00507 
00508     static inline QT3_SUPPORT void redirect(QPaintDevice *pdev, QPaintDevice *replacement)
00509     { setRedirected(pdev, replacement); }
00510     static inline QT3_SUPPORT QPaintDevice *redirect(QPaintDevice *pdev)
00511     { return const_cast<QPaintDevice*>(redirected(pdev)); }
00512 
00513     inline QT3_SUPPORT void setWorldXForm(bool enabled) { setMatrixEnabled(enabled); }
00514     inline QT3_SUPPORT bool hasWorldXForm() const { return matrixEnabled(); }
00515     inline QT3_SUPPORT void resetXForm() { resetTransform(); }
00516 
00517     inline QT3_SUPPORT void setViewXForm(bool enabled) { setViewTransformEnabled(enabled); }
00518     inline QT3_SUPPORT bool hasViewXForm() const { return viewTransformEnabled(); }
00519 
00520     QT3_SUPPORT void map(int x, int y, int *rx, int *ry) const;
00521     QT3_SUPPORT QPoint xForm(const QPoint &) const; // map virtual -> deviceb
00522     QT3_SUPPORT QRect xForm(const QRect &) const;
00523     QT3_SUPPORT QPolygon xForm(const QPolygon &) const;
00524     QT3_SUPPORT QPolygon xForm(const QPolygon &, int index, int npoints) const;
00525     QT3_SUPPORT QPoint xFormDev(const QPoint &) const; // map device -> virtual
00526     QT3_SUPPORT QRect xFormDev(const QRect &) const;
00527     QT3_SUPPORT QPolygon xFormDev(const QPolygon &) const;
00528     QT3_SUPPORT QPolygon xFormDev(const QPolygon &, int index, int npoints) const;
00529     QT3_SUPPORT qreal translationX() const;
00530     QT3_SUPPORT qreal translationY() const;
00531 #endif
00532 
00533 private:
00534     Q_DISABLE_COPY(QPainter)
00535     friend class Q3Painter;
00536 
00537     QScopedPointer<QPainterPrivate> d_ptr;
00538 
00539     friend class QFontEngine;
00540     friend class QFontEngineBox;
00541     friend class QFontEngineFT;
00542     friend class QFontEngineMac;
00543     friend class QFontEngineWin;
00544     friend class QFontEngineXLFD;
00545     friend class QWSManager;
00546     friend class QPaintEngine;
00547     friend class QPaintEngineExPrivate;
00548     friend class QOpenGLPaintEngine;
00549     friend class QX11PaintEngine;
00550     friend class QX11PaintEnginePrivate;
00551     friend class QWin32PaintEngine;
00552     friend class QWin32PaintEnginePrivate;
00553     friend class QRasterPaintEngine;
00554     friend class QAlphaPaintEngine;
00555     friend class QPreviewPaintEngine;
00556 };
00557 
00558 Q_DECLARE_OPERATORS_FOR_FLAGS(QPainter::RenderHints)
00559 
00560 //
00561 // functions
00562 //
00563 inline void QPainter::drawLine(const QLineF &l)
00564 {
00565     drawLines(&l, 1);
00566 }
00567 
00568 inline void QPainter::drawLine(const QLine &line)
00569 {
00570     drawLines(&line, 1);
00571 }
00572 
00573 inline void QPainter::drawLine(int x1, int y1, int x2, int y2)
00574 {
00575     QLine l(x1, y1, x2, y2);
00576     drawLines(&l, 1);
00577 }
00578 
00579 inline void QPainter::drawLine(const QPoint &p1, const QPoint &p2)
00580 {
00581     QLine l(p1, p2);
00582     drawLines(&l, 1);
00583 }
00584 
00585 inline void QPainter::drawLine(const QPointF &p1, const QPointF &p2)
00586 {
00587     drawLine(QLineF(p1, p2));
00588 }
00589 
00590 inline void QPainter::drawLines(const QVector<QLineF> &lines)
00591 {
00592     drawLines(lines.constData(), lines.size());
00593 }
00594 
00595 inline void QPainter::drawLines(const QVector<QLine> &lines)
00596 {
00597     drawLines(lines.constData(), lines.size());
00598 }
00599 
00600 inline void QPainter::drawLines(const QVector<QPointF> &pointPairs)
00601 {
00602     drawLines(pointPairs.constData(), pointPairs.size() / 2);
00603 }
00604 
00605 inline void QPainter::drawLines(const QVector<QPoint> &pointPairs)
00606 {
00607     drawLines(pointPairs.constData(), pointPairs.size() / 2);
00608 }
00609 
00610 inline void QPainter::drawPolyline(const QPolygonF &polyline)
00611 {
00612     drawPolyline(polyline.constData(), polyline.size());
00613 }
00614 
00615 inline void QPainter::drawPolyline(const QPolygon &polyline)
00616 {
00617     drawPolyline(polyline.constData(), polyline.size());
00618 }
00619 
00620 inline void QPainter::drawPolygon(const QPolygonF &polygon, Qt::FillRule fillRule)
00621 {
00622     drawPolygon(polygon.constData(), polygon.size(), fillRule);
00623 }
00624 
00625 inline void QPainter::drawPolygon(const QPolygon &polygon, Qt::FillRule fillRule)
00626 {
00627     drawPolygon(polygon.constData(), polygon.size(), fillRule);
00628 }
00629 
00630 inline void QPainter::drawConvexPolygon(const QPolygonF &poly)
00631 {
00632     drawConvexPolygon(poly.constData(), poly.size());
00633 }
00634 
00635 inline void QPainter::drawConvexPolygon(const QPolygon &poly)
00636 {
00637     drawConvexPolygon(poly.constData(), poly.size());
00638 }
00639 
00640 inline void QPainter::drawRect(const QRectF &rect)
00641 {
00642     drawRects(&rect, 1);
00643 }
00644 
00645 inline void QPainter::drawRect(int x, int y, int w, int h)
00646 {
00647     QRect r(x, y, w, h);
00648     drawRects(&r, 1);
00649 }
00650 
00651 inline void QPainter::drawRect(const QRect &r)
00652 {
00653     drawRects(&r, 1);
00654 }
00655 
00656 inline void QPainter::drawRects(const QVector<QRectF> &rects)
00657 {
00658     drawRects(rects.constData(), rects.size());
00659 }
00660 
00661 inline void QPainter::drawRects(const QVector<QRect> &rects)
00662 {
00663     drawRects(rects.constData(), rects.size());
00664 }
00665 
00666 inline void QPainter::drawPoint(const QPointF &p)
00667 {
00668     drawPoints(&p, 1);
00669 }
00670 
00671 inline void QPainter::drawPoint(int x, int y)
00672 {
00673     QPoint p(x, y);
00674     drawPoints(&p, 1);
00675 }
00676 
00677 inline void QPainter::drawPoint(const QPoint &p)
00678 {
00679     drawPoints(&p, 1);
00680 }
00681 
00682 inline void QPainter::drawPoints(const QPolygonF &points)
00683 {
00684     drawPoints(points.constData(), points.size());
00685 }
00686 
00687 inline void QPainter::drawPoints(const QPolygon &points)
00688 {
00689     drawPoints(points.constData(), points.size());
00690 }
00691 
00692 inline void QPainter::drawRoundRect(int x, int y, int w, int h, int xRnd, int yRnd)
00693 {
00694     drawRoundRect(QRectF(x, y, w, h), xRnd, yRnd);
00695 }
00696 
00697 inline void QPainter::drawRoundRect(const QRect &rect, int xRnd, int yRnd)
00698 {
00699     drawRoundRect(QRectF(rect), xRnd, yRnd);
00700 }
00701 
00702 inline void QPainter::drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius,
00703                             Qt::SizeMode mode)
00704 {
00705     drawRoundedRect(QRectF(x, y, w, h), xRadius, yRadius, mode);
00706 }
00707 
00708 inline void QPainter::drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius,
00709                             Qt::SizeMode mode)
00710 {
00711     drawRoundedRect(QRectF(rect), xRadius, yRadius, mode);
00712 }
00713 
00714 inline void QPainter::drawEllipse(int x, int y, int w, int h)
00715 {
00716     drawEllipse(QRect(x, y, w, h));
00717 }
00718 
00719 inline void QPainter::drawEllipse(const QPointF &center, qreal rx, qreal ry)
00720 {
00721     drawEllipse(QRectF(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
00722 }
00723 
00724 inline void QPainter::drawEllipse(const QPoint &center, int rx, int ry)
00725 {
00726     drawEllipse(QRect(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
00727 }
00728 
00729 inline void QPainter::drawArc(const QRect &r, int a, int alen)
00730 {
00731     drawArc(QRectF(r), a, alen);
00732 }
00733 
00734 inline void QPainter::drawArc(int x, int y, int w, int h, int a, int alen)
00735 {
00736     drawArc(QRectF(x, y, w, h), a, alen);
00737 }
00738 
00739 inline void QPainter::drawPie(const QRect &rect, int a, int alen)
00740 {
00741     drawPie(QRectF(rect), a, alen);
00742 }
00743 
00744 inline void QPainter::drawPie(int x, int y, int w, int h, int a, int alen)
00745 {
00746     drawPie(QRectF(x, y, w, h), a, alen);
00747 }
00748 
00749 inline void QPainter::drawChord(const QRect &rect, int a, int alen)
00750 {
00751     drawChord(QRectF(rect), a, alen);
00752 }
00753 
00754 inline void QPainter::drawChord(int x, int y, int w, int h, int a, int alen)
00755 {
00756     drawChord(QRectF(x, y, w, h), a, alen);
00757 }
00758 
00759 inline void QPainter::setClipRect(int x, int y, int w, int h, Qt::ClipOperation op)
00760 {
00761     setClipRect(QRect(x, y, w, h), op);
00762 }
00763 
00764 inline void QPainter::eraseRect(const QRect &rect)
00765 {
00766     eraseRect(QRectF(rect));
00767 }
00768 
00769 inline void QPainter::eraseRect(int x, int y, int w, int h)
00770 {
00771     eraseRect(QRectF(x, y, w, h));
00772 }
00773 
00774 inline void QPainter::fillRect(int x, int y, int w, int h, const QBrush &b)
00775 {
00776     fillRect(QRect(x, y, w, h), b);
00777 }
00778 
00779 inline void QPainter::fillRect(int x, int y, int w, int h, const QColor &b)
00780 {
00781     fillRect(QRect(x, y, w, h), b);
00782 }
00783 
00784 inline void QPainter::fillRect(int x, int y, int w, int h, Qt::GlobalColor c)
00785 {
00786     fillRect(QRect(x, y, w, h), QColor(c));
00787 }
00788 
00789 inline void QPainter::fillRect(const QRect &r, Qt::GlobalColor c)
00790 {
00791     fillRect(r, QColor(c));
00792 }
00793 
00794 inline void QPainter::fillRect(const QRectF &r, Qt::GlobalColor c)
00795 {
00796     fillRect(r, QColor(c));
00797 }
00798 
00799 inline void QPainter::fillRect(int x, int y, int w, int h, Qt::BrushStyle style)
00800 {
00801     fillRect(QRectF(x, y, w, h), QBrush(style));
00802 }
00803 
00804 inline void QPainter::fillRect(const QRect &r, Qt::BrushStyle style)
00805 {
00806     fillRect(QRectF(r), QBrush(style));
00807 }
00808 
00809 inline void QPainter::fillRect(const QRectF &r, Qt::BrushStyle style)
00810 {
00811     fillRect(r, QBrush(style));
00812 }
00813 
00814 
00815 inline void QPainter::setBrushOrigin(int x, int y)
00816 {
00817     setBrushOrigin(QPoint(x, y));
00818 }
00819 
00820 inline void QPainter::setBrushOrigin(const QPoint &p)
00821 {
00822     setBrushOrigin(QPointF(p));
00823 }
00824 
00825 inline void QPainter::drawTiledPixmap(const QRect &rect, const QPixmap &pm, const QPoint &offset)
00826 {
00827     drawTiledPixmap(QRectF(rect), pm, QPointF(offset));
00828 }
00829 
00830 inline void QPainter::drawTiledPixmap(int x, int y, int w, int h, const QPixmap &pm, int sx, int sy)
00831 {
00832     drawTiledPixmap(QRectF(x, y, w, h), pm, QPointF(sx, sy));
00833 }
00834 
00835 inline void QPainter::drawPixmap(const QRect &targetRect, const QPixmap &pixmap, const QRect &sourceRect)
00836 {
00837     drawPixmap(QRectF(targetRect), pixmap, QRectF(sourceRect));
00838 }
00839 
00840 inline void QPainter::drawPixmap(const QPoint &p, const QPixmap &pm)
00841 {
00842     drawPixmap(QPointF(p), pm);
00843 }
00844 
00845 inline void QPainter::drawPixmap(const QRect &r, const QPixmap &pm)
00846 {
00847     drawPixmap(QRectF(r), pm, QRectF());
00848 }
00849 
00850 inline void QPainter::drawPixmap(int x, int y, const QPixmap &pm)
00851 {
00852     drawPixmap(QPointF(x, y), pm);
00853 }
00854 
00855 inline void QPainter::drawPixmap(int x, int y, int w, int h, const QPixmap &pm)
00856 {
00857     drawPixmap(QRectF(x, y, w, h), pm, QRectF());
00858 }
00859 
00860 inline void QPainter::drawPixmap(int x, int y, int w, int h, const QPixmap &pm,
00861                                  int sx, int sy, int sw, int sh)
00862 {
00863     drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh));
00864 }
00865 
00866 inline void QPainter::drawPixmap(int x, int y, const QPixmap &pm,
00867                                  int sx, int sy, int sw, int sh)
00868 {
00869     drawPixmap(QRectF(x, y, -1, -1), pm, QRectF(sx, sy, sw, sh));
00870 }
00871 
00872 inline void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm, const QRectF &sr)
00873 {
00874     drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
00875 }
00876 
00877 inline void QPainter::drawPixmap(const QPoint &p, const QPixmap &pm, const QRect &sr)
00878 {
00879     drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
00880 }
00881 
00882 inline void QPainter::drawTextItem(int x, int y, const QTextItem &ti)
00883 {
00884     drawTextItem(QPointF(x, y), ti);
00885 }
00886 
00887 inline void QPainter::drawImage(const QRect &targetRect, const QImage &image, const QRect &sourceRect,
00888                                 Qt::ImageConversionFlags flags)
00889 {
00890     drawImage(QRectF(targetRect), image, QRectF(sourceRect), flags);
00891 }
00892 
00893 inline void QPainter::drawImage(const QPointF &p, const QImage &image, const QRectF &sr,
00894                                 Qt::ImageConversionFlags flags)
00895 {
00896     drawImage(QRectF(p.x(), p.y(), -1, -1), image, sr, flags);
00897 }
00898 
00899 inline void QPainter::drawImage(const QPoint &p, const QImage &image, const QRect &sr,
00900                                 Qt::ImageConversionFlags flags)
00901 {
00902     drawImage(QRect(p.x(), p.y(), -1, -1), image, sr, flags);
00903 }
00904 
00905 
00906 inline void QPainter::drawImage(const QRectF &r, const QImage &image)
00907 {
00908     drawImage(r, image, QRect(0, 0, image.width(), image.height()));
00909 }
00910 
00911 inline void QPainter::drawImage(const QRect &r, const QImage &image)
00912 {
00913     drawImage(r, image, QRectF(0, 0, image.width(), image.height()));
00914 }
00915 
00916 inline void QPainter::drawImage(const QPoint &p, const QImage &image)
00917 {
00918     drawImage(QPointF(p), image);
00919 }
00920 
00921 inline void QPainter::drawImage(int x, int y, const QImage &image, int sx, int sy, int sw, int sh,
00922                                 Qt::ImageConversionFlags flags)
00923 {
00924     if (sx == 0 && sy == 0 && sw == -1 && sh == -1 && flags == Qt::AutoColor)
00925         drawImage(QPointF(x, y), image);
00926     else
00927         drawImage(QRectF(x, y, -1, -1), image, QRectF(sx, sy, sw, sh), flags);
00928 }
00929 
00930 inline void QPainter::drawStaticText(const QPoint &p, const QStaticText &staticText)
00931 {
00932     drawStaticText(QPointF(p), staticText);
00933 }
00934 
00935 inline void QPainter::drawStaticText(int x, int y, const QStaticText &staticText)
00936 {
00937     drawStaticText(QPointF(x, y), staticText);
00938 }
00939 
00940 inline void QPainter::drawTextItem(const QPoint &p, const QTextItem &ti)
00941 {
00942     drawTextItem(QPointF(p), ti);
00943 }
00944 
00945 inline void QPainter::drawText(const QPoint &p, const QString &s)
00946 {
00947     drawText(QPointF(p), s);
00948 }
00949 
00950 inline void QPainter::drawText(int x, int y, int w, int h, int flags, const QString &str, QRect *br)
00951 {
00952     drawText(QRect(x, y, w, h), flags, str, br);
00953 }
00954 
00955 inline void QPainter::drawText(int x, int y, const QString &s)
00956 {
00957     drawText(QPointF(x, y), s);
00958 }
00959 
00960 inline QRect QPainter::boundingRect(int x, int y, int w, int h, int flags, const QString &text)
00961 {
00962     return boundingRect(QRect(x, y, w, h), flags, text);
00963 }
00964 
00965 inline void QPainter::translate(qreal dx, qreal dy)
00966 {
00967     translate(QPointF(dx, dy));
00968 }
00969 
00970 inline void QPainter::translate(const QPoint &offset)
00971 {
00972     translate(offset.x(), offset.y());
00973 }
00974 
00975 inline void QPainter::setViewport(int x, int y, int w, int h)
00976 {
00977     setViewport(QRect(x, y, w, h));
00978 }
00979 
00980 inline void QPainter::setWindow(int x, int y, int w, int h)
00981 {
00982     setWindow(QRect(x, y, w, h));
00983 }
00984 
00985 #ifndef QT_NO_PICTURE
00986 inline void QPainter::drawPicture(int x, int y, const QPicture &p)
00987 {
00988     drawPicture(QPoint(x, y), p);
00989 }
00990 
00991 inline void QPainter::drawPicture(const QPoint &pt, const QPicture &p)
00992 {
00993     drawPicture(QPointF(pt), p);
00994 }
00995 #endif
00996 
00997 QT_END_NAMESPACE
00998 
00999 QT_END_HEADER
01000 
01001 #endif // QPAINTER_H