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.painterpath;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.global;
19 import qt.core.list;
20 import qt.core.namespace;
21 import qt.core.point;
22 import qt.core.rect;
23 import qt.core.scopedpointer;
24 import qt.core.string;
25 import qt.core.vector;
26 import qt.gui.font;
27 import qt.gui.matrix;
28 import qt.gui.pen;
29 import qt.gui.polygon;
30 import qt.gui.region;
31 import qt.gui.transform;
32 import qt.helpers;
33 
34 /+ class QFont; +/
35 extern(C++, class) struct QPainterPathPrivate;
36 struct QPainterPathPrivateDeleter;
37 extern(C++, class) struct QPainterPathData;
38 extern(C++, class) struct QPainterPathStrokerPrivate;
39 /+ class QPen;
40 class QPolygonF;
41 class QRegion; +/
42 extern(C++, class) struct QVectorPath;
43 
44 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QPainterPath
45 {
46 public:
47     enum ElementType {
48         MoveToElement,
49         LineToElement,
50         CurveToElement,
51         CurveToDataElement
52     }
53 
54     extern(C++, class) struct Element {
55     public:
56         qreal x;
57         qreal y;
58         ElementType type;
59 
60         bool isMoveTo() const { return type == ElementType.MoveToElement; }
61         bool isLineTo() const { return type == ElementType.LineToElement; }
62         bool isCurveTo() const { return type == ElementType.CurveToElement; }
63 
64         /+auto opCast(T : QPointF) () const { return QPointF(x, y); }+/
65 
66         /+bool operator ==(ref const(Element) e) const { return qt.core.global.qFuzzyCompare(x, e.x)
67             && qt.core.global.qFuzzyCompare(y, e.y) && type == e.type; }+/
68         /+pragma(inline, true) bool operator !=(ref const(Element) e) const { return !operator==(e); }+/
69     }
70 
71     @disable this();
72     pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this))))
73     ref typeof(this) rawConstructor()/+ noexcept+/;
74     static typeof(this) create()
75     {
76         typeof(this) r = typeof(this).init;
77         r.rawConstructor();
78         return r;
79     }
80 
81     /+ explicit +/this(ref const(QPointF) startPoint);
82     @disable this(this);
83     this(ref const(QPainterPath) other);
84     /+ref QPainterPath operator =(ref const(QPainterPath) other);+/
85     /+ inline QPainterPath &operator=(QPainterPath &&other) noexcept
86     { qSwap(d_ptr, other.d_ptr); return *this; } +/
87     ~this();
88 
89     /+ inline void swap(QPainterPath &other) noexcept { d_ptr.swap(other.d_ptr); } +/
90 
91     void clear();
92     void reserve(int size);
93     int capacity() const;
94 
95     void closeSubpath();
96 
97     void moveTo(ref const(QPointF) p);
98     pragma(inline, true) void moveTo(qreal x, qreal y)
99     {
100         auto tmp = QPointF(x, y); moveTo(tmp);
101     }
102 
103     void lineTo(ref const(QPointF) p);
104     pragma(inline, true) void lineTo(qreal x, qreal y)
105     {
106         auto tmp = QPointF(x, y); lineTo(tmp);
107     }
108 
109     void arcMoveTo(ref const(QRectF) rect, qreal angle);
110     pragma(inline, true) void arcMoveTo(qreal x, qreal y, qreal w, qreal h, qreal angle)
111     {
112         auto tmp = QRectF(x, y, w, h); arcMoveTo(tmp, angle);
113     }
114 
115     void arcTo(ref const(QRectF) rect, qreal startAngle, qreal arcLength);
116     pragma(inline, true) void arcTo(qreal x, qreal y, qreal w, qreal h, qreal startAngle, qreal arcLength)
117     {
118         auto tmp = QRectF(x, y, w, h); arcTo(tmp, startAngle, arcLength);
119     }
120 
121     void cubicTo(ref const(QPointF) ctrlPt1, ref const(QPointF) ctrlPt2, ref const(QPointF) endPt);
122     pragma(inline, true) void cubicTo(qreal ctrlPt1x, qreal ctrlPt1y, qreal ctrlPt2x, qreal ctrlPt2y,
123                             qreal endPtx, qreal endPty)
124     {
125         auto tmp = QPointF(ctrlPt1x, ctrlPt1y); auto tmp__1 = QPointF(ctrlPt2x, ctrlPt2y); auto tmp__2 = QPointF(endPtx, endPty); cubicTo(tmp, tmp__1,
126                 tmp__2);
127     }
128     void quadTo(ref const(QPointF) ctrlPt, ref const(QPointF) endPt);
129     pragma(inline, true) void quadTo(qreal ctrlPtx, qreal ctrlPty, qreal endPtx, qreal endPty)
130     {
131         auto tmp = QPointF(ctrlPtx, ctrlPty); auto tmp__1 = QPointF(endPtx, endPty); quadTo(tmp, tmp__1);
132     }
133 
134     QPointF currentPosition() const;
135 
136     void addRect(ref const(QRectF) rect);
137     pragma(inline, true) void addRect(qreal x, qreal y, qreal w, qreal h)
138     {
139         auto tmp = QRectF(x, y, w, h); addRect(tmp);
140     }
141     void addEllipse(ref const(QRectF) rect);
142 /+    pragma(inline, true) void addEllipse(qreal x, qreal y, qreal w, qreal h)
143     {
144         auto tmp = QRectF(x, y, w, h); addEllipse(tmp);
145     }
146     pragma(inline, true) void addEllipse(ref const(QPointF) center, qreal rx, qreal ry)
147     {
148         auto tmp = QRectF(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry); addEllipse(tmp);
149     }+/
150     void addPolygon(ref const(QPolygonF) polygon);
151     void addText(ref const(QPointF) point, ref const(QFont) f, ref const(QString) text);
152     pragma(inline, true) void addText(qreal x, qreal y, ref const(QFont) f, ref const(QString) text)
153     {
154         auto tmp = QPointF(x, y); addText(tmp, f, text);
155     }
156     void addPath(ref const(QPainterPath) path);
157     void addRegion(ref const(QRegion) region);
158 
159     void addRoundedRect(ref const(QRectF) rect, qreal xRadius, qreal yRadius,
160                             /+ Qt:: +/qt.core.namespace.SizeMode mode = /+ Qt:: +/qt.core.namespace.SizeMode.AbsoluteSize);
161     pragma(inline, true) void addRoundedRect(qreal x, qreal y, qreal w, qreal h,
162                                    qreal xRadius, qreal yRadius,
163                                    /+ Qt:: +/qt.core.namespace.SizeMode mode = /+ Qt:: +/qt.core.namespace.SizeMode.AbsoluteSize)
164     {
165         auto tmp = QRectF(x, y, w, h); addRoundedRect(tmp, xRadius, yRadius, mode);
166     }
167 
168 /+ #if QT_DEPRECATED_SINCE(5, 13) +/
169     /+ QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead") +/
170         void addRoundRect(ref const(QRectF) rect, int xRnd, int yRnd);
171     /+ QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead") +/
172         void addRoundRect(qreal x, qreal y, qreal w, qreal h,
173                           int xRnd, int yRnd);
174     /+ QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead") +/
175         void addRoundRect(ref const(QRectF) rect, int roundness);
176     /+ QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead") +/
177         void addRoundRect(qreal x, qreal y, qreal w, qreal h,
178                           int roundness);
179 /+ #endif +/
180 
181     void connectPath(ref const(QPainterPath) path);
182 
183     bool contains(ref const(QPointF) pt) const;
184     bool contains(ref const(QRectF) rect) const;
185     bool intersects(ref const(QRectF) rect) const;
186 
187     void translate(qreal dx, qreal dy);
188     pragma(inline, true) void translate(ref const(QPointF) offset)
189     { translate(offset.x(), offset.y()); }
190 
191     /+ Q_REQUIRED_RESULT +/ QPainterPath translated(qreal dx, qreal dy) const;
192     /+ Q_REQUIRED_RESULT +/ pragma(inline, true) QPainterPath translated(ref const(QPointF) offset) const
193     { return translated(offset.x(), offset.y()); }
194 
195     QRectF boundingRect() const;
196     QRectF controlPointRect() const;
197 
198     /+ Qt:: +/qt.core.namespace.FillRule fillRule() const;
199     void setFillRule(/+ Qt:: +/qt.core.namespace.FillRule fillRule);
200 
201     bool isEmpty() const;
202 
203     /+ Q_REQUIRED_RESULT +/ QPainterPath toReversed() const;
204 
205 /+ #if QT_DEPRECATED_SINCE(5, 15) +/
206     /+ QT_DEPRECATED_X("Use toSubpathPolygons(const QTransform &)") +/
207         QList!(QPolygonF) toSubpathPolygons(ref const(QMatrix) matrix) const;
208     /+ QT_DEPRECATED_X("Use toFillPolygons(const QTransform &") +/
209         QList!(QPolygonF) toFillPolygons(ref const(QMatrix) matrix) const;
210     /+ QT_DEPRECATED_X("Use toFillPolygon(const QTransform &)") +/
211         QPolygonF toFillPolygon(ref const(QMatrix) matrix) const;
212 /+ #endif +/ // QT_DEPRECATED_SINCE(5, 15)
213     QList!(QPolygonF) toSubpathPolygons(ref const(QTransform) matrix = globalInitVar!QTransform) const;
214     QList!(QPolygonF) toFillPolygons(ref const(QTransform) matrix = globalInitVar!QTransform) const;
215     QPolygonF toFillPolygon(ref const(QTransform) matrix = globalInitVar!QTransform) const;
216 
217     int elementCount() const;
218     QPainterPath.Element elementAt(int i) const;
219     void setElementPositionAt(int i, qreal x, qreal y);
220 
221     qreal   length() const;
222     qreal   percentAtLength(qreal t) const;
223     QPointF pointAtPercent(qreal t) const;
224     qreal   angleAtPercent(qreal t) const;
225     qreal   slopeAtPercent(qreal t) const;
226 
227     bool intersects(ref const(QPainterPath) p) const;
228     bool contains(ref const(QPainterPath) p) const;
229     /+ Q_REQUIRED_RESULT +/ QPainterPath united(ref const(QPainterPath) r) const;
230     /+ Q_REQUIRED_RESULT +/ QPainterPath intersected(ref const(QPainterPath) r) const;
231     /+ Q_REQUIRED_RESULT +/ QPainterPath subtracted(ref const(QPainterPath) r) const;
232 /+ #if QT_DEPRECATED_SINCE(5, 13) +/
233     /+ QT_DEPRECATED_X("Use r.subtracted() instead") +/
234         /+ Q_REQUIRED_RESULT +/ QPainterPath subtractedInverted(ref const(QPainterPath) r) const;
235 /+ #endif +/
236 
237     /+ Q_REQUIRED_RESULT +/ QPainterPath simplified() const;
238 
239     /+bool operator ==(ref const(QPainterPath) other) const;+/
240     /+bool operator !=(ref const(QPainterPath) other) const;+/
241 
242     QPainterPath opBinary(string op)(ref const(QPainterPath) other) const if(op == "&");
243     QPainterPath opBinary(string op)(ref const(QPainterPath) other) const if(op == "|");
244     QPainterPath opBinary(string op)(ref const(QPainterPath) other) const if(op == "+");
245     QPainterPath opBinary(string op)(ref const(QPainterPath) other) const if(op == "-");
246     ref QPainterPath opOpAssign(string op)(ref const(QPainterPath) other) if(op == "&");
247     ref QPainterPath opOpAssign(string op)(ref const(QPainterPath) other) if(op == "|");
248     ref QPainterPath opOpAssign(string op)(ref const(QPainterPath) other) if(op == "+");
249     ref QPainterPath opOpAssign(string op)(ref const(QPainterPath) other) if(op == "-");
250 
251 private:
252     QScopedPointer!(QPainterPathPrivate, QPainterPathPrivateDeleter) d_ptr;
253 
254 //    pragma(inline, true) void ensureData() { if (!d_ptr) ensureData_helper(); }
255     void ensureData_helper();
256     void detach();
257     void detach_helper();
258     void setDirty(bool);
259     void computeBoundingRect() const;
260     void computeControlPointRect() const;
261 
262     /+ QPainterPathData *d_func() const { return reinterpret_cast<QPainterPathData *>(d_ptr.data()); } +/
263 
264     /+ friend class QPainterPathData; +/
265     /+ friend class QPainterPathStroker; +/
266     /+ friend class QPainterPathStrokerPrivate; +/
267     /+ friend class QMatrix; +/
268     /+ friend class QTransform; +/
269     /+ friend class QVectorPath; +/
270     /+ friend Q_GUI_EXPORT const QVectorPath &qtVectorPathForPath(const QPainterPath &); +/
271 
272     version(QT_NO_DATASTREAM){}else
273     {
274         /+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &); +/
275         /+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &); +/
276     }
277 }
278 
279 /+ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QPainterPath)
280 Q_DECLARE_TYPEINFO(QPainterPath::Element, Q_PRIMITIVE_TYPE);
281 
282 #ifndef QT_NO_DATASTREAM
283 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &);
284 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
285 #endif +/
286 
287 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QPainterPathStroker
288 {
289 private:
290     /+ Q_DECLARE_PRIVATE(QPainterPathStroker) +/
291 public:
292     @disable this();
293     pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this))))
294     ref typeof(this) rawConstructor();
295     static typeof(this) create()
296     {
297         typeof(this) r = typeof(this).init;
298         r.rawConstructor();
299         return r;
300     }
301 
302     /+ explicit +/this(ref const(QPen) pen);
303     ~this();
304 
305     void setWidth(qreal width);
306     qreal width() const;
307 
308     void setCapStyle(/+ Qt:: +/qt.core.namespace.PenCapStyle style);
309     /+ Qt:: +/qt.core.namespace.PenCapStyle capStyle() const;
310 
311     void setJoinStyle(/+ Qt:: +/qt.core.namespace.PenJoinStyle style);
312     /+ Qt:: +/qt.core.namespace.PenJoinStyle joinStyle() const;
313 
314     void setMiterLimit(qreal length);
315     qreal miterLimit() const;
316 
317     void setCurveThreshold(qreal threshold);
318     qreal curveThreshold() const;
319 
320     void setDashPattern(/+ Qt:: +/qt.core.namespace.PenStyle);
321     void setDashPattern(ref const(QVector!(qreal)) dashPattern);
322     QVector!(qreal) dashPattern() const;
323 
324     void setDashOffset(qreal offset);
325     qreal dashOffset() const;
326 
327     QPainterPath createStroke(ref const(QPainterPath) path) const;
328 
329 private:
330     /+ Q_DISABLE_COPY(QPainterPathStroker) +/
331 @disable this(this);
332 /+this(ref const(QPainterPathStroker));+//+ref QPainterPathStroker operator =(ref const(QPainterPathStroker));+/
333     /+ friend class QX11PaintEngine; +/
334 
335     QScopedPointer!(QPainterPathStrokerPrivate) d_ptr;
336 }
337 
338 /+pragma(inline, true) QPainterPath operator *(ref const(QPainterPath) p, ref const(QTransform) m)
339 { return m.map(p); }+/
340 
341 /+ #ifndef QT_NO_DEBUG_STREAM
342 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPainterPath &);
343 #endif +/
344