14
|
1 /**
|
|
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
|
|
3 * Authors: Jacob Carlborg
|
|
4 * Version: Initial created: Aug 3, 2009
|
|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
|
|
6 */
|
|
7 module dstep.foundation.NSAffineTransform;
|
|
8
|
|
9 import dstep.applicationservices.coregraphics.CGAffineTransform;
|
|
10 import dstep.foundation.NSGeometry;
|
|
11 import dstep.foundation.NSObject;
|
|
12 import dstep.objc.bridge.Bridge;
|
|
13 import dstep.objc.objc : id;
|
|
14
|
|
15 struct NSAffineTransformStruct
|
|
16 {
|
|
17 CGFloat m11;
|
|
18 CGFloat m12;
|
|
19 CGFloat m21;
|
|
20 CGFloat m22;
|
|
21 CGFloat tX;
|
|
22 CGFloat tY;
|
|
23 }
|
|
24
|
|
25 class NSAffineTransform : NSObject, INSCopying, INSCoding
|
|
26 {
|
|
27 mixin ObjcWrap;
|
|
28
|
|
29 static NSAffineTransform transform ()
|
|
30 {
|
|
31 return invokeObjcSelfClass!(NSAffineTransform, "transform"return result is this.objcObject ? this : (result !is null ? new NSAffineTransform(result) : null); }
|
|
32
|
|
33 Object initWithTransform (NSAffineTransform transform)
|
|
34 {
|
|
35 return invokeObjcSelf!(Object, "initWithTransform:", NSAffineTransform)(transform);
|
|
36 }
|
|
37
|
|
38 this (NSAffineTransform transform)
|
|
39 {
|
|
40 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
41 id result = Bridge.invokeObjcMethod!(id, "initWithTransform:", NSAffineTransform)(objcObject, transform);
|
|
42
|
|
43 if (result)
|
|
44 objcObject = ret;
|
|
45
|
|
46 dObject = this;
|
|
47 }
|
|
48
|
|
49 void translateXBy (CGFloat deltaX, CGFloat deltaY)
|
|
50 {
|
|
51 return invokeObjcSelf!(void, "translateXBy:yBy:", CGFloat, CGFloat)(deltaX, deltaY);
|
|
52 }
|
|
53
|
|
54 void rotateByDegrees (CGFloat angle)
|
|
55 {
|
|
56 return invokeObjcSelf!(void, "rotateByDegrees:", CGFloat)(angle);
|
|
57 }
|
|
58
|
|
59 void rotateByRadians (CGFloat angle)
|
|
60 {
|
|
61 return invokeObjcSelf!(void, "rotateByRadians:", CGFloat)(angle);
|
|
62 }
|
|
63
|
|
64 void scaleBy (CGFloat scale)
|
|
65 {
|
|
66 return invokeObjcSelf!(void, "scaleBy:", CGFloat)(scale);
|
|
67 }
|
|
68
|
|
69 void scaleXBy (CGFloat scaleX, CGFloat scaleY)
|
|
70 {
|
|
71 return invokeObjcSelf!(void, "scaleXBy:yBy:", CGFloat, CGFloat)(scaleX, scaleY);
|
|
72 }
|
|
73
|
|
74 void invert ()
|
|
75 {
|
|
76 return invokeObjcSelf!(void, "invert");
|
|
77 }
|
|
78
|
|
79 void appendTransform (NSAffineTransform transform)
|
|
80 {
|
|
81 return invokeObjcSelf!(void, "appendTransform:", NSAffineTransform)(transform);
|
|
82 }
|
|
83
|
|
84 void prependTransform (NSAffineTransform transform)
|
|
85 {
|
|
86 return invokeObjcSelf!(void, "prependTransform:", NSAffineTransform)(transform);
|
|
87 }
|
|
88
|
|
89 NSPoint transformPoint (NSPoint aPoint)
|
|
90 {
|
|
91 return invokeObjcSelf!(NSPoint, "transformPoint:", NSPoint)(aPoint);
|
|
92 }
|
|
93
|
|
94 NSSize transformSize (NSSize aSize)
|
|
95 {
|
|
96 return invokeObjcSelf!(NSSize, "transformSize:", NSSize)(aSize);
|
|
97 }
|
|
98
|
|
99 NSAffineTransformStruct transformStruct ()
|
|
100 {
|
|
101 return invokeObjcSelf!(NSAffineTransformStruct, "transformStruct");
|
|
102 }
|
|
103
|
|
104 void setTransformStruct (NSAffineTransformStruct transformStruct)
|
|
105 {
|
|
106 return invokeObjcSelf!(void, "setTransformStruct:", NSAffineTransformStruct)(transformStruct);
|
|
107 }
|
|
108
|
|
109 Object copyWithZone (NSZone* zone)
|
|
110 {
|
|
111 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
|
|
112 }
|
|
113
|
|
114 void encodeWithCoder (NSCoder aCoder)
|
|
115 {
|
|
116 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
|
|
117 }
|
|
118
|
|
119 Object initWithCoder (NSCoder aDecoder)
|
|
120 {
|
|
121 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
|
|
122 }
|
|
123
|
|
124 this (NSCoder aDecoder)
|
|
125 {
|
|
126 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
127 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
|
|
128
|
|
129 if (result)
|
|
130 objcObject = ret;
|
|
131
|
|
132 dObject = this;
|
|
133 }
|
|
134 }
|
|
135
|