311
|
1 module qt.core.QRectF;
|
|
2
|
|
3 public import qt.QGlobal;
|
|
4 public import qt.core.Qt;
|
|
5 public import qt.core.QPointF;
|
|
6 public import qt.core.QRect;
|
|
7 public import qt.core.QSizeF;
|
|
8 public import qt.core.QDataStream;
|
|
9
|
|
10
|
|
11 public struct QRectF
|
|
12 {
|
|
13 public static QRectF opCall()
|
|
14 {
|
|
15 QRectF rt;
|
|
16 rt.xp = rt.yp = 0.;
|
|
17 rt.w = rt.h = 0.;
|
|
18 return rt;
|
|
19 }
|
|
20
|
|
21 public this(qreal aleft, qreal atop, qreal awidth, qreal aheight)
|
|
22 {
|
|
23 xp = aleft;
|
|
24 yp = atop;
|
|
25 w = awidth;
|
|
26 h = aheight;
|
|
27 }
|
|
28
|
|
29 public this(QPointF atopLeft, QSizeF asize)
|
|
30 {
|
|
31 xp = atopLeft.x();
|
|
32 yp = atopLeft.y();
|
|
33 w = asize.width();
|
|
34 h = asize.height();
|
|
35 }
|
|
36
|
|
37 public this(QPointF atopLeft, QPointF abottomRight)
|
|
38 {
|
|
39 xp = atopLeft.x();
|
|
40 yp = atopLeft.y();
|
|
41 w = abottomRight.x() - xp;
|
|
42 h = abottomRight.y() - yp;
|
|
43 }
|
|
44
|
|
45 public this(QRect r)
|
|
46 {
|
|
47 xp = r.x();
|
|
48 yp = r.y();
|
|
49 w = r.width();
|
|
50 h = r.height();
|
|
51 }
|
|
52
|
|
53 bool isNull() const
|
|
54 { return qIsNull(w) && qIsNull(h); }
|
|
55
|
|
56 bool isEmpty() const
|
|
57 { return w <= 0. || h <= 0.; }
|
|
58
|
|
59 bool isValid() const
|
|
60 { return w > 0. && h > 0.; }
|
|
61
|
|
62 qreal x() const
|
|
63 { return xp; }
|
|
64
|
|
65 qreal y() const
|
|
66 { return yp; }
|
|
67
|
|
68 qreal left() const
|
|
69 { return xp; }
|
|
70
|
|
71 qreal top() const
|
|
72 { return yp; }
|
|
73
|
|
74 qreal right() const
|
|
75 { return xp + w; }
|
|
76
|
|
77 qreal bottom() const
|
|
78 { return yp + h; }
|
|
79
|
|
80 QPointF topLeft() const
|
|
81 { return QPointF(xp, yp); }
|
|
82
|
|
83 QPointF bottomRight() const
|
|
84 { return QPointF(xp+w, yp+h); }
|
|
85
|
|
86 QPointF topRight() const
|
|
87 { return QPointF(xp+w, yp); }
|
|
88
|
|
89 QPointF bottomLeft() const
|
|
90 { return QPointF(xp, yp+h); }
|
|
91
|
|
92 void setLeft(qreal pos) { qreal diff = pos - xp; xp += diff; w -= diff; }
|
|
93
|
|
94 void setRight(qreal pos) { w = pos - xp; }
|
|
95
|
|
96 void setTop(qreal pos) { qreal diff = pos - yp; yp += diff; h -= diff; }
|
|
97
|
|
98 void setBottom(qreal pos) { h = pos - yp; }
|
|
99
|
|
100 void setTopLeft(ref QPointF p) { setLeft(p.x()); setTop(p.y()); }
|
|
101
|
|
102 void setTopRight(ref QPointF p) { setRight(p.x()); setTop(p.y()); }
|
|
103
|
|
104 void setBottomLeft(ref QPointF p) { setLeft(p.x()); setBottom(p.y()); }
|
|
105
|
|
106 void setBottomRight(ref QPointF p) { setRight(p.x()); setBottom(p.y()); }
|
|
107
|
|
108 QPointF center() const
|
|
109 { return QPointF(xp + w/2, yp + h/2); }
|
|
110
|
|
111 void moveLeft(qreal pos) { xp = pos; }
|
|
112
|
|
113 void moveTop(qreal pos) { yp = pos; }
|
|
114
|
|
115 void moveRight(qreal pos) { xp = pos - w; }
|
|
116
|
|
117 void moveBottom(qreal pos) { yp = pos - h; }
|
|
118
|
|
119 void moveTopLeft(ref QPointF p) { moveLeft(p.x()); moveTop(p.y()); }
|
|
120
|
|
121 void moveTopRight(ref QPointF p) { moveRight(p.x()); moveTop(p.y()); }
|
|
122
|
|
123 void moveBottomLeft(ref QPointF p) { moveLeft(p.x()); moveBottom(p.y()); }
|
|
124
|
|
125 void moveBottomRight(ref QPointF p) { moveRight(p.x()); moveBottom(p.y()); }
|
|
126
|
|
127 void moveCenter(ref QPointF p) { xp = p.x() - w/2; yp = p.y() - h/2; }
|
|
128
|
|
129 qreal width() const
|
|
130 { return w; }
|
|
131
|
|
132 qreal height() const
|
|
133 { return h; }
|
|
134
|
|
135 QSizeF size() const
|
|
136 { return QSizeF(w, h); }
|
|
137
|
|
138 void translate(qreal dx, qreal dy)
|
|
139 {
|
|
140 xp += dx;
|
|
141 yp += dy;
|
|
142 }
|
|
143
|
|
144 void translate(ref QPointF p)
|
|
145 {
|
|
146 xp += p.x();
|
|
147 yp += p.y();
|
|
148 }
|
|
149
|
|
150 void moveTo(qreal ax, qreal ay)
|
|
151 {
|
|
152 xp = ax;
|
|
153 yp = ay;
|
|
154 }
|
|
155
|
|
156 void moveTo(ref QPointF p)
|
|
157 {
|
|
158 xp = p.x();
|
|
159 yp = p.y();
|
|
160 }
|
|
161
|
|
162 QRectF translated(qreal dx, qreal dy) const
|
|
163 { return QRectF(xp + dx, yp + dy, w, h); }
|
|
164
|
|
165 QRectF translated(ref QPointF p) const
|
|
166 { return QRectF(xp + p.x(), yp + p.y(), w, h); }
|
|
167
|
|
168 void getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) const
|
|
169 {
|
|
170 *ax = this.xp;
|
|
171 *ay = this.yp;
|
|
172 *aaw = this.w;
|
|
173 *aah = this.h;
|
|
174 }
|
|
175
|
|
176 void setRect(qreal ax, qreal ay, qreal aaw, qreal aah)
|
|
177 {
|
|
178 this.xp = ax;
|
|
179 this.yp = ay;
|
|
180 this.w = aaw;
|
|
181 this.h = aah;
|
|
182 }
|
|
183
|
|
184 void getCoords(qreal *xp1, qreal *yp1, qreal *xp2, qreal *yp2) const
|
|
185 {
|
|
186 *xp1 = xp;
|
|
187 *yp1 = yp;
|
|
188 *xp2 = xp + w;
|
|
189 *yp2 = yp + h;
|
|
190 }
|
|
191
|
|
192 void setCoords(qreal xp1, qreal yp1, qreal xp2, qreal yp2)
|
|
193 {
|
|
194 xp = xp1;
|
|
195 yp = yp1;
|
|
196 w = xp2 - xp1;
|
|
197 h = yp2 - yp1;
|
|
198 }
|
|
199
|
|
200 void adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2)
|
|
201 { xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; }
|
|
202
|
|
203 QRectF adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const
|
|
204 { return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); }
|
|
205
|
|
206 void setWidth(qreal aw) // for convenience
|
|
207 { this.w = aw; }
|
|
208
|
|
209 void setHeight(qreal ah) // for convenience
|
|
210 { this.h = ah; }
|
|
211
|
|
212 void setSize(ref QSizeF s) // for convenience
|
|
213 {
|
|
214 w = s.width();
|
|
215 h = s.height();
|
|
216 }
|
|
217
|
|
218 void width(qreal aw)
|
|
219 { this.w = aw; }
|
|
220
|
|
221 void height(qreal ah)
|
|
222 { this.h = ah; }
|
|
223
|
|
224 void size(ref QSizeF s)
|
|
225 {
|
|
226 w = s.width();
|
|
227 h = s.height();
|
|
228 }
|
|
229
|
|
230 bool contains(qreal ax, qreal ay) const
|
|
231 {
|
|
232 return contains(QPointF(ax, ay));
|
|
233 }
|
|
234
|
|
235 QRectF opOrAssign(ref QRectF r)
|
|
236 {
|
|
237 this = this | r;
|
|
238 return this;
|
|
239 }
|
|
240
|
|
241 QRectF opAndAssign(ref QRectF r)
|
|
242 {
|
|
243 this = this & r;
|
|
244 return this;
|
|
245 }
|
|
246
|
|
247 QRectF intersected(ref QRectF r) const
|
|
248 {
|
|
249 return this & r;
|
|
250 }
|
|
251
|
|
252 QRectF united(ref QRectF r) const
|
|
253 {
|
|
254 return this | r;
|
|
255 }
|
|
256
|
|
257 bool opEquals(ref QRectF r)
|
|
258 {
|
|
259 return qFuzzyCompare(xp, r.xp) && qFuzzyCompare(yp, r.yp)
|
|
260 && qFuzzyCompare(w, r.w) && qFuzzyCompare(h, r.h);
|
|
261 }
|
|
262
|
|
263 QRect toRect() const
|
|
264 {
|
|
265 return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h));
|
|
266 }
|
|
267
|
|
268 public final bool contains(QPointF p) const {
|
|
269 return qtd_QRectF_contains_QPointF(cast(void*)&this, &p);
|
|
270 }
|
|
271
|
|
272 public final bool contains(QRectF r) const {
|
|
273 return qtd_QRectF_contains_QRectF(cast(void*)&this, &r);
|
|
274 }
|
|
275
|
|
276 public final bool intersects(QRectF r) const {
|
|
277 return qtd_QRectF_intersects_QRectF(cast(void*)&this, &r);
|
|
278 }
|
|
279
|
|
280 public final QRectF normalized() const {
|
|
281 return qtd_QRectF_normalized(cast(void*)&this);
|
|
282 }
|
|
283
|
|
284 public final QRectF opAnd(ref QRectF r) const {
|
|
285 return qtd_QRectF_operator_and_QRectF(cast(void*)&this, &r);
|
|
286 }
|
|
287
|
|
288 public final void writeTo(QDataStream arg__1) {
|
|
289 qtd_QRectF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
|
|
290 }
|
|
291
|
|
292 public final void readFrom(QDataStream arg__1) {
|
|
293 qtd_QRectF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId);
|
|
294 }
|
|
295
|
|
296 public final QRectF opOr(ref QRectF r) const {
|
|
297 return qtd_QRectF_operator_or_QRectF(cast(void*)&this, &r);
|
|
298 }
|
|
299
|
|
300 public final QRect toAlignedRect() const
|
|
301 {
|
|
302 return qtd_QRectF_toAlignedRect(cast(void*)&this);
|
|
303 }
|
|
304
|
|
305 private:
|
|
306 qreal xp;
|
|
307 qreal yp;
|
|
308 qreal w;
|
|
309 qreal h;
|
|
310 }
|
|
311
|
|
312
|
|
313 // C wrappers
|
|
314 private extern(C) bool qtd_QRectF_contains_QPointF(void* __this_nativeId,
|
|
315 void* p0);
|
|
316 private extern(C) bool qtd_QRectF_contains_QRectF(void* __this_nativeId,
|
|
317 void* r0);
|
|
318 private extern(C) bool qtd_QRectF_intersects_QRectF(void* __this_nativeId,
|
|
319 void* r0);
|
|
320 private extern(C) QRectF qtd_QRectF_normalized(void* __this_nativeId);
|
|
321 private extern(C) QRectF qtd_QRectF_operator_and_QRectF(void* __this_nativeId,
|
|
322 void* r0);
|
|
323 private extern(C) void qtd_QRectF_writeTo_QDataStream(void* __this_nativeId,
|
|
324 void* arg__1);
|
|
325 private extern(C) void qtd_QRectF_readFrom_QDataStream(void* __this_nativeId,
|
|
326 void* arg__1);
|
|
327 private extern(C) QRectF qtd_QRectF_operator_or_QRectF(void* __this_nativeId,
|
|
328 void* r0);
|
|
329 private extern(C) QRect qtd_QRectF_toAlignedRect(void* __this_nativeId); |