# HG changeset patch # User Jacob Carlborg # Date 1244301411 -7200 # Node ID 476f8d5c0b0788ffb6a1c388a772712c640fad6b # Parent c41e13089a3c4b9e6d6b5ff1b25794ca769d5fe8 Fixes #39 diff -r c41e13089a3c -r 476f8d5c0b07 dwt/dwthelper/ResourceBundle.d --- a/dwt/dwthelper/ResourceBundle.d Fri Jun 05 01:25:10 2009 +0200 +++ b/dwt/dwthelper/ResourceBundle.d Sat Jun 06 17:16:51 2009 +0200 @@ -41,7 +41,7 @@ return; } } - Trace.formatln( "ResourceBundle default" ); + //Trace.formatln( "ResourceBundle default" ); initialize( cast(char[])data[0].data ); } public this( ImportData data ){ diff -r c41e13089a3c -r 476f8d5c0b07 dwt/graphics/GC.d --- a/dwt/graphics/GC.d Fri Jun 05 01:25:10 2009 +0200 +++ b/dwt/graphics/GC.d Sat Jun 06 17:16:51 2009 +0200 @@ -315,14 +315,14 @@ } NSBezierPath path = data.path; if ((state & LINE_WIDTH) !is 0) { - path.setLineWidth((data.lineWidth is 0 ? 1 : data.lineWidth)); + path.setLineWidth(data.lineWidth is 0 ? 1 : data.lineWidth); switch (data.lineStyle) { case DWT.LINE_DOT: case DWT.LINE_DASH: case DWT.LINE_DASHDOT: case DWT.LINE_DASHDOTDOT: state |= LINE_STYLE; - default: assert(false); + default: } } if ((state & LINE_STYLE) !is 0) { @@ -335,7 +335,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); + default: } if (dashes !is null) { Carbon.CGFloat[] lengths = new Carbon.CGFloat[dashes.length]; @@ -356,7 +356,7 @@ 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); + default: } path.setLineJoinStyle(joinStyle); } @@ -366,7 +366,7 @@ 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); + default: } path.setLineCapStyle(capStyle); } @@ -682,9 +682,8 @@ dict.setObject(paragraph, OS.NSParagraphStyleAttributeName); paragraph.release(); } - size_t length = string.length(); - char[] chars = new char[length]; - string.getChars(0, length, chars, 0); + size_t length_ = string.length(); + wchar[] chars = string.toString16(); int breakCount = 0; int[] breaks = null; if ((flags & DWT.DRAW_MNEMONIC) !is 0 || (flags & DWT.DRAW_DELIMITER) is 0) { @@ -719,9 +718,9 @@ default: } } - length = j; + length_ = j; } - NSString str = NSString.stringWithCharacters(chars.toCharArray().ptr, length); + NSString str = NSString.stringWithCharacters(chars.ptr, chars.length); return (cast(NSAttributedString)(new NSAttributedString()).alloc()).initWithString(str, dict); } @@ -975,7 +974,7 @@ NSAutoreleasePool pool = checkGC(DRAW); try { NSBezierPath path = data.path; - NSPoint pt = NSPoint(); + NSPoint pt = NSPoint(); pt.x = x1 + data.drawXOffset; pt.y = y1 + data.drawYOffset; path.moveToPoint(pt); @@ -1023,7 +1022,7 @@ height = -height; } NSBezierPath path = data.path; - NSRect rect = NSRect(); + NSRect rect = NSRect(); rect.x = x + data.drawXOffset; rect.y = y + data.drawXOffset; rect.width = width; @@ -1100,7 +1099,7 @@ if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); NSAutoreleasePool pool = checkGC(FOREGROUND_FILL | CLIPPING | TRANSFORM); try { - NSRect rect = NSRect(); + NSRect rect = NSRect(); rect.x = x; rect.y = y; rect.width = 1; @@ -1137,9 +1136,9 @@ if (pointArray.length < 4) return; NSAutoreleasePool pool = checkGC(DRAW); try { - float /*double*/ xOffset = data.drawXOffset, yOffset = data.drawYOffset; + Carbon.CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset; NSBezierPath path = data.path; - NSPoint pt = NSPoint(); + NSPoint pt = NSPoint(); pt.x = pointArray[0] + xOffset; pt.y = pointArray[1] + yOffset; path.moveToPoint(pt); @@ -1180,9 +1179,9 @@ if (pointArray.length < 4) return; NSAutoreleasePool pool = checkGC(DRAW); try { - float /*double*/ xOffset = data.drawXOffset, yOffset = data.drawYOffset; + Carbon.CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset; NSBezierPath path = data.path; - NSPoint pt = NSPoint(); + NSPoint pt = NSPoint(); pt.x = pointArray[0] + xOffset; pt.y = pointArray[1] + yOffset; path.moveToPoint(pt); @@ -1226,7 +1225,7 @@ y = y + height; height = -height; } - NSRect rect = NSRect(); + NSRect rect = NSRect(); rect.x = x + data.drawXOffset; rect.y = y + data.drawYOffset; rect.width = width; @@ -1292,7 +1291,7 @@ NSAutoreleasePool pool = checkGC(DRAW); try { NSBezierPath path = data.path; - NSRect rect = NSRect(); + NSRect rect = NSRect(); rect.x = x + data.drawXOffset; rect.y = y + data.drawYOffset; rect.width = width; @@ -1446,7 +1445,7 @@ transform.translateXBy(0, -(str.size().height + 2 * y)); transform.concat(); } - NSPoint pt = NSPoint(); + NSPoint pt = NSPoint(); pt.x = x; pt.y = y; str.drawAtPoint(pt); @@ -1524,14 +1523,14 @@ try { handle.saveGraphicsState(); NSAffineTransform transform = NSAffineTransform.transform(); - Carbon.CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset; + Carbon.CGFloat xOffset = data.drawXOffset, yOffset = data.drawYOffset; transform.translateXBy(x + xOffset + width / 2f, y + yOffset + height / 2f); transform.scaleXBy(width / 2f, height / 2f); NSBezierPath path = data.path; - NSPoint center = NSPoint(); + NSPoint center = NSPoint(); path.moveToPoint(center); - Carbon.CGFloat sAngle = -startAngle; - Carbon.CGFloat eAngle = -(startAngle + arcAngle); + Carbon.CGFloat sAngle = -startAngle; + Carbon.CGFloat eAngle = -(startAngle + arcAngle); path.appendBezierPathWithArcWithCenter(center, 1, sAngle, eAngle, arcAngle>0); path.closePath(); path.transformUsingAffineTransform(transform); @@ -1593,8 +1592,8 @@ } else { NSColor startingColor = NSColor.colorWithDeviceRed(fromRGB.red / 255f, fromRGB.green / 255f, fromRGB.blue / 255f, data.alpha / 255f); NSColor endingColor = NSColor.colorWithDeviceRed(toRGB.red / 255f, toRGB.green / 255f, toRGB.blue / 255f, data.alpha / 255f); - NSGradient gradient = (cast(NSGradient)(new NSGradient()).alloc()).initWithStartingColor(startingColor, endingColor); - NSRect rect = NSRect(); + NSGradient gradient = (cast(NSGradient)(new NSGradient()).alloc()).initWithStartingColor(startingColor, endingColor); + NSRect rect = NSRect(); rect.x = x; rect.y = y; rect.width = width; @@ -1636,7 +1635,7 @@ height = -height; } NSBezierPath path = data.path; - NSRect rect = NSRect(); + NSRect rect = NSRect(); rect.x = x; rect.y = y; rect.width = width; @@ -1730,7 +1729,7 @@ NSAutoreleasePool pool = checkGC(FILL); try { NSBezierPath path = data.path; - NSPoint pt = NSPoint(); + NSPoint pt = NSPoint(); pt.x = pointArray[0]; pt.y = pointArray[1]; path.moveToPoint(pt); @@ -1780,7 +1779,7 @@ y = y + height; height = -height; } - NSRect rect = NSRect(); + NSRect rect = NSRect(); rect.x = x; rect.y = y; rect.width = width; @@ -1846,7 +1845,7 @@ NSAutoreleasePool pool = checkGC(FILL); try { NSBezierPath path = data.path; - NSRect rect = NSRect(); + NSRect rect = NSRect(); rect.x = x; rect.y = y; rect.width = width; @@ -2192,8 +2191,8 @@ NSAutoreleasePool pool = checkGC(FONT); try { NSFont font = data.font.handle; - int ascent = cast(int)(0.5f + font.ascender()); - int descent = cast(int)(0.5f + (-font.descender() + font.leading())); + int ascent = cast(int)(0.5f + font.ascender()); + int descent = cast(int)(0.5f + (-font.descender() + font.leading())); String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; int averageCharWidth = stringExtent(s).x / s.length(); return FontMetrics.cocoa_new(ascent, descent, averageCharWidth, 0, ascent + descent); @@ -2466,8 +2465,8 @@ if (transform.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); NSAffineTransform cmt = data.transform; if (cmt !is null) { - NSAffineTransformStruct structt = cmt.transformStruct(); - transform.handle.setTransformStruct(structt); + NSAffineTransformStruct struct_ = cmt.transformStruct(); + transform.handle.setTransformStruct(struct_); } else { transform.setElements(1, 0, 0, 1, 0, 0); } @@ -2752,7 +2751,7 @@ data.backgroundPattern = pattern; data.state &= ~BACKGROUND; } - + /** * Sets the area of the receiver which can be changed * by drawing operations to the rectangular area specified @@ -3401,8 +3400,8 @@ if (data.inverseTransform !is null) data.inverseTransform.release(); data.transform = (cast(NSAffineTransform)(new NSAffineTransform()).alloc()).initWithTransform(transform.handle); data.inverseTransform = (cast(NSAffineTransform)(new NSAffineTransform()).alloc()).initWithTransform(transform.handle); - NSAffineTransformStruct structt = data.inverseTransform.transformStruct(); - if ((structt.m11 * structt.m22 - structt.m12 * structt.m21) !is 0) { + NSAffineTransformStruct struct_ = data.inverseTransform.transformStruct(); + if ((struct_.m11 * struct_.m22 - struct_.m12 * struct_.m21) !is 0) { data.inverseTransform.invert(); } } else { @@ -3495,7 +3494,7 @@ try { NSAttributedString str = createString(string, flags); NSSize size = str.size(); - return new Point(cast(int)size.width, cast(int)size.height); + return new Point(cast(int)size.width, cast(int)size.height); } finally { uncheckGC(pool); } diff -r c41e13089a3c -r 476f8d5c0b07 dwt/graphics/GCData.d --- a/dwt/graphics/GCData.d Fri Jun 05 01:25:10 2009 +0200 +++ b/dwt/graphics/GCData.d Sat Jun 06 17:16:51 2009 +0200 @@ -50,11 +50,11 @@ public Pattern backgroundPattern; public Font font; public int alpha = 0xFF; - public CGFloat lineWidth; + public CGFloat lineWidth = 0.0; public int lineStyle = DWT.LINE_SOLID; public int lineCap = DWT.CAP_FLAT; public int lineJoin = DWT.JOIN_MITER; - public CGFloat lineDashesOffset; + public CGFloat lineDashesOffset = 0.0; public CGFloat[] lineDashes; public CGFloat lineMiterLimit = 10; public bool xorMode; @@ -65,7 +65,7 @@ public Image image; - public CGFloat drawXOffset, drawYOffset; + public CGFloat drawXOffset = 0.0, drawYOffset = 0.0; public NSRect* paintRect; public NSBezierPath path; public NSAffineTransform transform, inverseTransform; diff -r c41e13089a3c -r 476f8d5c0b07 dwt/internal/cocoa/NSSize.d --- a/dwt/internal/cocoa/NSSize.d Fri Jun 05 01:25:10 2009 +0200 +++ b/dwt/internal/cocoa/NSSize.d Sat Jun 06 17:16:51 2009 +0200 @@ -18,7 +18,7 @@ public struct NSSize { - public CGFloat width = 0; - public CGFloat height = 0; + public CGFloat width = 0.0; + public CGFloat height = 0.0; //public static final int sizeof = OS.NSSize_sizeof(); }