QtGui/qpainter.h Source File

qpainter.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 
65 
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 
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 
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 
151 
152  //svg 1.2 blend modes
165 
166  // ROPs
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,
349  inline void drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius,
351  inline void drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius,
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  void drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount,
384  const QPixmap &pixmap, PixmapFragmentHints hints = 0);
385 
386  void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect,
387  Qt::ImageConversionFlags flags = Qt::AutoColor);
388  inline void drawImage(const QRect &targetRect, const QImage &image, const QRect &sourceRect,
389  Qt::ImageConversionFlags flags = Qt::AutoColor);
390  inline void drawImage(const QPointF &p, const QImage &image, const QRectF &sr,
391  Qt::ImageConversionFlags flags = Qt::AutoColor);
392  inline void drawImage(const QPoint &p, const QImage &image, const QRect &sr,
393  Qt::ImageConversionFlags flags = Qt::AutoColor);
394  inline void drawImage(const QRectF &r, const QImage &image);
395  inline void drawImage(const QRect &r, const QImage &image);
396  void drawImage(const QPointF &p, const QImage &image);
397  inline void drawImage(const QPoint &p, const QImage &image);
398  inline void drawImage(int x, int y, const QImage &image, int sx = 0, int sy = 0,
399  int sw = -1, int sh = -1, Qt::ImageConversionFlags flags = Qt::AutoColor);
400 
401  void setLayoutDirection(Qt::LayoutDirection direction);
402  Qt::LayoutDirection layoutDirection() const;
403 
404 #if !defined(QT_NO_RAWFONT)
405  void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun);
406 #endif
407 
408  void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText);
409  inline void drawStaticText(const QPoint &topLeftPosition, const QStaticText &staticText);
410  inline void drawStaticText(int left, int top, const QStaticText &staticText);
411 
412  void drawText(const QPointF &p, const QString &s);
413  inline void drawText(const QPoint &p, const QString &s);
414  inline void drawText(int x, int y, const QString &s);
415 
416  void drawText(const QPointF &p, const QString &str, int tf, int justificationPadding);
417 
418  void drawText(const QRectF &r, int flags, const QString &text, QRectF *br=0);
419  void drawText(const QRect &r, int flags, const QString &text, QRect *br=0);
420  inline void drawText(int x, int y, int w, int h, int flags, const QString &text, QRect *br=0);
421 
422  void drawText(const QRectF &r, const QString &text, const QTextOption &o = QTextOption());
423 
424  QRectF boundingRect(const QRectF &rect, int flags, const QString &text);
425  QRect boundingRect(const QRect &rect, int flags, const QString &text);
426  inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text);
427 
428  QRectF boundingRect(const QRectF &rect, const QString &text, const QTextOption &o = QTextOption());
429 
430  void drawTextItem(const QPointF &p, const QTextItem &ti);
431  inline void drawTextItem(int x, int y, const QTextItem &ti);
432  inline void drawTextItem(const QPoint &p, const QTextItem &ti);
433 
434  void fillRect(const QRectF &, const QBrush &);
435  inline void fillRect(int x, int y, int w, int h, const QBrush &);
436  void fillRect(const QRect &, const QBrush &);
437 
438  void fillRect(const QRectF &, const QColor &color);
439  inline void fillRect(int x, int y, int w, int h, const QColor &color);
440  void fillRect(const QRect &, const QColor &color);
441 
442  inline void fillRect(int x, int y, int w, int h, Qt::GlobalColor c);
443  inline void fillRect(const QRect &r, Qt::GlobalColor c);
444  inline void fillRect(const QRectF &r, Qt::GlobalColor c);
445 
446  inline void fillRect(int x, int y, int w, int h, Qt::BrushStyle style);
447  inline void fillRect(const QRect &r, Qt::BrushStyle style);
448  inline void fillRect(const QRectF &r, Qt::BrushStyle style);
449 
450  void eraseRect(const QRectF &);
451  inline void eraseRect(int x, int y, int w, int h);
452  inline void eraseRect(const QRect &);
453 
454  void setRenderHint(RenderHint hint, bool on = true);
455  void setRenderHints(RenderHints hints, bool on = true);
456  RenderHints renderHints() const;
457  inline bool testRenderHint(RenderHint hint) const { return renderHints() & hint; }
458 
459  QPaintEngine *paintEngine() const;
460 
461  static void setRedirected(const QPaintDevice *device, QPaintDevice *replacement,
462  const QPoint& offset = QPoint());
463  static QPaintDevice *redirected(const QPaintDevice *device, QPoint *offset = 0);
464  static void restoreRedirected(const QPaintDevice *device);
465 
466  void beginNativePainting();
467  void endNativePainting();
468 
469 #ifdef QT3_SUPPORT
470 
471  inline QT3_SUPPORT void setBackgroundColor(const QColor &color) { setBackground(color); }
472  inline QT3_SUPPORT const QColor &backgroundColor() const { return background().color(); }
473 
474  inline QT3_SUPPORT void drawText(int x, int y, const QString &s, int pos, int len)
475  { drawText(x, y, s.mid(pos, len)); }
476  inline QT3_SUPPORT void drawText(const QPoint &p, const QString &s, int pos, int len)
477  { drawText(p, s.mid(pos, len)); }
478  inline QT3_SUPPORT void drawText(int x, int y, const QString &s, int len)
479  { drawText(x, y, s.left(len)); }
480  inline QT3_SUPPORT void drawText(const QPoint &p, const QString &s, int len)
481  { drawText(p, s.left(len)); }
482  inline QT3_SUPPORT void drawText(const QRect &r, int flags, const QString &str, int len, QRect *br=0)
483  { drawText(r, flags, str.left(len), br); }
484  inline QT3_SUPPORT void drawText(int x, int y, int w, int h, int flags, const QString &text, int len, QRect *br=0)
485  { drawText(QRect(x, y, w, h), flags, text.left(len), br); }
486  inline QT3_SUPPORT QRect boundingRect(const QRect &rect, int flags, const QString &text, int len)
487  { return boundingRect(rect, flags, text.left(len)); }
488  inline QT3_SUPPORT QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text, int len)
489  { return boundingRect(QRect(x, y, w, h), flags, text.left(len)); }
490 
491  inline QT3_SUPPORT bool begin(QPaintDevice *pdev, const QWidget *init)
492  { bool ret = begin(pdev); initFrom(init); return ret; }
493  QT3_SUPPORT void drawPoints(const QPolygon &pa, int index, int npoints = -1)
494  { drawPoints(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
495 
496  QT3_SUPPORT void drawCubicBezier(const QPolygon &pa, int index = 0);
497 
498  QT3_SUPPORT void drawLineSegments(const QPolygon &points, int index = 0, int nlines = -1);
499 
500  inline QT3_SUPPORT void drawPolyline(const QPolygon &pa, int index, int npoints = -1)
501  { drawPolyline(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
502 
503  inline QT3_SUPPORT void drawPolygon(const QPolygon &pa, bool winding, int index = 0, int npoints = -1)
504  { drawPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints,
505  winding ? Qt::WindingFill : Qt::OddEvenFill); }
506 
507  inline QT3_SUPPORT void drawPolygon(const QPolygonF &polygon, bool winding, int index = 0,
508  int npoints = -1)
509  { drawPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints,
510  winding ? Qt::WindingFill : Qt::OddEvenFill); }
511 
512  inline QT3_SUPPORT void drawConvexPolygon(const QPolygonF &polygon, int index, int npoints = -1)
513  { drawConvexPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints); }
514  inline QT3_SUPPORT void drawConvexPolygon(const QPolygon &pa, int index, int npoints = -1)
515  { drawConvexPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
516 
517  static inline QT3_SUPPORT void redirect(QPaintDevice *pdev, QPaintDevice *replacement)
518  { setRedirected(pdev, replacement); }
519  static inline QT3_SUPPORT QPaintDevice *redirect(QPaintDevice *pdev)
520  { return const_cast<QPaintDevice*>(redirected(pdev)); }
521 
522  inline QT3_SUPPORT void setWorldXForm(bool enabled) { setMatrixEnabled(enabled); }
523  inline QT3_SUPPORT bool hasWorldXForm() const { return matrixEnabled(); }
524  inline QT3_SUPPORT void resetXForm() { resetTransform(); }
525 
526  inline QT3_SUPPORT void setViewXForm(bool enabled) { setViewTransformEnabled(enabled); }
527  inline QT3_SUPPORT bool hasViewXForm() const { return viewTransformEnabled(); }
528 
529  QT3_SUPPORT void map(int x, int y, int *rx, int *ry) const;
530  QT3_SUPPORT QPoint xForm(const QPoint &) const; // map virtual -> deviceb
531  QT3_SUPPORT QRect xForm(const QRect &) const;
532  QT3_SUPPORT QPolygon xForm(const QPolygon &) const;
533  QT3_SUPPORT QPolygon xForm(const QPolygon &, int index, int npoints) const;
534  QT3_SUPPORT QPoint xFormDev(const QPoint &) const; // map device -> virtual
535  QT3_SUPPORT QRect xFormDev(const QRect &) const;
536  QT3_SUPPORT QPolygon xFormDev(const QPolygon &) const;
537  QT3_SUPPORT QPolygon xFormDev(const QPolygon &, int index, int npoints) const;
538  QT3_SUPPORT qreal translationX() const;
539  QT3_SUPPORT qreal translationY() const;
540 #endif
541 
542 private:
543  Q_DISABLE_COPY(QPainter)
544  friend class Q3Painter;
545 
546  QScopedPointer<QPainterPrivate> d_ptr;
547 
548  friend class QFontEngine;
549  friend class QFontEngineBox;
550  friend class QFontEngineFT;
551  friend class QFontEngineMac;
552  friend class QFontEngineWin;
553  friend class QFontEngineXLFD;
554  friend class QWSManager;
555  friend class QPaintEngine;
556  friend class QPaintEngineExPrivate;
557  friend class QOpenGLPaintEngine;
558  friend class QVGPaintEngine;
559  friend class QX11PaintEngine;
560  friend class QX11PaintEnginePrivate;
561  friend class QWin32PaintEngine;
562  friend class QWin32PaintEnginePrivate;
563  friend class QRasterPaintEngine;
564  friend class QAlphaPaintEngine;
565  friend class QPreviewPaintEngine;
566 };
567 
568 Q_DECLARE_OPERATORS_FOR_FLAGS(QPainter::RenderHints)
569 
570 //
571 // functions
572 //
573 inline void QPainter::drawLine(const QLineF &l)
574 {
575  drawLines(&l, 1);
576 }
577 
578 inline void QPainter::drawLine(const QLine &line)
579 {
580  drawLines(&line, 1);
581 }
582 
583 inline void QPainter::drawLine(int x1, int y1, int x2, int y2)
584 {
585  QLine l(x1, y1, x2, y2);
586  drawLines(&l, 1);
587 }
588 
589 inline void QPainter::drawLine(const QPoint &p1, const QPoint &p2)
590 {
591  QLine l(p1, p2);
592  drawLines(&l, 1);
593 }
594 
595 inline void QPainter::drawLine(const QPointF &p1, const QPointF &p2)
596 {
597  drawLine(QLineF(p1, p2));
598 }
599 
600 inline void QPainter::drawLines(const QVector<QLineF> &lines)
601 {
602  drawLines(lines.constData(), lines.size());
603 }
604 
605 inline void QPainter::drawLines(const QVector<QLine> &lines)
606 {
607  drawLines(lines.constData(), lines.size());
608 }
609 
610 inline void QPainter::drawLines(const QVector<QPointF> &pointPairs)
611 {
612  drawLines(pointPairs.constData(), pointPairs.size() / 2);
613 }
614 
615 inline void QPainter::drawLines(const QVector<QPoint> &pointPairs)
616 {
617  drawLines(pointPairs.constData(), pointPairs.size() / 2);
618 }
619 
620 inline void QPainter::drawPolyline(const QPolygonF &polyline)
621 {
622  drawPolyline(polyline.constData(), polyline.size());
623 }
624 
625 inline void QPainter::drawPolyline(const QPolygon &polyline)
626 {
627  drawPolyline(polyline.constData(), polyline.size());
628 }
629 
630 inline void QPainter::drawPolygon(const QPolygonF &polygon, Qt::FillRule fillRule)
631 {
632  drawPolygon(polygon.constData(), polygon.size(), fillRule);
633 }
634 
635 inline void QPainter::drawPolygon(const QPolygon &polygon, Qt::FillRule fillRule)
636 {
637  drawPolygon(polygon.constData(), polygon.size(), fillRule);
638 }
639 
640 inline void QPainter::drawConvexPolygon(const QPolygonF &poly)
641 {
642  drawConvexPolygon(poly.constData(), poly.size());
643 }
644 
645 inline void QPainter::drawConvexPolygon(const QPolygon &poly)
646 {
647  drawConvexPolygon(poly.constData(), poly.size());
648 }
649 
650 inline void QPainter::drawRect(const QRectF &rect)
651 {
652  drawRects(&rect, 1);
653 }
654 
655 inline void QPainter::drawRect(int x, int y, int w, int h)
656 {
657  QRect r(x, y, w, h);
658  drawRects(&r, 1);
659 }
660 
661 inline void QPainter::drawRect(const QRect &r)
662 {
663  drawRects(&r, 1);
664 }
665 
666 inline void QPainter::drawRects(const QVector<QRectF> &rects)
667 {
668  drawRects(rects.constData(), rects.size());
669 }
670 
671 inline void QPainter::drawRects(const QVector<QRect> &rects)
672 {
673  drawRects(rects.constData(), rects.size());
674 }
675 
676 inline void QPainter::drawPoint(const QPointF &p)
677 {
678  drawPoints(&p, 1);
679 }
680 
681 inline void QPainter::drawPoint(int x, int y)
682 {
683  QPoint p(x, y);
684  drawPoints(&p, 1);
685 }
686 
687 inline void QPainter::drawPoint(const QPoint &p)
688 {
689  drawPoints(&p, 1);
690 }
691 
693 {
694  drawPoints(points.constData(), points.size());
695 }
696 
697 inline void QPainter::drawPoints(const QPolygon &points)
698 {
699  drawPoints(points.constData(), points.size());
700 }
701 
702 inline void QPainter::drawRoundRect(int x, int y, int w, int h, int xRnd, int yRnd)
703 {
704  drawRoundRect(QRectF(x, y, w, h), xRnd, yRnd);
705 }
706 
707 inline void QPainter::drawRoundRect(const QRect &rect, int xRnd, int yRnd)
708 {
709  drawRoundRect(QRectF(rect), xRnd, yRnd);
710 }
711 
712 inline void QPainter::drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius,
714 {
715  drawRoundedRect(QRectF(x, y, w, h), xRadius, yRadius, mode);
716 }
717 
718 inline void QPainter::drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius,
720 {
721  drawRoundedRect(QRectF(rect), xRadius, yRadius, mode);
722 }
723 
724 inline void QPainter::drawEllipse(int x, int y, int w, int h)
725 {
726  drawEllipse(QRect(x, y, w, h));
727 }
728 
729 inline void QPainter::drawEllipse(const QPointF &center, qreal rx, qreal ry)
730 {
731  drawEllipse(QRectF(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
732 }
733 
734 inline void QPainter::drawEllipse(const QPoint &center, int rx, int ry)
735 {
736  drawEllipse(QRect(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
737 }
738 
739 inline void QPainter::drawArc(const QRect &r, int a, int alen)
740 {
741  drawArc(QRectF(r), a, alen);
742 }
743 
744 inline void QPainter::drawArc(int x, int y, int w, int h, int a, int alen)
745 {
746  drawArc(QRectF(x, y, w, h), a, alen);
747 }
748 
749 inline void QPainter::drawPie(const QRect &rect, int a, int alen)
750 {
751  drawPie(QRectF(rect), a, alen);
752 }
753 
754 inline void QPainter::drawPie(int x, int y, int w, int h, int a, int alen)
755 {
756  drawPie(QRectF(x, y, w, h), a, alen);
757 }
758 
759 inline void QPainter::drawChord(const QRect &rect, int a, int alen)
760 {
761  drawChord(QRectF(rect), a, alen);
762 }
763 
764 inline void QPainter::drawChord(int x, int y, int w, int h, int a, int alen)
765 {
766  drawChord(QRectF(x, y, w, h), a, alen);
767 }
768 
769 inline void QPainter::setClipRect(int x, int y, int w, int h, Qt::ClipOperation op)
770 {
771  setClipRect(QRect(x, y, w, h), op);
772 }
773 
774 inline void QPainter::eraseRect(const QRect &rect)
775 {
776  eraseRect(QRectF(rect));
777 }
778 
779 inline void QPainter::eraseRect(int x, int y, int w, int h)
780 {
781  eraseRect(QRectF(x, y, w, h));
782 }
783 
784 inline void QPainter::fillRect(int x, int y, int w, int h, const QBrush &b)
785 {
786  fillRect(QRect(x, y, w, h), b);
787 }
788 
789 inline void QPainter::fillRect(int x, int y, int w, int h, const QColor &b)
790 {
791  fillRect(QRect(x, y, w, h), b);
792 }
793 
794 inline void QPainter::fillRect(int x, int y, int w, int h, Qt::GlobalColor c)
795 {
796  fillRect(QRect(x, y, w, h), QColor(c));
797 }
798 
800 {
801  fillRect(r, QColor(c));
802 }
803 
805 {
806  fillRect(r, QColor(c));
807 }
808 
809 inline void QPainter::fillRect(int x, int y, int w, int h, Qt::BrushStyle style)
810 {
811  fillRect(QRectF(x, y, w, h), QBrush(style));
812 }
813 
814 inline void QPainter::fillRect(const QRect &r, Qt::BrushStyle style)
815 {
816  fillRect(QRectF(r), QBrush(style));
817 }
818 
819 inline void QPainter::fillRect(const QRectF &r, Qt::BrushStyle style)
820 {
821  fillRect(r, QBrush(style));
822 }
823 
824 
825 inline void QPainter::setBrushOrigin(int x, int y)
826 {
827  setBrushOrigin(QPoint(x, y));
828 }
829 
830 inline void QPainter::setBrushOrigin(const QPoint &p)
831 {
833 }
834 
835 inline void QPainter::drawTiledPixmap(const QRect &rect, const QPixmap &pm, const QPoint &offset)
836 {
837  drawTiledPixmap(QRectF(rect), pm, QPointF(offset));
838 }
839 
840 inline void QPainter::drawTiledPixmap(int x, int y, int w, int h, const QPixmap &pm, int sx, int sy)
841 {
842  drawTiledPixmap(QRectF(x, y, w, h), pm, QPointF(sx, sy));
843 }
844 
845 inline void QPainter::drawPixmap(const QRect &targetRect, const QPixmap &pixmap, const QRect &sourceRect)
846 {
847  drawPixmap(QRectF(targetRect), pixmap, QRectF(sourceRect));
848 }
849 
850 inline void QPainter::drawPixmap(const QPoint &p, const QPixmap &pm)
851 {
852  drawPixmap(QPointF(p), pm);
853 }
854 
855 inline void QPainter::drawPixmap(const QRect &r, const QPixmap &pm)
856 {
857  drawPixmap(QRectF(r), pm, QRectF());
858 }
859 
860 inline void QPainter::drawPixmap(int x, int y, const QPixmap &pm)
861 {
862  drawPixmap(QPointF(x, y), pm);
863 }
864 
865 inline void QPainter::drawPixmap(int x, int y, int w, int h, const QPixmap &pm)
866 {
867  drawPixmap(QRectF(x, y, w, h), pm, QRectF());
868 }
869 
870 inline void QPainter::drawPixmap(int x, int y, int w, int h, const QPixmap &pm,
871  int sx, int sy, int sw, int sh)
872 {
873  drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh));
874 }
875 
876 inline void QPainter::drawPixmap(int x, int y, const QPixmap &pm,
877  int sx, int sy, int sw, int sh)
878 {
879  drawPixmap(QRectF(x, y, -1, -1), pm, QRectF(sx, sy, sw, sh));
880 }
881 
882 inline void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm, const QRectF &sr)
883 {
884  drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
885 }
886 
887 inline void QPainter::drawPixmap(const QPoint &p, const QPixmap &pm, const QRect &sr)
888 {
889  drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
890 }
891 
892 inline void QPainter::drawTextItem(int x, int y, const QTextItem &ti)
893 {
894  drawTextItem(QPointF(x, y), ti);
895 }
896 
897 inline void QPainter::drawImage(const QRect &targetRect, const QImage &image, const QRect &sourceRect,
898  Qt::ImageConversionFlags flags)
899 {
900  drawImage(QRectF(targetRect), image, QRectF(sourceRect), flags);
901 }
902 
903 inline void QPainter::drawImage(const QPointF &p, const QImage &image, const QRectF &sr,
904  Qt::ImageConversionFlags flags)
905 {
906  drawImage(QRectF(p.x(), p.y(), -1, -1), image, sr, flags);
907 }
908 
909 inline void QPainter::drawImage(const QPoint &p, const QImage &image, const QRect &sr,
910  Qt::ImageConversionFlags flags)
911 {
912  drawImage(QRect(p.x(), p.y(), -1, -1), image, sr, flags);
913 }
914 
915 
916 inline void QPainter::drawImage(const QRectF &r, const QImage &image)
917 {
918  drawImage(r, image, QRect(0, 0, image.width(), image.height()));
919 }
920 
921 inline void QPainter::drawImage(const QRect &r, const QImage &image)
922 {
923  drawImage(r, image, QRectF(0, 0, image.width(), image.height()));
924 }
925 
926 inline void QPainter::drawImage(const QPoint &p, const QImage &image)
927 {
928  drawImage(QPointF(p), image);
929 }
930 
931 inline void QPainter::drawImage(int x, int y, const QImage &image, int sx, int sy, int sw, int sh,
932  Qt::ImageConversionFlags flags)
933 {
934  if (sx == 0 && sy == 0 && sw == -1 && sh == -1 && flags == Qt::AutoColor)
935  drawImage(QPointF(x, y), image);
936  else
937  drawImage(QRectF(x, y, -1, -1), image, QRectF(sx, sy, sw, sh), flags);
938 }
939 
940 inline void QPainter::drawStaticText(const QPoint &p, const QStaticText &staticText)
941 {
942  drawStaticText(QPointF(p), staticText);
943 }
944 
945 inline void QPainter::drawStaticText(int x, int y, const QStaticText &staticText)
946 {
947  drawStaticText(QPointF(x, y), staticText);
948 }
949 
950 inline void QPainter::drawTextItem(const QPoint &p, const QTextItem &ti)
951 {
952  drawTextItem(QPointF(p), ti);
953 }
954 
955 inline void QPainter::drawText(const QPoint &p, const QString &s)
956 {
957  drawText(QPointF(p), s);
958 }
959 
960 inline void QPainter::drawText(int x, int y, int w, int h, int flags, const QString &str, QRect *br)
961 {
962  drawText(QRect(x, y, w, h), flags, str, br);
963 }
964 
965 inline void QPainter::drawText(int x, int y, const QString &s)
966 {
967  drawText(QPointF(x, y), s);
968 }
969 
970 inline QRect QPainter::boundingRect(int x, int y, int w, int h, int flags, const QString &text)
971 {
972  return boundingRect(QRect(x, y, w, h), flags, text);
973 }
974 
975 inline void QPainter::translate(qreal dx, qreal dy)
976 {
977  translate(QPointF(dx, dy));
978 }
979 
980 inline void QPainter::translate(const QPoint &offset)
981 {
982  translate(offset.x(), offset.y());
983 }
984 
985 inline void QPainter::setViewport(int x, int y, int w, int h)
986 {
987  setViewport(QRect(x, y, w, h));
988 }
989 
990 inline void QPainter::setWindow(int x, int y, int w, int h)
991 {
992  setWindow(QRect(x, y, w, h));
993 }
994 
995 #ifndef QT_NO_PICTURE
996 inline void QPainter::drawPicture(int x, int y, const QPicture &p)
997 {
998  drawPicture(QPoint(x, y), p);
999 }
1000 
1001 inline void QPainter::drawPicture(const QPoint &pt, const QPicture &p)
1002 {
1003  drawPicture(QPointF(pt), p);
1004 }
1005 #endif
1006 
1008 
1010 
1011 #endif // QPAINTER_H
ClipOperation
Definition: qnamespace.h:1495
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
GLuint GLenum matrix
Definition: GLee.h:6572
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
GLenum GLint GLint y
Definition: GLee.h:876
Definition: qline.h:57
GLint mode
Definition: GLee.h:4479
int int int int * dy
Definition: GLee.h:10535
#define QT_END_NAMESPACE
Definition: qglobal.h:128
GLintptr offset
Definition: GLee.h:1562
void setWindow(const QRect &window)
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
QFuture< void > map(Sequence &sequence, MapFunctor map)
GLXFBConfig Pixmap pixmap
Definition: GLee.h:10237
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
QString left(int n) const Q_REQUIRED_RESULT
void drawRects(const QRectF *rects, int rectCount)
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
void drawPicture(const QPointF &p, const QPicture &picture)
LayoutDirection
Definition: qnamespace.h:1580
void setViewport(const QRect &viewport)
void drawRoundRect(const QRectF &r, int xround=25, int yround=25)
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Definition: qcolor.h:67
int height() const
void drawText(const QPointF &p, const QString &s)
BGMode
Definition: qnamespace.h:588
#define inline
Definition: image.h:2490
void drawTextItem(const QPointF &p, const QTextItem &ti)
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: GLee.h:882
SizeMode
Definition: qnamespace.h:1187
void drawChord(const QRectF &rect, int a, int alen)
QRectF boundingRect(const QRectF &rect, int flags, const QString &text)
void drawLine(const QLineF &line)
Definition: qpainter.h:573
bool testRenderHint(RenderHint hint) const
Definition: qpainter.h:457
void drawPolyline(const QPointF *points, int pointCount)
Definition: qpoint.h:53
qreal y() const
Definition: qpoint.h:287
int y() const
Definition: qpoint.h:131
GlobalColor
Definition: qnamespace.h:104
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
Definition: qfont.h:64
BrushStyle
Definition: qnamespace.h:1162
GLuint GLenum GLenum transform
Definition: GLee.h:6572
Definition: qimage.h:87
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
GLenum GLint x
Definition: GLee.h:876
int width() const
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
void drawRect(const QRectF &rect)
Definition: qpainter.h:650
PixmapFragmentHint
Definition: qpainter.h:120
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
#define Q_GADGET
Definition: qobjectdefs.h:173
GLubyte GLubyte b
Definition: GLee.h:5404
void drawArc(const QRectF &rect, int a, int alen)
qreal x() const
Definition: qpoint.h:282
Definition: qline.h:212
const T * constData() const
Definition: qvector.h:154
GLuint GLuint end
Definition: GLee.h:872
Definition: qrect.h:58
Window window
Definition: GLee.h:10520
Antialiasing
Type of the antialiasing applied to extracted textures. This is only valid if utilizer type is set to...
Definition: qrect.h:511
GLfloat GLfloat p
Definition: GLee.h:5416
const GLubyte * c
Definition: GLee.h:5419
Definition: qpen.h:64
int int int int int int h
Definition: GLee.h:10534
void translate(const QPointF &offset)
RenderHint
Definition: qpainter.h:93
void drawConvexPolygon(const QPointF *points, int pointCount)
int x() const
Definition: qpoint.h:128
GLubyte GLubyte GLubyte a
Definition: GLee.h:5404
int int int * dx
Definition: GLee.h:10535
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
void eraseRect(const QRectF &)
void drawEllipse(const QRectF &r)
int size() const
Definition: qvector.h:137
Definition: qbrush.h:76
#define Q_FLAGS(x)
Definition: qobjectdefs.h:85
GLsizei const GLfloat * points
Definition: GLee.h:3793
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
void drawLines(const QLineF *lines, int lineCount)
void drawPie(const QRectF &rect, int a, int alen)
GLenum GLsizei len
Definition: GLee.h:2695
GLenum GLenum GLenum GLenum GLenum scale
Definition: GLee.h:5777
GLdouble s
Definition: GLee.h:1173
FillRule
Definition: qnamespace.h:1485
void drawPoint(const QPointF &pt)
Definition: qpainter.h:676
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
#define QT_END_HEADER
Definition: qglobal.h:142
GLclampf f
Definition: GLee.h:9303
void setBrushOrigin(int x, int y)
Definition: qpainter.h:825
void fillRect(const QRectF &, const QBrush &)
void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText)
GLuint index
Definition: GLee.h:1704
void drawPoints(const QPointF *points, int pointCount)
CompositionMode
Definition: qpainter.h:138
PenStyle
Definition: qnamespace.h:1134
GLuint color
Definition: GLee.h:8456