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