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