Mercurial > projects > qtd
annotate d2/qt/core/QPoint.d @ 372:a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Thu, 08 Jul 2010 17:19:05 +0300 |
parents | 96a75b1e5b26 |
children | 1f189d0ceab4 |
rev | line source |
---|---|
188 | 1 module qt.core.QPoint; |
2 | |
3 public import qt.QGlobal; | |
4 public import qt.core.Qt; | |
5 public import qt.core.QDataStream; | |
6 | |
7 | |
8 public struct QPoint | |
9 { | |
10 | |
11 // Functions | |
12 public static QPoint opCall() { | |
13 QPoint pt; | |
14 pt.xp = pt.yp = 0; | |
15 return pt; | |
16 } | |
17 | |
18 public this(int xpos, int ypos) { | |
19 xp = xpos; | |
20 yp = ypos; | |
21 } | |
22 | |
23 bool isNull() // const | |
24 { return xp == 0 && yp == 0; } | |
25 | |
205 | 26 int x() const |
188 | 27 { return xp; } |
28 | |
205 | 29 int y() const |
188 | 30 { return yp; } |
31 | |
32 void x(int xpos) | |
33 { xp = xpos; } | |
34 | |
35 void y(int ypos) | |
36 { yp = ypos; } | |
37 | |
38 void setX(int xpos) // for convenience | |
39 { xp = xpos; } | |
40 | |
41 void setY(int ypos) // for convenience | |
42 { yp = ypos; } | |
43 | |
44 public final int manhattanLength() { | |
45 return qtd_QPoint_manhattanLength(&this); | |
46 } | |
47 /* | |
48 inline int &rx() | |
49 { return xp; } | |
50 | |
51 inline int &ry() | |
52 { return yp; } | |
53 */ | |
54 | |
55 QPoint opAddAssign(ref QPoint p) | |
56 { xp+=p.xp; yp+=p.yp; return this; } | |
57 | |
58 QPoint opSubAssign(ref QPoint p) | |
59 { xp-=p.xp; yp-=p.yp; return this; } | |
60 | |
61 QPoint opMulAssign(qreal c) | |
62 { xp = qRound(xp*c); yp = qRound(yp*c); return this; } | |
254 | 63 |
325 | 64 bool opEquals(ref const QPoint p) const |
188 | 65 { return xp == p.xp && yp == p.yp; } |
66 | |
67 QPoint opAdd(ref QPoint p) | |
68 { return QPoint(this.xp+p.xp, this.yp+p.yp); } | |
69 | |
70 QPoint opSub(ref QPoint p) | |
71 { return QPoint(this.xp-p.xp, this.yp-p.yp); } | |
254 | 72 |
188 | 73 QPoint opMul(qreal c) |
74 { return QPoint(qRound(this.xp*c), qRound(this.yp*c)); } | |
75 | |
76 QPoint opDivAssign(qreal c) | |
77 { | |
78 xp = qRound(xp/c); | |
79 yp = qRound(yp/c); | |
80 return this; | |
81 } | |
82 | |
83 QPoint opDiv(qreal c) | |
84 { | |
85 return QPoint(qRound(this.xp/c), qRound(this.yp/c)); | |
86 } | |
87 | |
88 public final void writeTo(QDataStream arg__1) { | |
372
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
89 qtd_QPoint_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.qtdNativeId); |
188 | 90 } |
91 | |
92 public final void readFrom(QDataStream arg__1) { | |
372
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
93 qtd_QPoint_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.qtdNativeId); |
188 | 94 } |
372
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
95 |
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:
254
diff
changeset
|
96 // 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:
254
diff
changeset
|
97 public alias void __isNativeValueType; |
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:
254
diff
changeset
|
98 |
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:
254
diff
changeset
|
99 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:
254
diff
changeset
|
100 { |
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:
254
diff
changeset
|
101 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:
254
diff
changeset
|
102 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:
254
diff
changeset
|
103 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:
254
diff
changeset
|
104 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:
254
diff
changeset
|
105 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:
254
diff
changeset
|
106 } |
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:
254
diff
changeset
|
107 |
188 | 108 |
109 private: | |
110 // ### Qt 5; remove the ifdef and just have the same order on all platforms. | |
111 version(OSX) | |
112 { | |
113 int yp; | |
114 int xp; | |
115 } | |
116 else | |
117 { | |
118 int xp; | |
119 int yp; | |
120 } | |
121 } | |
122 | |
123 | |
124 public struct QPointF | |
125 { | |
126 public static QPointF opCall() { | |
127 QPointF pt; | |
128 pt.xp = pt.yp = 0; | |
129 return pt; | |
130 } | |
254 | 131 |
188 | 132 public this(qreal xpos, qreal ypos) { |
133 xp = xpos; | |
134 yp = ypos; | |
135 } | |
254 | 136 |
188 | 137 public this(QPoint p) { |
138 xp = p.x(); | |
139 yp = p.y(); | |
140 } | |
254 | 141 |
188 | 142 bool isNull() //const |
143 { | |
144 return qIsNull(xp) && qIsNull(yp); | |
145 } | |
254 | 146 |
188 | 147 qreal x() //const |
148 { | |
149 return xp; | |
150 } | |
254 | 151 |
188 | 152 qreal y() //const |
153 { | |
154 return yp; | |
155 } | |
254 | 156 |
188 | 157 void x(qreal xpos) |
158 { | |
159 xp = xpos; | |
160 } | |
254 | 161 |
188 | 162 void y(qreal ypos) |
163 { | |
164 yp = ypos; | |
165 } | |
254 | 166 /* |
188 | 167 inline qreal &QPointF::rx() |
168 { | |
169 return xp; | |
170 } | |
171 | |
172 inline qreal &QPointF::ry() | |
173 { | |
174 return yp; | |
175 } | |
176 */ | |
254 | 177 |
188 | 178 QPointF opAddAssign(ref QPointF p) |
179 { xp+=p.xp; yp+=p.yp; return this; } | |
254 | 180 |
188 | 181 QPointF opSubAssign(ref QPointF p) |
182 { xp-=p.xp; yp-=p.yp; return this; } | |
254 | 183 |
188 | 184 QPointF opMulAssign(qreal c) |
185 { xp*=c; yp*=c; return this; } | |
254 | 186 |
325 | 187 bool opEquals(ref const QPointF p) const |
188 | 188 { return qFuzzyCompare(xp, p.xp) && qFuzzyCompare(yp, p.yp); } |
254 | 189 |
188 | 190 QPointF opAdd(ref QPointF p) |
191 { return QPointF(this.xp+p.xp, this.yp+p.yp); } | |
254 | 192 |
188 | 193 QPointF opSub(ref QPointF p) |
194 { return QPointF(this.xp-p.xp, this.yp-p.yp); } | |
254 | 195 |
188 | 196 QPointF opMul(qreal c) |
197 { return QPointF(this.xp*c, this.yp*c); } | |
254 | 198 |
188 | 199 QPointF opDivAssign(qreal c) |
200 { | |
201 xp/=c; | |
202 yp/=c; | |
203 return this; | |
204 } | |
254 | 205 |
188 | 206 QPointF opDiv(qreal c) |
207 { | |
208 return QPointF(xp/c, yp/c); | |
209 } | |
254 | 210 |
188 | 211 QPoint toPoint() //const |
212 { | |
213 return QPoint(qRound(xp), qRound(yp)); | |
214 } | |
254 | 215 |
188 | 216 public final void writeTo(QDataStream arg__1) { |
372
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
217 qtd_QPointF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.qtdNativeId); |
188 | 218 } |
254 | 219 |
188 | 220 public final void readFrom(QDataStream arg__1) { |
372
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
221 qtd_QPointF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.qtdNativeId); |
188 | 222 } |
254 | 223 |
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:
254
diff
changeset
|
224 // 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:
254
diff
changeset
|
225 public alias void __isNativeValueType; |
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:
254
diff
changeset
|
226 |
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:
254
diff
changeset
|
227 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:
254
diff
changeset
|
228 { |
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:
254
diff
changeset
|
229 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:
254
diff
changeset
|
230 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:
254
diff
changeset
|
231 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:
254
diff
changeset
|
232 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:
254
diff
changeset
|
233 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:
254
diff
changeset
|
234 } |
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:
254
diff
changeset
|
235 |
188 | 236 private: |
237 qreal xp; | |
238 qreal yp; | |
239 } | |
240 | |
241 | |
242 // C wrappers | |
243 // QPoint | |
244 private extern(C) int qtd_QPoint_manhattanLength(void* __this_nativeId); | |
245 private extern(C) void qtd_QPoint_writeTo_QDataStream(void* __this_nativeId, | |
246 void* arg__1); | |
247 private extern(C) void qtd_QPoint_readFrom_QDataStream(void* __this_nativeId, | |
248 void* arg__1); | |
249 | |
250 // QPointF | |
251 private extern(C) void qtd_QPointF_writeTo_QDataStream(void* __this_nativeId, | |
252 void* arg__1); | |
253 private extern(C) void qtd_QPointF_readFrom_QDataStream(void* __this_nativeId, | |
372
a032df77b6ab
Simple debug helper. Unittests. Meta-object for polymorphic non-QObjects
Max Samukha <maxter@spambox.com>
parents:
344
diff
changeset
|
254 void* arg__1); |