CopperSpice API  1.7.2
QPaintEngine Class Referenceabstract

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

Inherited by QAlphaPaintEngine, QPaintEngineEx, QPdfEngine, QPicturePaintEngine, and QPreviewPaintEngine.

Public Types

enum  PolygonDrawMode
 
enum  Type
 

Public Methods

 QPaintEngine (PaintEngineFeatures features=PaintEngineFeatures ())
 
virtual ~QPaintEngine ()
 
virtual bool begin (QPaintDevice *pdev) = 0
 
virtual void drawEllipse (const QRect &r)
 
virtual void drawEllipse (const QRectF &r)
 
virtual void drawImage (const QRectF &r, const QImage &pm, const QRectF &sr, 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 &r, const QPixmap &pm, const QRectF &sr) = 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 &p, const QTextItem &textItem)
 
virtual void drawTiledPixmap (const QRectF &r, const QPixmap &pixmap, const QPointF &s)
 
virtual bool end () = 0
 
bool hasFeature (PaintEngineFeatures feature) const
 
bool isActive () const
 
QPaintDevicepaintDevice () const
 
QPainterpainter () const
 
void setActive (bool newState)
 
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  caps = PaintEngineFeatures())
explicit

Creates a paint engine with the featureset specified by caps.

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.

void QPaintEngine::drawEllipse ( const QRect rect)
virtual

The default implementation calls the floating point version of this method.

void QPaintEngine::drawEllipse ( const QRectF rect)
virtual

Reimplement this function to draw the largest ellipse that can be contained within rect.

The default implementation calls drawPolygon().

Reimplemented in QRasterPaintEngine.

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 flags, to convert it to a pixmap.

Reimplemented in QRasterPaintEngine.

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

The default implementation converts the first lineCount lines in lines to a QLineF and calls the floating point version of this method.

Reimplemented in QRasterPaintEngine.

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

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

Reimplemented in QRasterPaintEngine.

void QPaintEngine::drawPath ( const QPainterPath path)
virtual

The default implementation ignores the path and does nothing.

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

Reimplement this method to draw the part of the pm specified by the srcRect rectangle in the given rect.

Implemented in QRasterPaintEngine.

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

Using the buffer points, the first pointCount elements will be drawn.

Reimplemented in QRasterPaintEngine.

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

Using the buffer points, the first pointCount elements will be drawn.

Reimplemented in QRasterPaintEngine.

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

Reimplement this virtual method to draw the polygon defined by the pointCount first points in points, using mode mode.

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

Reimplemented in QRasterPaintEngine.

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

Reimplement this method to draw the polygon defined by the pointCount first points in points, using mode>.

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

Reimplemented in QRasterPaintEngine.

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

The default implementation converts the first rectCount rectangles in the buffer rectBuffer to QRectF and calls the floating point version of this method.

Reimplemented in QRasterPaintEngine.

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

Draws the first rectCount rectangles in the buffer rectBuffer. The default implementation of this function calls drawPath() or drawPolygon() depending on the feature set of the paint engine.

Reimplemented in QRasterPaintEngine.

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

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

Reimplemented in QRasterPaintEngine.

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.

bool QPaintEngine::end ( )
pure virtual

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

See also
begin(), isActive()

Implemented in QRasterPaintEngine.

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.

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