Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSBezierPath.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | db5a898b2119 |
children | 62202ce0039f |
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSBezierPath.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/internal/cocoa/NSBezierPath.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,26 +1,28 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 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 + * IBM Corporation - initial API and implementation * * Port to the D programming language: - * Jacob Carlborg <jacob.carlborg@gmail.com> + * Jacob Carlborg <doob@me.com> *******************************************************************************/ module dwt.internal.cocoa.NSBezierPath; -import dwt.internal.cocoa.CGFloat; +import dwt.dwthelper.utils; +import dwt.internal.c.Carbon; +import cocoa = dwt.internal.cocoa.id; 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 dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; enum NSBezierPathElement @@ -31,11 +33,6 @@ NSClosePathBezierPathElement } -alias NSBezierPathElement.NSMoveToBezierPathElement NSMoveToBezierPathElement; -alias NSBezierPathElement.NSLineToBezierPathElement NSLineToBezierPathElement; -alias NSBezierPathElement.NSCurveToBezierPathElement NSCurveToBezierPathElement; -alias NSBezierPathElement.NSClosePathBezierPathElement NSClosePathBezierPathElement; - enum NSLineCapStyle { NSButtLineCapStyle = 0, @@ -43,10 +40,6 @@ NSSquareLineCapStyle = 2 } -alias NSLineCapStyle.NSButtLineCapStyle NSButtLineCapStyle; -alias NSLineCapStyle.NSRoundLineCapStyle NSRoundLineCapStyle; -alias NSLineCapStyle.NSSquareLineCapStyle NSSquareLineCapStyle; - enum NSLineJoinStyle { NSMiterLineJoinStyle = 0, @@ -54,402 +47,181 @@ NSBevelLineJoinStyle = 2 } -alias NSLineJoinStyle.NSMiterLineJoinStyle NSMiterLineJoinStyle; -alias NSLineJoinStyle.NSRoundLineJoinStyle NSRoundLineJoinStyle; -alias 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 class NSBezierPath : NSObject { - public this (objc.id id) - { - super(id); - } - - public void addClip () - { - OS.objc_msgSend(this.id_, OS.sel_addClip); - } +public this() { + super(); +} - 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 this(objc.id id) { + super(id); +} - 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 this(cocoa.id id) { + super(id); +} - 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 addClip() { + OS.objc_msgSend(this.id, OS.sel_addClip); +} - 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 appendBezierPath(NSBezierPath path) { + OS.objc_msgSend(this.id, OS.sel_appendBezierPath_, path !is null ? path.id : null); +} - 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 appendBezierPathWithArcWithCenter(NSPoint center, CGFloat radius, CGFloat startAngle, CGFloat endAngle) { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_, center, radius, startAngle, endAngle); +} - 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 void appendBezierPathWithArcWithCenter(NSPoint center, CGFloat radius, CGFloat startAngle, CGFloat endAngle, bool clockwise) { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_, center, radius, startAngle, endAngle, clockwise); +} - 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 void appendBezierPathWithGlyphs(NSGlyph* glyphs, NSInteger count, NSFont font) { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithGlyphs_count_inFont_, glyphs, count, font !is null ? font.id : 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 void appendBezierPathWithOvalInRect(NSRect rect) { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithOvalInRect_, rect); +} - 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 void appendBezierPathWithRect(NSRect rect) { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithRect_, rect); +} - 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 void appendBezierPathWithRoundedRect(NSRect rect, CGFloat xRadius, CGFloat yRadius) { + OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithRoundedRect_xRadius_yRadius_, rect, xRadius, yRadius); +} - 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 NSBezierPath bezierPath() { + objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPath); + return result !is null ? new NSBezierPath(result) : 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 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 NSRect controlPointBounds () - { - NSRect result; - OS.objc_msgSend_stret(&result, this.id_, OS.sel_controlPointBounds); - return result; - } +public static NSBezierPath bezierPathWithRect(NSRect rect) { + objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithRect_, rect); + return result !is null ? new NSBezierPath(result) : null; +} - 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 NSRect bounds() { + NSRect result = NSRect(); + OS.objc_msgSend_stret(result, this.id, OS.sel_bounds); + return result; +} - 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 void closePath() { + OS.objc_msgSend(this.id, OS.sel_closePath); +} - public static CGFloat defaultMiterLimit () - { - return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultMiterLimit); - } +public bool containsPoint(NSPoint point) { + return OS.objc_msgSend_bool(this.id, OS.sel_containsPoint_, point); +} - 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 NSRect controlPointBounds() { + NSRect result = NSRect(); + OS.objc_msgSend_stret(result, this.id, OS.sel_controlPointBounds); + return result; +} - 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 NSPoint currentPoint() { + NSPoint result = NSPoint(); + OS.objc_msgSend_stret(result, this.id, OS.sel_currentPoint); + return result; +} - 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 void curveToPoint(NSPoint endPoint, NSPoint controlPoint1, NSPoint controlPoint2) { + OS.objc_msgSend(this.id, OS.sel_curveToPoint_controlPoint1_controlPoint2_, endPoint, controlPoint1, controlPoint2); +} - 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 static CGFloat defaultFlatness() { + return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultFlatness); +} - public void getLineDash (CGFloat* pattern, NSInteger* count, CGFloat* phase) - { - OS.objc_msgSend(this.id_, OS.sel_getLineDash_1count_1phase_1, pattern, count, phase); - } +public NSBezierPathElement elementAtIndex(NSInteger index, NSPointArray points) { + return cast(NSBezierPathElement) OS.objc_msgSend(this.id, OS.sel_elementAtIndex_associatedPoints_, index, points); +} - 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 NSInteger elementCount() { + return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_elementCount); +} - 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 void fill() { + OS.objc_msgSend(this.id, OS.sel_fill); +} - public CGFloat lineWidth () - { - return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_lineWidth); - } +public static void fillRect(NSRect rect) { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_fillRect_, rect); +} - 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 bool isEmpty() { + return OS.objc_msgSend_bool(this.id, OS.sel_isEmpty); +} - 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 lineToPoint(NSPoint point) { + OS.objc_msgSend(this.id, OS.sel_lineToPoint_, point); +} - public void relativeMoveToPoint (NSPoint point) - { - OS.objc_msgSend(this.id_, OS.sel_relativeMoveToPoint_1, point); - } +public void moveToPoint(NSPoint point) { + OS.objc_msgSend(this.id, OS.sel_moveToPoint_, 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 removeAllPoints() { + OS.objc_msgSend(this.id, OS.sel_removeAllPoints); +} - 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 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 setDefaultFlatness(CGFloat flatness) { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultFlatness_, flatness); +} - 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 void setLineCapStyle(NSLineCapStyle lineCapStyle) { + OS.objc_msgSend(this.id, OS.sel_setLineCapStyle_, lineCapStyle); +} - public static void setDefaultWindingRule (NSWindingRule windingRule) - { - OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultWindingRule_1, windingRule); - } +public void setLineDash(/*const*/CGFloat* pattern, NSInteger count, CGFloat phase) { + OS.objc_msgSend(this.id, OS.sel_setLineDash_count_phase_, pattern, count, phase); +} - 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 setLineJoinStyle(NSLineJoinStyle lineJoinStyle) { + OS.objc_msgSend(this.id, OS.sel_setLineJoinStyle_, lineJoinStyle); +} - 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_, lineWidth); +} - 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_, miterLimit); +} - 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 setWindingRule(NSWindingRule windingRule) { + OS.objc_msgSend(this.id, OS.sel_setWindingRule_, 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 void stroke() { + OS.objc_msgSend(this.id, OS.sel_stroke); +} - public static void strokeRect (NSRect rect) - { - OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeRect_1, rect); - } +public static void strokeRect(NSRect rect) { + OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeRect_, rect); +} - public void transformUsingAffineTransform (NSAffineTransform transform) - { - OS.objc_msgSend(this.id_, OS.sel_transformUsingAffineTransform_1, transform !is null ? transform.id_ : null); - } +public void transformUsingAffineTransform(NSAffineTransform transform) { + OS.objc_msgSend(this.id, OS.sel_transformUsingAffineTransform_, transform !is null ? transform.id : null); +} - public NSWindingRule windingRule () - { - return cast(NSWindingRule) OS.objc_msgSend(this.id_, OS.sel_windingRule); - } }