Mercurial > projects > qtd
comparison d2/qt/core/QSize.d @ 311:8674fd5f34f4 lifetime
Added d1/d2 top directories
author | maxter <spambox@d-coding.com> |
---|---|
date | Wed, 23 Dec 2009 16:17:22 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
310:5bcfe9e7db7f | 311:8674fd5f34f4 |
---|---|
1 module qt.core.QSize; | |
2 | |
3 public import qt.QGlobal; | |
4 public import qt.core.Qt; | |
5 | |
6 | |
7 public struct QSize | |
8 { | |
9 /* ctors, reserved for D2 | |
10 public this() | |
11 { wd = ht = -1; } | |
12 | |
13 public this(int w, int h) | |
14 { wd = w; ht = h; } | |
15 */ | |
16 | |
17 public static QSize opCall() { | |
18 QSize sz; | |
19 sz.wd = sz.ht = -1; | |
20 return sz; | |
21 } | |
22 | |
23 public this(int w, int h) { | |
24 wd = w; | |
25 ht = h; | |
26 } | |
27 | |
28 final bool isNull() | |
29 { return wd==0 && ht==0; } | |
30 | |
31 final bool isEmpty() | |
32 { return wd<1 || ht<1; } | |
33 | |
34 final bool isValid() | |
35 { return wd>=0 && ht>=0; } | |
36 | |
37 final int width() const | |
38 { return wd; } | |
39 | |
40 final int height() const | |
41 { return ht; } | |
42 | |
43 final void width(int w) | |
44 { wd = w; } | |
45 | |
46 final void height(int h) | |
47 { ht = h; } | |
48 | |
49 final void setWidth(int w) // for convenience | |
50 { wd = w; } | |
51 | |
52 final void setHeight(int h) // for convenience | |
53 { ht = h; } | |
54 | |
55 void transpose() { | |
56 int tmp = wd; | |
57 wd = ht; | |
58 ht = tmp; | |
59 } | |
60 | |
61 void scale(int w, int h, Qt.AspectRatioMode mode) { | |
62 scale(QSize(w, h), mode); | |
63 } | |
64 | |
65 void scale(ref QSize s, Qt.AspectRatioMode mode) { | |
66 __qtd_QSize_scale_QSize_AspectRatioMode(&this, &s, mode); | |
67 } | |
68 | |
69 QSize expandedTo(ref QSize otherSize) { | |
70 return QSize(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); | |
71 } | |
72 | |
73 QSize boundedTo(ref QSize otherSize) { | |
74 return QSize(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); | |
75 } | |
76 /* | |
77 public final void writeTo(QDataStream arg__1) { | |
78 __qtd_QSize_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); | |
79 } | |
80 | |
81 public final void readFrom(QDataStream arg__1) { | |
82 __qtd_QSize_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); | |
83 } | |
84 */ | |
85 QSize opAddAssign(ref QSize s) | |
86 { wd+=s.wd; ht+=s.ht; return this; } | |
87 | |
88 QSize opSubAssign(ref QSize s) | |
89 { wd-=s.wd; ht-=s.ht; return this; } | |
90 | |
91 QSize opMulAssign(qreal c) | |
92 { wd = qRound(wd*c); ht = qRound(ht*c); return this; } | |
93 | |
94 bool opEquals(ref QSize s) | |
95 { return wd == s.wd && ht == s.ht; } | |
96 | |
97 QSize opAdd(ref QSize s) | |
98 { return QSize(this.wd+s.wd, this.ht+s.ht); } | |
99 | |
100 QSize opSub(ref QSize s) | |
101 { return QSize(this.wd-s.wd, this.ht-s.ht); } | |
102 | |
103 QSize opMul(qreal c) | |
104 { return QSize(qRound(this.wd*c), qRound(this.ht*c)); } | |
105 | |
106 QSize opDivAssign(qreal c) { | |
107 assert(!qFuzzyCompare(c + 1, 1.)); | |
108 wd = qRound(wd/c); ht = qRound(ht/c); | |
109 return this; | |
110 } | |
111 | |
112 QSize opDiv(qreal c) { | |
113 assert(!qFuzzyCompare(c + 1, 1.)); | |
114 return QSize(qRound(this.wd/c), qRound(this.ht/c)); | |
115 } | |
116 | |
117 private: | |
118 int wd; | |
119 int ht; | |
120 } | |
121 | |
122 | |
123 public struct QSizeF | |
124 { | |
125 /* ctors, reserved for D2 | |
126 this() | |
127 { wd = ht = -1.; } | |
128 | |
129 this(ref QSize sz) | |
130 { wd = sz.width(); ht = sz.height(); } | |
131 | |
132 this(qreal w, qreal h) | |
133 { wd = w; ht = h; } | |
134 */ | |
135 public static QSizeF opCall() { | |
136 QSizeF sz; | |
137 sz.wd = sz.ht = -1.; | |
138 return sz; | |
139 } | |
140 | |
141 public static QSizeF opCall(ref QSizeF s) { | |
142 QSizeF sz; | |
143 sz.wd = s.width(); sz.ht = s.height(); | |
144 return sz; | |
145 } | |
146 | |
147 public static QSizeF opCall(qreal w, qreal h) { | |
148 QSizeF sz; | |
149 sz.wd = w; sz.ht = h; | |
150 return sz; | |
151 } | |
152 | |
153 bool isNull() | |
154 { return qIsNull(wd) && qIsNull(ht); } | |
155 | |
156 bool isEmpty() | |
157 { return wd <= 0. || ht <= 0.; } | |
158 | |
159 bool isValid() | |
160 { return wd >= 0. && ht >= 0.; } | |
161 | |
162 qreal width() | |
163 { return wd; } | |
164 | |
165 qreal height() | |
166 { return ht; } | |
167 | |
168 void width(qreal w) | |
169 { wd = w; } | |
170 | |
171 void height(qreal h) | |
172 { ht = h; } | |
173 | |
174 void setWidth(qreal w) | |
175 { wd = w; } | |
176 | |
177 void setHeight(qreal h) | |
178 { ht = h; } | |
179 | |
180 void scale(qreal w, qreal h, Qt.AspectRatioMode mode) | |
181 { scale(QSizeF(w, h), mode); } | |
182 | |
183 public final void scale(QSizeF s, Qt.AspectRatioMode mode) | |
184 { __qtd_QSizeF_scale_QSizeF_AspectRatioMode(&this, &s, mode); } | |
185 | |
186 void transpose() { | |
187 qreal tmp = wd; | |
188 wd = ht; | |
189 ht = tmp; | |
190 } | |
191 | |
192 QSizeF expandedTo(ref QSizeF otherSize) | |
193 { return QSizeF(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); } | |
194 | |
195 QSizeF boundedTo(ref QSizeF otherSize) | |
196 { return QSizeF(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); } | |
197 | |
198 QSize toSize() | |
199 { return QSize(qRound(wd), qRound(ht)); } | |
200 /* | |
201 public final void writeTo(QDataStream arg__1) { | |
202 __qtd_QSizeF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); | |
203 } | |
204 | |
205 public final void readFrom(QDataStream arg__1) { | |
206 __qtd_QSizeF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); | |
207 */ | |
208 QSizeF opAddAssign(ref QSizeF s) | |
209 { wd += s.wd; ht += s.ht; return this; } | |
210 | |
211 QSizeF opSubAssign(ref QSizeF s) | |
212 { wd -= s.wd; ht -= s.ht; return this; } | |
213 | |
214 QSizeF opMulAssign(qreal c) | |
215 { wd *= c; ht *= c; return this; } | |
216 | |
217 bool opEquals(ref QSizeF s) | |
218 { return qFuzzyCompare(wd, s.wd) && qFuzzyCompare(ht, s.ht); } | |
219 | |
220 QSizeF opAdd(ref QSizeF s) | |
221 { return QSizeF(this.wd+s.wd, this.ht+s.ht); } | |
222 | |
223 QSizeF opSub(ref QSizeF s) | |
224 { return QSizeF(this.wd-s.wd, this.ht-s.ht); } | |
225 | |
226 QSizeF opMul(qreal c) | |
227 { return QSizeF(this.wd*c, this.ht*c); } | |
228 | |
229 QSizeF opDivAssign(qreal c) | |
230 { | |
231 assert(!qFuzzyCompare(c + 1, 1.)); | |
232 wd = wd/c; ht = ht/c; | |
233 return this; | |
234 } | |
235 | |
236 QSizeF opDiv(qreal c) | |
237 { | |
238 assert(!qFuzzyCompare(c + 1, 1.)); | |
239 return QSizeF(this.wd/c, this.ht/c); | |
240 } | |
241 | |
242 private: | |
243 qreal wd; | |
244 qreal ht; | |
245 } | |
246 | |
247 | |
248 extern (C) void qtd_append_array_QSize(QSize[]* arr, QSize arg) | |
249 { | |
250 *arr ~= arg; | |
251 } | |
252 | |
253 extern (C) void qtd_append_array_QSizeF(QSizeF[]* arr, QSizeF arg) | |
254 { | |
255 *arr ~= arg; | |
256 } | |
257 | |
258 // C wrappers | |
259 // QSize | |
260 private extern(C) void __qtd_QSize_scale_QSize_AspectRatioMode(void* __this_nativeId, | |
261 void* s0, | |
262 int mode1); | |
263 private extern(C) void __qtd_QSize_writeTo_QDataStream(void* __this_nativeId, | |
264 void* arg__1); | |
265 private extern(C) void __qtd_QSize_readFrom_QDataStream(void* __this_nativeId, | |
266 void* arg__1); | |
267 | |
268 // QSizeF | |
269 private extern(C) void __qtd_QSizeF_writeTo_QDataStream(void* __this_nativeId, | |
270 void* arg__1); | |
271 private extern(C) void __qtd_QSizeF_readFrom_QDataStream(void* __this_nativeId, | |
272 void* arg__1); | |
273 private extern(C) void __qtd_QSizeF_scale_QSizeF_AspectRatioMode(void* __this_nativeId, | |
274 void* s0, | |
275 int mode1); |