CopperSpice API  1.9.1
QPaintEngine Class Referenceabstract

Abstract definition of how QPainter draws to a given device on a given platform. More...

Inherited by QAlphaPaintEngine, QPaintEngineEx, QPdfEngine, QPicturePaintEngine, QPreviewPaintEngine

Public Types

enum  PolygonDrawMode
 
enum  Type
 

Public Methods

 QPaintEngine (PaintEngineFeatures options=PaintEngineFeatures ())
 
virtual ~QPaintEngine ()
 
virtual bool begin (QPaintDevice *pdev) = 0
 
virtual void drawEllipse (const QRect &rect)
 
virtual void drawEllipse (const QRectF &rect)
 
virtual void drawImage (const QRectF &rect, const QImage &image, const QRectF &srcRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
 
virtual void drawLines (const QLine *lines, int lineCount)
 
virtual void drawLines (const QLineF *lines, int lineCount)
 
virtual void drawPath (const QPainterPath &path)
 
virtual void drawPixmap (const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect) = 0
 
virtual void drawPoints (const QPoint *points, int pointCount)
 
virtual void drawPoints (const QPointF *points, int pointCount)
 
virtual void drawPolygon (const QPoint *points, int pointCount, PolygonDrawMode mode)
 
virtual void drawPolygon (const QPointF *points, int pointCount, PolygonDrawMode mode)
 
virtual void drawRects (const QRect *rects, int rectCount)
 
virtual void drawRects (const QRectF *rects, int rectCount)
 
virtual void drawTextItem (const QPointF &point, const QTextItem &textItem)
 
virtual void drawTiledPixmap (const QRectF &rect, const QPixmap &pixmap, const QPointF &point)
 
virtual bool end () = 0
 
bool hasFeature (PaintEngineFeatures feature) const
 
bool isActive () const
 
QPaintDevicepaintDevice () const
 
QPainterpainter () const
 
void setActive (bool state)
 
virtual Type type () const = 0
 
virtual void updateState (const QPaintEngineState &state) = 0
 

Friends

class QPainter
 
class QWidget
 

Detailed Description

The QPaintEngine class provides an abstract definition for how QPainter draws to a given device on a given platform.

CopperSpice provides implementations of QPaintEngine for the different painter backends. There is one paint engine for each window system and painting supported platform. This includes X11 on Unix/Linux and Cocoa on Mac OS X.

QPaintEngine implementations are also provided for OpenGL (accessible through QGLWidget) and PostScript (accessible through QPSPrinter on X11). There is another raster-based paint engine which is a fallback for when an engine does not support a certain capability.

Use the QPainter class to draw to a different backend, subclass QPaintEngine and reimplement all virtual methods. The QPaintEngine class implementation is then made available by subclassing QPaintDevice and reimplementing the virtual function QPaintDevice::paintEngine().

QPaintEngine is created and owned by the QPaintDevice that created it.

See also
QPainter, QPaintDevice::paintEngine(), Paint System

Member Enumeration Documentation

ConstantValueDescription
QPaintEngine::OddEvenMode0The polygon should be drawn using OddEven fill rule.
QPaintEngine::WindingMode1The polygon should be drawn using Winding fill rule.
QPaintEngine::ConvexMode2The polygon is a convex polygon and can be drawn using specialized algorithms where available.
QPaintEngine::PolylineMode3Only the outline of the polygon should be drawn.
ConstantValueDescription
QPaintEngine::X110 
QPaintEngine::Windows1 
QPaintEngine::MacPrinter4 
QPaintEngine::CoreGraphics3Mac OS X's Quartz2D (CoreGraphics)
QPaintEngine::QuickDraw2Mac OS X's QuickDraw
QPaintEngine::QWindowSystem5For Embedded Linux
QPaintEngine::PostScript6Not supported
QPaintEngine::OpenGL7 
QPaintEngine::Picture8QPicture format
QPaintEngine::SVG9Scalable Vector Graphics XML format
QPaintEngine::Raster10 
QPaintEngine::Direct3D11Windows only, Direct3D based engine
QPaintEngine::Pdf12Portable Document Format
QPaintEngine::OpenVG13 
QPaintEngine::User50First user type ID
QPaintEngine::MaxUser100Last user type ID
QPaintEngine::OpenGL214 
QPaintEngine::PaintBuffer15 
QPaintEngine::Blitter16 

Constructor & Destructor Documentation

QPaintEngine::QPaintEngine ( PaintEngineFeatures  options = PaintEngineFeatures())
explicit

Creates a paint engine with the feature set specified by options.

QPaintEngine::~QPaintEngine ( )
virtual

Destroys the paint engine.

Method Documentation

bool QPaintEngine::begin ( QPaintDevice pdev)
pure virtual

Reimplement this method to initialize your paint engine when painting is to start on the paint device pdev. Return true if the initialization was successful, otherwise return false.

See also
end(), isActive()

Implemented in QRasterPaintEngine::begin()

void QPaintEngine::drawEllipse ( const QRect rect)
virtual

Reimplement this method to draw the largest ellipse that can be contained within rect. The default implementation calls drawPolygon().

void QPaintEngine::drawEllipse ( const QRectF rect)
virtual

Reimplement this method to draw the largest ellipse that can be contained within rect. The default implementation calls drawPolygon().

Reimplemented in QRasterPaintEngine::drawEllipse()

void QPaintEngine::drawImage ( const QRectF rect,
const QImage image,
const QRectF srcRect,
Qt::ImageConversionFlags  flags = Qt::AutoColor 
)
virtual

Reimplement this method to draw the part of the image specified by srcRect in the given rect using the given conversion flags, to convert it to a pixmap.

Reimplemented in QRasterPaintEngine::drawImage()

void QPaintEngine::drawLines ( const QLine lines,
int  lineCount 
)
virtual

The default implementation converts the list of lines starting at lines for the given number of lines, specified in lineCount, to a QLineF and calls the floating point version of this method.

Reimplemented in QRasterPaintEngine::drawLines()

void QPaintEngine::drawLines ( const QLineF lines,
int  lineCount 
)
virtual

The default implementation splits the list of lines starting at lines into lineCount separate calls to drawPath() or drawPolygon() depending on the feature set of the paint engine.

Reimplemented in QRasterPaintEngine::drawLines()

void QPaintEngine::drawPath ( const QPainterPath path)
virtual

The default implementation ignores the path and does nothing.

void QPaintEngine::drawPixmap ( const QRectF rect,
const QPixmap pixmap,
const QRectF srcRect 
)
pure virtual

Reimplement to draw a portion of the pixmap specified by the rectangle srcRect, in the given rect.

Implemented in QRasterPaintEngine::drawPixmap()

void QPaintEngine::drawPoints ( const QPoint points,
int  pointCount 
)
virtual

Draws points starting from points for the given number of points specified in pointCount.

Reimplemented in QRasterPaintEngine::drawPoints()

void QPaintEngine::drawPoints ( const QPointF points,
int  pointCount 
)
virtual

Draws points starting from points for the given number of points specified in pointCount.

Reimplemented in QRasterPaintEngine::drawPoints()

void QPaintEngine::drawPolygon ( const QPoint points,
int  pointCount,
PolygonDrawMode  mode 
)
virtual

Draws a polygon defined by points starting at points for the given number of points specified in pointCount. The mode specifies the algorithm used to draw the polygon.

Note
At least one of the drawPolygon() methods must be reimplemented.

Reimplemented in QRasterPaintEngine::drawPolygon()

void QPaintEngine::drawPolygon ( const QPointF points,
int  pointCount,
PolygonDrawMode  mode 
)
virtual

Draws a polygon defined by points starting at points for the given number of points specified in pointCount. The mode specifies the algorithm used to draw the polygon.

Note
At least one of the drawPolygon() methods must be reimplemented.

Reimplemented in QRasterPaintEngine::drawPolygon()

void QPaintEngine::drawRects ( const QRect rects,
int  rectCount 
)
virtual

The default implementation converts rectangles starting from rects for the given number of rectangles specified in rectCount, to QRectF and calls the floating point version of this method.

Reimplemented in QRasterPaintEngine::drawRects()

void QPaintEngine::drawRects ( const QRectF rects,
int  rectCount 
)
virtual

Draws rectangles starting from rects for the given number of rectangles specified in rectCount. The default implementation of this method calls drawPath() or drawPolygon() depending on the feature set of the paint engine.

Reimplemented in QRasterPaintEngine::drawRects()

void QPaintEngine::drawTextItem ( const QPointF point,
const QTextItem textItem 
)
virtual

Draws the text item textItem at position point. The default implementation of this function converts the text to a QPainterPath and paints the resulting path.

Reimplemented in QRasterPaintEngine::drawTextItem()

void QPaintEngine::drawTiledPixmap ( const QRectF rect,
const QPixmap pixmap,
const QPointF point 
)
virtual

Reimplement this method to draw the pixmap in the given rect, starting at the given point. The pixmap will be drawn repeatedly until the rect is filled.

Reimplemented in QRasterPaintEngine::drawTiledPixmap()

bool QPaintEngine::end ( )
pure virtual

Reimplement this method to finish painting on the current paint device. Returns true if painting was finished successfully, otherwise return false.

See also
begin(), isActive()

Implemented in QRasterPaintEngine::end()

bool QPaintEngine::hasFeature ( PaintEngineFeatures  feature) const
inline

Returns true if the paint engine supports the specified feature, otherwise returns false.

bool QPaintEngine::isActive ( ) const
inline

Returns true if the paint engine is actively drawing, otherwise returns false.

See also
setActive()
QPaintDevice * QPaintEngine::paintDevice ( ) const

Returns the device that this engine is painting on, if painting is active, otherwise returns a nullptr.

QPainter * QPaintEngine::painter ( ) const

Returns the paint engine's painter.

void QPaintEngine::setActive ( bool  state)
inline

Sets the active state of the paint engine to state.

See also
isActive()
Type QPaintEngine::type ( ) const
pure virtual

Reimplement this function to return the paint engine Type.

Implemented in QRasterPaintEngine::type()

void QPaintEngine::updateState ( const QPaintEngineState state)
pure virtual

Reimplement this function to update the state of a paint engine.

When implemented, this function is responsible for checking the paint engine's current state and update the properties that are changed. Use the QPaintEngineState::state() function to find out which properties that must be updated, then use the corresponding get function to retrieve the current values for the given properties.

See also
QPaintEngineState