KD Chart API Documentation  3.1
KDChartNullPaintDevice.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Chart library.
4 **
5 ** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: MIT
8 **
9 ****************************************************************************/
10 
11 #ifndef NULL_PAINT_DEVICE_H
12 #define NULL_PAINT_DEVICE_H
13 
14 #include <QPaintDevice>
15 #include <QPaintEngine>
16 
17 namespace KDChart {
18 class NullPaintEngine : public QPaintEngine
19 {
20 public:
21  bool begin(QPaintDevice * /*pdev*/) override
22  {
23  return true;
24  }
25  void drawEllipse(const QRectF & /*rect*/) override
26  {
27  }
28  void drawEllipse(const QRect & /*rect*/) override
29  {
30  }
31  void drawImage(const QRectF & /*rectangle*/, const QImage & /*image*/, const QRectF & /*sr*/, Qt::ImageConversionFlags /*flags*/) override
32  {
33  }
34  void drawLines(const QLineF * /*lines*/, int /*lineCount*/) override
35  {
36  }
37  void drawLines(const QLine * /*lines*/, int /*lineCount*/) override
38  {
39  }
40  void drawPath(const QPainterPath & /*path*/) override
41  {
42  }
43  void drawPixmap(const QRectF & /*r*/, const QPixmap & /*pm*/, const QRectF & /*sr*/) override
44  {
45  }
46  void drawPoints(const QPointF * /*points*/, int /*pointCount*/) override
47  {
48  }
49  void drawPoints(const QPoint * /*points*/, int /*pointCount*/) override
50  {
51  }
52  void drawPolygon(const QPointF * /*points*/, int /*pointCount*/, PolygonDrawMode /*mode*/) override
53  {
54  }
55  void drawPolygon(const QPoint * /*points*/, int /*pointCount*/, PolygonDrawMode /*mode*/) override
56  {
57  }
58  void drawRects(const QRectF * /*rects*/, int /*rectCount*/) override
59  {
60  }
61  void drawRects(const QRect * /*rects*/, int /*rectCount*/) override
62  {
63  }
64  void drawTextItem(const QPointF & /*p*/, const QTextItem & /*textItem*/) override
65  {
66  }
67  void drawTiledPixmap(const QRectF & /*rect*/, const QPixmap & /*pixmap*/, const QPointF & /*p*/) override
68  {
69  }
70  bool end() override
71  {
72  return true;
73  }
74 
75  Type type() const override
76  {
77  return QPaintEngine::User;
78  }
79  void updateState(const QPaintEngineState & /*state*/) override
80  {
81  }
82 };
83 
84 class NullPaintDevice : public QPaintDevice
85 {
86 public:
87  NullPaintDevice(const QSize &size)
88  : m_size(size)
89  {
90  }
91  ~NullPaintDevice() override
92  {
93  }
94 
95  int metric(PaintDeviceMetric metric) const override
96  {
97  switch (metric) {
98  case QPaintDevice::PdmWidth:
99  return m_size.width();
100  case QPaintDevice::PdmHeight:
101  return m_size.height();
102  case QPaintDevice::PdmWidthMM:
103  return 1;
104  case QPaintDevice::PdmHeightMM:
105  return 1;
106  case QPaintDevice::PdmNumColors:
107  return int(( uint )(-1));
108  case QPaintDevice::PdmDepth:
109  return 1;
110  case QPaintDevice::PdmDpiX:
111  return 1;
112  case QPaintDevice::PdmDpiY:
113  return 1;
114  case QPaintDevice::PdmPhysicalDpiX:
115  return 1;
116  case QPaintDevice::PdmPhysicalDpiY:
117  return 1;
118  case QPaintDevice::PdmDevicePixelRatio:
119  return 1;
120 #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
121  case QPaintDevice::PdmDevicePixelRatioScaled:
122  return 1;
123 #endif
124  }
125  return 1;
126  }
127 
128  QPaintEngine *paintEngine() const override
129  {
130  static NullPaintEngine nullPaintEngine;
131  return &nullPaintEngine;
132  }
133 
134 private:
135  QSize m_size;
136 };
137 }
138 
139 #endif
NullPaintDevice(const QSize &size)
int metric(PaintDeviceMetric metric) const override
QPaintEngine * paintEngine() const override
void updateState(const QPaintEngineState &) override
void drawPoints(const QPoint *, int) override
void drawPolygon(const QPoint *, int, PolygonDrawMode) override
void drawRects(const QRect *, int) override
void drawPoints(const QPointF *, int) override
void drawTextItem(const QPointF &, const QTextItem &) override
void drawPath(const QPainterPath &) override
void drawLines(const QLine *, int) override
bool begin(QPaintDevice *) override
void drawRects(const QRectF *, int) override
Type type() const override
void drawImage(const QRectF &, const QImage &, const QRectF &, Qt::ImageConversionFlags) override
void drawLines(const QLineF *, int) override
void drawEllipse(const QRectF &) override
void drawEllipse(const QRect &) override
void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) override
void drawPolygon(const QPointF *, int, PolygonDrawMode) override
void drawTiledPixmap(const QRectF &, const QPixmap &, const QPointF &) override

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated by doxygen 1.9.1