diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-10-15 06:26:19 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-10-15 06:49:48 (GMT) |
commit | 8b568a5afd24ecb343b7508bf6b27b27af59b226 (patch) | |
tree | e792a660a9dac1c514ef31b29080e84907671871 /src/gui | |
parent | 1f73b205ec57be6327f62ef39099358425a7f0a8 (diff) | |
download | Qt-8b568a5afd24ecb343b7508bf6b27b27af59b226.zip Qt-8b568a5afd24ecb343b7508bf6b27b27af59b226.tar.gz Qt-8b568a5afd24ecb343b7508bf6b27b27af59b226.tar.bz2 |
qt_paint_device_metric() for fetching metrics
Custom window surfaces, graphics systems, and Qt/Embedded screen
drivers often need to access QPaintDevice::metric(), but it is
protected. Hence the growing number of friends in QWidget and
QImage. The qt_paint_device_metric() function provides a more
future-proof approach that doesn't require lots of friends.
Reviewed-by: Gunnar
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qwidget.h | 3 | ||||
-rw-r--r-- | src/gui/painting/qpaintdevice.cpp | 5 | ||||
-rw-r--r-- | src/gui/painting/qpaintdevice.h | 1 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 9 |
4 files changed, 7 insertions, 11 deletions
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 3501c6e..3cc3093 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -726,14 +726,11 @@ private: friend class QGLContext; friend class QGLWidget; friend class QGLWindowSurface; - friend class QGLWindowSurfaceGLPaintDevice; - friend class QVGWindowSurface; friend class QX11PaintEngine; friend class QWin32PaintEngine; friend class QShortcutPrivate; friend class QShortcutMap; friend class QWindowSurface; - friend class QD3DWindowSurface; friend class QGraphicsProxyWidget; friend class QGraphicsProxyWidgetPrivate; friend class QStyleSheetStyle; diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp index 95c0b44..6114938 100644 --- a/src/gui/painting/qpaintdevice.cpp +++ b/src/gui/painting/qpaintdevice.cpp @@ -65,4 +65,9 @@ int QPaintDevice::metric(PaintDeviceMetric) const return 0; } +Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric) +{ + return device->metric(metric); +} + QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index 92aa3cb..c8e86b8 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -137,6 +137,7 @@ public: friend class QPainter; friend class QFontEngineMac; friend class QX11PaintEngine; + friend Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, PaintDeviceMetric metric); }; #ifdef QT3_SUPPORT diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 6037bd5..240403d 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4213,13 +4213,6 @@ void QRasterBuffer::prepare(QCustomRasterPaintDevice *device) drawHelper = qDrawHelper + format; } -class MetricAccessor : public QWidget { -public: - int metric(PaintDeviceMetric m) { - return QWidget::metric(m); - } -}; - int QCustomRasterPaintDevice::metric(PaintDeviceMetric m) const { switch (m) { @@ -4231,7 +4224,7 @@ int QCustomRasterPaintDevice::metric(PaintDeviceMetric m) const break; } - return (static_cast<MetricAccessor*>(widget)->metric(m)); + return qt_paint_device_metric(widget, m); } int QCustomRasterPaintDevice::bytesPerLine() const |