Mercurial > projects > qtd
annotate d2/qt/core/QSize.d @ 389:d37abad3def9
Added missing ?const? to qt.core.QModelIndex.object.
Previously, QModelIndex.internalPointer was const, while QModelIndex.object was not, even if they in fact do the same thing.
author | David Nadlinger <code@klickverbot.at> |
---|---|
date | Fri, 27 Aug 2010 14:44:09 +0200 |
parents | 96a75b1e5b26 |
children |
rev | line source |
---|---|
188 | 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 | |
205 | 37 final int width() const |
188 | 38 { return wd; } |
39 | |
205 | 40 final int height() const |
188 | 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 | |
325 | 94 bool opEquals(ref const QSize s) const |
188 | 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 } | |
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:
205
diff
changeset
|
116 |
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:
205
diff
changeset
|
117 // 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:
205
diff
changeset
|
118 public alias void __isNativeValueType; |
188 | 119 |
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:
205
diff
changeset
|
120 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:
205
diff
changeset
|
121 { |
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:
205
diff
changeset
|
122 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:
205
diff
changeset
|
123 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:
205
diff
changeset
|
124 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:
205
diff
changeset
|
125 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:
205
diff
changeset
|
126 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:
205
diff
changeset
|
127 } |
188 | 128 private: |
129 int wd; | |
130 int ht; | |
131 } | |
132 | |
133 | |
134 public struct QSizeF | |
135 { | |
136 /* ctors, reserved for D2 | |
137 this() | |
138 { wd = ht = -1.; } | |
139 | |
140 this(ref QSize sz) | |
141 { wd = sz.width(); ht = sz.height(); } | |
142 | |
143 this(qreal w, qreal h) | |
144 { wd = w; ht = h; } | |
145 */ | |
146 public static QSizeF opCall() { | |
147 QSizeF sz; | |
148 sz.wd = sz.ht = -1.; | |
149 return sz; | |
150 } | |
151 | |
152 public static QSizeF opCall(ref QSizeF s) { | |
153 QSizeF sz; | |
154 sz.wd = s.width(); sz.ht = s.height(); | |
155 return sz; | |
156 } | |
157 | |
158 public static QSizeF opCall(qreal w, qreal h) { | |
159 QSizeF sz; | |
160 sz.wd = w; sz.ht = h; | |
161 return sz; | |
162 } | |
163 | |
164 bool isNull() | |
165 { return qIsNull(wd) && qIsNull(ht); } | |
166 | |
167 bool isEmpty() | |
168 { return wd <= 0. || ht <= 0.; } | |
169 | |
170 bool isValid() | |
171 { return wd >= 0. && ht >= 0.; } | |
172 | |
173 qreal width() | |
174 { return wd; } | |
175 | |
176 qreal height() | |
177 { return ht; } | |
178 | |
179 void width(qreal w) | |
180 { wd = w; } | |
181 | |
182 void height(qreal h) | |
183 { ht = h; } | |
184 | |
185 void setWidth(qreal w) | |
186 { wd = w; } | |
187 | |
188 void setHeight(qreal h) | |
189 { ht = h; } | |
190 | |
191 void scale(qreal w, qreal h, Qt.AspectRatioMode mode) | |
192 { scale(QSizeF(w, h), mode); } | |
193 | |
194 public final void scale(QSizeF s, Qt.AspectRatioMode mode) | |
195 { __qtd_QSizeF_scale_QSizeF_AspectRatioMode(&this, &s, mode); } | |
196 | |
197 void transpose() { | |
198 qreal tmp = wd; | |
199 wd = ht; | |
200 ht = tmp; | |
201 } | |
202 | |
203 QSizeF expandedTo(ref QSizeF otherSize) | |
204 { return QSizeF(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); } | |
205 | |
206 QSizeF boundedTo(ref QSizeF otherSize) | |
207 { return QSizeF(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); } | |
208 | |
209 QSize toSize() | |
210 { return QSize(qRound(wd), qRound(ht)); } | |
211 /* | |
212 public final void writeTo(QDataStream arg__1) { | |
213 __qtd_QSizeF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); | |
214 } | |
215 | |
216 public final void readFrom(QDataStream arg__1) { | |
217 __qtd_QSizeF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); | |
218 */ | |
219 QSizeF opAddAssign(ref QSizeF s) | |
220 { wd += s.wd; ht += s.ht; return this; } | |
221 | |
222 QSizeF opSubAssign(ref QSizeF s) | |
223 { wd -= s.wd; ht -= s.ht; return this; } | |
224 | |
225 QSizeF opMulAssign(qreal c) | |
226 { wd *= c; ht *= c; return this; } | |
227 | |
325 | 228 bool opEquals(ref const QSizeF s) const |
188 | 229 { return qFuzzyCompare(wd, s.wd) && qFuzzyCompare(ht, s.ht); } |
230 | |
231 QSizeF opAdd(ref QSizeF s) | |
232 { return QSizeF(this.wd+s.wd, this.ht+s.ht); } | |
233 | |
234 QSizeF opSub(ref QSizeF s) | |
235 { return QSizeF(this.wd-s.wd, this.ht-s.ht); } | |
236 | |
237 QSizeF opMul(qreal c) | |
238 { return QSizeF(this.wd*c, this.ht*c); } | |
239 | |
240 QSizeF opDivAssign(qreal c) | |
241 { | |
242 assert(!qFuzzyCompare(c + 1, 1.)); | |
243 wd = wd/c; ht = ht/c; | |
244 return this; | |
245 } | |
246 | |
247 QSizeF opDiv(qreal c) | |
248 { | |
249 assert(!qFuzzyCompare(c + 1, 1.)); | |
250 return QSizeF(this.wd/c, this.ht/c); | |
251 } | |
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:
205
diff
changeset
|
252 |
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:
205
diff
changeset
|
253 // 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:
205
diff
changeset
|
254 public alias void __isNativeValueType; |
188 | 255 |
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:
205
diff
changeset
|
256 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:
205
diff
changeset
|
257 { |
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:
205
diff
changeset
|
258 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:
205
diff
changeset
|
259 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:
205
diff
changeset
|
260 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:
205
diff
changeset
|
261 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:
205
diff
changeset
|
262 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:
205
diff
changeset
|
263 } |
188 | 264 private: |
265 qreal wd; | |
266 qreal ht; | |
267 } | |
268 | |
269 | |
270 extern (C) void qtd_append_array_QSize(QSize[]* arr, QSize arg) | |
271 { | |
272 *arr ~= arg; | |
273 } | |
274 | |
275 extern (C) void qtd_append_array_QSizeF(QSizeF[]* arr, QSizeF arg) | |
276 { | |
277 *arr ~= arg; | |
278 } | |
279 | |
280 // C wrappers | |
281 // QSize | |
282 private extern(C) void __qtd_QSize_scale_QSize_AspectRatioMode(void* __this_nativeId, | |
283 void* s0, | |
284 int mode1); | |
285 private extern(C) void __qtd_QSize_writeTo_QDataStream(void* __this_nativeId, | |
286 void* arg__1); | |
287 private extern(C) void __qtd_QSize_readFrom_QDataStream(void* __this_nativeId, | |
288 void* arg__1); | |
289 | |
290 // QSizeF | |
291 private extern(C) void __qtd_QSizeF_writeTo_QDataStream(void* __this_nativeId, | |
292 void* arg__1); | |
293 private extern(C) void __qtd_QSizeF_readFrom_QDataStream(void* __this_nativeId, | |
294 void* arg__1); | |
295 private extern(C) void __qtd_QSizeF_scale_QSizeF_AspectRatioMode(void* __this_nativeId, | |
296 void* s0, | |
297 int mode1); |