Mercurial > projects > dwt-mac
diff dwt/graphics/GC.d @ 7:e831403a80a9
Add 'cast' to casts
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 14:30:35 +0200 |
parents | 1a8b3cb347e0 |
children | a9ab4c738ed8 |
line wrap: on
line diff
--- a/dwt/graphics/GC.d Wed Aug 27 14:10:03 2008 +0200 +++ b/dwt/graphics/GC.d Wed Aug 27 14:30:35 2008 +0200 @@ -331,13 +331,13 @@ float scaling = size.width; if (scaling < 0) scaling = -scaling; float strokeWidth = data.lineWidth * scaling; - if (strokeWidth is 0 || ((int)strokeWidth % 2) is 1) { + if (strokeWidth is 0 || (cast(int)strokeWidth % 2) is 1) { data.drawXOffset = 0.5f / scaling; } scaling = size.height; if (scaling < 0) scaling = -scaling; strokeWidth = data.lineWidth * scaling; - if (strokeWidth is 0 || ((int)strokeWidth % 2) is 1) { + if (strokeWidth is 0 || (cast(int)strokeWidth % 2) is 1) { data.drawYOffset = 0.5f / scaling; } } @@ -375,23 +375,23 @@ // int[] contentView = new int[1]; // OS.HIViewFindByID(OS.HIViewGetRoot(window), OS.kHIViewWindowContentID(), contentView); // OS.HIViewConvertPoint (pt, data.control, contentView[0]); -// x += (int) pt.x; -// y += (int) pt.y; +// x += cast(int) pt.x; +// y += cast(int) pt.y; // Rect inset = data.insetRect; // x -= inset.left; // y -= inset.top; -// srcRect.left = (short)x; -// srcRect.top = (short)y; -// srcRect.right = (short)(x + width); -// srcRect.bottom = (short)(y + height); +// srcRect.left = cast(short)x; +// srcRect.top = cast(short)y; +// srcRect.right = cast(short)(x + width); +// srcRect.bottom = cast(short)(y + height); // Rect destRect = new Rect(); -// destRect.right = (short)width; -// destRect.bottom = (short)height; +// destRect.right = cast(short)width; +// destRect.bottom = cast(short)height; // int bpl = width * 4; // int[] gWorld = new int[1]; // int port = OS.GetWindowPort(window); // OS.NewGWorldFromPtr(gWorld, OS.k32ARGBPixelFormat, destRect, 0, 0, 0, image.data, bpl); -// OS.CopyBits(OS.GetPortBitMapForCopyBits(port), OS.GetPortBitMapForCopyBits(gWorld[0]), srcRect, destRect, (short)OS.srcCopy, 0); +// OS.CopyBits(OS.GetPortBitMapForCopyBits(port), OS.GetPortBitMapForCopyBits(gWorld[0]), srcRect, destRect, cast(short)OS.srcCopy, 0); // OS.DisposeGWorld(gWorld [0]); // } else if (data.window !is 0) { // int imageHandle = image.handle; @@ -532,22 +532,22 @@ // int[] contentView = new int[1]; // OS.HIViewFindByID(OS.HIViewGetRoot(window), OS.kHIViewWindowContentID(), contentView); // OS.HIViewConvertPoint(pt, OS.HIViewGetSuperview(data.control), contentView[0]); -// convertX = rect.left + (int) pt.x; -// convertY = rect.top + (int) pt.y; -// rect.left += (int) pt.x; -// rect.top += (int) pt.y; -// rect.right += (int) pt.x; -// rect.bottom += (int) pt.y; +// convertX = rect.left + cast(int) pt.x; +// convertY = rect.top + cast(int) pt.y; +// rect.left += cast(int) pt.x; +// rect.top += cast(int) pt.y; +// rect.right += cast(int) pt.x; +// rect.bottom += cast(int) pt.y; // Rect srcRect = new Rect(); // int left = rect.left + srcX; // int top = rect.top + srcY; -// OS.SetRect(srcRect, (short)left, (short)top, (short)(left + width), (short)(top + height)); +// OS.SetRect(srcRect, cast(short)left, cast(short)top, cast(short)(left + width), cast(short)(top + height)); // int srcRgn = OS.NewRgn(); // OS.RectRgn(srcRgn, srcRect); // OS.SectRect(rect, srcRect, srcRect); // Rect destRect = new Rect (); // OS.SetRect(destRect, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom); -// OS.OffsetRect(destRect, (short)deltaX, (short)deltaY); +// OS.OffsetRect(destRect, cast(short)deltaX, cast(short)deltaY); // int destRgn = OS.NewRgn(); // OS.RectRgn(destRgn, destRect); // @@ -579,13 +579,13 @@ // OS.GetClip(oldClip); // OS.SetClip(clipRgn); // OS.UnionRect(srcRect, destRect, rect); -// OS.ScrollRect(rect, (short)deltaX, (short)deltaY, 0); +// OS.ScrollRect(rect, cast(short)deltaX, cast(short)deltaY, 0); // OS.SetClip(oldClip); // OS.DisposeRgn(oldClip); // OS.SetPort(currentPort[0]); // } else { // int portBitMap = OS.GetPortBitMapForCopyBits (port); -// OS.CopyBits(portBitMap, portBitMap, srcRect, destRect, (short)OS.srcCopy, clipRgn); +// OS.CopyBits(portBitMap, portBitMap, srcRect, destRect, cast(short)OS.srcCopy, clipRgn); // OS.QDFlushPortBuffer(port, destRgn); // } // } @@ -598,11 +598,11 @@ // if (paint) { // int invalRgn = OS.NewRgn(); // OS.DiffRgn(srcRgn, data.visibleRgn, invalRgn); -// OS.OffsetRgn(invalRgn, (short)deltaX, (short)deltaY); +// OS.OffsetRgn(invalRgn, cast(short)deltaX, cast(short)deltaY); // OS.DiffRgn(srcRgn, destRgn, srcRgn); // OS.UnionRgn(srcRgn, invalRgn, invalRgn); // OS.SectRgn(data.visibleRgn, invalRgn, invalRgn); -// OS.OffsetRgn(invalRgn, (short)-convertX, (short)-convertY); +// OS.OffsetRgn(invalRgn, cast(short)-convertX, cast(short)-convertY); // OS.HIViewSetNeedsDisplayInRegion(data.control, invalRgn, true); // OS.DisposeRgn(invalRgn); // } @@ -663,7 +663,7 @@ // length = j; // } NSString str = NSString.stringWithCharacters(chars, length); - return ((NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict); + return (cast(NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict); } void destroy() { @@ -859,8 +859,8 @@ checkGC(CLIPPING | TRANSFORM); NSImage imageHandle = srcImage.handle; NSSize size = imageHandle.size(); - int imgWidth = (int)size.width; - int imgHeight = (int)size.height; + int imgWidth = cast(int)size.width; + int imgHeight = cast(int)size.height; if (simple) { srcWidth = destWidth = imgWidth; srcHeight = destHeight = imgHeight; @@ -1401,7 +1401,7 @@ public bool equals(Object object) { if (object is this) return true; if (!(object instanceof GC)) return false; - return handle is ((GC)object).handle; + return handle is (cast(GC)object).handle; } /** @@ -1521,7 +1521,7 @@ } 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 = ((NSGradient)new NSGradient().alloc()).initWithStartingColor(startingColor, endingColor); + NSGradient gradient = (cast(NSGradient)new NSGradient().alloc()).initWithStartingColor(startingColor, endingColor); NSRect rect = new NSRect(); rect.x = x; rect.y = y; @@ -1983,7 +1983,7 @@ rect.height = size.height; } } - return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); + return new Rectangle(cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height); } /** @@ -2019,10 +2019,10 @@ rect.height = data.size.height; } } - region.add((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); + region.add(cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height); NSRect paintRect = data.paintRect; if (paintRect !is null) { - region.intersect((int)paintRect.x, (int)paintRect.y, (int)paintRect.width, (int)paintRect.height); + region.intersect(cast(int)paintRect.x, cast(int)paintRect.y, cast(int)paintRect.width, cast(int)paintRect.height); } if (data.clipPath !is null) { NSBezierPath clip = data.clipPath.bezierPathByFlatteningPath(); @@ -2040,13 +2040,13 @@ if (pointCount !is 0) clipRgn.add(pointArray, pointCount); pointCount = 0; OS.memmove(pt, points, NSPoint.sizeof); - pointArray[pointCount++] = (int)pt.x; - pointArray[pointCount++] = (int)pt.y; + pointArray[pointCount++] = cast(int)pt.x; + pointArray[pointCount++] = cast(int)pt.y; break; case OS.NSLineToBezierPathElement: OS.memmove(pt, points, NSPoint.sizeof); - pointArray[pointCount++] = (int)pt.x; - pointArray[pointCount++] = (int)pt.y; + pointArray[pointCount++] = cast(int)pt.x; + pointArray[pointCount++] = cast(int)pt.y; break; case OS.NSClosePathBezierPathElement: if (pointCount !is 0) clipRgn.add(pointArray, pointCount); @@ -2111,8 +2111,8 @@ if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); checkGC(FONT); NSFont font = data.font.handle; - int ascent = (int)(0.5f + font.ascender()); - int descent = (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); @@ -2257,7 +2257,7 @@ if (data.lineDashes is null) return null; int[] lineDashes = new int[data.lineDashes.length]; for (int i = 0; i < lineDashes.length; i++) { - lineDashes[i] = (int)data.lineDashes[i]; + lineDashes[i] = cast(int)data.lineDashes[i]; } return lineDashes; } @@ -2311,7 +2311,7 @@ */ public int getLineWidth() { if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); - return (int)data.lineWidth; + return cast(int)data.lineWidth; } /** @@ -2530,7 +2530,7 @@ setAlpha(0xFF); setAntialias(DWT.DEFAULT); setBackgroundPattern(null); - setClipping((Rectangle)null); + setClipping(cast(Rectangle)null); setForegroundPattern(null); setInterpolation(DWT.DEFAULT); setTextAntialias(DWT.DEFAULT); @@ -2748,7 +2748,7 @@ public void setClipping(Rectangle rect) { if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); if (rect is null) { - setClipping((NSBezierPath)null); + setClipping(cast(NSBezierPath)null); } else { setClipping(rect.x, rect.y, rect.width, rect.height); } @@ -3312,8 +3312,8 @@ if (transform !is null) { if (data.transform !is null) data.transform.release(); if (data.inverseTransform !is null) data.inverseTransform.release(); - data.transform = ((NSAffineTransform)new NSAffineTransform().alloc()).initWithTransform(transform.handle); - data.inverseTransform = ((NSAffineTransform)new NSAffineTransform().alloc()).initWithTransform(transform.handle); + data.transform = (cast(NSAffineTransform)new NSAffineTransform().alloc()).initWithTransform(transform.handle); + data.inverseTransform = (cast(NSAffineTransform)new NSAffineTransform().alloc()).initWithTransform(transform.handle); NSAffineTransformStruct struct = data.inverseTransform.transformStruct(); if ((struct.m11 * struct.m22 - struct.m12 * struct.m21) !is 0) { data.inverseTransform.invert(); @@ -3407,7 +3407,7 @@ checkGC(FONT); NSAttributedString str = createString(string, flags); NSSize size = str.size(); - return new Point((int)size.width, (int)size.height); + return new Point(cast(int)size.width, cast(int)size.height); } /**