# HG changeset patch # User Jacob Carlborg # Date 1230072001 -3600 # Node ID 3607217555f270007e0040b51488a6d073c60824 # Parent 2d5ef909b21d5cc472a944c007615e73ce52082c Ported dwt.widgets.Link diff -r 2d5ef909b21d -r 3607217555f2 dwt/widgets/Link.d --- a/dwt/widgets/Link.d Tue Dec 23 23:30:38 2008 +0100 +++ b/dwt/widgets/Link.d Tue Dec 23 23:40:01 2008 +0100 @@ -7,6 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ module dwt.widgets.Link; @@ -30,6 +33,14 @@ import dwt.internal.cocoa.SWTScrollView; import dwt.internal.cocoa.SWTTextView; +static import tango.text.Text; + +import objc = dwt.internal.objc.runtime; +import dwt.widgets.Composite; +import dwt.widgets.Control; + +alias tango.text.Text.Text!(char) Text8; + /** * Instances of this class represent a selectable * user interface object that displays a text with @@ -122,7 +133,7 @@ addListener (DWT.DefaultSelection, typedListener); } -bool textView_clickOnLink_atIndex(int /*long*/ id, int /*long*/ sel, int /*long*/ textView, int /*long*/ link, int /*long*/ charIndex) { +bool textView_clickOnLink_atIndex(objc.id id, objc.SEL sel, objc.id textView, objc.id link, objc.id charIndex) { NSString str = new NSString (link); Event event = new Event (); event.text = str.getString(); @@ -165,7 +176,7 @@ scrollWidget.setDrawsBackground(false); scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder); - NSTextView widget = cast(NSTextView)new SWTTextView().alloc(); + NSTextView widget = cast(NSTextView)(new SWTTextView()).alloc(); widget.initWithFrame(NSRect()); widget.setEditable(false); widget.setDrawsBackground(false); @@ -247,16 +258,16 @@ } String parse (String string) { - int length = string.length (); - offsets = new Point [length / 4]; - ids = new String [length / 4]; - mnemonics = new int [length / 4 + 1]; - StringBuffer result = new StringBuffer (); - char [] buffer = new char [length]; + int length_ = string.length (); + offsets = new Point [length_ / 4]; + ids = new String [length_ / 4]; + mnemonics = new int [length_ / 4 + 1]; + Text8 result = new Text8 (); + char [] buffer = new char [length_]; string.getChars (0, string.length (), buffer, 0); int index = 0, state = 0, linkIndex = 0; int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0; - while (index < length) { + while (index < length_) { char c = Character.toLowerCase (buffer [index]); switch (state) { case 0: @@ -355,9 +366,9 @@ } index++; } - if (start < length) { + if (start < length_) { int tmp = parseMnemonics (buffer, start, tagStart, result); - int mnemonic = parseMnemonics (buffer, Math.max (tagStart, linkStart), length, result); + int mnemonic = parseMnemonics (buffer, Math.max (tagStart, linkStart), length_, result); if (mnemonic is -1) mnemonic = tmp; mnemonics [linkIndex] = mnemonic; } else { @@ -377,7 +388,7 @@ return result.toString (); } -int parseMnemonics (char[] buffer, int start, int end, StringBuffer result) { +int parseMnemonics (char[] buffer, int start, int end, Text8 result) { int mnemonic = -1, index = start; while (index < end) { if (buffer [index] is '&') { @@ -396,7 +407,7 @@ } void setFont(NSFont font) { - ((NSTextView) view).setFont(font); + (cast(NSTextView) view).setFont(font); } /** diff -r 2d5ef909b21d -r 3607217555f2 dwt/widgets/List.d --- a/dwt/widgets/List.d Tue Dec 23 23:30:38 2008 +0100 +++ b/dwt/widgets/List.d Tue Dec 23 23:40:01 2008 +0100 @@ -7,6 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg *******************************************************************************/ module dwt.widgets.List;