Mercurial > projects > dstep
comparison dstep/foundation/NSGeometry.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
comparison
equal
deleted
inserted
replaced
13:4f583f7e242e | 14:89f3c3ef1fd2 |
---|---|
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.NSGeometry; | |
8 | |
9 import dstep.AvailabilityMacros; | |
10 import dstep.applicationservices.coregraphics.CGBase; | |
11 import dstep.applicationservices.coregraphics.CGGeometry; | |
12 import dstep.foundation.NSCoder; | |
13 import dstep.foundation.NSString; | |
14 import dstep.foundation.NSValue; | |
15 import dstep.objc.bridge.Bridge; | |
16 import dstep.objc.objc : id; | |
17 | |
18 import bindings = dstep.foundation.NSGeometry_bindings; | |
19 | |
20 alias CGPoint NSPoint; | |
21 alias NSPoint* NSPointPointer; | |
22 alias NSPoint* NSPointArray; | |
23 alias CGSize NSSize; | |
24 alias NSSize* NSSizePointer; | |
25 alias NSSize* NSSizeArray; | |
26 alias CGRect NSRect; | |
27 alias NSRect* NSRectPointer; | |
28 alias NSRect* NSRectArray; | |
29 alias NSUInteger NSRectEdge; | |
30 | |
31 extern (C) | |
32 { | |
33 extern | |
34 { | |
35 const NSPoint NSZeroPoint; | |
36 const NSSize NSZeroSize; | |
37 const NSRect NSZeroRect; | |
38 } | |
39 } | |
40 | |
41 template TNSGeometryCoding () | |
42 { | |
43 void encodePoint (NSPoint point) | |
44 { | |
45 return invokeObjcSelf!(void, "encodePoint:", NSPoint)(point); | |
46 } | |
47 | |
48 NSPoint decodePoint () | |
49 { | |
50 return invokeObjcSelf!(NSPoint, "decodePoint"); | |
51 } | |
52 | |
53 void encodeSize (NSSize size) | |
54 { | |
55 return invokeObjcSelf!(void, "encodeSize:", NSSize)(size); | |
56 } | |
57 | |
58 NSSize decodeSize () | |
59 { | |
60 return invokeObjcSelf!(NSSize, "decodeSize"); | |
61 } | |
62 | |
63 void encodeRect (NSRect rect) | |
64 { | |
65 return invokeObjcSelf!(void, "encodeRect:", NSRect)(rect); | |
66 } | |
67 | |
68 NSRect decodeRect () | |
69 { | |
70 return invokeObjcSelf!(NSRect, "decodeRect"); | |
71 } | |
72 } | |
73 | |
74 template TNSValueGeometryExtensions () | |
75 { | |
76 static NSValue valueWithPoint (NSPoint point) | |
77 { | |
78 return invokeObjcSelfClass!(NSValue, "valueWithPoint:", NSPoint)(point); | |
79 } | |
80 | |
81 static NSValue valueWithSize (NSSize size) | |
82 { | |
83 return invokeObjcSelfClass!(NSValue, "valueWithSize:", NSSize)(size); | |
84 } | |
85 | |
86 static NSValue valueWithRect (NSRect rect) | |
87 { | |
88 return invokeObjcSelfClass!(NSValue, "valueWithRect:", NSRect)(rect); | |
89 } | |
90 | |
91 NSPoint pointValue () | |
92 { | |
93 return invokeObjcSelf!(NSPoint, "pointValue"); | |
94 } | |
95 | |
96 NSSize sizeValue () | |
97 { | |
98 return invokeObjcSelf!(NSSize, "sizeValue"); | |
99 } | |
100 | |
101 NSRect rectValue () | |
102 { | |
103 return invokeObjcSelf!(NSRect, "rectValue"); | |
104 } | |
105 } | |
106 | |
107 NSString NSStringFromPoint (NSPoint aPoint) | |
108 { | |
109 return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromPoint, NSPoint)(aPoint); | |
110 } | |
111 | |
112 NSString NSStringFromSize (NSSize aSize) | |
113 { | |
114 return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromSize, NSSize)(aSize); | |
115 } | |
116 | |
117 NSString NSStringFromRect (NSRect aRect) | |
118 { | |
119 return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromRect, NSRect)(aRect); | |
120 } | |
121 | |
122 NSPoint NSPointFromString (NSString aString) | |
123 { | |
124 return Bridge.invokeObjcFunction!(NSPoint, bindings.NSPointFromString, NSString)(aString); | |
125 } | |
126 | |
127 NSSize NSSizeFromString (NSString aString) | |
128 { | |
129 return Bridge.invokeObjcFunction!(NSSize, bindings.NSSizeFromString, NSString)(aString); | |
130 } | |
131 | |
132 NSRect NSRectFromString (NSString aString) | |
133 { | |
134 return Bridge.invokeObjcFunction!(NSRect, bindings.NSRectFromString, NSString)(aString); | |
135 } | |
136 | |
137 extern (C) | |
138 { | |
139 bool NSEqualPoints (NSPoint aPoint, NSPoint bPoint); | |
140 bool NSEqualSizes (NSSize aSize, NSSize bSize); | |
141 bool NSEqualRects (NSRect aRect, NSRect bRect); | |
142 bool NSIsEmptyRect (NSRect aRect); | |
143 NSRect NSInsetRect (NSRect aRect, CGFloat dX, CGFloat dY); | |
144 NSRect NSIntegralRect (NSRect aRect); | |
145 NSRect NSUnionRect (NSRect aRect, NSRect bRect); | |
146 NSRect NSIntersectionRect (NSRect aRect, NSRect bRect); | |
147 NSRect NSOffsetRect (NSRect aRect, CGFloat dX, CGFloat dY); | |
148 void NSDivideRect (NSRect inRect, NSRect* slice, NSRect* rem, CGFloat amount, int edge); | |
149 bool NSPointInRect (NSPoint aPoint, NSRect aRect); | |
150 bool NSMouseInRect (NSPoint aPoint, NSRect aRect, bool flipped); | |
151 bool NSContainsRect (NSRect aRect, NSRect bRect); | |
152 bool NSIntersectsRect (NSRect aRect, NSRect bRect); | |
153 } |