KD Chart 2  [rev.2.5.1]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
KDChartNullPaintDevice.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2013 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  }
87  return 1;
88  }
89 
91  {
92  static NullPaintEngine nullPaintEngine;
93  return &nullPaintEngine;
94  }
95 
96  private:
97  QSize m_size;
98  };
99 
100 }
101 
102 #endif

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