Mercurial > projects > dwt-addons
diff dwtx/ui/internal/forms/widgets/Paragraph.d @ 77:26c6c9dfd13c
ui.forms compile, just FormTextModel with xml reimpl left todo
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 24 May 2008 06:59:31 +0200 |
parents | 5d489b9f966c |
children | 7ffeace6c47f |
line wrap: on
line diff
--- a/dwtx/ui/internal/forms/widgets/Paragraph.d Sat May 24 06:18:55 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/Paragraph.d Sat May 24 06:59:31 2008 +0200 @@ -16,6 +16,8 @@ import dwtx.ui.internal.forms.widgets.Locator; import dwtx.ui.internal.forms.widgets.IHyperlinkSegment; import dwtx.ui.internal.forms.widgets.SelectionData; +import dwtx.ui.internal.forms.widgets.TextSegment; +import dwtx.ui.internal.forms.widgets.TextHyperlinkSegment; import dwt.graphics.GC; import dwt.graphics.Rectangle; @@ -24,6 +26,8 @@ import dwt.dwthelper.utils; import tango.util.collection.ArraySeq; import tango.util.collection.HashMap; +import tango.io.FileConst; +import tango.text.Text; /** * @version 1.0 @@ -56,7 +60,7 @@ */ public ParagraphSegment[] getSegments() { if (segments is null) - return new TArraySeqParagraphSegment; + return null; return segments .toArray(); } @@ -74,7 +78,7 @@ public void parseRegularText(String text, bool expandURLs, bool wrapAllowed, HyperlinkSettings settings, String fontId, String colorId) { - if (text.length() is 0) + if (text.length is 0) return; if (expandURLs) { int loc = text.indexOf(HTTP); @@ -87,9 +91,9 @@ addSegment(new TextSegment(text.substring(textLoc, loc), fontId, colorId, wrapAllowed)); bool added = false; - for (textLoc = loc; textLoc < text.length(); textLoc++) { + for (textLoc = loc; textLoc < text.length; textLoc++) { char c = text.charAt(textLoc); - if (Character.isSpaceChar(c)) { + if (CharacterIsWhitespace(c)) { addHyperlinkSegment(text.substring(loc, textLoc), settings, fontId); added = true; @@ -104,7 +108,7 @@ } loc = text.indexOf(HTTP, textLoc); } - if (textLoc < text.length()) { + if (textLoc < text.length) { addSegment(new TextSegment(text.substring(textLoc), fontId, colorId, wrapAllowed)); } @@ -128,7 +132,7 @@ ParagraphSegment[] segments = getSegments(); // compute heights Locator hloc = loc.create(); - ArrayList heights = new ArrayList(); + ArraySeq!(ArrayWrapperInt) heights = new ArraySeq!(ArrayWrapperInt); hloc.heights = heights; hloc.rowCounter = 0; int innerWidth = width - loc.marginWidth*2; @@ -157,7 +161,7 @@ for (int j = 0; j < segments.length; j++) { ParagraphSegment segment = segments[j]; bool doSelect = false; - if (selectedLink !is null && segment.equals(selectedLink)) + if (selectedLink !is null && segment.opEquals(cast(Object)selectedLink)) doSelect = true; segment.layout(gc, width, loc, resourceTable, doSelect); } @@ -178,7 +182,7 @@ if (!segment.intersects(repaintRegion)) continue; bool doSelect = false; - if (selectedLink !is null && segment.equals(selectedLink)) + if (selectedLink !is null && segment.opEquals(cast(Object)selectedLink)) doSelect = true; segment.paint(gc, false, resourceTable, doSelect, selData, repaintRegion); } @@ -199,18 +203,16 @@ public String getAccessibleText() { ParagraphSegment[] segments = getSegments(); - StringWriter swriter = new StringWriter(); - PrintWriter writer = new PrintWriter(swriter); + auto txt = new tango.text.Text.Text!(char); for (int i = 0; i < segments.length; i++) { ParagraphSegment segment = segments[i]; if ( auto ts = cast(TextSegment)segment ) { String text = ts.getText(); - writer.print(text); + txt.append(text); } } - writer.println(); - swriter.flush(); - return swriter.toString(); + txt.append( FileConst.NewlineString ); + return txt.toString(); } public ParagraphSegment findSegmentAt(int x, int y) {