annotate d2/qt/core/QPoint.d @ 373:1f189d0ceab4

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