Mercurial > projects > qtd
annotate qt/d2/qt/core/QRectF.d @ 298:adae77fdc1ea signals
Native QList implementation is now used throughout QtD
author | eldar |
---|---|
date | Sun, 06 Dec 2009 17:26:37 +0000 |
parents | 463563fc9e17 |
children | b460cd08041f |
rev | line source |
---|---|
188 | 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 | |
205 | 10 |
188 | 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 } | |
254 | 20 |
188 | 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 | |
204 | 53 bool isNull() const |
188 | 54 { return qIsNull(w) && qIsNull(h); } |
55 | |
204 | 56 bool isEmpty() const |
188 | 57 { return w <= 0. || h <= 0.; } |
58 | |
204 | 59 bool isValid() const |
188 | 60 { return w > 0. && h > 0.; } |
61 | |
204 | 62 qreal x() const |
188 | 63 { return xp; } |
64 | |
204 | 65 qreal y() const |
188 | 66 { return yp; } |
67 | |
204 | 68 qreal left() const |
188 | 69 { return xp; } |
254 | 70 |
204 | 71 qreal top() const |
188 | 72 { return yp; } |
254 | 73 |
204 | 74 qreal right() const |
188 | 75 { return xp + w; } |
254 | 76 |
204 | 77 qreal bottom() const |
188 | 78 { return yp + h; } |
254 | 79 |
204 | 80 QPointF topLeft() const |
188 | 81 { return QPointF(xp, yp); } |
254 | 82 |
204 | 83 QPointF bottomRight() const |
188 | 84 { return QPointF(xp+w, yp+h); } |
254 | 85 |
204 | 86 QPointF topRight() const |
188 | 87 { return QPointF(xp+w, yp); } |
254 | 88 |
204 | 89 QPointF bottomLeft() const |
188 | 90 { return QPointF(xp, yp+h); } |
254 | 91 |
188 | 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 | |
204 | 108 QPointF center() const |
188 | 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 | |
204 | 129 qreal width() const |
188 | 130 { return w; } |
131 | |
204 | 132 qreal height() const |
188 | 133 { return h; } |
134 | |
204 | 135 QSizeF size() const |
188 | 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 | |
204 | 162 QRectF translated(qreal dx, qreal dy) const |
188 | 163 { return QRectF(xp + dx, yp + dy, w, h); } |
164 | |
204 | 165 QRectF translated(ref QPointF p) const |
188 | 166 { return QRectF(xp + p.x(), yp + p.y(), w, h); } |
167 | |
204 | 168 void getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) const |
188 | 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 | |
204 | 184 void getCoords(qreal *xp1, qreal *yp1, qreal *xp2, qreal *yp2) const |
188 | 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 | |
204 | 203 QRectF adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const |
188 | 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 } | |
254 | 229 |
204 | 230 bool contains(qreal ax, qreal ay) const |
188 | 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 | |
204 | 247 QRectF intersected(ref QRectF r) const |
188 | 248 { |
249 return this & r; | |
250 } | |
251 | |
204 | 252 QRectF united(ref QRectF r) const |
188 | 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 | |
204 | 263 QRect toRect() const |
188 | 264 { |
265 return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h)); | |
266 } | |
267 | |
204 | 268 public final bool contains(QPointF p) const { |
269 return qtd_QRectF_contains_QPointF(cast(void*)&this, &p); | |
188 | 270 } |
271 | |
204 | 272 public final bool contains(QRectF r) const { |
273 return qtd_QRectF_contains_QRectF(cast(void*)&this, &r); | |
188 | 274 } |
275 | |
204 | 276 public final bool intersects(QRectF r) const { |
277 return qtd_QRectF_intersects_QRectF(cast(void*)&this, &r); | |
188 | 278 } |
279 | |
204 | 280 public final QRectF normalized() const { |
281 return qtd_QRectF_normalized(cast(void*)&this); | |
188 | 282 } |
283 | |
204 | 284 public final QRectF opAnd(ref QRectF r) const { |
285 return qtd_QRectF_operator_and_QRectF(cast(void*)&this, &r); | |
188 | 286 } |
287 | |
288 public final void writeTo(QDataStream arg__1) { | |
254 | 289 qtd_QRectF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId); |
188 | 290 } |
291 | |
292 public final void readFrom(QDataStream arg__1) { | |
254 | 293 qtd_QRectF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.__nativeId); |
188 | 294 } |
295 | |
204 | 296 public final QRectF opOr(ref QRectF r) const { |
297 return qtd_QRectF_operator_or_QRectF(cast(void*)&this, &r); | |
188 | 298 } |
299 | |
204 | 300 public final QRect toAlignedRect() const |
188 | 301 { |
204 | 302 return qtd_QRectF_toAlignedRect(cast(void*)&this); |
188 | 303 } |
295
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
304 |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
305 // service stuff |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
306 public alias void __isNativeValueType; |
188 | 307 |
295
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
308 struct QTypeInfo |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
309 { |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
310 enum bool isComplex = true; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
311 enum bool isStatic = false; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
312 enum bool isLarge = true; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
313 enum bool isPointer = false; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
314 enum bool isDummy = false; |
463563fc9e17
more of QList. const functions in C++ are now const in D too. Drop of the store result feature, which was incompatible with const functions and introduced too much of the bloat in the generator.
eldar
parents:
254
diff
changeset
|
315 } |
188 | 316 private: |
317 qreal xp; | |
318 qreal yp; | |
319 qreal w; | |
320 qreal h; | |
321 } | |
322 | |
323 | |
324 // C wrappers | |
325 private extern(C) bool qtd_QRectF_contains_QPointF(void* __this_nativeId, | |
326 void* p0); | |
327 private extern(C) bool qtd_QRectF_contains_QRectF(void* __this_nativeId, | |
328 void* r0); | |
329 private extern(C) bool qtd_QRectF_intersects_QRectF(void* __this_nativeId, | |
330 void* r0); | |
331 private extern(C) QRectF qtd_QRectF_normalized(void* __this_nativeId); | |
332 private extern(C) QRectF qtd_QRectF_operator_and_QRectF(void* __this_nativeId, | |
333 void* r0); | |
334 private extern(C) void qtd_QRectF_writeTo_QDataStream(void* __this_nativeId, | |
335 void* arg__1); | |
336 private extern(C) void qtd_QRectF_readFrom_QDataStream(void* __this_nativeId, | |
337 void* arg__1); | |
338 private extern(C) QRectF qtd_QRectF_operator_or_QRectF(void* __this_nativeId, | |
339 void* r0); | |
340 private extern(C) QRect qtd_QRectF_toAlignedRect(void* __this_nativeId); |