Mercurial > projects > dwt-addons
diff dwtx/ui/internal/forms/widgets/FormUtil.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 | 4ac9946b9fb5 |
children | 11e8159caf7a |
line wrap: on
line diff
--- a/dwtx/ui/internal/forms/widgets/FormUtil.d Sun Jun 22 22:57:31 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/FormUtil.d Sun Jul 06 23:30:07 2008 +0200 @@ -14,6 +14,8 @@ module dwtx.ui.internal.forms.widgets.FormUtil; +// import com.ibm.icu.text.BreakIterator; + import dwt.DWT; import dwt.custom.ScrolledComposite; import dwt.events.MouseEvent; @@ -40,42 +42,13 @@ import dwt.dwthelper.utils; -//import com.ibm.icu.text.BreakIterator; +import dwtx.dwtxhelper.BreakIterator; +// import mango.icu.UString; +// import mango.icu.ULocale; +// import mango.icu.UBreakIterator; + public class FormUtil { - //DWT_TODO temp type - static class BreakIterator{ - - public static const int DONE = 0; - char[] text; - static BreakIterator inst; - public static BreakIterator getWordInstance() { - if( inst is null ){ - inst = new BreakIterator; - } - return inst; - } - uint last = 0; - - public void setText(String text) { - this.text = text; - last = 0; - } - public int first() { - // TODO Auto-generated method stub - return text.length > 0 ? 1 : 0; - } - - public int next() { - // TODO Auto-generated method stub - last++; - if( last >= text.length ){ - return DONE; - } - return last; - } - - } public static const String PLUGIN_ID = "dwtx.ui.forms"; //$NON-NLS-1$ static const int H_SCROLL_INCREMENT = 5; @@ -138,13 +111,12 @@ } public static int computeMinimumWidth(GC gc, String text) { - BreakIterator wb = BreakIterator.getWordInstance(); - wb.setText(text); + auto wb = UBreakIterator.openWordIterator( ULocale.Default, text ); + scope(exit) wb.close(); int last = 0; - int width = 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()) { String word = text.substring(last, loc); Point extent = gc.textExtent(word); width = Math.max(width, extent.x); @@ -157,8 +129,8 @@ } public static Point computeWrapSize(GC gc, String text, int wHint) { - BreakIterator wb = BreakIterator.getWordInstance(); - wb.setText(text); + auto wb = UBreakIterator.openWordIterator( ULocale.Default, text ); + scope(exit) wb.close(); FontMetrics fm = gc.getFontMetrics(); int lineHeight = fm.getHeight(); @@ -166,7 +138,7 @@ int last = 0; int height = lineHeight; int maxWidth = 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()) { String word = text.substring(saved, loc); Point extent = gc.textExtent(word); if (extent.x > wHint) { @@ -196,8 +168,8 @@ public static void paintWrapText(GC gc, String text, Rectangle bounds, bool underline) { - BreakIterator wb = BreakIterator.getWordInstance(); - wb.setText(text); + auto wb = UBreakIterator.openWordIterator( ULocale.Default, text ); + scope(exit) wb.close(); FontMetrics fm = gc.getFontMetrics(); int lineHeight = fm.getHeight(); int descent = fm.getDescent(); @@ -207,7 +179,7 @@ int y = bounds.y; int width = bounds.width; - for (int loc = wb.first(); loc !is BreakIterator.DONE; loc = wb.next()) { + for (int loc = wb.first(); loc !is UBreakIterator.DONE; loc = wb.next()) { String line = text.substring(saved, loc); Point extent = gc.textExtent(line);