src/gui/painting/qpainter.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QPAINTER_H
       
    43 #define QPAINTER_H
       
    44 
       
    45 #include <QtCore/qnamespace.h>
       
    46 #include <QtCore/qrect.h>
       
    47 #include <QtCore/qpoint.h>
       
    48 #include <QtCore/qscopedpointer.h>
       
    49 #include <QtGui/qpixmap.h>
       
    50 #include <QtGui/qimage.h>
       
    51 #include <QtGui/qtextoption.h>
       
    52 #include <QtGui/qdrawutil.h>
       
    53 
       
    54 #ifndef QT_INCLUDE_COMPAT
       
    55 #include <QtGui/qpolygon.h>
       
    56 #include <QtGui/qpen.h>
       
    57 #include <QtGui/qbrush.h>
       
    58 #include <QtGui/qmatrix.h>
       
    59 #include <QtGui/qtransform.h>
       
    60 #include <QtGui/qfontinfo.h>
       
    61 #include <QtGui/qfontmetrics.h>
       
    62 #endif
       
    63 
       
    64 QT_BEGIN_HEADER
       
    65 
       
    66 QT_BEGIN_NAMESPACE
       
    67 
       
    68 QT_MODULE(Gui)
       
    69 
       
    70 class QBrush;
       
    71 class QFontInfo;
       
    72 class QFontMetrics;
       
    73 class QPaintDevice;
       
    74 class QPainterPath;
       
    75 class QPainterPrivate;
       
    76 class QPen;
       
    77 class QPolygon;
       
    78 class QTextItem;
       
    79 class QMatrix;
       
    80 class QTransform;
       
    81 
       
    82 class QPainterPrivateDeleter;
       
    83 
       
    84 class Q_GUI_EXPORT QPainter
       
    85 {
       
    86     Q_DECLARE_PRIVATE(QPainter)
       
    87     Q_GADGET
       
    88     Q_FLAGS(RenderHint RenderHints)
       
    89 
       
    90 public:
       
    91     enum RenderHint {
       
    92         Antialiasing = 0x01,
       
    93         TextAntialiasing = 0x02,
       
    94         SmoothPixmapTransform = 0x04,
       
    95         HighQualityAntialiasing = 0x08,
       
    96         NonCosmeticDefaultPen = 0x10
       
    97     };
       
    98 
       
    99     Q_DECLARE_FLAGS(RenderHints, RenderHint)
       
   100 
       
   101     QPainter();
       
   102     explicit QPainter(QPaintDevice *);
       
   103     ~QPainter();
       
   104 
       
   105     QPaintDevice *device() const;
       
   106 
       
   107     bool begin(QPaintDevice *);
       
   108     bool end();
       
   109     bool isActive() const;
       
   110 
       
   111     void initFrom(const QWidget *widget);
       
   112 
       
   113     enum CompositionMode {
       
   114         CompositionMode_SourceOver,
       
   115         CompositionMode_DestinationOver,
       
   116         CompositionMode_Clear,
       
   117         CompositionMode_Source,
       
   118         CompositionMode_Destination,
       
   119         CompositionMode_SourceIn,
       
   120         CompositionMode_DestinationIn,
       
   121         CompositionMode_SourceOut,
       
   122         CompositionMode_DestinationOut,
       
   123         CompositionMode_SourceAtop,
       
   124         CompositionMode_DestinationAtop,
       
   125         CompositionMode_Xor,
       
   126 
       
   127         //svg 1.2 blend modes
       
   128         CompositionMode_Plus,
       
   129         CompositionMode_Multiply,
       
   130         CompositionMode_Screen,
       
   131         CompositionMode_Overlay,
       
   132         CompositionMode_Darken,
       
   133         CompositionMode_Lighten,
       
   134         CompositionMode_ColorDodge,
       
   135         CompositionMode_ColorBurn,
       
   136         CompositionMode_HardLight,
       
   137         CompositionMode_SoftLight,
       
   138         CompositionMode_Difference,
       
   139         CompositionMode_Exclusion,
       
   140 
       
   141         // ROPs
       
   142         RasterOp_SourceOrDestination,
       
   143         RasterOp_SourceAndDestination,
       
   144         RasterOp_SourceXorDestination,
       
   145         RasterOp_NotSourceAndNotDestination,
       
   146         RasterOp_NotSourceOrNotDestination,
       
   147         RasterOp_NotSourceXorDestination,
       
   148         RasterOp_NotSource,
       
   149         RasterOp_NotSourceAndDestination,
       
   150         RasterOp_SourceAndNotDestination
       
   151     };
       
   152     void setCompositionMode(CompositionMode mode);
       
   153     CompositionMode compositionMode() const;
       
   154 
       
   155     const QFont &font() const;
       
   156     void setFont(const QFont &f);
       
   157 
       
   158     QFontMetrics fontMetrics() const;
       
   159     QFontInfo fontInfo() const;
       
   160 
       
   161     void setPen(const QColor &color);
       
   162     void setPen(const QPen &pen);
       
   163     void setPen(Qt::PenStyle style);
       
   164     const QPen &pen() const;
       
   165 
       
   166     void setBrush(const QBrush &brush);
       
   167     void setBrush(Qt::BrushStyle style);
       
   168     const QBrush &brush() const;
       
   169 
       
   170     // attributes/modes
       
   171     void setBackgroundMode(Qt::BGMode mode);
       
   172     Qt::BGMode backgroundMode() const;
       
   173 
       
   174     QPoint brushOrigin() const;
       
   175     inline void setBrushOrigin(int x, int y);
       
   176     inline void setBrushOrigin(const QPoint &);
       
   177     void setBrushOrigin(const QPointF &);
       
   178 
       
   179     void setBackground(const QBrush &bg);
       
   180     const QBrush &background() const;
       
   181 
       
   182     qreal opacity() const;
       
   183     void setOpacity(qreal opacity);
       
   184 
       
   185     // Clip functions
       
   186     QRegion clipRegion() const;
       
   187     QPainterPath clipPath() const;
       
   188 
       
   189     void setClipRect(const QRectF &, Qt::ClipOperation op = Qt::ReplaceClip);
       
   190     void setClipRect(const QRect &, Qt::ClipOperation op = Qt::ReplaceClip);
       
   191     inline void setClipRect(int x, int y, int w, int h, Qt::ClipOperation op = Qt::ReplaceClip);
       
   192 
       
   193     void setClipRegion(const QRegion &, Qt::ClipOperation op = Qt::ReplaceClip);
       
   194 
       
   195     void setClipPath(const QPainterPath &path, Qt::ClipOperation op = Qt::ReplaceClip);
       
   196 
       
   197     void setClipping(bool enable);
       
   198     bool hasClipping() const;
       
   199 
       
   200     void save();
       
   201     void restore();
       
   202 
       
   203     // XForm functions
       
   204     void setMatrix(const QMatrix &matrix, bool combine = false);
       
   205     const QMatrix &matrix() const;
       
   206     const QMatrix &deviceMatrix() const;
       
   207     void resetMatrix();
       
   208 
       
   209     void setTransform(const QTransform &transform, bool combine = false);
       
   210     const QTransform &transform() const;
       
   211     const QTransform &deviceTransform() const;
       
   212     void resetTransform();
       
   213 
       
   214     void setWorldMatrix(const QMatrix &matrix, bool combine = false);
       
   215     const QMatrix &worldMatrix() const;
       
   216 
       
   217     void setWorldTransform(const QTransform &matrix, bool combine = false);
       
   218     const QTransform &worldTransform() const;
       
   219 
       
   220     QMatrix combinedMatrix() const;
       
   221     QTransform combinedTransform() const;
       
   222 
       
   223     void setMatrixEnabled(bool enabled);
       
   224     bool matrixEnabled() const;
       
   225 
       
   226     void setWorldMatrixEnabled(bool enabled);
       
   227     bool worldMatrixEnabled() const;
       
   228 
       
   229     void scale(qreal sx, qreal sy);
       
   230     void shear(qreal sh, qreal sv);
       
   231     void rotate(qreal a);
       
   232 
       
   233     void translate(const QPointF &offset);
       
   234     inline void translate(const QPoint &offset);
       
   235     inline void translate(qreal dx, qreal dy);
       
   236 
       
   237     QRect window() const;
       
   238     void setWindow(const QRect &window);
       
   239     inline void setWindow(int x, int y, int w, int h);
       
   240 
       
   241     QRect viewport() const;
       
   242     void setViewport(const QRect &viewport);
       
   243     inline void setViewport(int x, int y, int w, int h);
       
   244 
       
   245     void setViewTransformEnabled(bool enable);
       
   246     bool viewTransformEnabled() const;
       
   247 
       
   248     // drawing functions
       
   249     void strokePath(const QPainterPath &path, const QPen &pen);
       
   250     void fillPath(const QPainterPath &path, const QBrush &brush);
       
   251     void drawPath(const QPainterPath &path);
       
   252 
       
   253     inline void drawPoint(const QPointF &pt);
       
   254     inline void drawPoint(const QPoint &p);
       
   255     inline void drawPoint(int x, int y);
       
   256 
       
   257     void drawPoints(const QPointF *points, int pointCount);
       
   258     inline void drawPoints(const QPolygonF &points);
       
   259     void drawPoints(const QPoint *points, int pointCount);
       
   260     inline void drawPoints(const QPolygon &points);
       
   261 
       
   262     inline void drawLine(const QLineF &line);
       
   263     inline void drawLine(const QLine &line);
       
   264     inline void drawLine(int x1, int y1, int x2, int y2);
       
   265     inline void drawLine(const QPoint &p1, const QPoint &p2);
       
   266     inline void drawLine(const QPointF &p1, const QPointF &p2);
       
   267 
       
   268     void drawLines(const QLineF *lines, int lineCount);
       
   269     inline void drawLines(const QVector<QLineF> &lines);
       
   270     void drawLines(const QPointF *pointPairs, int lineCount);
       
   271     inline void drawLines(const QVector<QPointF> &pointPairs);
       
   272     void drawLines(const QLine *lines, int lineCount);
       
   273     inline void drawLines(const QVector<QLine> &lines);
       
   274     void drawLines(const QPoint *pointPairs, int lineCount);
       
   275     inline void drawLines(const QVector<QPoint> &pointPairs);
       
   276 
       
   277     inline void drawRect(const QRectF &rect);
       
   278     inline void drawRect(int x1, int y1, int w, int h);
       
   279     inline void drawRect(const QRect &rect);
       
   280 
       
   281     void drawRects(const QRectF *rects, int rectCount);
       
   282     inline void drawRects(const QVector<QRectF> &rectangles);
       
   283     void drawRects(const QRect *rects, int rectCount);
       
   284     inline void drawRects(const QVector<QRect> &rectangles);
       
   285 
       
   286     void drawEllipse(const QRectF &r);
       
   287     void drawEllipse(const QRect &r);
       
   288     inline void drawEllipse(int x, int y, int w, int h);
       
   289 
       
   290     inline void drawEllipse(const QPointF &center, qreal rx, qreal ry);
       
   291     inline void drawEllipse(const QPoint &center, int rx, int ry);
       
   292 
       
   293     void drawPolyline(const QPointF *points, int pointCount);
       
   294     inline void drawPolyline(const QPolygonF &polyline);
       
   295     void drawPolyline(const QPoint *points, int pointCount);
       
   296     inline void drawPolyline(const QPolygon &polygon);
       
   297 
       
   298     void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill);
       
   299     inline void drawPolygon(const QPolygonF &polygon, Qt::FillRule fillRule = Qt::OddEvenFill);
       
   300     void drawPolygon(const QPoint *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill);
       
   301     inline void drawPolygon(const QPolygon &polygon, Qt::FillRule fillRule = Qt::OddEvenFill);
       
   302 
       
   303     void drawConvexPolygon(const QPointF *points, int pointCount);
       
   304     inline void drawConvexPolygon(const QPolygonF &polygon);
       
   305     void drawConvexPolygon(const QPoint *points, int pointCount);
       
   306     inline void drawConvexPolygon(const QPolygon &polygon);
       
   307 
       
   308     void drawArc(const QRectF &rect, int a, int alen);
       
   309     inline void drawArc(const QRect &, int a, int alen);
       
   310     inline void drawArc(int x, int y, int w, int h, int a, int alen);
       
   311 
       
   312     void drawPie(const QRectF &rect, int a, int alen);
       
   313     inline void drawPie(int x, int y, int w, int h, int a, int alen);
       
   314     inline void drawPie(const QRect &, int a, int alen);
       
   315 
       
   316     void drawChord(const QRectF &rect, int a, int alen);
       
   317     inline void drawChord(int x, int y, int w, int h, int a, int alen);
       
   318     inline void drawChord(const QRect &, int a, int alen);
       
   319 
       
   320     void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius,
       
   321                          Qt::SizeMode mode = Qt::AbsoluteSize);
       
   322     inline void drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius,
       
   323                                 Qt::SizeMode mode = Qt::AbsoluteSize);
       
   324     inline void drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius,
       
   325                                 Qt::SizeMode mode = Qt::AbsoluteSize);
       
   326 
       
   327     void drawRoundRect(const QRectF &r, int xround = 25, int yround = 25);
       
   328     inline void drawRoundRect(int x, int y, int w, int h, int = 25, int = 25);
       
   329     inline void drawRoundRect(const QRect &r, int xround = 25, int yround = 25);
       
   330 
       
   331     void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset = QPointF());
       
   332     inline void drawTiledPixmap(int x, int y, int w, int h, const QPixmap &, int sx=0, int sy=0);
       
   333     inline void drawTiledPixmap(const QRect &, const QPixmap &, const QPoint & = QPoint());
       
   334 #ifndef QT_NO_PICTURE
       
   335     void drawPicture(const QPointF &p, const QPicture &picture);
       
   336     inline void drawPicture(int x, int y, const QPicture &picture);
       
   337     inline void drawPicture(const QPoint &p, const QPicture &picture);
       
   338 #endif
       
   339 
       
   340     void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect);
       
   341     inline void drawPixmap(const QRect &targetRect, const QPixmap &pixmap, const QRect &sourceRect);
       
   342     inline void drawPixmap(int x, int y, int w, int h, const QPixmap &pm,
       
   343                            int sx, int sy, int sw, int sh);
       
   344     inline void drawPixmap(int x, int y, const QPixmap &pm,
       
   345                            int sx, int sy, int sw, int sh);
       
   346     inline void drawPixmap(const QPointF &p, const QPixmap &pm, const QRectF &sr);
       
   347     inline void drawPixmap(const QPoint &p, const QPixmap &pm, const QRect &sr);
       
   348     void drawPixmap(const QPointF &p, const QPixmap &pm);
       
   349     inline void drawPixmap(const QPoint &p, const QPixmap &pm);
       
   350     inline void drawPixmap(int x, int y, const QPixmap &pm);
       
   351     inline void drawPixmap(const QRect &r, const QPixmap &pm);
       
   352     inline void drawPixmap(int x, int y, int w, int h, const QPixmap &pm);
       
   353 
       
   354     void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect,
       
   355                    Qt::ImageConversionFlags flags = Qt::AutoColor);
       
   356     inline void drawImage(const QRect &targetRect, const QImage &image, const QRect &sourceRect,
       
   357                           Qt::ImageConversionFlags flags = Qt::AutoColor);
       
   358     inline void drawImage(const QPointF &p, const QImage &image, const QRectF &sr,
       
   359                           Qt::ImageConversionFlags flags = Qt::AutoColor);
       
   360     inline void drawImage(const QPoint &p, const QImage &image, const QRect &sr,
       
   361                           Qt::ImageConversionFlags flags = Qt::AutoColor);
       
   362     inline void drawImage(const QRectF &r, const QImage &image);
       
   363     inline void drawImage(const QRect &r, const QImage &image);
       
   364     void drawImage(const QPointF &p, const QImage &image);
       
   365     inline void drawImage(const QPoint &p, const QImage &image);
       
   366     inline void drawImage(int x, int y, const QImage &image, int sx = 0, int sy = 0,
       
   367                           int sw = -1, int sh = -1, Qt::ImageConversionFlags flags = Qt::AutoColor);
       
   368 
       
   369     void setLayoutDirection(Qt::LayoutDirection direction);
       
   370     Qt::LayoutDirection layoutDirection() const;
       
   371 
       
   372     void drawText(const QPointF &p, const QString &s);
       
   373     inline void drawText(const QPoint &p, const QString &s);
       
   374     inline void drawText(int x, int y, const QString &s);
       
   375 
       
   376     void drawText(const QPointF &p, const QString &str, int tf, int justificationPadding);
       
   377 
       
   378     void drawText(const QRectF &r, int flags, const QString &text, QRectF *br=0);
       
   379     void drawText(const QRect &r, int flags, const QString &text, QRect *br=0);
       
   380     inline void drawText(int x, int y, int w, int h, int flags, const QString &text, QRect *br=0);
       
   381 
       
   382     void drawText(const QRectF &r, const QString &text, const QTextOption &o = QTextOption());
       
   383 
       
   384     QRectF boundingRect(const QRectF &rect, int flags, const QString &text);
       
   385     QRect boundingRect(const QRect &rect, int flags, const QString &text);
       
   386     inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text);
       
   387 
       
   388     QRectF boundingRect(const QRectF &rect, const QString &text, const QTextOption &o = QTextOption());
       
   389 
       
   390     void drawTextItem(const QPointF &p, const QTextItem &ti);
       
   391     inline void drawTextItem(int x, int y, const QTextItem &ti);
       
   392     inline void drawTextItem(const QPoint &p, const QTextItem &ti);
       
   393 
       
   394     void fillRect(const QRectF &, const QBrush &);
       
   395     inline void fillRect(int x, int y, int w, int h, const QBrush &);
       
   396     void fillRect(const QRect &, const QBrush &);
       
   397 
       
   398     void fillRect(const QRectF &, const QColor &color);
       
   399     inline void fillRect(int x, int y, int w, int h, const QColor &color);
       
   400     void fillRect(const QRect &, const QColor &color);
       
   401 
       
   402     inline void fillRect(int x, int y, int w, int h, Qt::GlobalColor c);
       
   403     inline void fillRect(const QRect &r, Qt::GlobalColor c);
       
   404     inline void fillRect(const QRectF &r, Qt::GlobalColor c);
       
   405 
       
   406     inline void fillRect(int x, int y, int w, int h, Qt::BrushStyle style);
       
   407     inline void fillRect(const QRect &r, Qt::BrushStyle style);
       
   408     inline void fillRect(const QRectF &r, Qt::BrushStyle style);
       
   409 
       
   410     void eraseRect(const QRectF &);
       
   411     inline void eraseRect(int x, int y, int w, int h);
       
   412     inline void eraseRect(const QRect &);
       
   413 
       
   414     void setRenderHint(RenderHint hint, bool on = true);
       
   415     void setRenderHints(RenderHints hints, bool on = true);
       
   416     RenderHints renderHints() const;
       
   417     inline bool testRenderHint(RenderHint hint) const { return renderHints() & hint; }
       
   418 
       
   419     QPaintEngine *paintEngine() const;
       
   420 
       
   421     static void setRedirected(const QPaintDevice *device, QPaintDevice *replacement,
       
   422                               const QPoint& offset = QPoint());
       
   423     static QPaintDevice *redirected(const QPaintDevice *device, QPoint *offset = 0);
       
   424     static void restoreRedirected(const QPaintDevice *device);
       
   425 
       
   426     void beginNativePainting();
       
   427     void endNativePainting();
       
   428 
       
   429 #ifdef QT3_SUPPORT
       
   430 
       
   431     inline QT3_SUPPORT void setBackgroundColor(const QColor &color) { setBackground(color); }
       
   432     inline QT3_SUPPORT const QColor &backgroundColor() const { return background().color(); }
       
   433 
       
   434     inline QT3_SUPPORT void drawText(int x, int y, const QString &s, int pos, int len)
       
   435         { drawText(x, y, s.mid(pos, len)); }
       
   436     inline QT3_SUPPORT void drawText(const QPoint &p, const QString &s, int pos, int len)
       
   437         { drawText(p, s.mid(pos, len)); }
       
   438     inline QT3_SUPPORT void drawText(int x, int y, const QString &s, int len)
       
   439         { drawText(x, y, s.left(len)); }
       
   440     inline QT3_SUPPORT void drawText(const QPoint &p, const QString &s, int len)
       
   441         { drawText(p, s.left(len)); }
       
   442     inline QT3_SUPPORT void drawText(const QRect &r, int flags, const QString &str, int len, QRect *br=0)
       
   443         { drawText(r, flags, str.left(len), br); }
       
   444     inline QT3_SUPPORT void drawText(int x, int y, int w, int h, int flags, const QString &text, int len, QRect *br=0)
       
   445         { drawText(QRect(x, y, w, h), flags, text.left(len), br); }
       
   446     inline QT3_SUPPORT QRect boundingRect(const QRect &rect, int flags, const QString &text, int len)
       
   447         { return boundingRect(rect, flags, text.left(len)); }
       
   448     inline QT3_SUPPORT QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text, int len)
       
   449         { return boundingRect(QRect(x, y, w, h), flags, text.left(len)); }
       
   450 
       
   451     inline QT3_SUPPORT bool begin(QPaintDevice *pdev, const QWidget *init)
       
   452         { bool ret = begin(pdev); initFrom(init); return ret; }
       
   453     QT3_SUPPORT void drawPoints(const QPolygon &pa, int index, int npoints = -1)
       
   454     { drawPoints(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
       
   455 
       
   456     QT3_SUPPORT void drawCubicBezier(const QPolygon &pa, int index = 0);
       
   457 
       
   458     QT3_SUPPORT void drawLineSegments(const QPolygon &points, int index = 0, int nlines = -1);
       
   459 
       
   460     inline QT3_SUPPORT void drawPolyline(const QPolygon &pa, int index, int npoints = -1)
       
   461     { drawPolyline(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
       
   462 
       
   463     inline QT3_SUPPORT void drawPolygon(const QPolygon &pa, bool winding, int index = 0, int npoints = -1)
       
   464     { drawPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints,
       
   465                   winding ? Qt::WindingFill : Qt::OddEvenFill); }
       
   466 
       
   467     inline QT3_SUPPORT void drawPolygon(const QPolygonF &polygon, bool winding, int index = 0,
       
   468                                       int npoints = -1)
       
   469     { drawPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints,
       
   470                   winding ? Qt::WindingFill : Qt::OddEvenFill); }
       
   471 
       
   472     inline QT3_SUPPORT void drawConvexPolygon(const QPolygonF &polygon, int index, int npoints = -1)
       
   473     { drawConvexPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints); }
       
   474     inline QT3_SUPPORT void drawConvexPolygon(const QPolygon &pa, int index, int npoints = -1)
       
   475     { drawConvexPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
       
   476 
       
   477     static inline QT3_SUPPORT void redirect(QPaintDevice *pdev, QPaintDevice *replacement)
       
   478     { setRedirected(pdev, replacement); }
       
   479     static inline QT3_SUPPORT QPaintDevice *redirect(QPaintDevice *pdev)
       
   480     { return const_cast<QPaintDevice*>(redirected(pdev)); }
       
   481 
       
   482     inline QT3_SUPPORT void setWorldXForm(bool enabled) { setMatrixEnabled(enabled); }
       
   483     inline QT3_SUPPORT bool hasWorldXForm() const { return matrixEnabled(); }
       
   484     inline QT3_SUPPORT void resetXForm() { resetTransform(); }
       
   485 
       
   486     inline QT3_SUPPORT void setViewXForm(bool enabled) { setViewTransformEnabled(enabled); }
       
   487     inline QT3_SUPPORT bool hasViewXForm() const { return viewTransformEnabled(); }
       
   488 
       
   489     QT3_SUPPORT void map(int x, int y, int *rx, int *ry) const;
       
   490     QT3_SUPPORT QPoint xForm(const QPoint &) const; // map virtual -> deviceb
       
   491     QT3_SUPPORT QRect xForm(const QRect &) const;
       
   492     QT3_SUPPORT QPolygon xForm(const QPolygon &) const;
       
   493     QT3_SUPPORT QPolygon xForm(const QPolygon &, int index, int npoints) const;
       
   494     QT3_SUPPORT QPoint xFormDev(const QPoint &) const; // map device -> virtual
       
   495     QT3_SUPPORT QRect xFormDev(const QRect &) const;
       
   496     QT3_SUPPORT QPolygon xFormDev(const QPolygon &) const;
       
   497     QT3_SUPPORT QPolygon xFormDev(const QPolygon &, int index, int npoints) const;
       
   498     QT3_SUPPORT qreal translationX() const;
       
   499     QT3_SUPPORT qreal translationY() const;
       
   500 #endif
       
   501 
       
   502 private:
       
   503     Q_DISABLE_COPY(QPainter)
       
   504     friend class Q3Painter;
       
   505 
       
   506     QScopedPointer<QPainterPrivate> d_ptr;
       
   507 
       
   508     friend class QFontEngine;
       
   509     friend class QFontEngineBox;
       
   510     friend class QFontEngineFT;
       
   511     friend class QFontEngineMac;
       
   512     friend class QFontEngineWin;
       
   513     friend class QFontEngineXLFD;
       
   514     friend class QWSManager;
       
   515     friend class QPaintEngine;
       
   516     friend class QPaintEngineExPrivate;
       
   517     friend class QOpenGLPaintEngine;
       
   518     friend class QX11PaintEngine;
       
   519     friend class QX11PaintEnginePrivate;
       
   520     friend class QWin32PaintEngine;
       
   521     friend class QWin32PaintEnginePrivate;
       
   522     friend class QRasterPaintEngine;
       
   523     friend class QAlphaPaintEngine;
       
   524     friend class QPreviewPaintEngine;
       
   525 };
       
   526 
       
   527 Q_DECLARE_OPERATORS_FOR_FLAGS(QPainter::RenderHints)
       
   528 
       
   529 //
       
   530 // functions
       
   531 //
       
   532 inline void QPainter::drawLine(const QLineF &l)
       
   533 {
       
   534     drawLines(&l, 1);
       
   535 }
       
   536 
       
   537 inline void QPainter::drawLine(const QLine &line)
       
   538 {
       
   539     drawLines(&line, 1);
       
   540 }
       
   541 
       
   542 inline void QPainter::drawLine(int x1, int y1, int x2, int y2)
       
   543 {
       
   544     QLine l(x1, y1, x2, y2);
       
   545     drawLines(&l, 1);
       
   546 }
       
   547 
       
   548 inline void QPainter::drawLine(const QPoint &p1, const QPoint &p2)
       
   549 {
       
   550     QLine l(p1, p2);
       
   551     drawLines(&l, 1);
       
   552 }
       
   553 
       
   554 inline void QPainter::drawLine(const QPointF &p1, const QPointF &p2)
       
   555 {
       
   556     drawLine(QLineF(p1, p2));
       
   557 }
       
   558 
       
   559 inline void QPainter::drawLines(const QVector<QLineF> &lines)
       
   560 {
       
   561     drawLines(lines.constData(), lines.size());
       
   562 }
       
   563 
       
   564 inline void QPainter::drawLines(const QVector<QLine> &lines)
       
   565 {
       
   566     drawLines(lines.constData(), lines.size());
       
   567 }
       
   568 
       
   569 inline void QPainter::drawLines(const QVector<QPointF> &pointPairs)
       
   570 {
       
   571     drawLines(pointPairs.constData(), pointPairs.size() / 2);
       
   572 }
       
   573 
       
   574 inline void QPainter::drawLines(const QVector<QPoint> &pointPairs)
       
   575 {
       
   576     drawLines(pointPairs.constData(), pointPairs.size() / 2);
       
   577 }
       
   578 
       
   579 inline void QPainter::drawPolyline(const QPolygonF &polyline)
       
   580 {
       
   581     drawPolyline(polyline.constData(), polyline.size());
       
   582 }
       
   583 
       
   584 inline void QPainter::drawPolyline(const QPolygon &polyline)
       
   585 {
       
   586     drawPolyline(polyline.constData(), polyline.size());
       
   587 }
       
   588 
       
   589 inline void QPainter::drawPolygon(const QPolygonF &polygon, Qt::FillRule fillRule)
       
   590 {
       
   591     drawPolygon(polygon.constData(), polygon.size(), fillRule);
       
   592 }
       
   593 
       
   594 inline void QPainter::drawPolygon(const QPolygon &polygon, Qt::FillRule fillRule)
       
   595 {
       
   596     drawPolygon(polygon.constData(), polygon.size(), fillRule);
       
   597 }
       
   598 
       
   599 inline void QPainter::drawConvexPolygon(const QPolygonF &poly)
       
   600 {
       
   601     drawConvexPolygon(poly.constData(), poly.size());
       
   602 }
       
   603 
       
   604 inline void QPainter::drawConvexPolygon(const QPolygon &poly)
       
   605 {
       
   606     drawConvexPolygon(poly.constData(), poly.size());
       
   607 }
       
   608 
       
   609 inline void QPainter::drawRect(const QRectF &rect)
       
   610 {
       
   611     drawRects(&rect, 1);
       
   612 }
       
   613 
       
   614 inline void QPainter::drawRect(int x, int y, int w, int h)
       
   615 {
       
   616     QRect r(x, y, w, h);
       
   617     drawRects(&r, 1);
       
   618 }
       
   619 
       
   620 inline void QPainter::drawRect(const QRect &r)
       
   621 {
       
   622     drawRects(&r, 1);
       
   623 }
       
   624 
       
   625 inline void QPainter::drawRects(const QVector<QRectF> &rects)
       
   626 {
       
   627     drawRects(rects.constData(), rects.size());
       
   628 }
       
   629 
       
   630 inline void QPainter::drawRects(const QVector<QRect> &rects)
       
   631 {
       
   632     drawRects(rects.constData(), rects.size());
       
   633 }
       
   634 
       
   635 inline void QPainter::drawPoint(const QPointF &p)
       
   636 {
       
   637     drawPoints(&p, 1);
       
   638 }
       
   639 
       
   640 inline void QPainter::drawPoint(int x, int y)
       
   641 {
       
   642     QPoint p(x, y);
       
   643     drawPoints(&p, 1);
       
   644 }
       
   645 
       
   646 inline void QPainter::drawPoint(const QPoint &p)
       
   647 {
       
   648     drawPoints(&p, 1);
       
   649 }
       
   650 
       
   651 inline void QPainter::drawPoints(const QPolygonF &points)
       
   652 {
       
   653     drawPoints(points.constData(), points.size());
       
   654 }
       
   655 
       
   656 inline void QPainter::drawPoints(const QPolygon &points)
       
   657 {
       
   658     drawPoints(points.constData(), points.size());
       
   659 }
       
   660 
       
   661 inline void QPainter::drawRoundRect(int x, int y, int w, int h, int xRnd, int yRnd)
       
   662 {
       
   663     drawRoundRect(QRectF(x, y, w, h), xRnd, yRnd);
       
   664 }
       
   665 
       
   666 inline void QPainter::drawRoundRect(const QRect &rect, int xRnd, int yRnd)
       
   667 {
       
   668     drawRoundRect(QRectF(rect), xRnd, yRnd);
       
   669 }
       
   670 
       
   671 inline void QPainter::drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius,
       
   672                             Qt::SizeMode mode)
       
   673 {
       
   674     drawRoundedRect(QRectF(x, y, w, h), xRadius, yRadius, mode);
       
   675 }
       
   676 
       
   677 inline void QPainter::drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius,
       
   678                             Qt::SizeMode mode)
       
   679 {
       
   680     drawRoundedRect(QRectF(rect), xRadius, yRadius, mode);
       
   681 }
       
   682 
       
   683 inline void QPainter::drawEllipse(int x, int y, int w, int h)
       
   684 {
       
   685     drawEllipse(QRect(x, y, w, h));
       
   686 }
       
   687 
       
   688 inline void QPainter::drawEllipse(const QPointF &center, qreal rx, qreal ry)
       
   689 {
       
   690     drawEllipse(QRectF(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
       
   691 }
       
   692 
       
   693 inline void QPainter::drawEllipse(const QPoint &center, int rx, int ry)
       
   694 {
       
   695     drawEllipse(QRect(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
       
   696 }
       
   697 
       
   698 inline void QPainter::drawArc(const QRect &r, int a, int alen)
       
   699 {
       
   700     drawArc(QRectF(r), a, alen);
       
   701 }
       
   702 
       
   703 inline void QPainter::drawArc(int x, int y, int w, int h, int a, int alen)
       
   704 {
       
   705     drawArc(QRectF(x, y, w, h), a, alen);
       
   706 }
       
   707 
       
   708 inline void QPainter::drawPie(const QRect &rect, int a, int alen)
       
   709 {
       
   710     drawPie(QRectF(rect), a, alen);
       
   711 }
       
   712 
       
   713 inline void QPainter::drawPie(int x, int y, int w, int h, int a, int alen)
       
   714 {
       
   715     drawPie(QRectF(x, y, w, h), a, alen);
       
   716 }
       
   717 
       
   718 inline void QPainter::drawChord(const QRect &rect, int a, int alen)
       
   719 {
       
   720     drawChord(QRectF(rect), a, alen);
       
   721 }
       
   722 
       
   723 inline void QPainter::drawChord(int x, int y, int w, int h, int a, int alen)
       
   724 {
       
   725     drawChord(QRectF(x, y, w, h), a, alen);
       
   726 }
       
   727 
       
   728 inline void QPainter::setClipRect(int x, int y, int w, int h, Qt::ClipOperation op)
       
   729 {
       
   730     setClipRect(QRect(x, y, w, h), op);
       
   731 }
       
   732 
       
   733 inline void QPainter::eraseRect(const QRect &rect)
       
   734 {
       
   735     eraseRect(QRectF(rect));
       
   736 }
       
   737 
       
   738 inline void QPainter::eraseRect(int x, int y, int w, int h)
       
   739 {
       
   740     eraseRect(QRectF(x, y, w, h));
       
   741 }
       
   742 
       
   743 inline void QPainter::fillRect(int x, int y, int w, int h, const QBrush &b)
       
   744 {
       
   745     fillRect(QRect(x, y, w, h), b);
       
   746 }
       
   747 
       
   748 inline void QPainter::fillRect(int x, int y, int w, int h, const QColor &b)
       
   749 {
       
   750     fillRect(QRect(x, y, w, h), b);
       
   751 }
       
   752 
       
   753 inline void QPainter::fillRect(int x, int y, int w, int h, Qt::GlobalColor c)
       
   754 {
       
   755     fillRect(QRect(x, y, w, h), QColor(c));
       
   756 }
       
   757 
       
   758 inline void QPainter::fillRect(const QRect &r, Qt::GlobalColor c)
       
   759 {
       
   760     fillRect(r, QColor(c));
       
   761 }
       
   762 
       
   763 inline void QPainter::fillRect(const QRectF &r, Qt::GlobalColor c)
       
   764 {
       
   765     fillRect(r, QColor(c));
       
   766 }
       
   767 
       
   768 inline void QPainter::fillRect(int x, int y, int w, int h, Qt::BrushStyle style)
       
   769 {
       
   770     fillRect(QRectF(x, y, w, h), QBrush(style));
       
   771 }
       
   772 
       
   773 inline void QPainter::fillRect(const QRect &r, Qt::BrushStyle style)
       
   774 {
       
   775     fillRect(QRectF(r), QBrush(style));
       
   776 }
       
   777 
       
   778 inline void QPainter::fillRect(const QRectF &r, Qt::BrushStyle style)
       
   779 {
       
   780     fillRect(r, QBrush(style));
       
   781 }
       
   782 
       
   783 
       
   784 inline void QPainter::setBrushOrigin(int x, int y)
       
   785 {
       
   786     setBrushOrigin(QPoint(x, y));
       
   787 }
       
   788 
       
   789 inline void QPainter::setBrushOrigin(const QPoint &p)
       
   790 {
       
   791     setBrushOrigin(QPointF(p));
       
   792 }
       
   793 
       
   794 inline void QPainter::drawTiledPixmap(const QRect &rect, const QPixmap &pm, const QPoint &offset)
       
   795 {
       
   796     drawTiledPixmap(QRectF(rect), pm, QPointF(offset));
       
   797 }
       
   798 
       
   799 inline void QPainter::drawTiledPixmap(int x, int y, int w, int h, const QPixmap &pm, int sx, int sy)
       
   800 {
       
   801     drawTiledPixmap(QRectF(x, y, w, h), pm, QPointF(sx, sy));
       
   802 }
       
   803 
       
   804 inline void QPainter::drawPixmap(const QRect &targetRect, const QPixmap &pixmap, const QRect &sourceRect)
       
   805 {
       
   806     drawPixmap(QRectF(targetRect), pixmap, QRectF(sourceRect));
       
   807 }
       
   808 
       
   809 inline void QPainter::drawPixmap(const QPoint &p, const QPixmap &pm)
       
   810 {
       
   811     drawPixmap(QPointF(p), pm);
       
   812 }
       
   813 
       
   814 inline void QPainter::drawPixmap(const QRect &r, const QPixmap &pm)
       
   815 {
       
   816     drawPixmap(QRectF(r), pm, QRectF());
       
   817 }
       
   818 
       
   819 inline void QPainter::drawPixmap(int x, int y, const QPixmap &pm)
       
   820 {
       
   821     drawPixmap(QPointF(x, y), pm);
       
   822 }
       
   823 
       
   824 inline void QPainter::drawPixmap(int x, int y, int w, int h, const QPixmap &pm)
       
   825 {
       
   826     drawPixmap(QRectF(x, y, w, h), pm, QRectF());
       
   827 }
       
   828 
       
   829 inline void QPainter::drawPixmap(int x, int y, int w, int h, const QPixmap &pm,
       
   830                                  int sx, int sy, int sw, int sh)
       
   831 {
       
   832     drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh));
       
   833 }
       
   834 
       
   835 inline void QPainter::drawPixmap(int x, int y, const QPixmap &pm,
       
   836                                  int sx, int sy, int sw, int sh)
       
   837 {
       
   838     drawPixmap(QRectF(x, y, -1, -1), pm, QRectF(sx, sy, sw, sh));
       
   839 }
       
   840 
       
   841 inline void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm, const QRectF &sr)
       
   842 {
       
   843     drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
       
   844 }
       
   845 
       
   846 inline void QPainter::drawPixmap(const QPoint &p, const QPixmap &pm, const QRect &sr)
       
   847 {
       
   848     drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
       
   849 }
       
   850 
       
   851 inline void QPainter::drawTextItem(int x, int y, const QTextItem &ti)
       
   852 {
       
   853     drawTextItem(QPointF(x, y), ti);
       
   854 }
       
   855 
       
   856 inline void QPainter::drawImage(const QRect &targetRect, const QImage &image, const QRect &sourceRect,
       
   857                                 Qt::ImageConversionFlags flags)
       
   858 {
       
   859     drawImage(QRectF(targetRect), image, QRectF(sourceRect), flags);
       
   860 }
       
   861 
       
   862 inline void QPainter::drawImage(const QPointF &p, const QImage &image, const QRectF &sr,
       
   863                                 Qt::ImageConversionFlags flags)
       
   864 {
       
   865     drawImage(QRectF(p.x(), p.y(), -1, -1), image, sr, flags);
       
   866 }
       
   867 
       
   868 inline void QPainter::drawImage(const QPoint &p, const QImage &image, const QRect &sr,
       
   869                                 Qt::ImageConversionFlags flags)
       
   870 {
       
   871     drawImage(QRect(p.x(), p.y(), -1, -1), image, sr, flags);
       
   872 }
       
   873 
       
   874 
       
   875 inline void QPainter::drawImage(const QRectF &r, const QImage &image)
       
   876 {
       
   877     drawImage(r, image, QRect(0, 0, image.width(), image.height()));
       
   878 }
       
   879 
       
   880 inline void QPainter::drawImage(const QRect &r, const QImage &image)
       
   881 {
       
   882     drawImage(r, image, QRectF(0, 0, image.width(), image.height()));
       
   883 }
       
   884 
       
   885 inline void QPainter::drawImage(const QPoint &p, const QImage &image)
       
   886 {
       
   887     drawImage(QPointF(p), image);
       
   888 }
       
   889 
       
   890 inline void QPainter::drawImage(int x, int y, const QImage &image, int sx, int sy, int sw, int sh,
       
   891                                 Qt::ImageConversionFlags flags)
       
   892 {
       
   893     if (sx == 0 && sy == 0 && sw == -1 && sh == -1 && flags == Qt::AutoColor)
       
   894         drawImage(QPointF(x, y), image);
       
   895     else
       
   896         drawImage(QRectF(x, y, -1, -1), image, QRectF(sx, sy, sw, sh), flags);
       
   897 }
       
   898 
       
   899 inline void QPainter::drawTextItem(const QPoint &p, const QTextItem &ti)
       
   900 {
       
   901     drawTextItem(QPointF(p), ti);
       
   902 }
       
   903 
       
   904 inline void QPainter::drawText(const QPoint &p, const QString &s)
       
   905 {
       
   906     drawText(QPointF(p), s);
       
   907 }
       
   908 
       
   909 inline void QPainter::drawText(int x, int y, int w, int h, int flags, const QString &str, QRect *br)
       
   910 {
       
   911     drawText(QRect(x, y, w, h), flags, str, br);
       
   912 }
       
   913 
       
   914 inline void QPainter::drawText(int x, int y, const QString &s)
       
   915 {
       
   916     drawText(QPointF(x, y), s);
       
   917 }
       
   918 
       
   919 inline QRect QPainter::boundingRect(int x, int y, int w, int h, int flags, const QString &text)
       
   920 {
       
   921     return boundingRect(QRect(x, y, w, h), flags, text);
       
   922 }
       
   923 
       
   924 inline void QPainter::translate(qreal dx, qreal dy)
       
   925 {
       
   926     translate(QPointF(dx, dy));
       
   927 }
       
   928 
       
   929 inline void QPainter::translate(const QPoint &offset)
       
   930 {
       
   931     translate(offset.x(), offset.y());
       
   932 }
       
   933 
       
   934 inline void QPainter::setViewport(int x, int y, int w, int h)
       
   935 {
       
   936     setViewport(QRect(x, y, w, h));
       
   937 }
       
   938 
       
   939 inline void QPainter::setWindow(int x, int y, int w, int h)
       
   940 {
       
   941     setWindow(QRect(x, y, w, h));
       
   942 }
       
   943 
       
   944 #ifndef QT_NO_PICTURE
       
   945 inline void QPainter::drawPicture(int x, int y, const QPicture &p)
       
   946 {
       
   947     drawPicture(QPoint(x, y), p);
       
   948 }
       
   949 
       
   950 inline void QPainter::drawPicture(const QPoint &pt, const QPicture &p)
       
   951 {
       
   952     drawPicture(QPointF(pt), p);
       
   953 }
       
   954 #endif
       
   955 
       
   956 QT_END_NAMESPACE
       
   957 
       
   958 QT_END_HEADER
       
   959 
       
   960 #endif // QPAINTER_H