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