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