Mercurial > projects > dwt-mac
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/cocoa/NSBezierPath.d Sat Aug 09 17:00:02 2008 +0200 @@ -0,0 +1,419 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * + * Port to the D Programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> + *******************************************************************************/ +module dwt.internal.cocoa.NSBezierPath; + +import dwt.internal.cocoa.CGFloat; +import dwt.internal.cocoa.NSAffineTransform; +import dwt.internal.cocoa.NSFont; +import dwt.internal.cocoa.NSInteger; +import dwt.internal.cocoa.NSObject; +import dwt.internal.cocoa.NSPoint; +import dwt.internal.cocoa.NSRect; +import dwt.internal.cocoa.OS; +import objc = dwt.internal.objc.runtime; + +enum NSBezierPathElement +{ + NSMoveToBezierPathElement, + NSLineToBezierPathElement, + NSCurveToBezierPathElement, + NSClosePathBezierPathElement +} + +public class NSBezierPath : NSObject +{ + public this () + { + super(); + } + + public this (objc.id id) + { + super(id); + } + + public void addClip () + { + OS.objc_msgSend(this.id, OS.sel_addClip); + } + + public void appendBezierPath (NSBezierPath path) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPath_1, path !is null ? path.id : null); + } + + public void appendBezierPathWithArcFromPoint (NSPoint point1, NSPoint point2, CGFloat radius) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcFromPoint_1toPoint_1radius_1, point1, point2, radius); + } + + public void appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_ (NSPoint center, CGFloat radius, CGFloat startAngle, CGFloat endAngle) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcWithCenter_1radius_1startAngle_1endAngle_1, center, radius, startAngle, endAngle); + } + + public void appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_ (NSPoint center, CGFloat radius, CGFloat startAngle, + CGFloat endAngle, bool clockwise) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcWithCenter_1radius_1startAngle_1endAngle_1clockwise_1, center, radius, startAngle, + endAngle, clockwise); + } + + public void appendBezierPathWithGlyph (objc.id glyph, NSFont font) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithGlyph_1inFont_1, glyph, font !is null ? font.id : null); + } + + public void appendBezierPathWithGlyphs (objc.id glyphs, NSInteger count, NSFont font) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithGlyphs_1count_1inFont_1, glyphs, count, font !is null ? font.id : null); + } + + public void appendBezierPathWithOvalInRect (NSRect rect) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithOvalInRect_1, rect); + } + + public void appendBezierPathWithPackedGlyphs (objc.id packedGlyphs) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithPackedGlyphs_1, packedGlyphs); + } + + public void appendBezierPathWithPoints (objc.id points, NSInteger count) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithPoints_1count_1, points, count); + } + + public void appendBezierPathWithRect (NSRect rect) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithRect_1, rect); + } + + public void appendBezierPathWithRoundedRect (NSRect rect, CGFloat xRadius, CGFloat yRadius) + { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithRoundedRect_1xRadius_1yRadius_1, rect, xRadius, yRadius); + } + + public static NSBezierPath bezierPath () + { + objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPath); + return result !is null ? new NSBezierPath(result) : null; + } + + public NSBezierPath bezierPathByFlatteningPath () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_bezierPathByFlatteningPath); + return result is this.id ? this : (result !is null ? new NSBezierPath(result) : null); + } + + public NSBezierPath bezierPathByReversingPath () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_bezierPathByReversingPath); + return result is this.id ? this : (result !is null ? new NSBezierPath(result) : null); + } + + public static NSBezierPath bezierPathWithOvalInRect (NSRect rect) + { + objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithOvalInRect_1, rect); + return result !is null ? new NSBezierPath(result) : null; + } + + public static NSBezierPath bezierPathWithRect (NSRect rect) + { + objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithRect_1, rect); + return result !is null ? new NSBezierPath(result) : null; + } + + public static NSBezierPath bezierPathWithRoundedRect (NSRect rect, CGFloat xRadius, CGFloat yRadius) + { + objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithRoundedRect_1xRadius_1yRadius_1, rect, xRadius, yRadius); + return result !is null ? new NSBezierPath(result) : null; + } + + public NSRect bounds () + { + NSRect result; + OS.objc_msgSend_stret(result, this.id, OS.sel_bounds); + return result; + } + + public bool cachesBezierPath () + { + return OS.objc_msgSend(this.id, OS.sel_cachesBezierPath) !is null; + } + + public static void clipRect (NSRect rect) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_clipRect_1, rect); + } + + public void closePath () + { + OS.objc_msgSend(this.id, OS.sel_closePath); + } + + public bool containsPoint (NSPoint point) + { + return OS.objc_msgSend(this.id, OS.sel_containsPoint_1, point) !is null; + } + + public NSRect controlPointBounds () + { + NSRect result; + OS.objc_msgSend_stret(result, this.id, OS.sel_controlPointBounds); + return result; + } + + public NSPoint currentPoint () + { + NSPoint result; + OS.objc_msgSend_stret(result, this.id, OS.sel_currentPoint); + return result; + } + + public void curveToPoint (NSPoint endPoint, NSPoint controlPoint1, NSPoint controlPoint2) + { + OS.objc_msgSend(this.id, OS.sel_curveToPoint_1controlPoint1_1controlPoint2_1, endPoint, controlPoint1, controlPoint2); + } + + public static CGFloat defaultFlatness () + { + return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultFlatness); + } + + public static objc.id defaultLineCapStyle () + { + return OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultLineCapStyle); + } + + public static objc.id defaultLineJoinStyle () + { + return OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultLineJoinStyle); + } + + public static CGFloat defaultLineWidth () + { + return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultLineWidth); + } + + public static CGFloat defaultMiterLimit () + { + return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultMiterLimit); + } + + public static objc.id defaultWindingRule () + { + return OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultWindingRule); + } + + public static void drawPackedGlyphs (/*const*/char* packedGlyphs, NSPoint point) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_drawPackedGlyphs_1atPoint_1, packedGlyphs, point); + } + + public objc.id elementAtIndex_ (NSInteger index) + { + return OS.objc_msgSend(this.id, OS.sel_elementAtIndex_1, index); + } + + public NSBezierPathElement elementAtIndex_associatedPoints_ (NSInteger index, NSPointArray points) + { + return OS.objc_msgSend(this.id, OS.sel_elementAtIndex_1associatedPoints_1, index, points); + } + + public NSInteger elementCount () + { + return OS.objc_msgSend(this.id, OS.sel_elementCount); + } + + public void fill () + { + OS.objc_msgSend(this.id, OS.sel_fill); + } + + public static void fillRect (NSRect rect) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_fillRect_1, rect); + } + + public CGFloat flatness () + { + return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_flatness); + } + + public void getLineDash (CGFloat* pattern, NSInteger* count, CGFloat* phase) + { + OS.objc_msgSend(this.id, OS.sel_getLineDash_1count_1phase_1, pattern, count, phase); + } + + public bool isEmpty () + { + return OS.objc_msgSend(this.id, OS.sel_isEmpty) !is null; + } + + public objc.id lineCapStyle () + { + return OS.objc_msgSend(this.id, OS.sel_lineCapStyle); + } + + public objc.id lineJoinStyle () + { + return OS.objc_msgSend(this.id, OS.sel_lineJoinStyle); + } + + public void lineToPoint (NSPoint point) + { + OS.objc_msgSend(this.id, OS.sel_lineToPoint_1, point); + } + + public CGFloat lineWidth () + { + return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_lineWidth); + } + + public CGFloat miterLimit () + { + return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_miterLimit); + } + + public void moveToPoint (NSPoint point) + { + OS.objc_msgSend(this.id, OS.sel_moveToPoint_1, point); + } + + public void relativeCurveToPoint (NSPoint endPoint, NSPoint controlPoint1, NSPoint controlPoint2) + { + OS.objc_msgSend(this.id, OS.sel_relativeCurveToPoint_1controlPoint1_1controlPoint2_1, endPoint, controlPoint1, controlPoint2); + } + + public void relativeLineToPoint (NSPoint point) + { + OS.objc_msgSend(this.id, OS.sel_relativeLineToPoint_1, point); + } + + public void relativeMoveToPoint (NSPoint point) + { + OS.objc_msgSend(this.id, OS.sel_relativeMoveToPoint_1, point); + } + + public void removeAllPoints () + { + OS.objc_msgSend(this.id, OS.sel_removeAllPoints); + } + + public void setAssociatedPoints (NSPointArray points, NSInteger index) + { + OS.objc_msgSend(this.id, OS.sel_setAssociatedPoints_1atIndex_1, points, index); + } + + public void setCachesBezierPath (bool flag) + { + OS.objc_msgSend(this.id, OS.sel_setCachesBezierPath_1, flag); + } + + public void setClip () + { + OS.objc_msgSend(this.id, OS.sel_setClip); + } + + public static void setDefaultFlatness (CGFloat flatness) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultFlatness_1, flatness); + } + + public static void setDefaultLineCapStyle (objc.id lineCapStyle) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineCapStyle_1, lineCapStyle); + } + + public static void setDefaultLineJoinStyle (objc.id lineJoinStyle) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineJoinStyle_1, lineJoinStyle); + } + + public static void setDefaultLineWidth (CGFloat lineWidth) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineWidth_1, lineWidth); + } + + public static void setDefaultMiterLimit (CGFloat limit) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultMiterLimit_1, limit); + } + + public static void setDefaultWindingRule (objc.id windingRule) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultWindingRule_1, windingRule); + } + + public void setFlatness (CGFloat flatness) + { + OS.objc_msgSend(this.id, OS.sel_setFlatness_1, flatness); + } + + public void setLineCapStyle (objc.id lineCapStyle) + { + OS.objc_msgSend(this.id, OS.sel_setLineCapStyle_1, lineCapStyle); + } + + public void setLineDash (/*const*/CGFloat* pattern, NSInteger count, CGFloat phase) + { + OS.objc_msgSend(this.id, OS.sel_setLineDash_1count_1phase_1, pattern, count, phase); + } + + public void setLineJoinStyle (objc.id lineJoinStyle) + { + OS.objc_msgSend(this.id, OS.sel_setLineJoinStyle_1, lineJoinStyle); + } + + public void setLineWidth (CGFloat lineWidth) + { + OS.objc_msgSend(this.id, OS.sel_setLineWidth_1, lineWidth); + } + + public void setMiterLimit (CGFloat miterLimit) + { + OS.objc_msgSend(this.id, OS.sel_setMiterLimit_1, miterLimit); + } + + public void setWindingRule (objc.id windingRule) + { + OS.objc_msgSend(this.id, OS.sel_setWindingRule_1, windingRule); + } + + public void stroke () + { + OS.objc_msgSend(this.id, OS.sel_stroke); + } + + public static void strokeLineFromPoint (NSPoint point1, NSPoint point2) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeLineFromPoint_1toPoint_1, point1, point2); + } + + public static void strokeRect (NSRect rect) + { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeRect_1, rect); + } + + public void transformUsingAffineTransform (NSAffineTransform transform) + { + OS.objc_msgSend(this.id, OS.sel_transformUsingAffineTransform_1, transform !is null ? transform.id : null); + } + + public objc.id windingRule () + { + return OS.objc_msgSend(this.id, OS.sel_windingRule); + } +}