10#include "qwt_null_paintdevice.h"
11#include <qpaintengine.h>
12#include <qpainterpath.h>
14class QwtNullPaintDevice::PrivateData
25class QwtNullPaintDevice::PaintEngine QWT_FINAL :
public QPaintEngine
30 virtual bool begin( QPaintDevice* ) QWT_OVERRIDE;
31 virtual bool end() QWT_OVERRIDE;
33 virtual Type type () const QWT_OVERRIDE;
34 virtual
void updateState(const QPaintEngineState&) QWT_OVERRIDE;
36 virtual
void drawRects(const QRect*,
int ) QWT_OVERRIDE;
37 virtual
void drawRects(const QRectF*,
int ) QWT_OVERRIDE;
39 virtual
void drawLines(const QLine*,
int ) QWT_OVERRIDE;
40 virtual
void drawLines(const QLineF*,
int ) QWT_OVERRIDE;
42 virtual
void drawEllipse(const QRectF&) QWT_OVERRIDE;
43 virtual
void drawEllipse(const QRect&) QWT_OVERRIDE;
45 virtual
void drawPath(const QPainterPath&) QWT_OVERRIDE;
47 virtual
void drawPoints(const QPointF*,
int ) QWT_OVERRIDE;
48 virtual
void drawPoints(const QPoint*,
int ) QWT_OVERRIDE;
50 virtual
void drawPolygon(
51 const QPointF*,
int, PolygonDrawMode ) QWT_OVERRIDE;
53 virtual
void drawPolygon(
54 const QPoint*,
int, PolygonDrawMode ) QWT_OVERRIDE;
56 virtual
void drawPixmap(const QRectF&,
57 const QPixmap&, const QRectF&) QWT_OVERRIDE;
59 virtual
void drawTextItem(
60 const QPointF&, const QTextItem&) QWT_OVERRIDE;
62 virtual
void drawTiledPixmap(const QRectF&,
63 const QPixmap&, const QPointF& s) QWT_OVERRIDE;
65 virtual
void drawImage(const QRectF&, const QImage&,
66 const QRectF&, Qt::ImageConversionFlags ) QWT_OVERRIDE;
73 : QPaintEngine( QPaintEngine::AllFeatures )
77bool QwtNullPaintDevice::PaintEngine::begin( QPaintDevice* )
83bool QwtNullPaintDevice::PaintEngine::end()
89QPaintEngine::Type QwtNullPaintDevice::PaintEngine::type()
const
96 return static_cast< QPaintEngine::Type
>( QPaintEngine::MaxUser - 2 );
99void QwtNullPaintDevice::PaintEngine::drawRects(
100 const QRect* rects,
int rectCount)
103 if ( device == NULL )
108 QPaintEngine::drawRects( rects, rectCount );
115void QwtNullPaintDevice::PaintEngine::drawRects(
116 const QRectF* rects,
int rectCount)
119 if ( device == NULL )
124 QPaintEngine::drawRects( rects, rectCount );
131void QwtNullPaintDevice::PaintEngine::drawLines(
132 const QLine* lines,
int lineCount)
135 if ( device == NULL )
140 QPaintEngine::drawLines( lines, lineCount );
147void QwtNullPaintDevice::PaintEngine::drawLines(
148 const QLineF* lines,
int lineCount)
151 if ( device == NULL )
156 QPaintEngine::drawLines( lines, lineCount );
163void QwtNullPaintDevice::PaintEngine::drawEllipse(
167 if ( device == NULL )
172 QPaintEngine::drawEllipse( rect );
179void QwtNullPaintDevice::PaintEngine::drawEllipse(
183 if ( device == NULL )
188 QPaintEngine::drawEllipse( rect );
196void QwtNullPaintDevice::PaintEngine::drawPath(
197 const QPainterPath& path)
200 if ( device == NULL )
206void QwtNullPaintDevice::PaintEngine::drawPoints(
207 const QPointF* points,
int pointCount)
210 if ( device == NULL )
215 QPaintEngine::drawPoints( points, pointCount );
222void QwtNullPaintDevice::PaintEngine::drawPoints(
223 const QPoint* points,
int pointCount)
226 if ( device == NULL )
231 QPaintEngine::drawPoints( points, pointCount );
238void QwtNullPaintDevice::PaintEngine::drawPolygon(
239 const QPointF* points,
int pointCount, PolygonDrawMode
mode)
242 if ( device == NULL )
249 if ( pointCount > 0 )
251 path.moveTo( points[0] );
252 for (
int i = 1; i < pointCount; i++ )
253 path.lineTo( points[i] );
255 if (
mode != PolylineMode )
266void QwtNullPaintDevice::PaintEngine::drawPolygon(
267 const QPoint* points,
int pointCount, PolygonDrawMode
mode)
270 if ( device == NULL )
277 if ( pointCount > 0 )
279 path.moveTo( points[0] );
280 for (
int i = 1; i < pointCount; i++ )
281 path.lineTo( points[i] );
283 if (
mode != PolylineMode )
294void QwtNullPaintDevice::PaintEngine::drawPixmap(
295 const QRectF& rect,
const QPixmap& pm,
const QRectF& subRect )
298 if ( device == NULL )
304void QwtNullPaintDevice::PaintEngine::drawTextItem(
305 const QPointF& pos,
const QTextItem& textItem)
308 if ( device == NULL )
313 QPaintEngine::drawTextItem( pos, textItem );
320void QwtNullPaintDevice::PaintEngine::drawTiledPixmap(
321 const QRectF& rect,
const QPixmap& pixmap,
322 const QPointF& subRect)
325 if ( device == NULL )
330 QPaintEngine::drawTiledPixmap( rect, pixmap, subRect );
337void QwtNullPaintDevice::PaintEngine::drawImage(
338 const QRectF& rect,
const QImage& image,
339 const QRectF& subRect, Qt::ImageConversionFlags flags)
342 if ( device == NULL )
345 device->
drawImage( rect, image, subRect, flags );
348void QwtNullPaintDevice::PaintEngine::updateState(
349 const QPaintEngineState& engineState)
352 if ( device == NULL )
370 m_data =
new PrivateData;
403 if ( m_engine == NULL )
408 that->m_engine =
new PaintEngine();
426 switch ( deviceMetric )
448 case PdmPhysicalDpiX:
449 case PdmPhysicalDpiY:
458 value = qRound(
metric( PdmWidth ) * 25.4 /
metric( PdmDpiX ) );
463 value = qRound(
metric( PdmHeight ) * 25.4 /
metric( PdmDpiY ) );
466#if QT_VERSION >= 0x050100
467 case PdmDevicePixelRatio:
475 value = QPaintDevice::metric( deviceMetric );
484 const QRect* rects,
int rectCount)
492 const QRectF* rects,
int rectCount)
500 const QLine* lines,
int lineCount)
508 const QLineF* lines,
int lineCount)
534 const QPointF* points,
int pointCount)
537 Q_UNUSED(pointCount);
542 const QPoint* points,
int pointCount)
545 Q_UNUSED(pointCount);
550 const QPointF* points,
int pointCount,
551 QPaintEngine::PolygonDrawMode mode)
554 Q_UNUSED(pointCount);
560 const QPoint* points,
int pointCount,
561 QPaintEngine::PolygonDrawMode mode)
564 Q_UNUSED(pointCount);
570 const QPixmap& pm,
const QRectF& subRect )
579 const QPointF& pos,
const QTextItem& textItem)
587 const QRectF& rect,
const QPixmap& pixmap,
588 const QPointF& subRect)
597 const QRectF& rect,
const QImage& image,
598 const QRectF& subRect, Qt::ImageConversionFlags flags)
608 const QPaintEngineState& state )
A null paint device doing nothing.
virtual ~QwtNullPaintDevice()
Destructor.
virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &)
See QPaintEngine::drawPixmap()
virtual void drawPath(const QPainterPath &)
See QPaintEngine::drawPath()
virtual void drawRects(const QRect *, int)
See QPaintEngine::drawRects()
virtual void drawEllipse(const QRectF &)
See QPaintEngine::drawEllipse()
virtual void drawLines(const QLine *, int)
See QPaintEngine::drawLines()
virtual int metric(PaintDeviceMetric) const override
virtual void drawPoints(const QPointF *, int)
See QPaintEngine::drawPoints()
virtual QPaintEngine * paintEngine() const override
See QPaintDevice::paintEngine()
virtual void drawImage(const QRectF &, const QImage &, const QRectF &, Qt::ImageConversionFlags)
See QPaintEngine::drawImage()
virtual void updateState(const QPaintEngineState &)
See QPaintEngine::updateState()
QwtNullPaintDevice()
Constructor.
virtual void drawTextItem(const QPointF &, const QTextItem &)
See QPaintEngine::drawTextItem()
virtual QSize sizeMetrics() const =0
virtual void drawPolygon(const QPointF *, int, QPaintEngine::PolygonDrawMode)
See QPaintEngine::drawPolygon()
virtual void drawTiledPixmap(const QRectF &, const QPixmap &, const QPointF &)
See QPaintEngine::drawTiledPixmap()