Mercurial > projects > qtd
comparison qt/d1/qt/core/QSize.d @ 231:99e74c8a22f8
change ref to in in structs
author | eldar |
---|---|
date | Fri, 17 Jul 2009 21:16:44 +0000 |
parents | 7dd099050621 |
children |
comparison
equal
deleted
inserted
replaced
230:0c2a27b23238 | 231:99e74c8a22f8 |
---|---|
13 public this(int w, int h) | 13 public this(int w, int h) |
14 { wd = w; ht = h; } | 14 { wd = w; ht = h; } |
15 */ | 15 */ |
16 | 16 |
17 public static QSize opCall() { | 17 public static QSize opCall() { |
18 QSize sz; | 18 QSize sz; |
19 sz.wd = sz.ht = -1; | 19 sz.wd = sz.ht = -1; |
20 return sz; | 20 return sz; |
21 } | 21 } |
22 | 22 |
23 public static QSize opCall(int w, int h) { | 23 public static QSize opCall(int w, int h) { |
24 QSize sz; | 24 QSize sz; |
25 sz.wd = w; | 25 sz.wd = w; |
26 sz.ht = h; | 26 sz.ht = h; |
27 return sz; | 27 return sz; |
28 } | 28 } |
29 | 29 |
30 final bool isNull() | 30 final bool isNull() |
31 { return wd==0 && ht==0; } | 31 { return wd==0 && ht==0; } |
32 | 32 |
53 | 53 |
54 final void setHeight(int h) // for convenience | 54 final void setHeight(int h) // for convenience |
55 { ht = h; } | 55 { ht = h; } |
56 | 56 |
57 void transpose() { | 57 void transpose() { |
58 int tmp = wd; | 58 int tmp = wd; |
59 wd = ht; | 59 wd = ht; |
60 ht = tmp; | 60 ht = tmp; |
61 } | 61 } |
62 | 62 |
63 void scale(int w, int h, Qt.AspectRatioMode mode) { | 63 void scale(int w, int h, Qt.AspectRatioMode mode) { |
64 scale(QSize(w, h), mode); | 64 scale(QSize(w, h), mode); |
65 } | 65 } |
66 | 66 |
67 void scale(ref QSize s, Qt.AspectRatioMode mode) { | 67 void scale(in QSize s, Qt.AspectRatioMode mode) { |
68 __qtd_QSize_scale_QSize_AspectRatioMode(this, &s, mode); | 68 __qtd_QSize_scale_QSize_AspectRatioMode(this, &s, mode); |
69 } | 69 } |
70 | 70 |
71 QSize expandedTo(ref QSize otherSize) { | 71 QSize expandedTo(in QSize otherSize) { |
72 return QSize(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); | 72 return QSize(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); |
73 } | 73 } |
74 | 74 |
75 QSize boundedTo(ref QSize otherSize) { | 75 QSize boundedTo(in QSize otherSize) { |
76 return QSize(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); | 76 return QSize(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); |
77 } | 77 } |
78 /* | 78 /* |
79 public final void writeTo(QDataStream arg__1) { | 79 public final void writeTo(QDataStream arg__1) { |
80 __qtd_QSize_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); | 80 __qtd_QSize_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); |
81 } | 81 } |
82 | 82 |
83 public final void readFrom(QDataStream arg__1) { | 83 public final void readFrom(QDataStream arg__1) { |
84 __qtd_QSize_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); | 84 __qtd_QSize_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); |
85 } | 85 } |
86 */ | 86 */ |
87 QSize opAddAssign(ref QSize s) | 87 QSize opAddAssign(in QSize s) |
88 { wd+=s.wd; ht+=s.ht; return *this; } | 88 { wd+=s.wd; ht+=s.ht; return *this; } |
89 | 89 |
90 QSize opSubAssign(ref QSize s) | 90 QSize opSubAssign(in QSize s) |
91 { wd-=s.wd; ht-=s.ht; return *this; } | 91 { wd-=s.wd; ht-=s.ht; return *this; } |
92 | 92 |
93 QSize opMulAssign(qreal c) | 93 QSize opMulAssign(qreal c) |
94 { wd = qRound(wd*c); ht = qRound(ht*c); return *this; } | 94 { wd = qRound(wd*c); ht = qRound(ht*c); return *this; } |
95 | 95 |
96 bool opEquals(ref QSize s) | 96 bool opEquals(in QSize s) |
97 { return wd == s.wd && ht == s.ht; } | 97 { return wd == s.wd && ht == s.ht; } |
98 | 98 |
99 QSize opAdd(ref QSize s) | 99 QSize opAdd(in QSize s) |
100 { return QSize(this.wd+s.wd, this.ht+s.ht); } | 100 { return QSize(this.wd+s.wd, this.ht+s.ht); } |
101 | 101 |
102 QSize opSub(ref QSize s) | 102 QSize opSub(in QSize s) |
103 { return QSize(this.wd-s.wd, this.ht-s.ht); } | 103 { return QSize(this.wd-s.wd, this.ht-s.ht); } |
104 | 104 |
105 QSize opMul(qreal c) | 105 QSize opMul(qreal c) |
106 { return QSize(qRound(this.wd*c), qRound(this.ht*c)); } | 106 { return QSize(qRound(this.wd*c), qRound(this.ht*c)); } |
107 | 107 |
108 QSize opDivAssign(qreal c) { | 108 QSize opDivAssign(qreal c) { |
109 assert(!qFuzzyCompare(c + 1, 1.)); | 109 assert(!qFuzzyCompare(c + 1, 1.)); |
110 wd = qRound(wd/c); ht = qRound(ht/c); | 110 wd = qRound(wd/c); ht = qRound(ht/c); |
111 return *this; | 111 return *this; |
112 } | 112 } |
113 | 113 |
114 QSize opDiv(qreal c) { | 114 QSize opDiv(qreal c) { |
115 assert(!qFuzzyCompare(c + 1, 1.)); | 115 assert(!qFuzzyCompare(c + 1, 1.)); |
116 return QSize(qRound(this.wd/c), qRound(this.ht/c)); | 116 return QSize(qRound(this.wd/c), qRound(this.ht/c)); |
117 } | 117 } |
118 | 118 |
119 private: | 119 private: |
120 int wd; | 120 int wd; |
121 int ht; | 121 int ht; |
122 } | 122 } |
123 | 123 |
124 | 124 |
125 public struct QSizeF | 125 public struct QSizeF |
126 { | 126 { |
127 /* ctors, reserved for D2 | 127 /* ctors, reserved for D2 |
128 this() | 128 this() |
129 { wd = ht = -1.; } | 129 { wd = ht = -1.; } |
130 | 130 |
131 this(ref QSize sz) | 131 this(ref QSize sz) |
132 { wd = sz.width(); ht = sz.height(); } | 132 { wd = sz.width(); ht = sz.height(); } |
133 | 133 |
134 this(qreal w, qreal h) | 134 this(qreal w, qreal h) |
135 { wd = w; ht = h; } | 135 { wd = w; ht = h; } |
136 */ | 136 */ |
137 public static QSizeF opCall() { | 137 public static QSizeF opCall() { |
138 QSizeF sz; | 138 QSizeF sz; |
139 sz.wd = sz.ht = -1.; | 139 sz.wd = sz.ht = -1.; |
140 return sz; | 140 return sz; |
141 } | 141 } |
142 | 142 |
143 public static QSizeF opCall(ref QSizeF s) { | 143 public static QSizeF opCall(in QSizeF s) { |
144 QSizeF sz; | 144 QSizeF sz; |
145 sz.wd = s.width(); sz.ht = s.height(); | 145 sz.wd = s.width(); sz.ht = s.height(); |
146 return sz; | 146 return sz; |
147 } | 147 } |
148 | 148 |
149 public static QSizeF opCall(qreal w, qreal h) { | 149 public static QSizeF opCall(qreal w, qreal h) { |
150 QSizeF sz; | 150 QSizeF sz; |
151 sz.wd = w; sz.ht = h; | 151 sz.wd = w; sz.ht = h; |
152 return sz; | 152 return sz; |
153 } | 153 } |
154 | 154 |
155 bool isNull() | 155 bool isNull() |
156 { return qIsNull(wd) && qIsNull(ht); } | 156 { return qIsNull(wd) && qIsNull(ht); } |
157 | 157 |
158 bool isEmpty() | 158 bool isEmpty() |
159 { return wd <= 0. || ht <= 0.; } | 159 { return wd <= 0. || ht <= 0.; } |
160 | 160 |
161 bool isValid() | 161 bool isValid() |
162 { return wd >= 0. && ht >= 0.; } | 162 { return wd >= 0. && ht >= 0.; } |
163 | 163 |
164 qreal width() | 164 qreal width() |
165 { return wd; } | 165 { return wd; } |
166 | 166 |
167 qreal height() | 167 qreal height() |
168 { return ht; } | 168 { return ht; } |
169 | 169 |
170 void width(qreal w) | 170 void width(qreal w) |
171 { wd = w; } | 171 { wd = w; } |
172 | 172 |
173 void height(qreal h) | 173 void height(qreal h) |
174 { ht = h; } | 174 { ht = h; } |
175 | 175 |
176 void setWidth(qreal w) | 176 void setWidth(qreal w) |
177 { wd = w; } | 177 { wd = w; } |
178 | 178 |
179 void setHeight(qreal h) | 179 void setHeight(qreal h) |
180 { ht = h; } | 180 { ht = h; } |
181 | 181 |
182 void scale(qreal w, qreal h, Qt.AspectRatioMode mode) | 182 void scale(qreal w, qreal h, Qt.AspectRatioMode mode) |
183 { scale(QSizeF(w, h), mode); } | 183 { scale(QSizeF(w, h), mode); } |
184 | 184 |
185 public final void scale(QSizeF s, Qt.AspectRatioMode mode) | 185 public final void scale(QSizeF s, Qt.AspectRatioMode mode) |
186 { __qtd_QSizeF_scale_QSizeF_AspectRatioMode(this, &s, mode); } | 186 { __qtd_QSizeF_scale_QSizeF_AspectRatioMode(this, &s, mode); } |
187 | 187 |
188 void transpose() { | 188 void transpose() { |
189 qreal tmp = wd; | 189 qreal tmp = wd; |
190 wd = ht; | 190 wd = ht; |
191 ht = tmp; | 191 ht = tmp; |
192 } | 192 } |
193 | 193 |
194 QSizeF expandedTo(ref QSizeF otherSize) | 194 QSizeF expandedTo(in QSizeF otherSize) |
195 { return QSizeF(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); } | 195 { return QSizeF(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); } |
196 | 196 |
197 QSizeF boundedTo(ref QSizeF otherSize) | 197 QSizeF boundedTo(in QSizeF otherSize) |
198 { return QSizeF(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); } | 198 { return QSizeF(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); } |
199 | 199 |
200 QSize toSize() | 200 QSize toSize() |
201 { return QSize(qRound(wd), qRound(ht)); } | 201 { return QSize(qRound(wd), qRound(ht)); } |
202 /* | 202 /* |
203 public final void writeTo(QDataStream arg__1) { | 203 public final void writeTo(QDataStream arg__1) { |
204 __qtd_QSizeF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); | 204 __qtd_QSizeF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); |
205 } | 205 } |
206 | 206 |
207 public final void readFrom(QDataStream arg__1) { | 207 public final void readFrom(QDataStream arg__1) { |
208 __qtd_QSizeF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); | 208 __qtd_QSizeF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId); |
209 */ | 209 */ |
210 QSizeF opAddAssign(ref QSizeF s) | 210 QSizeF opAddAssign(in QSizeF s) |
211 { wd += s.wd; ht += s.ht; return *this; } | 211 { wd += s.wd; ht += s.ht; return *this; } |
212 | 212 |
213 QSizeF opSubAssign(ref QSizeF s) | 213 QSizeF opSubAssign(in QSizeF s) |
214 { wd -= s.wd; ht -= s.ht; return *this; } | 214 { wd -= s.wd; ht -= s.ht; return *this; } |
215 | 215 |
216 QSizeF opMulAssign(qreal c) | 216 QSizeF opMulAssign(qreal c) |
217 { wd *= c; ht *= c; return *this; } | 217 { wd *= c; ht *= c; return *this; } |
218 | 218 |
219 bool opEquals(ref QSizeF s) | 219 bool opEquals(in QSizeF s) |
220 { return qFuzzyCompare(wd, s.wd) && qFuzzyCompare(ht, s.ht); } | 220 { return qFuzzyCompare(wd, s.wd) && qFuzzyCompare(ht, s.ht); } |
221 | 221 |
222 QSizeF opAdd(ref QSizeF s) | 222 QSizeF opAdd(in QSizeF s) |
223 { return QSizeF(this.wd+s.wd, this.ht+s.ht); } | 223 { return QSizeF(this.wd+s.wd, this.ht+s.ht); } |
224 | 224 |
225 QSizeF opSub(ref QSizeF s) | 225 QSizeF opSub(in QSizeF s) |
226 { return QSizeF(this.wd-s.wd, this.ht-s.ht); } | 226 { return QSizeF(this.wd-s.wd, this.ht-s.ht); } |
227 | 227 |
228 QSizeF opMul(qreal c) | 228 QSizeF opMul(qreal c) |
229 { return QSizeF(this.wd*c, this.ht*c); } | 229 { return QSizeF(this.wd*c, this.ht*c); } |
230 | 230 |
231 QSizeF opDivAssign(qreal c) | 231 QSizeF opDivAssign(qreal c) |
232 { | 232 { |
233 assert(!qFuzzyCompare(c + 1, 1.)); | 233 assert(!qFuzzyCompare(c + 1, 1.)); |
234 wd = wd/c; ht = ht/c; | 234 wd = wd/c; ht = ht/c; |
235 return *this; | 235 return *this; |
236 } | 236 } |
237 | 237 |
238 QSizeF opDiv(qreal c) | 238 QSizeF opDiv(qreal c) |
239 { | 239 { |
240 assert(!qFuzzyCompare(c + 1, 1.)); | 240 assert(!qFuzzyCompare(c + 1, 1.)); |
241 return QSizeF(this.wd/c, this.ht/c); | 241 return QSizeF(this.wd/c, this.ht/c); |
242 } | 242 } |
243 | 243 |
244 private: | 244 private: |
245 qreal wd; | 245 qreal wd; |
246 qreal ht; | 246 qreal ht; |
247 } | 247 } |