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