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