KDChartNullPaintDevice.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB.  All rights reserved.
00003 **
00004 ** This file is part of the KD Chart library.
00005 **
00006 ** Licensees holding valid commercial KD Chart licenses may use this file in
00007 ** accordance with the KD Chart Commercial License Agreement provided with
00008 ** the Software.
00009 **
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 and version 3 as published by the
00013 ** Free Software Foundation and appearing in the file LICENSE.GPL included.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** Contact info@kdab.com if any conditions of this licensing are not
00019 ** clear to you.
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 * /*pdev*/) { return true; }
00035         virtual void drawEllipse(const QRectF & /*rect*/) { }
00036         virtual void drawEllipse(const QRect & /*rect*/) { }
00037         virtual void drawImage(const QRectF & /*rectangle*/, const QImage & /*image*/, const QRectF & /*sr*/, Qt::ImageConversionFlags /*flags*/) { }
00038         virtual void drawLines(const QLineF * /*lines*/, int /*lineCount*/) { }
00039         virtual void drawLines(const QLine * /*lines*/, int /*lineCount*/) { }
00040         virtual void drawPath(const QPainterPath & /*path*/) { }
00041         virtual void drawPixmap(const QRectF & /*r*/, const QPixmap & /*pm*/, const QRectF & /*sr*/) { }
00042         virtual void drawPoints(const QPointF * /*points*/, int /*pointCount*/) { }
00043         virtual void drawPoints(const QPoint * /*points*/, int /*pointCount*/) { }
00044         virtual void drawPolygon(const QPointF * /*points*/, int /*pointCount*/, PolygonDrawMode /*mode*/) { }
00045         virtual void drawPolygon(const QPoint * /*points*/, int /*pointCount*/, PolygonDrawMode /*mode*/) { }
00046         virtual void drawRects(const QRectF * /*rects*/, int /*rectCount*/) { }
00047         virtual void drawRects(const QRect * /*rects*/, int /*rectCount*/) { }
00048         virtual void drawTextItem(const QPointF & /*p*/, const QTextItem & /*textItem*/) { }
00049         virtual void drawTiledPixmap(const QRectF & /*rect*/, const QPixmap & /*pixmap*/, const QPointF & /*p*/) { }
00050         virtual bool end()  { return true; }
00051 
00052         virtual Type type() const { return QPaintEngine::User; }
00053         virtual void updateState(const QPaintEngineState & /*state*/) { }
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