Mercurial > projects > dwt-addons
diff dwtx/ui/internal/forms/widgets/TextSegment.d @ 90:7ffeace6c47f
Update 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 23:30:07 +0200 |
parents | 26c6c9dfd13c |
children | 11e8159caf7a |
line wrap: on
line diff
--- a/dwtx/ui/internal/forms/widgets/TextSegment.d Sun Jun 22 22:57:31 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/TextSegment.d Sun Jul 06 23:30:07 2008 +0200 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,6 +17,8 @@ import dwtx.ui.internal.forms.widgets.SelectionData; import dwtx.ui.internal.forms.widgets.FormTextModel; +// import com.ibm.icu.text.BreakIterator; + import dwt.DWT; import dwt.graphics.Color; import dwt.graphics.Font; @@ -26,6 +28,10 @@ import dwt.graphics.Rectangle; import dwt.dwthelper.utils; +// import mango.icu.ULocale; +// import mango.icu.UString; +// import mango.icu.UBreakIterator; +import dwtx.dwtxhelper.BreakIterator; import tango.util.collection.ArraySeq; /** @@ -34,32 +40,6 @@ */ public class TextSegment : ParagraphSegment { - //DWT_TODO temp type - static class BreakIterator{ - - public static const int DONE = 0; - - public static BreakIterator getLineInstance() { - // TODO Auto-generated method stub - return null; - } - - public void setText(String text) { - // TODO Auto-generated method stub - - } - - public int first() { - // TODO Auto-generated method stub - return 0; - } - - public int next() { - // TODO Auto-generated method stub - return 0; - } - - } private String colorId; private String fontId; @@ -304,7 +284,9 @@ if (isSelectable()) currentExtent += 1; - if (i !is 0 && currentExtent + textFragment.length > wHint) { + // i !is 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0) means: + // only wrap on the first fragment if we are not at the start of a line + if ((i !is 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0)) && currentExtent + textFragment.length > wHint) { // overflow int lineWidth = currentExtent; locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y); @@ -623,13 +605,17 @@ } if (reverse) { drawUnderline(gc, swidth, clipX, clipLineY, hover, rolloverMode); - gc.drawString(s, clipX, clipY, false); + drawString(gc, s, clipX, clipY); } else { - gc.drawString(s, clipX, clipY, false); + drawString(gc, s, clipX, clipY); drawUnderline(gc, swidth, clipX, clipLineY, hover, rolloverMode); } } + protected void drawString(GC gc, String s, int clipX, int clipY) { + gc.drawString(s, clipX, clipY, true); + } + private void drawUnderline(GC gc, int swidth, int x, int y, bool hover, bool rolloverMode) { if (underline || hover || rolloverMode) { @@ -682,7 +668,9 @@ int breakLoc = fragment.index; if (breakLoc is 0) continue; - if (i !is 0 && locator.x + lineExtent.x + fragment.length > rightEdge) { + // (i !is 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0)) means: + // only wrap on the first fragment if we are not at the start of a line + if ((i !is 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0)) && locator.x + lineExtent.x + fragment.length > rightEdge) { // overflow int lineWidth = locator.x + lineExtent.x; if (isSelectable()) @@ -732,10 +720,10 @@ if (textFragments !is null) return; ArraySeq!(Object) list = new ArraySeq!(Object); - BreakIterator wb = BreakIterator.getLineInstance(); - wb.setText(getText()); + auto wb = UBreakIterator.openLineIterator( ULocale.Default, getText() ); + scope(exit) wb.close(); int cursor = 0; - for (int loc = wb.first(); loc !is BreakIterator.DONE; loc = wb.next()) { + for (int loc = wb.first(); loc !is UBreakIterator.DONE; loc = wb.next()) { if (loc is 0) continue; String word = text.substring(cursor, loc);