Mercurial > projects > qtd
comparison qt/d2/qt/core/QPoint.d @ 188:7dd099050621
initial commit for D2 support
author | eldar |
---|---|
date | Sun, 12 Jul 2009 18:58:03 +0000 |
parents | |
children | 3dadfee97421 |
comparison
equal
deleted
inserted
replaced
187:34fe79a9915b | 188:7dd099050621 |
---|---|
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 | |
26 int x() // const | |
27 { return xp; } | |
28 | |
29 int y() // const | |
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; } | |
63 | |
64 bool opEquals(ref QPoint p) | |
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); } | |
72 | |
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) { | |
89 qtd_QPoint_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); | |
90 } | |
91 | |
92 public final void readFrom(QDataStream arg__1) { | |
93 qtd_QPoint_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); | |
94 } | |
95 | |
96 private: | |
97 // ### Qt 5; remove the ifdef and just have the same order on all platforms. | |
98 version(OSX) | |
99 { | |
100 int yp; | |
101 int xp; | |
102 } | |
103 else | |
104 { | |
105 int xp; | |
106 int yp; | |
107 } | |
108 } | |
109 | |
110 | |
111 public struct QPointF | |
112 { | |
113 public static QPointF opCall() { | |
114 QPointF pt; | |
115 pt.xp = pt.yp = 0; | |
116 return pt; | |
117 } | |
118 | |
119 public this(qreal xpos, qreal ypos) { | |
120 xp = xpos; | |
121 yp = ypos; | |
122 } | |
123 | |
124 public this(QPoint p) { | |
125 xp = p.x(); | |
126 yp = p.y(); | |
127 } | |
128 | |
129 bool isNull() //const | |
130 { | |
131 return qIsNull(xp) && qIsNull(yp); | |
132 } | |
133 | |
134 qreal x() //const | |
135 { | |
136 return xp; | |
137 } | |
138 | |
139 qreal y() //const | |
140 { | |
141 return yp; | |
142 } | |
143 | |
144 void x(qreal xpos) | |
145 { | |
146 xp = xpos; | |
147 } | |
148 | |
149 void y(qreal ypos) | |
150 { | |
151 yp = ypos; | |
152 } | |
153 /* | |
154 inline qreal &QPointF::rx() | |
155 { | |
156 return xp; | |
157 } | |
158 | |
159 inline qreal &QPointF::ry() | |
160 { | |
161 return yp; | |
162 } | |
163 */ | |
164 | |
165 QPointF opAddAssign(ref QPointF p) | |
166 { xp+=p.xp; yp+=p.yp; return this; } | |
167 | |
168 QPointF opSubAssign(ref QPointF p) | |
169 { xp-=p.xp; yp-=p.yp; return this; } | |
170 | |
171 QPointF opMulAssign(qreal c) | |
172 { xp*=c; yp*=c; return this; } | |
173 | |
174 bool opEquals(ref QPointF p) | |
175 { return qFuzzyCompare(xp, p.xp) && qFuzzyCompare(yp, p.yp); } | |
176 | |
177 QPointF opAdd(ref QPointF p) | |
178 { return QPointF(this.xp+p.xp, this.yp+p.yp); } | |
179 | |
180 QPointF opSub(ref QPointF p) | |
181 { return QPointF(this.xp-p.xp, this.yp-p.yp); } | |
182 | |
183 QPointF opMul(qreal c) | |
184 { return QPointF(this.xp*c, this.yp*c); } | |
185 | |
186 QPointF opDivAssign(qreal c) | |
187 { | |
188 xp/=c; | |
189 yp/=c; | |
190 return this; | |
191 } | |
192 | |
193 QPointF opDiv(qreal c) | |
194 { | |
195 return QPointF(xp/c, yp/c); | |
196 } | |
197 | |
198 QPoint toPoint() //const | |
199 { | |
200 return QPoint(qRound(xp), qRound(yp)); | |
201 } | |
202 | |
203 public final void writeTo(QDataStream arg__1) { | |
204 qtd_QPointF_writeTo_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); | |
205 } | |
206 | |
207 public final void readFrom(QDataStream arg__1) { | |
208 qtd_QPointF_readFrom_QDataStream(&this, arg__1 is null ? null : arg__1.nativeId); | |
209 } | |
210 | |
211 private: | |
212 qreal xp; | |
213 qreal yp; | |
214 } | |
215 | |
216 | |
217 // C wrappers | |
218 // QPoint | |
219 private extern(C) int qtd_QPoint_manhattanLength(void* __this_nativeId); | |
220 private extern(C) void qtd_QPoint_writeTo_QDataStream(void* __this_nativeId, | |
221 void* arg__1); | |
222 private extern(C) void qtd_QPoint_readFrom_QDataStream(void* __this_nativeId, | |
223 void* arg__1); | |
224 | |
225 // QPointF | |
226 private extern(C) void qtd_QPointF_writeTo_QDataStream(void* __this_nativeId, | |
227 void* arg__1); | |
228 private extern(C) void qtd_QPointF_readFrom_QDataStream(void* __this_nativeId, | |
229 void* arg__1); |