Mercurial > projects > dwt-mac
diff dwt/graphics/GC.d @ 46:cfa563df4fdd
Updated Widget and Display to 3.514
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Fri, 05 Dec 2008 16:00:41 +0100 |
parents | d8635bb48c7c |
children | 62202ce0039f |
line wrap: on
line diff
--- a/dwt/graphics/GC.d Mon Dec 01 17:07:00 2008 +0100 +++ b/dwt/graphics/GC.d Fri Dec 05 16:00:41 2008 +0100 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * 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 @@ -28,7 +28,6 @@ import dwt.internal.cocoa.NSGradient; import dwt.internal.cocoa.NSGraphicsContext; import dwt.internal.cocoa.NSImage; -import dwt.internal.cocoa.NSInteger; import dwt.internal.cocoa.NSMutableDictionary; import dwt.internal.cocoa.NSMutableParagraphStyle; import dwt.internal.cocoa.NSPoint; @@ -59,7 +58,8 @@ import dwt.graphics.Resource; import dwt.graphics.RGB; import dwt.graphics.Transform; -import dwt.internal.cocoa.CGFloat; +import dwt.internal.c.Carbon; +import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; /** @@ -240,7 +240,7 @@ NSAutoreleasePool checkGC (int mask) { NSAutoreleasePool pool = null; - if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); + if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init(); if ((mask & (CLIPPING | TRANSFORM)) !is 0) { NSGraphicsContext.setCurrentContext(handle); NSView view = data.view; @@ -253,8 +253,10 @@ visibleRect.width !is data.visibleRect.width || visibleRect.height !is data.visibleRect.height) { data.state &= ~CLIPPING; - data.windowRect = rect; - data.visibleRect = visibleRect; + data.windowRectStruct = rect; + data.windowRect = &data.windowRectStruct; + data.visibleRectStruct = visibleRect; + data.visibleRect = &data.visibleRectStruct; } } if ((data.state & CLIPPING) is 0 || (data.state & TRANSFORM) is 0) { @@ -262,11 +264,11 @@ handle.saveGraphicsState(); if (view !is null && data.paintRect is null) { NSAffineTransform transform = NSAffineTransform.transform(); - NSRect rect = data.windowRect; + NSRect rect = data.windowRectStruct; transform.translateXBy(rect.x, rect.y + rect.height); transform.scaleXBy(1, -1); transform.concat(); - NSBezierPath.bezierPathWithRect(data.visibleRect).addClip(); + NSBezierPath.bezierPathWithRect(data.visibleRectStruct).addClip(); } if (data.clipPath !is null) data.clipPath.addClip(); if (data.transform !is null) data.transform.concat(); @@ -319,6 +321,7 @@ case DWT.LINE_DASHDOT: case DWT.LINE_DASHDOTDOT: state |= LINE_STYLE; + default: assert(false); } } if ((state & LINE_STYLE) !is 0) { @@ -331,6 +334,7 @@ case DWT.LINE_DASHDOT: dashes = width !is 0 ? LINE_DASHDOT : LINE_DASHDOT_ZERO; break; case DWT.LINE_DASHDOTDOT: dashes = width !is 0 ? LINE_DASHDOTDOT : LINE_DASHDOTDOT_ZERO; break; case DWT.LINE_CUSTOM: dashes = data.lineDashes; break; + default: assert(false); } if (dashes !is null) { CGFloat[] lengths = new CGFloat[dashes.length]; @@ -348,18 +352,20 @@ if ((state & LINE_JOIN) !is 0) { NSLineJoinStyle joinStyle; switch (data.lineJoin) { - case DWT.JOIN_MITER: joinStyle = NSMiterLineJoinStyle; break; - case DWT.JOIN_ROUND: joinStyle = NSRoundLineJoinStyle; break; - case DWT.JOIN_BEVEL: joinStyle = NSBevelLineJoinStyle; break; + case DWT.JOIN_MITER: joinStyle = OS.NSMiterLineJoinStyle; break; + case DWT.JOIN_ROUND: joinStyle = OS.NSRoundLineJoinStyle; break; + case DWT.JOIN_BEVEL: joinStyle = OS.NSBevelLineJoinStyle; break; + default: assert(false); } path.setLineJoinStyle(joinStyle); } if ((state & LINE_CAP) !is 0) { NSLineCapStyle capStyle; switch (data.lineCap) { - case DWT.CAP_ROUND: capStyle = NSRoundLineCapStyle; break; - case DWT.CAP_FLAT: capStyle = NSButtLineCapStyle; break; - case DWT.CAP_SQUARE: capStyle = NSSquareLineCapStyle; break; + case DWT.CAP_ROUND: capStyle = OS.NSRoundLineCapStyle; break; + case DWT.CAP_FLAT: capStyle = OS.NSButtLineCapStyle; break; + case DWT.CAP_SQUARE: capStyle = OS.NSSquareLineCapStyle; break; + default: assert(false); } path.setLineCapStyle(capStyle); } @@ -665,10 +671,10 @@ if ((flags & DWT.DRAW_TRANSPARENT) is 0) { CGFloat[] background = data.background; color = NSColor.colorWithDeviceRed(background[0], background[1], background[2], data.alpha / 255f); - dict.setObject(color, OS.FuncNSBackgroundColorAttributeName()); + dict.setObject(color, OS.NSBackgroundColorAttributeName); } if ((flags & DWT.DRAW_TAB) is 0) { - NSMutableParagraphStyle paragraph = (NSMutableParagraphStyle)new NSMutableParagraphStyle().alloc().init(); + NSMutableParagraphStyle paragraph = cast(NSMutableParagraphStyle)(new NSMutableParagraphStyle()).alloc().init(); paragraph.setAlignment(OS.NSLeftTextAlignment); paragraph.setLineBreakMode(OS.NSLineBreakByClipping); paragraph.setTabStops(NSArray.array()); @@ -2098,7 +2104,7 @@ } if (data.clipPath !is null) { NSBezierPath clip = data.clipPath.bezierPathByFlatteningPath(); - int count = (int)/*64*/clip.elementCount(); + int count = cast(int)/*64*/clip.elementCount(); int pointCount = 0; Region clipRgn = new Region(device); int[] pointArray = new int[count * 2]; @@ -2267,7 +2273,7 @@ */ public int getInterpolation() { if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); - int interpolation = (int)/*64*/handle.imageInterpolation(); + int interpolation = cast(int)/*64*/handle.imageInterpolation(); switch (interpolation) { case OS.NSImageInterpolationDefault: return DWT.DEFAULT; case OS.NSImageInterpolationNone: return DWT.NONE;