1 /* 2 * DQt - D bindings for the Qt Toolkit 3 * 4 * GNU Lesser General Public License Usage 5 * This file may be used under the terms of the GNU Lesser 6 * General Public License version 3 as published by the Free Software 7 * Foundation and appearing in the file LICENSE.LGPL3 included in the 8 * packaging of this file. Please review the following information to 9 * ensure the GNU Lesser General Public License version 3 requirements 10 * will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 11 */ 12 module qt.gui.paintdevice; 13 extern(C++): 14 15 import qt.config; 16 import qt.core.global; 17 import qt.core.point; 18 import qt.gui.paintengine; 19 import qt.gui.painter; 20 import qt.helpers; 21 22 23 interface QPaintDeviceInterface 24 { 25 alias PaintDeviceMetric = QPaintDevice.PaintDeviceMetric; 26 27 // /+ virtual +/~this(); 28 /+ virtual +/ int devType() const; 29 /+ virtual +/ QPaintEngine paintEngine() const /+ = 0 +/; 30 protected: 31 /+ virtual +/ int metric(PaintDeviceMetric metric) const; 32 /+ virtual +/ void initPainter(QPainter * painter) const; 33 /+ virtual +/ QPaintDevice redirected(QPoint * offset) const; 34 /+ virtual +/ QPainter * sharedPainter() const; 35 } 36 37 /// Binding for C++ class [QPaintDevice](https://doc.qt.io/qt-6/qpaintdevice.html). 38 abstract class /+ Q_GUI_EXPORT +/ QPaintDevice//: QPaintDeviceInterface // device for QPainter 39 { 40 public: 41 enum PaintDeviceMetric { 42 PdmWidth = 1, 43 PdmHeight, 44 PdmWidthMM, 45 PdmHeightMM, 46 PdmNumColors, 47 PdmDepth, 48 PdmDpiX, 49 PdmDpiY, 50 PdmPhysicalDpiX, 51 PdmPhysicalDpiY, 52 PdmDevicePixelRatio, 53 PdmDevicePixelRatioScaled 54 } 55 56 /+ virtual +/~this(); 57 58 /+ virtual +/ pragma(inline, true) int devType() const 59 { 60 import qt.core.namespace; 61 return QInternal.PaintDeviceFlags.UnknownDevice; 62 } 63 pragma(inline, true) final bool paintingActive() const 64 { return painters != 0; } 65 /+ virtual +/ abstract QPaintEngine paintEngine() const; 66 67 final int width() const { return metric(PaintDeviceMetric.PdmWidth); } 68 final int height() const { return metric(PaintDeviceMetric.PdmHeight); } 69 final int widthMM() const { return metric(PaintDeviceMetric.PdmWidthMM); } 70 final int heightMM() const { return metric(PaintDeviceMetric.PdmHeightMM); } 71 final int logicalDpiX() const { return metric(PaintDeviceMetric.PdmDpiX); } 72 final int logicalDpiY() const { return metric(PaintDeviceMetric.PdmDpiY); } 73 final int physicalDpiX() const { return metric(PaintDeviceMetric.PdmPhysicalDpiX); } 74 final int physicalDpiY() const { return metric(PaintDeviceMetric.PdmPhysicalDpiY); } 75 final qreal devicePixelRatio() const { return metric(PaintDeviceMetric.PdmDevicePixelRatioScaled) / devicePixelRatioFScale(); } 76 final qreal devicePixelRatioF() const { return devicePixelRatio(); } 77 final int colorCount() const { return metric(PaintDeviceMetric.PdmNumColors); } 78 final int depth() const { return metric(PaintDeviceMetric.PdmDepth); } 79 80 pragma(inline, true) static qreal devicePixelRatioFScale() { return 0x10000; } 81 protected: 82 mixin(changeItaniumMangling(q{mangleConstructorBaseObject}, q{ 83 this()/+ noexcept+/; 84 })); 85 /+ virtual +/ int metric(PaintDeviceMetric metric) const; 86 /+ virtual +/ void initPainter(QPainter* painter) const; 87 /+ virtual +/ QPaintDevice redirected(QPoint* offset) const; 88 /+ virtual +/ QPainter* sharedPainter() const; 89 90 ushort painters; // refcount 91 private: 92 /+ Q_DISABLE_COPY(QPaintDevice) +/ 93 94 /+ friend class QPainter; +/ 95 /+ friend class QPainterPrivate; +/ 96 /+ friend class QFontEngineMac; +/ 97 /+ friend class QX11PaintEngine; +/ 98 /+ friend Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, PaintDeviceMetric metric); +/ 99 mixin(CREATE_CONVENIENCE_WRAPPERS); 100 } 101 102 /***************************************************************************** 103 Inline functions 104 *****************************************************************************/ 105 106 static assert(__traits(classInstanceSize, QPaintDevice) == (void*).sizeof + ushort.sizeof); 107 struct QPaintDeviceFakeInheritance 108 { 109 ushort painters; 110 }