File indexing completed on 2025-01-18 10:08:14
0001
0002
0003
0004 #ifndef QPAINTDEVICE_H
0005 #define QPAINTDEVICE_H
0006
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtGui/qwindowdefs.h>
0009 #include <QtCore/qrect.h>
0010
0011 QT_BEGIN_NAMESPACE
0012
0013
0014
0015 class QPaintEngine;
0016
0017 class Q_GUI_EXPORT QPaintDevice
0018 {
0019 public:
0020 enum PaintDeviceMetric {
0021 PdmWidth = 1,
0022 PdmHeight,
0023 PdmWidthMM,
0024 PdmHeightMM,
0025 PdmNumColors,
0026 PdmDepth,
0027 PdmDpiX,
0028 PdmDpiY,
0029 PdmPhysicalDpiX,
0030 PdmPhysicalDpiY,
0031 PdmDevicePixelRatio,
0032 PdmDevicePixelRatioScaled
0033 };
0034
0035 virtual ~QPaintDevice();
0036
0037 virtual int devType() const;
0038 bool paintingActive() const;
0039 virtual QPaintEngine *paintEngine() const = 0;
0040
0041 int width() const { return metric(PdmWidth); }
0042 int height() const { return metric(PdmHeight); }
0043 int widthMM() const { return metric(PdmWidthMM); }
0044 int heightMM() const { return metric(PdmHeightMM); }
0045 int logicalDpiX() const { return metric(PdmDpiX); }
0046 int logicalDpiY() const { return metric(PdmDpiY); }
0047 int physicalDpiX() const { return metric(PdmPhysicalDpiX); }
0048 int physicalDpiY() const { return metric(PdmPhysicalDpiY); }
0049 qreal devicePixelRatio() const { return metric(PdmDevicePixelRatioScaled) / devicePixelRatioFScale(); }
0050 qreal devicePixelRatioF() const { return devicePixelRatio(); }
0051 int colorCount() const { return metric(PdmNumColors); }
0052 int depth() const { return metric(PdmDepth); }
0053
0054 static inline qreal devicePixelRatioFScale() { return 0x10000; }
0055 protected:
0056 QPaintDevice() noexcept;
0057 virtual int metric(PaintDeviceMetric metric) const;
0058 virtual void initPainter(QPainter *painter) const;
0059 virtual QPaintDevice *redirected(QPoint *offset) const;
0060 virtual QPainter *sharedPainter() const;
0061
0062 ushort painters;
0063 private:
0064 Q_DISABLE_COPY(QPaintDevice)
0065
0066 friend class QPainter;
0067 friend class QPainterPrivate;
0068 friend class QFontEngineMac;
0069 friend class QX11PaintEngine;
0070 friend Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, PaintDeviceMetric metric);
0071 };
0072
0073
0074
0075
0076
0077 inline int QPaintDevice::devType() const
0078 { return QInternal::UnknownDevice; }
0079
0080 inline bool QPaintDevice::paintingActive() const
0081 { return painters != 0; }
0082
0083 QT_END_NAMESPACE
0084
0085 #endif