00001 #ifndef NULL_PAINT_DEVICE_H
00002 #define NULL_PAINT_DEVICE_H
00003
00004 #include <QPaintDevice>
00005 #include <QPaintEngine>
00006
00007 namespace KDChart
00008 {
00009 class NullPaintEngine : public QPaintEngine
00010 {
00011 public:
00012 virtual bool begin(QPaintDevice * ) { return true; }
00013 virtual void drawEllipse(const QRectF & ) { }
00014 virtual void drawEllipse(const QRect & ) { }
00015 virtual void drawImage(const QRectF & , const QImage & , const QRectF & , Qt::ImageConversionFlags ) { }
00016 virtual void drawLines(const QLineF * , int ) { }
00017 virtual void drawLines(const QLine * , int ) { }
00018 virtual void drawPath(const QPainterPath & ) { }
00019 virtual void drawPixmap(const QRectF & , const QPixmap & , const QRectF & ) { }
00020 virtual void drawPoints(const QPointF * , int ) { }
00021 virtual void drawPoints(const QPoint * , int ) { }
00022 virtual void drawPolygon(const QPointF * , int , PolygonDrawMode ) { }
00023 virtual void drawPolygon(const QPoint * , int , PolygonDrawMode ) { }
00024 virtual void drawRects(const QRectF * , int ) { }
00025 virtual void drawRects(const QRect * , int ) { }
00026 virtual void drawTextItem(const QPointF & , const QTextItem & ) { }
00027 virtual void drawTiledPixmap(const QRectF & , const QPixmap & , const QPointF & ) { }
00028 virtual bool end() { return true; }
00029
00030 virtual Type type() const { return QPaintEngine::User; }
00031 virtual void updateState(const QPaintEngineState & ) { }
00032 };
00033
00034 class NullPaintDevice : public QPaintDevice
00035 {
00036 public:
00037 NullPaintDevice(const QSize& size) : m_size(size) { }
00038 ~NullPaintDevice() { }
00039
00040 int metric(PaintDeviceMetric metric) const
00041 {
00042 switch(metric)
00043 {
00044 case QPaintDevice::PdmWidth:
00045 return m_size.width();
00046 case QPaintDevice::PdmHeight:
00047 return m_size.height();
00048 case QPaintDevice::PdmWidthMM:
00049 return 1;
00050 case QPaintDevice::PdmHeightMM:
00051 return 1;
00052 case QPaintDevice::PdmNumColors:
00053 return int((uint)(-1));
00054 case QPaintDevice::PdmDepth:
00055 return 1;
00056 case QPaintDevice::PdmDpiX:
00057 return 1;
00058 case QPaintDevice::PdmDpiY:
00059 return 1;
00060 case QPaintDevice::PdmPhysicalDpiX:
00061 return 1;
00062 case QPaintDevice::PdmPhysicalDpiY:
00063 return 1;
00064 }
00065 return 1;
00066 }
00067
00068 QPaintEngine* paintEngine() const
00069 {
00070 static NullPaintEngine nullPaintEngine;
00071 return &nullPaintEngine;
00072 }
00073
00074 private:
00075 QSize m_size;
00076 };
00077
00078 }
00079
00080 #endif