Mercurial > projects > dwt-mac
diff dwt/graphics/Region.d @ 36:db5a898b2119
Fixed a lot of compile errors
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Tue, 07 Oct 2008 12:56:18 +0200 |
parents | 5123b17c98ef |
children | 642f460a0908 |
line wrap: on
line diff
--- a/dwt/graphics/Region.d Sun Sep 14 23:32:29 2008 +0200 +++ b/dwt/graphics/Region.d Tue Oct 07 12:56:18 2008 +0200 @@ -30,8 +30,9 @@ import dwt.graphics.Point; import dwt.graphics.Rectangle; import dwt.graphics.Resource; +import dwt.internal.c.carboncore.MacTypes; import dwt.internal.c.qd.Quickdraw; -import dwt.internal.c.qd.QuickdrawTypes; +static import QuickdrawTypes = dwt.internal.c.qd.QuickdrawTypes; /** * Instances of this class represent areas of an x-y coordinate @@ -44,6 +45,9 @@ * </p> */ public final class Region : Resource { + + alias Resource.init_ init_; + /** * the OS resource for the region * (Warning: This field is platform dependent) @@ -54,7 +58,7 @@ * platforms and should never be accessed from application code. * </p> */ - public RgnHandle handle; + public QuickdrawTypes.RgnHandle handle; /** * Constructs a new empty region. @@ -90,10 +94,10 @@ super(device); handle = OS.NewRgn(); if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); - init(); + init_(); } -this(Device device, RgnHandle handle) { +this(Device device, QuickdrawTypes.RgnHandle handle) { super(device); this.handle = handle; } @@ -122,7 +126,7 @@ void add(int[] pointArray, int count) { if (count <= 2) return; - RgnHandle polyRgn = OS.NewRgn(); + QuickdrawTypes.RgnHandle polyRgn = OS.NewRgn(); OS.OpenRgn(); OS.MoveTo(cast(short)pointArray[0], cast(short)pointArray[1]); for (int i = 1; i < count / 2; i++) { @@ -176,7 +180,7 @@ public void add(int x, int y, int width, int height) { if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT); - RgnHandle rectRgn = OS.NewRgn(); + QuickdrawTypes.RgnHandle rectRgn = OS.NewRgn(); Rect r; OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height)); OS.RectRgn(rectRgn, &r); @@ -221,7 +225,7 @@ */ public bool contains(int x, int y) { if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); - Point point = Point(cast(short)x, cast(short)y); + QuickdrawTypes.Point point = {cast(short)x, cast(short)y}; return OS.PtInRgn(point, handle); } @@ -247,8 +251,8 @@ NSAffineTransform transform; void convertRgn(NSAffineTransform transform) { - RgnHandle newRgn = OS.NewRgn(); - RegionToRectsUPP proc = &convertRgn; + QuickdrawTypes.RgnHandle newRgn = OS.NewRgn(); + RegionToRectsUPP proc = &Region.convertRgn_; this.transform = transform; OS.QDRegionToRects(handle, OS.kQDParseRegionFromTopLeft, proc, newRgn); this.transform = null; @@ -256,12 +260,12 @@ OS.DisposeRgn(newRgn); } -extern(C) private static OSStatus* convertRgn(ushort message, RgnHandle rgn, Rect* r, void* newRgn) { +extern(C) private static OSStatus* convertRgn_(ushort message, QuickdrawTypes.RgnHandle rgn, Rect* r, void* newRgn) { if (message is OS.kQDRegionToRectsMsgParse) { Rect rect; OS.memmove(&rect, r, rect.sizeof); NSPoint point = NSPoint(); - RgnHandle polyRgn = OS.NewRgn(); + QuickdrawTypes.RgnHandle polyRgn = OS.NewRgn(); OS.OpenRgn(); point.x = rect.left; point.y = rect.top; @@ -282,7 +286,7 @@ OS.LineTo(cast(short)point.x, cast(short)Math.round(point.y)); OS.LineTo(startX, startY); OS.CloseRgn(polyRgn); - OS.UnionRgn(newRgn, polyRgn, newRgn); + OS.UnionRgn(cast(QuickdrawTypes.RgnHandle) newRgn, polyRgn, cast(QuickdrawTypes.RgnHandle) newRgn); OS.DisposeRgn(polyRgn); } return null; @@ -290,7 +294,7 @@ void destroy() { OS.DisposeRgn(handle); - handle = 0; + handle = null; } /** @@ -337,32 +341,32 @@ NSBezierPath getPath() { NSBezierPath path = NSBezierPath.bezierPath(); path.retain(); - OS.QDRegionToRects(handle, OS.kQDParseRegionFromTopLeft, ®ionToRects, path.id_); + OS.QDRegionToRects(handle, OS.kQDParseRegionFromTopLeft, &Region.regionToRects, path.id_); if (path.isEmpty()) path.appendBezierPathWithRect(NSRect()); return path; } -NSPoint pt = NSPoint(); -Rect rect; -extern(C) private static OSStatus* regionToRects(ushort message, RgnHandle rgn, Rect* r, void* path) { +static NSPoint pt = NSPoint(); +static Rect rect; +extern(C) private static OSStatus* regionToRects(ushort message, QuickdrawTypes.RgnHandle rgn, Rect* r, void* path) { if (message is OS.kQDRegionToRectsMsgParse) { - OS.memmove(rect, r, rect.sizeof); + OS.memmove(&rect, r, rect.sizeof); pt.x = rect.left; pt.y = rect.top; - OS.objc_msgSend(path, OS.sel_moveToPoint_1, pt); + OS.objc_msgSend(cast(objc.id) path, OS.sel_moveToPoint_1, pt); pt.x = rect.right; - OS.objc_msgSend(path, OS.sel_lineToPoint_1, pt); + OS.objc_msgSend(cast(objc.id) path, OS.sel_lineToPoint_1, pt); pt.x = rect.right; pt.y = rect.bottom; - OS.objc_msgSend(path, OS.sel_lineToPoint_1, pt); + OS.objc_msgSend(cast(objc.id) path, OS.sel_lineToPoint_1, pt); pt.x = rect.left; - OS.objc_msgSend(path, OS.sel_lineToPoint_1, pt); - OS.objc_msgSend(path, OS.sel_closePath); + OS.objc_msgSend(cast(objc.id) path, OS.sel_lineToPoint_1, pt); + OS.objc_msgSend(cast(objc.id) path, OS.sel_closePath); } return null; } -public static Region carbon_new(Device device, RgnHandle handle) { +public static Region carbon_new(Device device, QuickdrawTypes.RgnHandle handle) { return new Region(device, handle); } @@ -377,7 +381,7 @@ * @see #equals */ public hash_t toHash() { - return handle; + return cast(hash_t) handle; } alias toHash hashCode; @@ -425,7 +429,7 @@ public void intersect(int x, int y, int width, int height) { if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT); - RgnHandle rectRgn = OS.NewRgn(); + QuickdrawTypes.RgnHandle rectRgn = OS.NewRgn(); Rect r; OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height)); OS.RectRgn(rectRgn, &r); @@ -552,7 +556,7 @@ if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (pointArray.length < 2) return; - RgnHandle polyRgn = OS.NewRgn(); + QuickdrawTypes.RgnHandle polyRgn = OS.NewRgn(); OS.OpenRgn(); OS.MoveTo(cast(short)pointArray[0], cast(short)pointArray[1]); for (int i = 1; i < pointArray.length / 2; i++) { @@ -607,9 +611,9 @@ public void subtract(int x, int y, int width, int height) { if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT); - RgnHandle rectRgn = OS.NewRgn(); + QuickdrawTypes.RgnHandle rectRgn = OS.NewRgn(); Rect r; - OS.SetRect(r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height)); + OS.SetRect(&r, cast(short)x, cast(short)y, cast(short)(x + width),cast(short)(y + height)); OS.RectRgn(rectRgn, &r); OS.DiffRgn(handle, rectRgn, handle); OS.DisposeRgn(rectRgn);