From 025a7395153c3708e2964cfd93957532b19ae04f Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 17 Aug 2009 13:15:08 +0200 Subject: QPaintDevice implemented in qpaintdevice.cpp. Saves duplicated code Reviewed-by: Eskil --- src/gui/painting/painting.pri | 5 +-- src/gui/painting/qpaintdevice.cpp | 66 +++++++++++++++++++++++++++++++++++ src/gui/painting/qpaintdevice_mac.cpp | 28 --------------- src/gui/painting/qpaintdevice_win.cpp | 21 ----------- src/gui/painting/qpaintdevice_x11.cpp | 21 ----------- 5 files changed, 69 insertions(+), 72 deletions(-) create mode 100644 src/gui/painting/qpaintdevice.cpp diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index adb73aa..b9d293c 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -46,7 +46,7 @@ HEADERS += \ SOURCES += \ painting/qbezier.cpp \ - painting/qblendfunctions.cpp \ + painting/qblendfunctions.cpp \ painting/qbrush.cpp \ painting/qcolor.cpp \ painting/qcolor_p.cpp \ @@ -57,6 +57,7 @@ SOURCES += \ painting/qmatrix.cpp \ painting/qmemrotate.cpp \ painting/qoutlinemapper.cpp \ + painting/qpaintdevice.cpp \ painting/qpaintengine.cpp \ painting/qpaintengine_alpha.cpp \ painting/qpaintengine_preview.cpp \ @@ -75,9 +76,9 @@ SOURCES += \ painting/qstroker.cpp \ painting/qstylepainter.cpp \ painting/qtessellator.cpp \ - painting/qwindowsurface.cpp \ painting/qtextureglyphcache.cpp \ painting/qtransform.cpp \ + painting/qwindowsurface.cpp \ DEFINES += QT_RASTER_IMAGEENGINE win32:DEFINES += QT_RASTER_PAINTENGINE diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp new file mode 100644 index 0000000..6477952 --- /dev/null +++ b/src/gui/painting/qpaintdevice.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qpaintdevice.h" + +QT_BEGIN_NAMESPACE + +extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp + +QPaintDevice::QPaintDevice() +{ + painters = 0; +} + +QPaintDevice::~QPaintDevice() +{ + if (paintingActive()) + qWarning("QPaintDevice: Cannot destroy paint device that is being " + "painted"); + qt_painter_removePaintDevice(this); +} + + +int QPaintDevice::metric(PaintDeviceMetric) const +{ + qWarning("QPaintDevice::metrics: Device has no metric information"); + return 0; +} diff --git a/src/gui/painting/qpaintdevice_mac.cpp b/src/gui/painting/qpaintdevice_mac.cpp index bf5e261..aa7c2ac 100644 --- a/src/gui/painting/qpaintdevice_mac.cpp +++ b/src/gui/painting/qpaintdevice_mac.cpp @@ -57,34 +57,6 @@ QT_BEGIN_NAMESPACE Internal variables and functions *****************************************************************************/ - -/***************************************************************************** - External functions - *****************************************************************************/ - -extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp - -/***************************************************************************** - QPaintDevice member functions - *****************************************************************************/ -QPaintDevice::QPaintDevice() -{ - painters = 0; -} - -QPaintDevice::~QPaintDevice() -{ - if(paintingActive()) - qWarning("QPaintDevice: Cannot destroy paint device that is being " - "painted, be sure to QPainter::end() painters"); - qt_painter_removePaintDevice(this); -} - -int QPaintDevice::metric(PaintDeviceMetric) const -{ - return 0; -} - /*! \internal */ float qt_mac_defaultDpi_x() { diff --git a/src/gui/painting/qpaintdevice_win.cpp b/src/gui/painting/qpaintdevice_win.cpp index 86de028..f964feb 100644 --- a/src/gui/painting/qpaintdevice_win.cpp +++ b/src/gui/painting/qpaintdevice_win.cpp @@ -50,27 +50,6 @@ QT_BEGIN_NAMESPACE -QPaintDevice::QPaintDevice() -{ - painters = 0; -} - -extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp - -QPaintDevice::~QPaintDevice() -{ - if (paintingActive()) - qWarning("QPaintDevice: Cannot destroy paint device that is being " - "painted. Be sure to QPainter::end() painters!"); - qt_painter_removePaintDevice(this); -} - -int QPaintDevice::metric(PaintDeviceMetric) const -{ - qWarning("QPaintDevice::metrics: Device has no metric information"); - return 0; -} - HDC QPaintDevice::getDC() const { return 0; diff --git a/src/gui/painting/qpaintdevice_x11.cpp b/src/gui/painting/qpaintdevice_x11.cpp index b0ed732..474f3f1 100644 --- a/src/gui/painting/qpaintdevice_x11.cpp +++ b/src/gui/painting/qpaintdevice_x11.cpp @@ -49,21 +49,6 @@ QT_BEGIN_NAMESPACE -QPaintDevice::QPaintDevice() -{ - painters = 0; -} - -extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp - -QPaintDevice::~QPaintDevice() -{ - if (paintingActive()) - qWarning("QPaintDevice: Cannot destroy paint device that is being " - "painted"); - qt_painter_removePaintDevice(this); -} - /*! \internal Returns the X11 Drawable of the paint device. 0 is returned if it @@ -96,12 +81,6 @@ const Q_GUI_EXPORT QX11Info *qt_x11Info(const QPaintDevice *pd) return 0; } -int QPaintDevice::metric(PaintDeviceMetric) const -{ - qWarning("QPaintDevice::metrics: Device has no metric information"); - return 0; -} - #ifdef QT3_SUPPORT -- cgit v0.12