Mercurial > projects > dwt-mac
diff dwt/graphics/TextLayout.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 | db5a898b2119 |
line wrap: on
line diff
--- a/dwt/graphics/TextLayout.d Wed Aug 27 14:10:03 2008 +0200 +++ b/dwt/graphics/TextLayout.d Wed Aug 27 14:30:35 2008 +0200 @@ -111,10 +111,10 @@ void computeRuns() { if (textStorage !is null) return; NSString str = NSString.stringWith(text); - textStorage = ((NSTextStorage)new NSTextStorage().alloc()); + textStorage = (cast(NSTextStorage)new NSTextStorage().alloc()); textStorage.initWithString_(str); - layoutManager = (NSLayoutManager)new NSLayoutManager().alloc().init(); - textContainer = (NSTextContainer)new NSTextContainer().alloc(); + layoutManager = cast(NSLayoutManager)new NSLayoutManager().alloc().init(); + textContainer = cast(NSTextContainer)new NSTextContainer().alloc(); NSSize size = new NSSize(); size.width = wrapWidth !is -1 ? wrapWidth : Float.MAX_VALUE; size.height = Float.MAX_VALUE; @@ -128,7 +128,7 @@ range.length = str.length(); textStorage.addAttribute(OS.NSFontAttributeName(), defaultFont.handle, range); - NSMutableParagraphStyle paragraph = (NSMutableParagraphStyle)new NSMutableParagraphStyle().alloc().init(); + NSMutableParagraphStyle paragraph = cast(NSMutableParagraphStyle)new NSMutableParagraphStyle().alloc().init(); int align = OS.NSLeftTextAlignment; if (justify) { align = OS.NSJustifiedTextAlignment; @@ -423,7 +423,7 @@ rect.height = Math.max(rect.height, layoutManager.defaultLineHeightForFont(nsFont)); } rect.height = Math.max(rect.height, ascent + descent); - return new Rectangle(0, 0, (int)rect.width, (int)rect.height); + return new Rectangle(0, 0, cast(int)rect.width, cast(int)rect.height); } /** @@ -454,7 +454,7 @@ range.location = layoutManager.glyphIndexForCharacterAtIndex(start); range.length = layoutManager.glyphIndexForCharacterAtIndex(end + 1) - range.location; NSRect rect = layoutManager.boundingRectForGlyphRange(range, textContainer); - return new Rectangle((int)rect.x, (int)rect.y, (int)Math.ceil(rect.width), (int)Math.ceil(rect.height)); + return new Rectangle(cast(int)rect.x, cast(int)rect.y, cast(int)Math.ceil(rect.width), cast(int)Math.ceil(rect.height)); } /** @@ -615,7 +615,7 @@ computeRuns(); if (!(0 <= lineIndex && lineIndex < lineBounds.length)) DWT.error(DWT.ERROR_INVALID_RANGE); NSRect rect = lineBounds[lineIndex]; - 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); } /** @@ -656,14 +656,14 @@ if (length is 0) { Font font = this.font !is null ? this.font : device.systemFont; NSFont nsFont = font.handle; - int ascent = (int)(0.5f + nsFont.ascender()); - int descent = (int)(0.5f + (-nsFont.descender() + nsFont.leading())); + int ascent = cast(int)(0.5f + nsFont.ascender()); + int descent = cast(int)(0.5f + (-nsFont.descender() + nsFont.leading())); ascent = Math.max(ascent, this.ascent); descent = Math.max(descent, this.descent); return FontMetrics.cocoa_new(ascent, descent, 0, 0, ascent + descent); } Rectangle rect = getLineBounds(lineIndex); - int baseline = (int)layoutManager.typesetter().baselineOffsetInLayoutManager(layoutManager, getLineOffsets()[lineIndex]); + int baseline = cast(int)layoutManager.typesetter().baselineOffsetInLayoutManager(layoutManager, getLineOffsets()[lineIndex]); return FontMetrics.cocoa_new(rect.height - baseline, baseline, 0, 0, rect.height); } @@ -700,7 +700,7 @@ NSRect bounds = layoutManager.boundingRectForGlyphRange(range, textContainer); point.x += bounds.width; } - return new Point((int)point.x, (int)rect.y); + return new Point(cast(int)point.x, cast(int)rect.y); } /**