Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSBezierPath.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * | |
11 * Port to the D Programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
13 *******************************************************************************/ | |
14 module dwt.internal.cocoa.NSBezierPath; | |
15 | |
16 import dwt.internal.cocoa.CGFloat; | |
17 import dwt.internal.cocoa.NSAffineTransform; | |
18 import dwt.internal.cocoa.NSFont; | |
19 import dwt.internal.cocoa.NSInteger; | |
20 import dwt.internal.cocoa.NSObject; | |
21 import dwt.internal.cocoa.NSPoint; | |
22 import dwt.internal.cocoa.NSRect; | |
23 import dwt.internal.cocoa.OS; | |
24 import objc = dwt.internal.objc.runtime; | |
25 | |
26 enum NSBezierPathElement | |
27 { | |
28 NSMoveToBezierPathElement, | |
29 NSLineToBezierPathElement, | |
30 NSCurveToBezierPathElement, | |
31 NSClosePathBezierPathElement | |
32 } | |
33 | |
34 public class NSBezierPath : NSObject | |
35 { | |
36 public this () | |
37 { | |
38 super(); | |
39 } | |
40 | |
41 public this (objc.id id) | |
42 { | |
43 super(id); | |
44 } | |
45 | |
46 public void addClip () | |
47 { | |
48 OS.objc_msgSend(this.id, OS.sel_addClip); | |
49 } | |
50 | |
51 public void appendBezierPath (NSBezierPath path) | |
52 { | |
53 OS.objc_msgSend(this.id, OS.sel_appendBezierPath_1, path !is null ? path.id : null); | |
54 } | |
55 | |
56 public void appendBezierPathWithArcFromPoint (NSPoint point1, NSPoint point2, CGFloat radius) | |
57 { | |
58 OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcFromPoint_1toPoint_1radius_1, point1, point2, radius); | |
59 } | |
60 | |
61 public void appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_ (NSPoint center, CGFloat radius, CGFloat startAngle, CGFloat endAngle) | |
62 { | |
63 OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcWithCenter_1radius_1startAngle_1endAngle_1, center, radius, startAngle, endAngle); | |
64 } | |
65 | |
66 public void appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_ (NSPoint center, CGFloat radius, CGFloat startAngle, | |
67 CGFloat endAngle, bool clockwise) | |
68 { | |
69 OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcWithCenter_1radius_1startAngle_1endAngle_1clockwise_1, center, radius, startAngle, | |
70 endAngle, clockwise); | |
71 } | |
72 | |
73 public void appendBezierPathWithGlyph (objc.id glyph, NSFont font) | |
74 { | |
75 OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithGlyph_1inFont_1, glyph, font !is null ? font.id : null); | |
76 } | |
77 | |
78 public void appendBezierPathWithGlyphs (objc.id glyphs, NSInteger count, NSFont font) | |
79 { | |
80 OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithGlyphs_1count_1inFont_1, glyphs, count, font !is null ? font.id : null); | |
81 } | |
82 | |
83 public void appendBezierPathWithOvalInRect (NSRect rect) | |
84 { | |
85 OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithOvalInRect_1, rect); | |
86 } | |
87 | |
88 public void appendBezierPathWithPackedGlyphs (objc.id packedGlyphs) | |
89 { | |
90 OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithPackedGlyphs_1, packedGlyphs); | |
91 } | |
92 | |
93 public void appendBezierPathWithPoints (objc.id points, NSInteger count) | |
94 { | |
95 OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithPoints_1count_1, points, count); | |
96 } | |
97 | |
98 public void appendBezierPathWithRect (NSRect rect) | |
99 { | |
100 OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithRect_1, rect); | |
101 } | |
102 | |
103 public void appendBezierPathWithRoundedRect (NSRect rect, CGFloat xRadius, CGFloat yRadius) | |
104 { | |
105 OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithRoundedRect_1xRadius_1yRadius_1, rect, xRadius, yRadius); | |
106 } | |
107 | |
108 public static NSBezierPath bezierPath () | |
109 { | |
110 objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPath); | |
111 return result !is null ? new NSBezierPath(result) : null; | |
112 } | |
113 | |
114 public NSBezierPath bezierPathByFlatteningPath () | |
115 { | |
116 objc.id result = OS.objc_msgSend(this.id, OS.sel_bezierPathByFlatteningPath); | |
117 return result is this.id ? this : (result !is null ? new NSBezierPath(result) : null); | |
118 } | |
119 | |
120 public NSBezierPath bezierPathByReversingPath () | |
121 { | |
122 objc.id result = OS.objc_msgSend(this.id, OS.sel_bezierPathByReversingPath); | |
123 return result is this.id ? this : (result !is null ? new NSBezierPath(result) : null); | |
124 } | |
125 | |
126 public static NSBezierPath bezierPathWithOvalInRect (NSRect rect) | |
127 { | |
128 objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithOvalInRect_1, rect); | |
129 return result !is null ? new NSBezierPath(result) : null; | |
130 } | |
131 | |
132 public static NSBezierPath bezierPathWithRect (NSRect rect) | |
133 { | |
134 objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithRect_1, rect); | |
135 return result !is null ? new NSBezierPath(result) : null; | |
136 } | |
137 | |
138 public static NSBezierPath bezierPathWithRoundedRect (NSRect rect, CGFloat xRadius, CGFloat yRadius) | |
139 { | |
140 objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithRoundedRect_1xRadius_1yRadius_1, rect, xRadius, yRadius); | |
141 return result !is null ? new NSBezierPath(result) : null; | |
142 } | |
143 | |
144 public NSRect bounds () | |
145 { | |
146 NSRect result; | |
147 OS.objc_msgSend_stret(result, this.id, OS.sel_bounds); | |
148 return result; | |
149 } | |
150 | |
151 public bool cachesBezierPath () | |
152 { | |
153 return OS.objc_msgSend(this.id, OS.sel_cachesBezierPath) !is null; | |
154 } | |
155 | |
156 public static void clipRect (NSRect rect) | |
157 { | |
158 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_clipRect_1, rect); | |
159 } | |
160 | |
161 public void closePath () | |
162 { | |
163 OS.objc_msgSend(this.id, OS.sel_closePath); | |
164 } | |
165 | |
166 public bool containsPoint (NSPoint point) | |
167 { | |
168 return OS.objc_msgSend(this.id, OS.sel_containsPoint_1, point) !is null; | |
169 } | |
170 | |
171 public NSRect controlPointBounds () | |
172 { | |
173 NSRect result; | |
174 OS.objc_msgSend_stret(result, this.id, OS.sel_controlPointBounds); | |
175 return result; | |
176 } | |
177 | |
178 public NSPoint currentPoint () | |
179 { | |
180 NSPoint result; | |
181 OS.objc_msgSend_stret(result, this.id, OS.sel_currentPoint); | |
182 return result; | |
183 } | |
184 | |
185 public void curveToPoint (NSPoint endPoint, NSPoint controlPoint1, NSPoint controlPoint2) | |
186 { | |
187 OS.objc_msgSend(this.id, OS.sel_curveToPoint_1controlPoint1_1controlPoint2_1, endPoint, controlPoint1, controlPoint2); | |
188 } | |
189 | |
190 public static CGFloat defaultFlatness () | |
191 { | |
192 return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultFlatness); | |
193 } | |
194 | |
195 public static objc.id defaultLineCapStyle () | |
196 { | |
197 return OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultLineCapStyle); | |
198 } | |
199 | |
200 public static objc.id defaultLineJoinStyle () | |
201 { | |
202 return OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultLineJoinStyle); | |
203 } | |
204 | |
205 public static CGFloat defaultLineWidth () | |
206 { | |
207 return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultLineWidth); | |
208 } | |
209 | |
210 public static CGFloat defaultMiterLimit () | |
211 { | |
212 return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultMiterLimit); | |
213 } | |
214 | |
215 public static objc.id defaultWindingRule () | |
216 { | |
217 return OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultWindingRule); | |
218 } | |
219 | |
220 public static void drawPackedGlyphs (/*const*/char* packedGlyphs, NSPoint point) | |
221 { | |
222 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_drawPackedGlyphs_1atPoint_1, packedGlyphs, point); | |
223 } | |
224 | |
225 public objc.id elementAtIndex_ (NSInteger index) | |
226 { | |
227 return OS.objc_msgSend(this.id, OS.sel_elementAtIndex_1, index); | |
228 } | |
229 | |
230 public NSBezierPathElement elementAtIndex_associatedPoints_ (NSInteger index, NSPointArray points) | |
231 { | |
232 return OS.objc_msgSend(this.id, OS.sel_elementAtIndex_1associatedPoints_1, index, points); | |
233 } | |
234 | |
235 public NSInteger elementCount () | |
236 { | |
237 return OS.objc_msgSend(this.id, OS.sel_elementCount); | |
238 } | |
239 | |
240 public void fill () | |
241 { | |
242 OS.objc_msgSend(this.id, OS.sel_fill); | |
243 } | |
244 | |
245 public static void fillRect (NSRect rect) | |
246 { | |
247 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_fillRect_1, rect); | |
248 } | |
249 | |
250 public CGFloat flatness () | |
251 { | |
252 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_flatness); | |
253 } | |
254 | |
255 public void getLineDash (CGFloat* pattern, NSInteger* count, CGFloat* phase) | |
256 { | |
257 OS.objc_msgSend(this.id, OS.sel_getLineDash_1count_1phase_1, pattern, count, phase); | |
258 } | |
259 | |
260 public bool isEmpty () | |
261 { | |
262 return OS.objc_msgSend(this.id, OS.sel_isEmpty) !is null; | |
263 } | |
264 | |
265 public objc.id lineCapStyle () | |
266 { | |
267 return OS.objc_msgSend(this.id, OS.sel_lineCapStyle); | |
268 } | |
269 | |
270 public objc.id lineJoinStyle () | |
271 { | |
272 return OS.objc_msgSend(this.id, OS.sel_lineJoinStyle); | |
273 } | |
274 | |
275 public void lineToPoint (NSPoint point) | |
276 { | |
277 OS.objc_msgSend(this.id, OS.sel_lineToPoint_1, point); | |
278 } | |
279 | |
280 public CGFloat lineWidth () | |
281 { | |
282 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_lineWidth); | |
283 } | |
284 | |
285 public CGFloat miterLimit () | |
286 { | |
287 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_miterLimit); | |
288 } | |
289 | |
290 public void moveToPoint (NSPoint point) | |
291 { | |
292 OS.objc_msgSend(this.id, OS.sel_moveToPoint_1, point); | |
293 } | |
294 | |
295 public void relativeCurveToPoint (NSPoint endPoint, NSPoint controlPoint1, NSPoint controlPoint2) | |
296 { | |
297 OS.objc_msgSend(this.id, OS.sel_relativeCurveToPoint_1controlPoint1_1controlPoint2_1, endPoint, controlPoint1, controlPoint2); | |
298 } | |
299 | |
300 public void relativeLineToPoint (NSPoint point) | |
301 { | |
302 OS.objc_msgSend(this.id, OS.sel_relativeLineToPoint_1, point); | |
303 } | |
304 | |
305 public void relativeMoveToPoint (NSPoint point) | |
306 { | |
307 OS.objc_msgSend(this.id, OS.sel_relativeMoveToPoint_1, point); | |
308 } | |
309 | |
310 public void removeAllPoints () | |
311 { | |
312 OS.objc_msgSend(this.id, OS.sel_removeAllPoints); | |
313 } | |
314 | |
315 public void setAssociatedPoints (NSPointArray points, NSInteger index) | |
316 { | |
317 OS.objc_msgSend(this.id, OS.sel_setAssociatedPoints_1atIndex_1, points, index); | |
318 } | |
319 | |
320 public void setCachesBezierPath (bool flag) | |
321 { | |
322 OS.objc_msgSend(this.id, OS.sel_setCachesBezierPath_1, flag); | |
323 } | |
324 | |
325 public void setClip () | |
326 { | |
327 OS.objc_msgSend(this.id, OS.sel_setClip); | |
328 } | |
329 | |
330 public static void setDefaultFlatness (CGFloat flatness) | |
331 { | |
332 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultFlatness_1, flatness); | |
333 } | |
334 | |
335 public static void setDefaultLineCapStyle (objc.id lineCapStyle) | |
336 { | |
337 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineCapStyle_1, lineCapStyle); | |
338 } | |
339 | |
340 public static void setDefaultLineJoinStyle (objc.id lineJoinStyle) | |
341 { | |
342 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineJoinStyle_1, lineJoinStyle); | |
343 } | |
344 | |
345 public static void setDefaultLineWidth (CGFloat lineWidth) | |
346 { | |
347 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineWidth_1, lineWidth); | |
348 } | |
349 | |
350 public static void setDefaultMiterLimit (CGFloat limit) | |
351 { | |
352 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultMiterLimit_1, limit); | |
353 } | |
354 | |
355 public static void setDefaultWindingRule (objc.id windingRule) | |
356 { | |
357 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultWindingRule_1, windingRule); | |
358 } | |
359 | |
360 public void setFlatness (CGFloat flatness) | |
361 { | |
362 OS.objc_msgSend(this.id, OS.sel_setFlatness_1, flatness); | |
363 } | |
364 | |
365 public void setLineCapStyle (objc.id lineCapStyle) | |
366 { | |
367 OS.objc_msgSend(this.id, OS.sel_setLineCapStyle_1, lineCapStyle); | |
368 } | |
369 | |
370 public void setLineDash (/*const*/CGFloat* pattern, NSInteger count, CGFloat phase) | |
371 { | |
372 OS.objc_msgSend(this.id, OS.sel_setLineDash_1count_1phase_1, pattern, count, phase); | |
373 } | |
374 | |
375 public void setLineJoinStyle (objc.id lineJoinStyle) | |
376 { | |
377 OS.objc_msgSend(this.id, OS.sel_setLineJoinStyle_1, lineJoinStyle); | |
378 } | |
379 | |
380 public void setLineWidth (CGFloat lineWidth) | |
381 { | |
382 OS.objc_msgSend(this.id, OS.sel_setLineWidth_1, lineWidth); | |
383 } | |
384 | |
385 public void setMiterLimit (CGFloat miterLimit) | |
386 { | |
387 OS.objc_msgSend(this.id, OS.sel_setMiterLimit_1, miterLimit); | |
388 } | |
389 | |
390 public void setWindingRule (objc.id windingRule) | |
391 { | |
392 OS.objc_msgSend(this.id, OS.sel_setWindingRule_1, windingRule); | |
393 } | |
394 | |
395 public void stroke () | |
396 { | |
397 OS.objc_msgSend(this.id, OS.sel_stroke); | |
398 } | |
399 | |
400 public static void strokeLineFromPoint (NSPoint point1, NSPoint point2) | |
401 { | |
402 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeLineFromPoint_1toPoint_1, point1, point2); | |
403 } | |
404 | |
405 public static void strokeRect (NSRect rect) | |
406 { | |
407 OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeRect_1, rect); | |
408 } | |
409 | |
410 public void transformUsingAffineTransform (NSAffineTransform transform) | |
411 { | |
412 OS.objc_msgSend(this.id, OS.sel_transformUsingAffineTransform_1, transform !is null ? transform.id : null); | |
413 } | |
414 | |
415 public objc.id windingRule () | |
416 { | |
417 return OS.objc_msgSend(this.id, OS.sel_windingRule); | |
418 } | |
419 } |