Mercurial > projects > dwt-mac
view dwt/internal/cocoa/NSBezierPath.d @ 34:5123b17c98ef
Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sun, 14 Sep 2008 01:45:57 +0200 |
parents | f565d3a95c0a |
children | db5a898b2119 |
line wrap: on
line source
/******************************************************************************* * 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 } NSBezierPathElement.NSMoveToBezierPathElement NSMoveToBezierPathElement; NSBezierPathElement.NSLineToBezierPathElement NSLineToBezierPathElement; NSBezierPathElement.NSCurveToBezierPathElement NSCurveToBezierPathElement; NSBezierPathElement.NSClosePathBezierPathElement NSClosePathBezierPathElement; enum NSLineCapStyle { NSButtLineCapStyle = 0, NSRoundLineCapStyle = 1, NSSquareLineCapStyle = 2 } NSLineCapStyle.NSButtLineCapStyle NSButtLineCapStyle; NSLineCapStyle.NSRoundLineCapStyle NSRoundLineCapStyle; NSLineCapStyle.NSSquareLineCapStyle NSSquareLineCapStyle; enum NSLineJoinStyle { NSMiterLineJoinStyle = 0, NSRoundLineJoinStyle = 1, NSBevelLineJoinStyle = 2 } NSLineJoinStyle.NSMiterLineJoinStyle NSMiterLineJoinStyle; NSLineJoinStyle.NSRoundLineJoinStyle NSRoundLineJoinStyle; NSLineJoinStyle.NSBevelLineJoinStyle NSBevelLineJoinStyle; enum NSWindingRule { NSNonZeroWindingRule = 0, NSEvenOddWindingRule = 1 } alias NSWindingRule.NSNonZeroWindingRule NSNonZeroWindingRule; alias NSWindingRule.NSEvenOddWindingRule NSEvenOddWindingRule; 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 (NSGlyph glyph, NSFont font) { OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithGlyph_1inFont_1, glyph, font !is null ? font.id_ : null); } public void appendBezierPathWithGlyphs (NSGlyph* 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 (/*const*/char* packedGlyphs) { OS.objc_msgSend(this.id_, OS.sel_appendBezierPathWithPackedGlyphs_1, packedGlyphs); } public void appendBezierPathWithPoints (NSPointArray 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 NSLineCapStyle defaultLineCapStyle () { return cast(NSLineCapStyle) OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultLineCapStyle); } public static NSLineJoinStyle defaultLineJoinStyle () { return cast(NSLineJoinStyle) 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 NSWindingRule defaultWindingRule () { return cast(NSWindingRule) 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 NSBezierPathElement elementAtIndex_ (NSInteger index) { return cast(NSBezierPathElement) OS.objc_msgSend(this.id_, OS.sel_elementAtIndex_1, index); } public NSBezierPathElement elementAtIndex_associatedPoints_ (NSInteger index, NSPointArray points) { return cast(NSBezierPathElement) OS.objc_msgSend(this.id_, OS.sel_elementAtIndex_1associatedPoints_1, index, points); } public NSInteger elementCount () { return cast(NSInteger) 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 NSLineCapStyle lineCapStyle () { return cast(NSLineCapStyle) OS.objc_msgSend(this.id_, OS.sel_lineCapStyle); } public NSLineJoinStyle lineJoinStyle () { return cast(NSLineJoinStyle) 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 (NSLineCapStyle lineCapStyle) { OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineCapStyle_1, lineCapStyle); } public static void setDefaultLineJoinStyle (NSLineJoinStyle 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 (NSWindingRule 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 (NSLineCapStyle 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 (NSLineJoinStyle 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 (NSWindingRule 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 NSWindingRule windingRule () { return cast(NSWindingRule) OS.objc_msgSend(this.id_, OS.sel_windingRule); } }