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> 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> 84 class QPainterPrivateDeleter;
95 TextAntialiasing = 0x02,
96 SmoothPixmapTransform = 0x04,
97 HighQualityAntialiasing = 0x08,
98 NonCosmeticDefaultPen = 0x10
134 bool isActive()
const;
175 RasterOp_SourceAndNotDestination
180 const QFont &font()
const;
181 void setFont(
const QFont &f);
186 void setPen(
const QColor &color);
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);
222 void setClipping(
bool enable);
223 bool hasClipping()
const;
225 QRectF clipBoundingRect()
const;
231 void setMatrix(
const QMatrix &matrix,
bool combine =
false);
233 const QMatrix &deviceMatrix()
const;
236 void setTransform(
const QTransform &transform,
bool combine =
false);
239 void resetTransform();
241 void setWorldMatrix(
const QMatrix &matrix,
bool combine =
false);
242 const QMatrix &worldMatrix()
const;
247 QMatrix combinedMatrix()
const;
250 void setMatrixEnabled(
bool enabled);
251 bool matrixEnabled()
const;
253 void setWorldMatrixEnabled(
bool enabled);
254 bool worldMatrixEnabled()
const;
260 void translate(
const QPointF &offset);
261 inline void translate(
const QPoint &offset);
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;
280 inline void drawPoint(
const QPointF &pt);
281 inline void drawPoint(
const QPoint &p);
282 inline void drawPoint(
int x,
int y);
291 inline void drawLine(
int x1,
int y1,
int x2,
int y2);
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);
313 void drawEllipse(
const QRectF &r);
314 void drawEllipse(
const QRect &r);
315 inline void drawEllipse(
int x,
int y,
int w,
int h);
318 inline void drawEllipse(
const QPoint &
center,
int rx,
int ry);
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);
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);
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);
364 inline void drawPicture(
const QPoint &p,
const QPicture &picture);
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);
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);
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);
386 void drawImage(
const QRectF &targetRect,
const QImage &image,
const QRectF &sourceRect,
388 inline void drawImage(
const QRect &targetRect,
const QImage &image,
const QRect &sourceRect,
394 inline void drawImage(
const QRectF &r,
const QImage &image);
395 inline void drawImage(
const QRect &r,
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);
404 #if !defined(QT_NO_RAWFONT) 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);
431 inline void drawTextItem(
int x,
int y,
const QTextItem &ti);
435 inline void fillRect(
int x,
int y,
int w,
int h,
const QBrush &);
439 inline void fillRect(
int x,
int y,
int w,
int h,
const QColor &color);
446 inline void fillRect(
int x,
int y,
int w,
int h,
Qt::BrushStyle style);
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;
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); }
492 {
bool ret = begin(pdev); initFrom(init);
return ret; }
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)
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,
512 inline QT3_SUPPORT
void drawConvexPolygon(
const QPolygonF &polygon,
int index,
int npoints = -1)
514 inline QT3_SUPPORT
void drawConvexPolygon(
const QPolygon &pa,
int index,
int npoints = -1)
518 { setRedirected(pdev, replacement); }
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;
535 QT3_SUPPORT
QRect xFormDev(
const QRect &)
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;
562 friend
class QWin32PaintEnginePrivate;
704 drawRoundRect(
QRectF(x, y, w, h), xRnd, yRnd);
709 drawRoundRect(
QRectF(rect), xRnd, yRnd);
715 drawRoundedRect(
QRectF(x, y, w, h), xRadius, yRadius, mode);
721 drawRoundedRect(
QRectF(rect), xRadius, yRadius, mode);
726 drawEllipse(
QRect(x, y, w, h));
731 drawEllipse(
QRectF(center.
x() - rx, center.
y() - ry, 2 * rx, 2 * ry));
736 drawEllipse(
QRect(center.
x() - rx, center.
y() - ry, 2 * rx, 2 * ry));
741 drawArc(
QRectF(r), a, alen);
746 drawArc(
QRectF(x, y, w, h), a, alen);
751 drawPie(
QRectF(rect), a, alen);
756 drawPie(
QRectF(x, y, w, h), a, alen);
761 drawChord(
QRectF(rect), a, alen);
766 drawChord(
QRectF(x, y, w, h), a, alen);
771 setClipRect(
QRect(x, y, w, h), op);
781 eraseRect(
QRectF(x, y, w, h));
786 fillRect(
QRect(x, y, w, h), b);
791 fillRect(
QRect(x, y, w, h), b);
821 fillRect(r,
QBrush(style));
827 setBrushOrigin(
QPoint(x, y));
847 drawPixmap(
QRectF(targetRect), pixmap,
QRectF(sourceRect));
871 int sx,
int sy,
int sw,
int sh)
873 drawPixmap(
QRectF(x, y, w, h), pm,
QRectF(sx, sy, sw, sh));
877 int sx,
int sy,
int sw,
int sh)
879 drawPixmap(
QRectF(x, y, -1, -1), pm,
QRectF(sx, sy, sw, sh));
884 drawPixmap(
QRectF(p.
x(), p.
y(), -1, -1), pm, sr);
889 drawPixmap(
QRectF(p.
x(), p.
y(), -1, -1), pm, sr);
894 drawTextItem(
QPointF(x, y), ti);
898 Qt::ImageConversionFlags flags)
900 drawImage(
QRectF(targetRect), image,
QRectF(sourceRect), flags);
904 Qt::ImageConversionFlags flags)
906 drawImage(
QRectF(p.
x(), p.
y(), -1, -1), image, sr, flags);
910 Qt::ImageConversionFlags flags)
912 drawImage(
QRect(p.
x(), p.
y(), -1, -1), image, sr, flags);
932 Qt::ImageConversionFlags flags)
934 if (sx == 0 && sy == 0 && sw == -1 && sh == -1 && flags ==
Qt::AutoColor)
935 drawImage(
QPointF(x, y), image);
937 drawImage(
QRectF(x, y, -1, -1), image,
QRectF(sx, sy, sw, sh), flags);
942 drawStaticText(
QPointF(p), staticText);
947 drawStaticText(
QPointF(x, y), staticText);
962 drawText(
QRect(x, y, w, h), flags, str, br);
982 translate(offset.
x(), offset.
y());
987 setViewport(
QRect(x, y, w, h));
992 setWindow(
QRect(x, y, w, h));
995 #ifndef QT_NO_PICTURE 998 drawPicture(
QPoint(x, y), p);
1011 #endif // QPAINTER_H QRectF boundingRect(const QRectF &rect, int flags, const QString &text)
Returns the bounding rectangle of the text as it will appear when drawn inside the given rectangle wi...
void drawChord(const QRectF &rect, int a, int alen)
Draws the chord defined by the given rectangle, startAngle and spanAngle.
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
qreal sourceTop
the top coordinate of the source rectangle.
qreal scaleY
the vertical scale of the target rectangle.
static void setWorldTransform(QPainter *painter, const QTransform *const transformPtr, const QTransform *effectTransform)
void drawPie(const QRectF &rect, int a, int alen)
Draws a pie defined by the given rectangle, startAngle and and spanAngle.
qreal width
the width of the source rectangle and is used to calculate the width of the target rectangle...
void drawArc(const QRectF &rect, int a, int alen)
Draws the arc defined by the given rectangle, startAngle and spanAngle.
The QStaticText class enables optimized drawing of text when the text and its layout is updated rarel...
The QFontMetrics class provides font metrics information.
#define QT_END_NAMESPACE
This macro expands to.
void drawRoundRect(const QRectF &r, int xround=25, int yround=25)
Draws a rectangle r with rounded corners.
QPointer< QWidget > widget
CompositionMode
Defines the modes supported for digital image compositing.
The QLine class provides a two-dimensional vector using integer precision.
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the array points using the current pen's color.
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
void setViewport(const QRect &viewport)
Sets the painter's viewport rectangle to the given rectangle, and enables view transformations.
The QMatrix class specifies 2D transformations of a coordinate system.
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
The QPointF class defines a point in the plane using floating point precision.
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
long ASN1_INTEGER_get ASN1_INTEGER * a
The QPolygon class provides a vector of points using integer precision.
void drawLine(const QLineF &line)
Draws a line defined by line.
bool testRenderHint(RenderHint hint) const
Returns true if hint is set; otherwise returns false.
The QString class provides a Unicode character string.
qreal opacity
the opacity of the target rectangle, where 0.0 is fully transparent and 1.0 is fully opaque...
The QVector class is a template class that provides a dynamic array.
qreal rotation
the rotation of the target rectangle in degrees.
The QPen class defines how a QPainter should draw lines and outlines of shapes.
void setBrushOrigin(int x, int y)
Sets the brush's origin to point (x, y).
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen's color.
qreal x() const
Returns the x-coordinate of this point.
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
The QLineF class provides a two-dimensional vector using floating point precision.
static const QRectF boundingRect(const QPointF *points, int pointCount)
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount of the given rectangles using the current pen and brush.
QFuture< void > map(Sequence &sequence, MapFunction function)
#define QT_BEGIN_NAMESPACE
This macro expands to.
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
The QRectF class defines a rectangle in the plane using floating point precision. ...
qreal y
the y coordinate of the center point in the target rectangle.
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
void drawPicture(const QPointF &p, const QPicture &picture)
Replays the given picture at the given point.
void drawConvexPolygon(const QPointF *points, int pointCount)
Draws the convex polygon defined by the first pointCount points in the array points using the current...
static void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface)
qreal x
the x coordinate of center point in the target rectangle.
The QPolygonF class provides a vector of points using floating point precision.
The QImage class provides a hardware-independent image representation that allows direct access to th...
RenderHint
Renderhints are used to specify flags to QPainter that may or may not be respected by any given engin...
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
The QRegion class specifies a clip region for a painter.
The QGlyphRun class provides direct access to the internal glyphs in a font.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
The QFontInfo class provides general information about fonts.
void setWindow(const QRect &window)
Sets the painter's window to the given rectangle, and enables view transformations.
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
int width() const
Returns the width of the image.
static bool drawLine(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, qreal y2, int caps)
The QFont class specifies a font used for drawing text.
void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText)
Draws the given staticText at the given topLeftPosition.
This class is used in conjunction with the QPainter::drawPixmapFragments() function to specify how a ...
qreal scaleX
the horizontal scale of the target rectangle.
void eraseRect(const QRectF &)
Erases the area inside the given rectangle.
The QPoint class defines a point in the plane using integer precision.
void drawTextItem(const QPointF &p, const QTextItem &ti)
Draws the text item ti at position p.
The QRect class defines a rectangle in the plane using integer precision.
The QTextOption class provides a description of general rich text properties.
int height() const
Returns the height of the image.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
int y() const
Returns the y coordinate of this point.
static void drawPoints(const T *points, int n, const QTransform &transform, IDirectFBSurface *surface)
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
qreal y() const
Returns the y-coordinate of this point.
The QPixmap class is an off-screen image representation that can be used as a paint device...
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
#define Q_DECLARE_PRIVATE(Class)
const T * constData() const
Returns a const pointer to the data stored in the vector.
int x() const
Returns the x coordinate of this point.
The QRasterPaintEngine class enables hardware acceleration of painting operations in Qt for Embedded ...
static void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface)
The QTextItem class provides all the information required to draw text in a custom paint engine...
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
Draws the given rectangle rect with rounded corners.
qreal sourceLeft
the left coordinate of the source rectangle.
static const KeyPair *const end
The QPicture class is a paint device that records and replays QPainter commands.
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen...
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
qreal height
the height of the source rectangle and is used to calculate the height of the target rectangle...
int size() const
Returns the number of items in the vector.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Qt::LayoutDirection direction
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.