54 #ifndef QT_INCLUDE_COMPAT
75 class QPainterPrivate;
84 class QPainterPrivateDeleter;
88 Q_DECLARE_PRIVATE(QPainter)
95 TextAntialiasing = 0x02,
96 SmoothPixmapTransform = 0x04,
97 HighQualityAntialiasing = 0x08,
98 NonCosmeticDefaultPen = 0x10
101 Q_DECLARE_FLAGS(RenderHints, RenderHint)
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);
124 Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)
127 explicit QPainter(QPaintDevice *);
130 QPaintDevice *device() const;
132 bool begin(QPaintDevice *);
134 bool isActive() const;
136 void initFrom(const
QWidget *widget);
175 RasterOp_SourceAndNotDestination
177 void setCompositionMode(CompositionMode
mode);
178 CompositionMode compositionMode()
const;
180 const QFont &font()
const;
181 void setFont(
const QFont &
f);
183 QFontMetrics fontMetrics()
const;
184 QFontInfo fontInfo()
const;
187 void setPen(
const QPen &pen);
189 const QPen &pen()
const;
191 void setBrush(
const QBrush &brush);
193 const QBrush &brush()
const;
199 QPoint brushOrigin()
const;
200 inline void setBrushOrigin(
int x,
int y);
201 inline void setBrushOrigin(
const QPoint &);
202 void setBrushOrigin(
const QPointF &);
204 void setBackground(
const QBrush &bg);
205 const QBrush &background()
const;
207 qreal opacity()
const;
208 void setOpacity(qreal opacity);
212 QPainterPath clipPath()
const;
222 void setClipping(
bool enable);
223 bool hasClipping()
const;
225 QRectF clipBoundingRect()
const;
231 void setMatrix(
const QMatrix &
matrix,
bool combine =
false);
232 const QMatrix &
matrix()
const;
233 const QMatrix &deviceMatrix()
const;
236 void setTransform(
const QTransform &
transform,
bool combine =
false);
238 const QTransform &deviceTransform()
const;
239 void resetTransform();
241 void setWorldMatrix(
const QMatrix &
matrix,
bool combine =
false);
242 const QMatrix &worldMatrix()
const;
244 void setWorldTransform(
const QTransform &
matrix,
bool combine =
false);
245 const QTransform &worldTransform()
const;
247 QMatrix combinedMatrix()
const;
248 QTransform combinedTransform()
const;
250 void setMatrixEnabled(
bool enabled);
251 bool matrixEnabled()
const;
253 void setWorldMatrixEnabled(
bool enabled);
254 bool worldMatrixEnabled()
const;
256 void scale(qreal sx, qreal sy);
257 void shear(qreal sh, qreal sv);
258 void rotate(qreal
a);
262 inline void translate(qreal
dx, qreal
dy);
266 inline void setWindow(
int x,
int y,
int w,
int h);
268 QRect viewport()
const;
269 void setViewport(
const QRect &viewport);
270 inline void setViewport(
int x,
int y,
int w,
int h);
272 void setViewTransformEnabled(
bool enable);
273 bool viewTransformEnabled()
const;
276 void strokePath(
const QPainterPath &path,
const QPen &pen);
277 void fillPath(
const QPainterPath &path,
const QBrush &brush);
278 void drawPath(
const QPainterPath &path);
280 inline void drawPoint(
const QPointF &pt);
281 inline void drawPoint(
const QPoint &
p);
282 inline void drawPoint(
int x,
int y);
287 inline void drawPoints(
const QPolygon &
points);
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);
295 void drawLines(
const QLineF *lines,
int lineCount);
297 void drawLines(
const QPointF *pointPairs,
int lineCount);
299 void drawLines(
const QLine *lines,
int lineCount);
301 void drawLines(
const QPoint *pointPairs,
int lineCount);
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);
308 void drawRects(
const QRectF *rects,
int rectCount);
310 void drawRects(
const QRect *rects,
int rectCount);
313 void drawEllipse(
const QRectF &
r);
314 void drawEllipse(
const QRect &
r);
315 inline void drawEllipse(
int x,
int y,
int w,
int h);
317 inline void drawEllipse(
const QPointF &
center, qreal rx, qreal ry);
318 inline void drawEllipse(
const QPoint &
center,
int rx,
int ry);
321 inline void drawPolyline(
const QPolygonF &polyline);
322 void drawPolyline(
const QPoint *
points,
int pointCount);
323 inline void drawPolyline(
const QPolygon &polygon);
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);
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);
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);
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);
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,
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);
359 inline void drawTiledPixmap(
int x,
int y,
int w,
int h,
const QPixmap &,
int sx=0,
int sy=0);
361 #ifndef QT_NO_PICTURE
363 inline void drawPicture(
int x,
int y,
const QPicture &picture);
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);
377 inline void drawPixmap(
int x,
int y,
const QPixmap &pm);
379 inline void drawPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm);
381 void drawPixmapFragments(
const PixmapFragment *fragments,
int fragmentCount,
383 void drawPixmapFragments(
const QRectF *targetRects,
const QRectF *sourceRects,
int fragmentCount,
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);
404 #if !defined(QT_NO_RAWFONT)
405 void drawGlyphRun(
const QPointF &position,
const QGlyphRun &glyphRun);
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);
414 inline void drawText(
int x,
int y,
const QString &
s);
416 void drawText(
const QPointF &
p,
const QString &str,
int tf,
int justificationPadding);
420 inline void drawText(
int x,
int y,
int w,
int h,
int flags,
const QString &text,
QRect *br=0);
426 inline QRect boundingRect(
int x,
int y,
int w,
int h,
int flags,
const QString &text);
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);
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 &);
450 void eraseRect(
const QRectF &);
451 inline void eraseRect(
int x,
int y,
int w,
int h);
452 inline void eraseRect(
const QRect &);
454 void setRenderHint(RenderHint hint,
bool on =
true);
455 void setRenderHints(RenderHints hints,
bool on =
true);
456 RenderHints renderHints()
const;
461 static void setRedirected(
const QPaintDevice *device, QPaintDevice *replacement,
463 static QPaintDevice *redirected(
const QPaintDevice *device,
QPoint *
offset = 0);
464 static void restoreRedirected(
const QPaintDevice *device);
466 void beginNativePainting();
467 void endNativePainting();
471 inline QT3_SUPPORT
void setBackgroundColor(
const QColor &
color) { setBackground(color); }
472 inline QT3_SUPPORT
const QColor &backgroundColor()
const {
return background().color(); }
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)); }
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)
496 QT3_SUPPORT
void drawCubicBezier(
const QPolygon &pa,
int index = 0);
498 QT3_SUPPORT
void drawLineSegments(
const QPolygon &
points,
int index = 0,
int nlines = -1);
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); }
503 inline QT3_SUPPORT
void drawPolygon(
const QPolygon &pa,
bool winding,
int index = 0,
int npoints = -1)
507 inline QT3_SUPPORT
void drawPolygon(
const QPolygonF &polygon,
bool winding,
int index = 0,
509 { drawPolygon(polygon.
constData() +
index, npoints == -1 ? polygon.
size() - index : npoints,
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); }
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)); }
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(); }
526 inline QT3_SUPPORT
void setViewXForm(
bool enabled) { setViewTransformEnabled(enabled); }
527 inline QT3_SUPPORT
bool hasViewXForm()
const {
return viewTransformEnabled(); }
529 QT3_SUPPORT
void map(
int x,
int y,
int *rx,
int *ry)
const;
532 QT3_SUPPORT QPolygon xForm(
const QPolygon &)
const;
533 QT3_SUPPORT QPolygon xForm(
const QPolygon &,
int index,
int npoints)
const;
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;
543 Q_DISABLE_COPY(QPainter)
544 friend class Q3Painter;
548 friend class QFontEngine;
549 friend class QFontEngineBox;
550 friend class QFontEngineFT;
551 friend class QFontEngineMac;
552 friend class QFontEngineWin;
553 friend class QFontEngineXLFD;
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;
568 Q_DECLARE_OPERATORS_FOR_FLAGS(QPainter::RenderHints)
585 QLine l(x1, y1, x2, y2);
871 int sx,
int sy,
int sw,
int sh)
877 int sx,
int sy,
int sw,
int sh)
898 Qt::ImageConversionFlags flags)
904 Qt::ImageConversionFlags flags)
910 Qt::ImageConversionFlags flags)
932 Qt::ImageConversionFlags flags)
934 if (sx == 0 && sy == 0 && sw == -1 && sh == -1 && flags ==
Qt::AutoColor)
995 #ifndef QT_NO_PICTURE
1011 #endif // QPAINTER_H
GLdouble GLdouble GLdouble r
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
void setWindow(const QRect &window)
QFuture< void > map(Sequence &sequence, MapFunctor map)
GLXFBConfig Pixmap pixmap
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)
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())
void drawText(const QPointF &p, const QString &s)
void drawTextItem(const QPointF &p, const QTextItem &ti)
GLenum GLsizei GLenum GLenum const GLvoid * image
void drawChord(const QRectF &rect, int a, int alen)
QRectF boundingRect(const QRectF &rect, int flags, const QString &text)
void drawLine(const QLineF &line)
bool testRenderHint(RenderHint hint) const
void drawPolyline(const QPointF *points, int pointCount)
#define QT_BEGIN_NAMESPACE
GLuint GLenum GLenum transform
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
void drawRect(const QRectF &rect)
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
void drawArc(const QRectF &rect, int a, int alen)
const T * constData() const
int int int int int int h
void translate(const QPointF &offset)
void drawConvexPolygon(const QPointF *points, int pointCount)
GLubyte GLubyte GLubyte a
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
void eraseRect(const QRectF &)
void drawEllipse(const QRectF &r)
GLsizei const GLfloat * points
GLubyte GLubyte GLubyte GLubyte w
void drawLines(const QLineF *lines, int lineCount)
void drawPie(const QRectF &rect, int a, int alen)
GLenum GLenum GLenum GLenum GLenum scale
void drawPoint(const QPointF &pt)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
void setBrushOrigin(int x, int y)
void fillRect(const QRectF &, const QBrush &)
void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText)
void drawPoints(const QPointF *points, int pointCount)