comparison qt/d2/qt/core/QRectF.d @ 204:6aeaf24018d7

more D2 examples fixes
author eldar
date Mon, 13 Jul 2009 23:16:08 +0000
parents 7dd099050621
children 3dadfee97421
comparison
equal deleted inserted replaced
203:d3383b16f1d7 204:6aeaf24018d7
48 yp = r.y(); 48 yp = r.y();
49 w = r.width(); 49 w = r.width();
50 h = r.height(); 50 h = r.height();
51 } 51 }
52 52
53 bool isNull() // conts 53 bool isNull() const
54 { return qIsNull(w) && qIsNull(h); } 54 { return qIsNull(w) && qIsNull(h); }
55 55
56 bool isEmpty() // conts 56 bool isEmpty() const
57 { return w <= 0. || h <= 0.; } 57 { return w <= 0. || h <= 0.; }
58 58
59 bool isValid() // conts 59 bool isValid() const
60 { return w > 0. && h > 0.; } 60 { return w > 0. && h > 0.; }
61 61
62 qreal x() // conts 62 qreal x() const
63 { return xp; } 63 { return xp; }
64 64
65 qreal y() // conts 65 qreal y() const
66 { return yp; } 66 { return yp; }
67 67
68 qreal left() // const 68 qreal left() const
69 { return xp; } 69 { return xp; }
70 70
71 qreal top() // const 71 qreal top() const
72 { return yp; } 72 { return yp; }
73 73
74 qreal right() // const 74 qreal right() const
75 { return xp + w; } 75 { return xp + w; }
76 76
77 qreal bottom() // const 77 qreal bottom() const
78 { return yp + h; } 78 { return yp + h; }
79 79
80 QPointF topLeft() // const 80 QPointF topLeft() const
81 { return QPointF(xp, yp); } 81 { return QPointF(xp, yp); }
82 82
83 QPointF bottomRight() // const 83 QPointF bottomRight() const
84 { return QPointF(xp+w, yp+h); } 84 { return QPointF(xp+w, yp+h); }
85 85
86 QPointF topRight() // const 86 QPointF topRight() const
87 { return QPointF(xp+w, yp); } 87 { return QPointF(xp+w, yp); }
88 88
89 QPointF bottomLeft() // const 89 QPointF bottomLeft() const
90 { return QPointF(xp, yp+h); } 90 { return QPointF(xp, yp+h); }
91 91
92 void setLeft(qreal pos) { qreal diff = pos - xp; xp += diff; w -= diff; } 92 void setLeft(qreal pos) { qreal diff = pos - xp; xp += diff; w -= diff; }
93 93
94 void setRight(qreal pos) { w = pos - xp; } 94 void setRight(qreal pos) { w = pos - xp; }
103 103
104 void setBottomLeft(ref QPointF p) { setLeft(p.x()); setBottom(p.y()); } 104 void setBottomLeft(ref QPointF p) { setLeft(p.x()); setBottom(p.y()); }
105 105
106 void setBottomRight(ref QPointF p) { setRight(p.x()); setBottom(p.y()); } 106 void setBottomRight(ref QPointF p) { setRight(p.x()); setBottom(p.y()); }
107 107
108 QPointF center() // conts 108 QPointF center() const
109 { return QPointF(xp + w/2, yp + h/2); } 109 { return QPointF(xp + w/2, yp + h/2); }
110 110
111 void moveLeft(qreal pos) { xp = pos; } 111 void moveLeft(qreal pos) { xp = pos; }
112 112
113 void moveTop(qreal pos) { yp = pos; } 113 void moveTop(qreal pos) { yp = pos; }
124 124
125 void moveBottomRight(ref QPointF p) { moveRight(p.x()); moveBottom(p.y()); } 125 void moveBottomRight(ref QPointF p) { moveRight(p.x()); moveBottom(p.y()); }
126 126
127 void moveCenter(ref QPointF p) { xp = p.x() - w/2; yp = p.y() - h/2; } 127 void moveCenter(ref QPointF p) { xp = p.x() - w/2; yp = p.y() - h/2; }
128 128
129 qreal width() // conts 129 qreal width() const
130 { return w; } 130 { return w; }
131 131
132 qreal height() // conts 132 qreal height() const
133 { return h; } 133 { return h; }
134 134
135 QSizeF size() // conts 135 QSizeF size() const
136 { return QSizeF(w, h); } 136 { return QSizeF(w, h); }
137 137
138 void translate(qreal dx, qreal dy) 138 void translate(qreal dx, qreal dy)
139 { 139 {
140 xp += dx; 140 xp += dx;
157 { 157 {
158 xp = p.x(); 158 xp = p.x();
159 yp = p.y(); 159 yp = p.y();
160 } 160 }
161 161
162 QRectF translated(qreal dx, qreal dy) // conts 162 QRectF translated(qreal dx, qreal dy) const
163 { return QRectF(xp + dx, yp + dy, w, h); } 163 { return QRectF(xp + dx, yp + dy, w, h); }
164 164
165 QRectF translated(ref QPointF p) // conts 165 QRectF translated(ref QPointF p) const
166 { return QRectF(xp + p.x(), yp + p.y(), w, h); } 166 { return QRectF(xp + p.x(), yp + p.y(), w, h); }
167 167
168 void getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) // conts 168 void getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) const
169 { 169 {
170 *ax = this.xp; 170 *ax = this.xp;
171 *ay = this.yp; 171 *ay = this.yp;
172 *aaw = this.w; 172 *aaw = this.w;
173 *aah = this.h; 173 *aah = this.h;
179 this.yp = ay; 179 this.yp = ay;
180 this.w = aaw; 180 this.w = aaw;
181 this.h = aah; 181 this.h = aah;
182 } 182 }
183 183
184 void getCoords(qreal *xp1, qreal *yp1, qreal *xp2, qreal *yp2) // conts 184 void getCoords(qreal *xp1, qreal *yp1, qreal *xp2, qreal *yp2) const
185 { 185 {
186 *xp1 = xp; 186 *xp1 = xp;
187 *yp1 = yp; 187 *yp1 = yp;
188 *xp2 = xp + w; 188 *xp2 = xp + w;
189 *yp2 = yp + h; 189 *yp2 = yp + h;
198 } 198 }
199 199
200 void adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2) 200 void adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2)
201 { xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; } 201 { xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; }
202 202
203 QRectF adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) // conts 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); } 204 { return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); }
205 205
206 void setWidth(qreal aw) // for convenience 206 void setWidth(qreal aw) // for convenience
207 { this.w = aw; } 207 { this.w = aw; }
208 208
225 { 225 {
226 w = s.width(); 226 w = s.width();
227 h = s.height(); 227 h = s.height();
228 } 228 }
229 229
230 bool contains(qreal ax, qreal ay) // conts 230 bool contains(qreal ax, qreal ay) const
231 { 231 {
232 return contains(QPointF(ax, ay)); 232 return contains(QPointF(ax, ay));
233 } 233 }
234 234
235 QRectF opOrAssign(ref QRectF r) 235 QRectF opOrAssign(ref QRectF r)
242 { 242 {
243 this = this & r; 243 this = this & r;
244 return this; 244 return this;
245 } 245 }
246 246
247 QRectF intersected(ref QRectF r) // conts 247 QRectF intersected(ref QRectF r) const
248 { 248 {
249 return this & r; 249 return this & r;
250 } 250 }
251 251
252 QRectF united(ref QRectF r) // conts 252 QRectF united(ref QRectF r) const
253 { 253 {
254 return this | r; 254 return this | r;
255 } 255 }
256 256
257 bool opEquals(ref QRectF r) 257 bool opEquals(ref QRectF r)
258 { 258 {
259 return qFuzzyCompare(xp, r.xp) && qFuzzyCompare(yp, r.yp) 259 return qFuzzyCompare(xp, r.xp) && qFuzzyCompare(yp, r.yp)
260 && qFuzzyCompare(w, r.w) && qFuzzyCompare(h, r.h); 260 && qFuzzyCompare(w, r.w) && qFuzzyCompare(h, r.h);
261 } 261 }
262 262
263 QRect toRect() // conts 263 QRect toRect() const
264 { 264 {
265 return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h)); 265 return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h));
266 } 266 }
267 267
268 public final bool contains(QPointF p) { 268 public final bool contains(QPointF p) const {
269 return qtd_QRectF_contains_QPointF(&this, &p); 269 return qtd_QRectF_contains_QPointF(cast(void*)&this, &p);
270 } 270 }
271 271
272 public final bool contains(QRectF r) { 272 public final bool contains(QRectF r) const {
273 return qtd_QRectF_contains_QRectF(&this, &r); 273 return qtd_QRectF_contains_QRectF(cast(void*)&this, &r);
274 } 274 }
275 275
276 public final bool intersects(QRectF r) { 276 public final bool intersects(QRectF r) const {
277 return qtd_QRectF_intersects_QRectF(&this, &r); 277 return qtd_QRectF_intersects_QRectF(cast(void*)&this, &r);
278 } 278 }
279 279
280 public final QRectF normalized() { 280 public final QRectF normalized() const {
281 return qtd_QRectF_normalized(&this); 281 return qtd_QRectF_normalized(cast(void*)&this);
282 } 282 }
283 283
284 public final QRectF opAnd(ref QRectF r) { 284 public final QRectF opAnd(ref QRectF r) const {
285 return qtd_QRectF_operator_and_QRectF(&this, &r); 285 return qtd_QRectF_operator_and_QRectF(cast(void*)&this, &r);
286 } 286 }
287 287
288 public final void writeTo(QDataStream arg__1) { 288 public final void writeTo(QDataStream arg__1) {
289 qtd_QRectF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); 289 qtd_QRectF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
290 } 290 }
291 291
292 public final void readFrom(QDataStream arg__1) { 292 public final void readFrom(QDataStream arg__1) {
293 qtd_QRectF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); 293 qtd_QRectF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId);
294 } 294 }
295 295
296 public final QRectF opOr(ref QRectF r) { 296 public final QRectF opOr(ref QRectF r) const {
297 return qtd_QRectF_operator_or_QRectF(&this, &r); 297 return qtd_QRectF_operator_or_QRectF(cast(void*)&this, &r);
298 } 298 }
299 299
300 public final QRect toAlignedRect() // const 300 public final QRect toAlignedRect() const
301 { 301 {
302 return qtd_QRectF_toAlignedRect(&this); 302 return qtd_QRectF_toAlignedRect(cast(void*)&this);
303 } 303 }
304 304
305 private: 305 private:
306 qreal xp; 306 qreal xp;
307 qreal yp; 307 qreal yp;