Changeset 229:5ff96efb6f4b
- Timestamp:
- 05/24/08 02:37:28
(8 months ago)
- Author:
- Frank Benoit <benoit@tionex.de>
- branch:
- default
- Message:
Additions for forms
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r228 |
r229 |
|
| 121 | 121 | class Integer : ValueWrapperT!(int) { |
|---|
| 122 | 122 | |
|---|
| 123 | | public static int MIN_VALUE = 0x80000000; |
|---|
| 124 | | public static int MAX_VALUE = 0x7fffffff; |
|---|
| 125 | | public static int SIZE = 32; |
|---|
| | 123 | public static const int MIN_VALUE = 0x80000000; |
|---|
| | 124 | public static const int MAX_VALUE = 0x7fffffff; |
|---|
| | 125 | public static const int SIZE = 32; |
|---|
| 126 | 126 | |
|---|
| 127 | 127 | public this ( int value ){ |
|---|
| … | … | |
| 594 | 594 | return tango.text.Unicode.toFold(src) < tango.text.Unicode.toFold(other); |
|---|
| 595 | 595 | } |
|---|
| | 596 | public int compareTo( String src, String other ){ |
|---|
| | 597 | return src < other; |
|---|
| | 598 | } |
|---|
| 596 | 599 | |
|---|
| 597 | 600 | public bool startsWith( String src, String pattern ){ |
|---|
| r227 |
r229 |
|
| 12 | 12 | *******************************************************************************/ |
|---|
| 13 | 13 | module dwt.graphics.TextLayout; |
|---|
| | 14 | |
|---|
| | 15 | import tango.util.log.Trace; |
|---|
| 14 | 16 | |
|---|
| 15 | 17 | import dwt.DWT; |
|---|
| … | … | |
| 58 | 60 | |
|---|
| 59 | 61 | /++ |
|---|
| 60 | | DWT doku |
|---|
| 61 | | The styles has at minimum 2 member, each with a start. The last element is the end marker. |
|---|
| 62 | | ++/ |
|---|
| 63 | | |
|---|
| 64 | | invariant{ |
|---|
| 65 | | assert( stylesCount >= 2 ); |
|---|
| 66 | | assert( stylesCount <= styles.length ); |
|---|
| 67 | | assert( styles[stylesCount-1] ); |
|---|
| 68 | | assert( styles[stylesCount-1].start is text.length ); |
|---|
| 69 | | } |
|---|
| | 62 | + DWT doku |
|---|
| | 63 | + The styles has at minimum 2 member, each with a start. The last element is the end marker. |
|---|
| | 64 | + |
|---|
| | 65 | + invariant{ |
|---|
| | 66 | + assert( stylesCount >= 2 ); |
|---|
| | 67 | + assert( stylesCount <= styles.length ); |
|---|
| | 68 | + assert( styles[stylesCount-1] ); |
|---|
| | 69 | + assert( styles[stylesCount-1].start is text.length ); |
|---|
| | 70 | + } |
|---|
| | 71 | +/ |
|---|
| | 72 | |
|---|
| 70 | 73 | |
|---|
| 71 | 74 | Font font; |
|---|
| … | … | |
| 2261 | 2264 | int pcItems; |
|---|
| 2262 | 2265 | wchar[] chars = StrToWCHARs( segmentsText ); |
|---|
| | 2266 | Trace.formatln( "{} {}: segmentsText='{}' chars='{}'", __FILE__,__LINE__, segmentsText, chars ); |
|---|
| 2263 | 2267 | OS.ScriptItemize(chars.ptr, chars.length, MAX_ITEM, &scriptControl, &scriptState, pItems, &pcItems); |
|---|
| 2264 | 2268 | // if (hr is E_OUTOFMEMORY) //TODO handle it |
|---|
| | 2269 | |
|---|
| | 2270 | // Translate the utf16 indices to utf8 indices |
|---|
| | 2271 | Trace.formatln( "{} {}: pcItems={} chars.length={} segmentsText.length={}", __FILE__,__LINE__,pcItems, chars.length, segmentsText.length ); |
|---|
| | 2272 | int utf8idx = 0; |
|---|
| | 2273 | SCRIPT_ITEM* si = pItems; |
|---|
| | 2274 | foreach( uint utf16idx, char c; chars ){ |
|---|
| | 2275 | Trace.formatln( "{} {}: utf8idx={} utf16idx={} si.iCharPos={}", __FILE__,__LINE__,utf8idx, utf16idx, si.iCharPos ); |
|---|
| | 2276 | if( si.iCharPos is utf16idx ){ |
|---|
| | 2277 | si.iCharPos = utf8idx; |
|---|
| | 2278 | si++; |
|---|
| | 2279 | } |
|---|
| | 2280 | utf8idx++; |
|---|
| | 2281 | } |
|---|
| 2265 | 2282 | |
|---|
| 2266 | 2283 | StyleItem[] runs = merge(pItems, pcItems); |
|---|
| … | … | |
| 2279 | 2296 | } |
|---|
| 2280 | 2297 | int count = 0, start = 0, end = segmentsText.length, itemIndex = 0, styleIndex = 0; |
|---|
| | 2298 | Trace.formatln( "{} {}: itemCount={} stylesCount={}", __FILE__,__LINE__,itemCount, stylesCount ); |
|---|
| 2281 | 2299 | StyleItem[] runs = new StyleItem[itemCount + stylesCount]; |
|---|
| 2282 | 2300 | SCRIPT_ITEM* scriptItem = new SCRIPT_ITEM(); |
|---|
| 2283 | 2301 | bool linkBefore = false; |
|---|
| | 2302 | Trace.formatln( "{} {}: start={} end={}", __FILE__,__LINE__,start, end ); |
|---|
| 2284 | 2303 | while (start < end) { |
|---|
| 2285 | 2304 | StyleItem item = new StyleItem(); |
|---|
| 2286 | 2305 | item.start = start; |
|---|
| 2287 | 2306 | item.style = styles[styleIndex].style; |
|---|
| | 2307 | Trace.formatln( "{} {}: count={}", __FILE__,__LINE__,count ); |
|---|
| 2288 | 2308 | runs[count++] = item; |
|---|
| 2289 | 2309 | OS.MoveMemory(scriptItem, (cast(void*)items) + itemIndex * SCRIPT_ITEM.sizeof, SCRIPT_ITEM.sizeof); |
|---|
| … | … | |
| 2314 | 2334 | } |
|---|
| 2315 | 2335 | item.length = start - item.start; |
|---|
| | 2336 | Trace.formatln( "{} {}: start={} end={}", __FILE__,__LINE__,start, end ); |
|---|
| 2316 | 2337 | } |
|---|
| 2317 | 2338 | StyleItem item = new StyleItem(); |
|---|
| … | … | |
| 2319 | 2340 | OS.MoveMemory(scriptItem, (cast(void*)items) + itemCount * SCRIPT_ITEM.sizeof, SCRIPT_ITEM.sizeof); |
|---|
| 2320 | 2341 | item.analysis = scriptItem.a; |
|---|
| | 2342 | Trace.formatln( "{} {}: count={}", __FILE__,__LINE__,count ); |
|---|
| 2321 | 2343 | runs[count++] = item; |
|---|
| 2322 | 2344 | if (runs.length !is count) { |
|---|
| … | … | |
| 2722 | 2744 | public void setText (String text) { |
|---|
| 2723 | 2745 | checkLayout(); |
|---|
| | 2746 | |
|---|
| 2724 | 2747 | //PORTING_CHANGE: allow null argument |
|---|
| 2725 | 2748 | //if (text is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| … | … | |
| 2732 | 2755 | styles[1].start = text.length; |
|---|
| 2733 | 2756 | stylesCount = 2; |
|---|
| | 2757 | Trace.formatln( "{} {}: text='{}'", __FILE__,__LINE__, text ); |
|---|
| 2734 | 2758 | } |
|---|
| 2735 | 2759 | |
|---|