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