KD Chart 2  [rev.2.6]
KDChartNullPaintDevice.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2019 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #ifndef NULL_PAINT_DEVICE_H
24 #define NULL_PAINT_DEVICE_H
25 
26 #include <QPaintDevice>
27 #include <QPaintEngine>
28 
29 namespace KDChart
30 {
32  {
33  public:
34  virtual bool begin(QPaintDevice * /*pdev*/) { return true; }
35  virtual void drawEllipse(const QRectF & /*rect*/) { }
36  virtual void drawEllipse(const QRect & /*rect*/) { }
37  virtual void drawImage(const QRectF & /*rectangle*/, const QImage & /*image*/, const QRectF & /*sr*/, Qt::ImageConversionFlags /*flags*/) { }
38  virtual void drawLines(const QLineF * /*lines*/, int /*lineCount*/) { }
39  virtual void drawLines(const QLine * /*lines*/, int /*lineCount*/) { }
40  virtual void drawPath(const QPainterPath & /*path*/) { }
41  virtual void drawPixmap(const QRectF & /*r*/, const QPixmap & /*pm*/, const QRectF & /*sr*/) { }
42  virtual void drawPoints(const QPointF * /*points*/, int /*pointCount*/) { }
43  virtual void drawPoints(const QPoint * /*points*/, int /*pointCount*/) { }
44  virtual void drawPolygon(const QPointF * /*points*/, int /*pointCount*/, PolygonDrawMode /*mode*/) { }
45  virtual void drawPolygon(const QPoint * /*points*/, int /*pointCount*/, PolygonDrawMode /*mode*/) { }
46  virtual void drawRects(const QRectF * /*rects*/, int /*rectCount*/) { }
47  virtual void drawRects(const QRect * /*rects*/, int /*rectCount*/) { }
48  virtual void drawTextItem(const QPointF & /*p*/, const QTextItem & /*textItem*/) { }
49  virtual void drawTiledPixmap(const QRectF & /*rect*/, const QPixmap & /*pixmap*/, const QPointF & /*p*/) { }
50  virtual bool end() { return true; }
51 
52  virtual Type type() const { return QPaintEngine::User; }
53  virtual void updateState(const QPaintEngineState & /*state*/) { }
54  };
55 
57  {
58  public:
59  NullPaintDevice(const QSize& size) : m_size(size) { }
61 
62  int metric(PaintDeviceMetric metric) const
63  {
64  switch (metric)
65  {
66  case QPaintDevice::PdmWidth:
67  return m_size.width();
68  case QPaintDevice::PdmHeight:
69  return m_size.height();
70  case QPaintDevice::PdmWidthMM:
71  return 1;
72  case QPaintDevice::PdmHeightMM:
73  return 1;
74  case QPaintDevice::PdmNumColors:
75  return int((uint)(-1));
76  case QPaintDevice::PdmDepth:
77  return 1;
78  case QPaintDevice::PdmDpiX:
79  return 1;
80  case QPaintDevice::PdmDpiY:
81  return 1;
82  case QPaintDevice::PdmPhysicalDpiX:
83  return 1;
84  case QPaintDevice::PdmPhysicalDpiY:
85  return 1;
86 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
87  case QPaintDevice::PdmDevicePixelRatio:
88  return 1;
89 #endif
90  }
91  return 1;
92  }
93 
95  {
96  static NullPaintEngine nullPaintEngine;
97  return &nullPaintEngine;
98  }
99 
100  private:
101  QSize m_size;
102  };
103 
104 }
105 
106 #endif
virtual void drawEllipse(const QRectF &)
virtual void drawPolygon(const QPoint *, int, PolygonDrawMode)
virtual void drawPolygon(const QPointF *, int, PolygonDrawMode)
int metric(PaintDeviceMetric metric) const
virtual void drawPath(const QPainterPath &)
virtual void drawLines(const QLine *, int)
virtual bool begin(QPaintDevice *)
virtual void updateState(const QPaintEngineState &)
NullPaintDevice(const QSize &size)
virtual void drawLines(const QLineF *, int)
virtual void drawImage(const QRectF &, const QImage &, const QRectF &, Qt::ImageConversionFlags)
virtual void drawPoints(const QPointF *, int)
virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &)
virtual void drawRects(const QRect *, int)
virtual void drawEllipse(const QRect &)
QPaintEngine * paintEngine() const
virtual void drawPoints(const QPoint *, int)
virtual void drawRects(const QRectF *, int)
virtual void drawTiledPixmap(const QRectF &, const QPixmap &, const QPointF &)
virtual void drawTextItem(const QPointF &, const QTextItem &)
virtual Type type() const

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
https://www.kdab.com/
https://www.kdab.com/products/kd-chart/