Mercurial > projects > dwt-win
changeset 229:5ff96efb6f4b
Additions for forms
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 24 May 2008 08:37:28 +0200 |
parents | 628e9518870e |
children | c853f6513712 |
files | dwt/dwthelper/utils.d dwt/graphics/TextLayout.d |
diffstat | 2 files changed, 39 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/dwthelper/utils.d Thu May 22 19:46:10 2008 +0200 +++ b/dwt/dwthelper/utils.d Sat May 24 08:37:28 2008 +0200 @@ -120,9 +120,9 @@ class Integer : ValueWrapperT!(int) { - public static int MIN_VALUE = 0x80000000; - public static int MAX_VALUE = 0x7fffffff; - public static int SIZE = 32; + public static const int MIN_VALUE = 0x80000000; + public static const int MAX_VALUE = 0x7fffffff; + public static const int SIZE = 32; public this ( int value ){ super( value ); @@ -593,6 +593,9 @@ public int compareToIgnoreCase( String src, String other ){ return tango.text.Unicode.toFold(src) < tango.text.Unicode.toFold(other); } +public int compareTo( String src, String other ){ + return src < other; +} public bool startsWith( String src, String pattern ){ if( src.length < pattern.length ){
--- a/dwt/graphics/TextLayout.d Thu May 22 19:46:10 2008 +0200 +++ b/dwt/graphics/TextLayout.d Sat May 24 08:37:28 2008 +0200 @@ -12,6 +12,8 @@ *******************************************************************************/ module dwt.graphics.TextLayout; +import tango.util.log.Trace; + import dwt.DWT; import dwt.DWTException; import dwt.internal.Compatibility; @@ -57,16 +59,17 @@ alias Resource.init_ init_; /++ - DWT doku - The styles has at minimum 2 member, each with a start. The last element is the end marker. -++/ + + DWT doku + + The styles has at minimum 2 member, each with a start. The last element is the end marker. + + + + invariant{ + + assert( stylesCount >= 2 ); + + assert( stylesCount <= styles.length ); + + assert( styles[stylesCount-1] ); + + assert( styles[stylesCount-1].start is text.length ); + + } + +/ - invariant{ - assert( stylesCount >= 2 ); - assert( stylesCount <= styles.length ); - assert( styles[stylesCount-1] ); - assert( styles[stylesCount-1].start is text.length ); - } Font font; String text, segmentsText; @@ -2260,9 +2263,23 @@ if (pItems is null) DWT.error(DWT.ERROR_NO_HANDLES); int pcItems; wchar[] chars = StrToWCHARs( segmentsText ); + Trace.formatln( "{} {}: segmentsText='{}' chars='{}'", __FILE__,__LINE__, segmentsText, chars ); OS.ScriptItemize(chars.ptr, chars.length, MAX_ITEM, &scriptControl, &scriptState, pItems, &pcItems); // if (hr is E_OUTOFMEMORY) //TODO handle it + // Translate the utf16 indices to utf8 indices + Trace.formatln( "{} {}: pcItems={} chars.length={} segmentsText.length={}", __FILE__,__LINE__,pcItems, chars.length, segmentsText.length ); + int utf8idx = 0; + SCRIPT_ITEM* si = pItems; + foreach( uint utf16idx, char c; chars ){ + Trace.formatln( "{} {}: utf8idx={} utf16idx={} si.iCharPos={}", __FILE__,__LINE__,utf8idx, utf16idx, si.iCharPos ); + if( si.iCharPos is utf16idx ){ + si.iCharPos = utf8idx; + si++; + } + utf8idx++; + } + StyleItem[] runs = merge(pItems, pcItems); OS.HeapFree(hHeap, 0, pItems); return runs; @@ -2278,13 +2295,16 @@ styles = newStyles; } int count = 0, start = 0, end = segmentsText.length, itemIndex = 0, styleIndex = 0; +Trace.formatln( "{} {}: itemCount={} stylesCount={}", __FILE__,__LINE__,itemCount, stylesCount ); StyleItem[] runs = new StyleItem[itemCount + stylesCount]; SCRIPT_ITEM* scriptItem = new SCRIPT_ITEM(); bool linkBefore = false; +Trace.formatln( "{} {}: start={} end={}", __FILE__,__LINE__,start, end ); while (start < end) { StyleItem item = new StyleItem(); item.start = start; item.style = styles[styleIndex].style; +Trace.formatln( "{} {}: count={}", __FILE__,__LINE__,count ); runs[count++] = item; OS.MoveMemory(scriptItem, (cast(void*)items) + itemIndex * SCRIPT_ITEM.sizeof, SCRIPT_ITEM.sizeof); item.analysis = scriptItem.a; @@ -2313,11 +2333,13 @@ start = itemLimit; } item.length = start - item.start; +Trace.formatln( "{} {}: start={} end={}", __FILE__,__LINE__,start, end ); } StyleItem item = new StyleItem(); item.start = end; OS.MoveMemory(scriptItem, (cast(void*)items) + itemCount * SCRIPT_ITEM.sizeof, SCRIPT_ITEM.sizeof); item.analysis = scriptItem.a; +Trace.formatln( "{} {}: count={}", __FILE__,__LINE__,count ); runs[count++] = item; if (runs.length !is count) { StyleItem[] result = new StyleItem[count]; @@ -2721,6 +2743,7 @@ */ public void setText (String text) { checkLayout(); + //PORTING_CHANGE: allow null argument //if (text is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (text.equals(this.text)) return; @@ -2731,6 +2754,7 @@ styles[1] = new StyleItem(); styles[1].start = text.length; stylesCount = 2; +Trace.formatln( "{} {}: text='{}'", __FILE__,__LINE__, text ); } /**