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