diff dwtx/ui/internal/forms/widgets/TextSegment.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/TextSegment.d	Sat May 24 06:18:55 2008 +0200
+++ b/dwtx/ui/internal/forms/widgets/TextSegment.d	Sat May 24 06:59:31 2008 +0200
@@ -15,6 +15,7 @@
 import dwtx.ui.internal.forms.widgets.ParagraphSegment;
 import dwtx.ui.internal.forms.widgets.Locator;
 import dwtx.ui.internal.forms.widgets.SelectionData;
+import dwtx.ui.internal.forms.widgets.FormTextModel;
 
 import dwt.DWT;
 import dwt.graphics.Color;
@@ -145,7 +146,7 @@
 
     private String cleanup(String text) {
         StringBuffer buf = new StringBuffer();
-        for (int i = 0; i < text.length(); i++) {
+        for (int i = 0; i < text.length; i++) {
             char c = text.charAt(i);
             if (c is '\n' || c is '\r' || c is '\f') {
                 if (i > 0)
@@ -363,7 +364,7 @@
         //int lineY = ly + lineHeight - descent + 1;
         Rectangle br = new Rectangle(locator.x, ly, ewidth,
                 lineHeight - descent + 3);
-        areaRectangles.add(new AreaRectangle(br, 0, -1));
+        areaRectangles.append(new AreaRectangle(br, 0, -1));
         locator.x += ewidth;
         locator.width = ewidth;
         locator.rowHeight = Math.max(locator.rowHeight, extent.y);
@@ -371,7 +372,7 @@
 
     protected int convertOffsetToStringIndex(GC gc, String s, int x,
             int swidth, int selOffset) {
-        int index = s.length();
+        int index = s.length;
         while (index > 0 && x + swidth > selOffset) {
             index--;
             String ss = s.substring(0, index);
@@ -542,7 +543,7 @@
             }
             if (selectedRow) {
                 int lindex = sstart !is -1 ? sstart : 0;
-                int rindex = sstop !is -1 ? sstop : s.length();
+                int rindex = sstop !is -1 ? sstop : s.length;
                 String mid = s.substring(lindex, rindex);
                 Point extent = gc.textExtent(mid);
                 gc.setForeground(selData.fg);
@@ -589,7 +590,7 @@
 
         if (selectedRow) {
             int lindex = sstart !is -1 ? sstart : 0;
-            int rindex = sstop !is -1 ? sstop : s.length();
+            int rindex = sstop !is -1 ? sstop : s.length;
             String mid = s.substring(lindex, rindex);
             selData.addSegment(mid);
         }
@@ -691,7 +692,7 @@
                             locator.x - 1:locator.x, ly,
                             isSelectable()?lineExtent.x + 1:lineExtent.x, lineHeight - descent + 3);
                     areaRectangles
-                            .add(new AreaRectangle(br, lineStart, lastLoc));
+                            .append(new AreaRectangle(br, lineStart, lastLoc));
 
                     locator.rowHeight = Math.max(locator.rowHeight,
                             lineExtent.y);
@@ -718,7 +719,7 @@
                     isSelectable()?lineExtent.x + 1:lineExtent.x,
                     lineHeight - descent + 3);
             //int lineY = ly + lineHeight - descent + 1;
-            areaRectangles.add(new AreaRectangle(br, lineStart, lastLoc));
+            areaRectangles.append(new AreaRectangle(br, lineStart, lastLoc));
             locator.x += lastWidth;
             locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y);
         }
@@ -730,7 +731,7 @@
     private void computeTextFragments(GC gc) {
         if (textFragments !is null)
             return;
-        ArrayList list = new ArrayList();
+        ArraySeq!(Object) list = new ArraySeq!(Object);
         BreakIterator wb = BreakIterator.getLineInstance();
         wb.setText(getText());
         int cursor = 0;
@@ -739,15 +740,14 @@
                 continue;
             String word = text.substring(cursor, loc);
             Point extent = gc.textExtent(word);
-            list.add(new TextFragment(cast(short) loc, cast(short) extent.x));
+            list.append(new TextFragment(cast(short) loc, cast(short) extent.x));
             cursor = loc;
         }
-        textFragments = cast(TextFragment[]) list.toArray(new TextFragment[list
-                .size()]);
+        textFragments = arraycast!(TextFragment)(list.toArray());
     }
 
     public void clearCache(String fontId) {
-        if (fontIdisnull && (this.fontId is null||this.fontId.equals(FormTextModel.BOLD_FONT_ID)))
+        if (fontId is null && (this.fontId is null||this.fontId.equals(FormTextModel.BOLD_FONT_ID)))
             textFragments = null;
         else if (fontId !is null && this.fontId !is null && fontId.equals(this.fontId))
             textFragments = null;