Mercurial > projects > dwt-mac
diff dwt/graphics/TextLayout.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 | e831403a80a9 |
children | 642f460a0908 |
line wrap: on
line diff
--- a/dwt/graphics/TextLayout.d Sun Sep 14 23:32:29 2008 +0200 +++ b/dwt/graphics/TextLayout.d Tue Oct 07 12:56:18 2008 +0200 @@ -7,11 +7,12 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.graphics.TextLayout; -import dwt.dwthelper.utils; - import dwt.DWT; import dwt.DWTException; import dwt.internal.cocoa.NSColor; @@ -28,6 +29,20 @@ import dwt.internal.cocoa.NSTextStorage; import dwt.internal.cocoa.OS; +import dwt.dwthelper.utils; +import dwt.graphics.Color; +import dwt.graphics.Device; +import dwt.graphics.Font; +import dwt.graphics.FontMetrics; +import dwt.graphics.GC; +import dwt.graphics.GCData; +import dwt.graphics.GlyphMetrics; +import dwt.graphics.Point; +import dwt.graphics.Rectangle; +import dwt.graphics.Region; +import dwt.graphics.Resource; +import dwt.graphics.TextStyle; + /** * <code>TextLayout</code> is a graphic object that represents * styled text. @@ -44,6 +59,8 @@ * @since 3.0 */ public final class TextLayout : Resource { + + alias Resource.init_ init_; NSTextStorage textStorage; NSLayoutManager layoutManager; @@ -101,7 +118,7 @@ styles = new StyleItem[2]; styles[0] = new StyleItem(); styles[1] = new StyleItem(); - init(); + init_(); } void checkLayout() { @@ -111,10 +128,10 @@ void computeRuns() { if (textStorage !is null) return; NSString str = NSString.stringWith(text); - textStorage = (cast(NSTextStorage)new NSTextStorage().alloc()); + textStorage = (cast(NSTextStorage)(new NSTextStorage()).alloc()); textStorage.initWithString_(str); - layoutManager = cast(NSLayoutManager)new NSLayoutManager().alloc().init(); - textContainer = cast(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,20 +145,20 @@ range.length = str.length(); textStorage.addAttribute(OS.NSFontAttributeName(), defaultFont.handle, range); - NSMutableParagraphStyle paragraph = cast(NSMutableParagraphStyle)new NSMutableParagraphStyle().alloc().init(); - int align = OS.NSLeftTextAlignment; + NSMutableParagraphStyle paragraph = cast(NSMutableParagraphStyle)(new NSMutableParagraphStyle()).alloc().init(); + int align_ = OS.NSLeftTextAlignment; if (justify) { - align = OS.NSJustifiedTextAlignment; + align_ = OS.NSJustifiedTextAlignment; } else { switch (alignment) { case DWT.CENTER: - align = OS.NSCenterTextAlignment; + align_ = OS.NSCenterTextAlignment; break; case DWT.RIGHT: - align = OS.NSRightTextAlignment; + align_ = OS.NSRightTextAlignment; } } - paragraph.setAlignment(align); + paragraph.setAlignment(align_); paragraph.setLineSpacing(spacing); paragraph.setFirstLineHeadIndent(indent); @@ -1229,7 +1246,7 @@ public void setSegments(int[] segments) { checkLayout(); if (this.segments is null && segments is null) return; - if (this.segments !is null && segments !isnull) { + if (this.segments !is null && segments !is null) { if (this.segments.length is segments.length) { int i; for (i = 0; i <segments.length; i++) { @@ -1361,7 +1378,7 @@ public void setTabs(int[] tabs) { checkLayout(); if (this.tabs is null && tabs is null) return; - if (this.tabs !is null && tabs !isnull) { + if (this.tabs !is null && tabs !is null) { if (this.tabs.length is tabs.length) { int i; for (i = 0; i < tabs.length; i++) {