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