1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.gui.polygon; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.global; 19 import qt.core.metatype; 20 import qt.core.namespace; 21 import qt.core.point; 22 import qt.core.rect; 23 import qt.core.typeinfo; 24 import qt.core.variant; 25 import qt.core.vector; 26 import qt.helpers; 27 28 /+ class QMatrix; 29 class QTransform; 30 class QRect; 31 class QVariant; +/ 32 33 @(QMetaType.Type.QPolygon) @Q_MOVABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QPolygon 34 { 35 public QVector!(QPoint) base0; 36 alias base0 this; 37 public: 38 @disable this(); 39 /+pragma(inline, true) this() {}+/ 40 pragma(inline, true) ~this() {} 41 /+/+ explicit +/pragma(inline, true) this(int asize) 42 { 43 this.QVector!(QPoint) = asize; 44 } 45 pragma(inline, true) this(ref const(QVector!(QPoint)) v) 46 { 47 this.QVector!(QPoint) = v; 48 }+/ 49 /*implicit*/ /+ QPolygon(QVector<QPoint> &&v) noexcept : QVector<QPoint>(std::move(v)) {} +/ 50 this(ref const(QRect) r, bool closed=false); 51 this(int nPoints, const(int)* points); 52 @disable this(this); 53 this(ref const(QPolygon) other) 54 { 55 this.base0 = *cast(QVector!QPoint*)&other.base0; 56 } 57 /+ QPolygon(QPolygon &&other) noexcept : QVector<QPoint>(std::move(other)) {} +/ 58 /+ QPolygon &operator=(QPolygon &&other) noexcept { swap(other); return *this; } +/ 59 /+ref QPolygon operator =(ref const(QPolygon) other) { QVector!(QPoint).operator=(other); return this; }+/ 60 /+ void swap(QPolygon &other) noexcept { QVector<QPoint>::swap(other); } +/ // prevent QVector<QPoint><->QPolygon swaps 61 62 /+auto opCast(T : QVariant)() const;+/ 63 64 void translate(int dx, int dy); 65 pragma(inline, true) void translate(ref const(QPoint) offset) 66 { translate(offset.x(), offset.y()); } 67 68 /+ Q_REQUIRED_RESULT +/ QPolygon translated(int dx, int dy) const; 69 /+ Q_REQUIRED_RESULT +/ pragma(inline, true) QPolygon translated(ref const(QPoint) offset) const 70 { return translated(offset.x(), offset.y()); } 71 72 QRect boundingRect() const; 73 74 void point(int i, int* x, int* y) const; 75 /+ pragma(inline, true) QPoint point(int index) const 76 { return at(index); } 77 pragma(inline, true) void setPoint(int index, int x, int y) 78 { (this)[index] = QPoint(x, y); } 79 pragma(inline, true) void setPoint(int index, ref const(QPoint) pt) 80 { (this)[index] = pt; } 81 +/ 82 void setPoints(int nPoints, const(int)* points); 83 void setPoints(int nPoints, int firstx, int firsty, ...); 84 void putPoints(int index, int nPoints, const(int)* points); 85 void putPoints(int index, int nPoints, int firstx, int firsty, ...); 86 void putPoints(int index, int nPoints, ref const(QPolygon) from, int fromIndex=0); 87 88 bool containsPoint(ref const(QPoint) pt, /+ Qt:: +/qt.core.namespace.FillRule fillRule) const; 89 90 /+ Q_REQUIRED_RESULT +/ QPolygon united(ref const(QPolygon) r) const; 91 /+ Q_REQUIRED_RESULT +/ QPolygon intersected(ref const(QPolygon) r) const; 92 /+ Q_REQUIRED_RESULT +/ QPolygon subtracted(ref const(QPolygon) r) const; 93 94 bool intersects(ref const(QPolygon) r) const; 95 } 96 /+ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QPolygon) 97 98 #ifndef QT_NO_DEBUG_STREAM 99 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygon &); 100 #endif 101 102 /***************************************************************************** 103 QPolygon stream functions 104 *****************************************************************************/ 105 #ifndef QT_NO_DATASTREAM 106 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygon &polygon); 107 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygon &polygon); 108 #endif 109 110 /***************************************************************************** 111 Misc. QPolygon functions 112 *****************************************************************************/ 113 114 class QRectF; +/ 115 116 @(QMetaType.Type.QPolygonF) extern(C++, class) struct /+ Q_GUI_EXPORT +/ QPolygonF 117 { 118 public QVector!(QPointF) base0; 119 alias base0 this; 120 public: 121 @disable this(); 122 /+pragma(inline, true) this() {}+/ 123 pragma(inline, true) ~this() {} 124 /+/+ explicit +/pragma(inline, true) this(int asize) 125 { 126 this.QVector!(QPointF) = asize; 127 } 128 pragma(inline, true) this(ref const(QVector!(QPointF)) v) 129 { 130 this.QVector!(QPointF) = v; 131 }+/ 132 /* implicit */ /+ QPolygonF(QVector<QPointF> &&v) noexcept : QVector<QPointF>(std::move(v)) {} +/ 133 this(ref const(QRectF) r); 134 /*implicit*/ this(ref const(QPolygon) a); 135 //@disable this(this); 136 /+pragma(inline, true) this(ref const(QPolygonF) a) 137 { 138 this.QVector!(QPointF) = a; 139 }+/ 140 /+ QPolygonF(QPolygonF &&other) noexcept : QVector<QPointF>(std::move(other)) {} +/ 141 /+ QPolygonF &operator=(QPolygonF &&other) noexcept { swap(other); return *this; } +/ 142 /+ref QPolygonF operator =(ref const(QPolygonF) other) { QVector!(QPointF).operator=(other); return this; }+/ 143 /+ inline void swap(QPolygonF &other) { QVector<QPointF>::swap(other); } +/ // prevent QVector<QPointF><->QPolygonF swaps 144 145 /+auto opCast(T : QVariant)() const;+/ 146 147 pragma(inline, true) void translate(qreal dx, qreal dy) 148 { auto tmp = QPointF(dx, dy); translate(tmp); } 149 void translate(ref const(QPointF) offset); 150 151 pragma(inline, true) QPolygonF translated(qreal dx, qreal dy) const 152 { auto tmp = QPointF(dx, dy); return translated(tmp); } 153 /+ Q_REQUIRED_RESULT +/ QPolygonF translated(ref const(QPointF) offset) const; 154 155 QPolygon toPolygon() const; 156 157 bool isClosed() const { return !isEmpty() && first() == last(); } 158 159 QRectF boundingRect() const; 160 161 bool containsPoint(ref const(QPointF) pt, /+ Qt:: +/qt.core.namespace.FillRule fillRule) const; 162 163 /+ Q_REQUIRED_RESULT +/ QPolygonF united(ref const(QPolygonF) r) const; 164 /+ Q_REQUIRED_RESULT +/ QPolygonF intersected(ref const(QPolygonF) r) const; 165 /+ Q_REQUIRED_RESULT +/ QPolygonF subtracted(ref const(QPolygonF) r) const; 166 167 bool intersects(ref const(QPolygonF) r) const; 168 } 169 /+ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QPolygonF) 170 171 #ifndef QT_NO_DEBUG_STREAM 172 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygonF &); 173 #endif 174 175 /***************************************************************************** 176 QPolygonF stream functions 177 *****************************************************************************/ 178 #ifndef QT_NO_DATASTREAM 179 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygonF &array); 180 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygonF &array); 181 #endif +/ 182