changeset 197:184ab53b7785

Changes and fixes for jface
author Frank Benoit <benoit@tionex.de>
date Thu, 10 Apr 2008 11:19:49 +0200
parents 1e7701c27c03
children be4ce760802a
files dwt/custom/BusyIndicator.d dwt/custom/CTabFolder.d dwt/custom/StyledText.d dwt/dnd/HTMLTransfer.d dwt/dnd/RTFTransfer.d dwt/dnd/TextTransfer.d dwt/dnd/URLTransfer.d dwt/dwthelper/BufferedInputStream.d dwt/dwthelper/Float.d dwt/dwthelper/Integer.d dwt/dwthelper/ResourceBundle.d dwt/dwthelper/System.d dwt/dwthelper/utils.d dwt/graphics/Color.d dwt/graphics/Cursor.d dwt/graphics/Device.d dwt/graphics/Font.d dwt/graphics/FontData.d dwt/graphics/GC.d dwt/graphics/Image.d dwt/internal/BidiUtil.d dwt/internal/DWTEventObject.d dwt/internal/image/TIFFDirectory.d dwt/layout/GridLayout.d dwt/program/Program.d dwt/widgets/Display.d dwt/widgets/Spinner.d
diffstat 27 files changed, 638 insertions(+), 371 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/custom/BusyIndicator.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/custom/BusyIndicator.d	Thu Apr 10 11:19:49 2008 +0200
@@ -18,7 +18,7 @@
 import dwt.graphics.Cursor;
 import dwt.widgets.Display;
 import dwt.widgets.Shell;
-import dwt.dwthelper.Integer;
+import dwt.dwthelper.utils;
 import dwt.dwthelper.Runnable;
 
 /**
--- a/dwt/custom/CTabFolder.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/custom/CTabFolder.d	Thu Apr 10 11:19:49 2008 +0200
@@ -49,7 +49,6 @@
 import dwt.custom.CTabFolderEvent;
 
 import dwt.dwthelper.utils;
-import dwt.dwthelper.Integer;
 import tango.util.Convert;
 static import tango.text.convert.Utf;
 
--- a/dwt/custom/StyledText.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/custom/StyledText.d	Thu Apr 10 11:19:49 2008 +0200
@@ -465,7 +465,7 @@
             printerRenderer = null;
         }
     }
-    void init() {
+    void init_() {
         Rectangle trim = printer.computeTrim(0, 0, 0, 0);
         Point dpi = printer.getDPI();
 
@@ -694,7 +694,7 @@
             jobName = "Printing";
         }
         if (printer.startJob(jobName)) {
-            init();
+            init_();
             print();
             dispose();
             printer.endJob();
--- a/dwt/dnd/HTMLTransfer.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/dnd/HTMLTransfer.d	Thu Apr 10 11:19:49 2008 +0200
@@ -20,7 +20,6 @@
 import dwt.dnd.TransferData;
 import dwt.dnd.DND;
 
-import dwt.dwthelper.Integer;
 import dwt.dwthelper.utils;
 static import tango.text.Text;
 alias tango.text.Text.Text!(char) StringBuffer;
--- a/dwt/dnd/RTFTransfer.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/dnd/RTFTransfer.d	Thu Apr 10 11:19:49 2008 +0200
@@ -20,7 +20,6 @@
 import dwt.dnd.TransferData;
 import dwt.dnd.DND;
 
-import dwt.dwthelper.Integer;
 import dwt.dwthelper.utils;
 static import tango.text.Text;
 alias tango.text.Text.Text!(char) StringBuffer;
--- a/dwt/dnd/TextTransfer.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/dnd/TextTransfer.d	Thu Apr 10 11:19:49 2008 +0200
@@ -20,7 +20,6 @@
 import dwt.dnd.TransferData;
 import dwt.dnd.DND;
 
-import dwt.dwthelper.Integer;
 import dwt.dwthelper.utils;
 static import tango.text.Text;
 alias tango.text.Text.Text!(char) StringBuffer;
--- a/dwt/dnd/URLTransfer.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/dnd/URLTransfer.d	Thu Apr 10 11:19:49 2008 +0200
@@ -22,7 +22,6 @@
 import dwt.dnd.TransferData;
 import dwt.dnd.DND;
 
-import dwt.dwthelper.Integer;
 import dwt.dwthelper.utils;
 static import tango.text.Text;
 alias tango.text.Text.Text!(char) StringBuffer;
--- a/dwt/dwthelper/BufferedInputStream.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/dwthelper/BufferedInputStream.d	Thu Apr 10 11:19:49 2008 +0200
@@ -50,7 +50,7 @@
         assert( pos == count );
         pos = 0;
         count = 0;
-        int count = getAndCheckIstr().read( buf );
+        count = getAndCheckIstr().read( buf );
         if( count < 0 ){
             count = 0;
             istr = null;
--- a/dwt/dwthelper/Float.d	Mon Apr 07 13:08:57 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-module dwt.dwthelper.Float;
-
-import dwt.dwthelper.utils;
-static import tango.text.convert.Float;
-import tango.core.Exception;
-
-public final class Float {
-
-    public static float POSITIVE_INFINITY = (1.0f / 0.0f);
-    public static float NEGATIVE_INFINITY = ((-1.0f) / 0.0f);
-    public static float NaN = (0.0f / 0.0f);
-    public static float MAX_VALUE = 3.4028235e+38f;
-    public static float MIN_VALUE = 1.4e-45f;
-    public static int SIZE = 32;
-    public this ( float value ){
-        implMissing( __FILE__, __LINE__ );
-    }
-
-    public this ( double value ){
-        implMissing( __FILE__, __LINE__ );
-    }
-
-    public this ( char[] s ){
-        implMissing( __FILE__, __LINE__ );
-    }
-
-    public static char[] toString( float f ){
-        implMissing( __FILE__, __LINE__ );
-        return null;
-    }
-
-    public static char[] toHexString( float f ){
-        implMissing( __FILE__, __LINE__ );
-        return null;
-    }
-
-    public static Float valueOf( char[] s ){
-        implMissing( __FILE__, __LINE__ );
-        return null;
-    }
-
-    public static Float valueOf( float f ){
-        implMissing( __FILE__, __LINE__ );
-        return null;
-    }
-
-    public static float parseFloat( char[] s ){
-        try{
-            return tango.text.convert.Float.toFloat( s );
-        }
-        catch( IllegalArgumentException e ){
-            throw new NumberFormatException( e );
-        }
-    }
-
-    public static bool isNaN( float v ){
-        implMissing( __FILE__, __LINE__ );
-        return false;
-    }
-
-    public static bool isInfinite( float v ){
-        implMissing( __FILE__, __LINE__ );
-        return false;
-    }
-
-    public bool isNaN(){
-        implMissing( __FILE__, __LINE__ );
-        return false;
-    }
-
-    public bool isInfinite(){
-        implMissing( __FILE__, __LINE__ );
-        return false;
-    }
-
-    public char[] toString(){
-        implMissing( __FILE__, __LINE__ );
-        return null;
-    }
-
-    public byte byteValue(){
-        implMissing( __FILE__, __LINE__ );
-        return 0;
-    }
-
-    public short shortValue(){
-        implMissing( __FILE__, __LINE__ );
-        return 0;
-    }
-
-    public int intValue(){
-        implMissing( __FILE__, __LINE__ );
-        return 0;
-    }
-
-    public long longValue(){
-        implMissing( __FILE__, __LINE__ );
-        return 0L;
-    }
-
-    public float floatValue(){
-        implMissing( __FILE__, __LINE__ );
-        return 0.0f;
-    }
-
-    public double doubleValue(){
-        implMissing( __FILE__, __LINE__ );
-        return 0.0;
-    }
-
-    public hash_t toHash(){
-        implMissing( __FILE__, __LINE__ );
-        return 0;
-    }
-
-    public int opEquals( Object obj ){
-        implMissing( __FILE__, __LINE__ );
-        return false;
-    }
-
-    public static int floatToIntBits( float value ){
-        implMissing( __FILE__, __LINE__ );
-        return 0;
-    }
-
-    public static int floatToRawIntBits( float value ){
-        implMissing( __FILE__, __LINE__ );
-        return 0;
-    }
-
-    public static float intBitsToFloat( int bits ){
-        implMissing( __FILE__, __LINE__ );
-        return 0.0f;
-    }
-
-    public int compareTo( Object anotherByte ){
-        implMissing( __FILE__, __LINE__ );
-        return 0;
-    }
-
-    public static int compare( float f1, float f2 ){
-        implMissing( __FILE__, __LINE__ );
-        return 0;
-    }
-
-
-}
-
-
--- a/dwt/dwthelper/Integer.d	Mon Apr 07 13:08:57 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/**
- * Authors: Frank Benoit <keinfarbton@googlemail.com>
- */
-
-module dwt.dwthelper.Integer;
-
-import dwt.dwthelper.utils;
-
-static import tango.text.convert.Integer;
-private import tango.core.Exception;
-
-public final class Byte {
-    public static byte parseByte( char[] s ){
-        try{
-            int res = tango.text.convert.Integer.parse( s );
-            if( res < byte.min || res > byte.max ){
-                throw new NumberFormatException( "out of range" );
-            }
-            return res;
-        }
-        catch( IllegalArgumentException e ){
-            throw new NumberFormatException( e );
-        }
-    }
-}
-public final class Integer {
-
-    public static int MIN_VALUE = 0x80000000;
-    public static int MAX_VALUE = 0x7fffffff;
-    public static int SIZE = 32;
-
-    public int value;
-    public this ( int value ){
-        this.value = value;
-    }
-
-    public this ( char[] s ){
-    }
-
-    public static char[] toString( int i, int radix ){
-        switch( radix ){
-        case 2:
-            return toBinaryString(i);
-        case 8:
-            return toOctalString(i);
-        case 10:
-            return toString(i);
-        case 16:
-            return toHexString(i);
-        default:
-            implMissing( __FILE__, __LINE__ );
-            return null;
-        }
-    }
-
-    public static char[] toHexString( int i ){
-        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex );
-    }
-
-    public static char[] toOctalString( int i ){
-        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal );
-    }
-
-    public static char[] toBinaryString( int i ){
-        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary );
-    }
-
-    public static char[] toString( int i ){
-        return tango.text.convert.Integer.toString(i);
-    }
-
-    public static int parseInt( char[] s, int radix ){
-        try{
-            return tango.text.convert.Integer.parse( s, cast(uint)radix );
-        }
-        catch( IllegalArgumentException e ){
-            throw new NumberFormatException( e );
-        }
-    }
-
-    public static int parseInt( char[] s ){
-        try{
-            return tango.text.convert.Integer.parse( s );
-        }
-        catch( IllegalArgumentException e ){
-            throw new NumberFormatException( e );
-        }
-    }
-
-    public static Integer valueOf( char[] s, int radix ){
-        implMissing( __FILE__, __LINE__ );
-        return null;
-    }
-
-    public static Integer valueOf( char[] s ){
-        implMissing( __FILE__, __LINE__ );
-        return null;
-    }
-
-    public static Integer valueOf( int i ){
-        implMissing( __FILE__, __LINE__ );
-        return null;
-    }
-
-    public byte byteValue(){
-        return cast(byte)value;
-    }
-
-    public short shortValue(){
-        return cast(short)value;
-    }
-
-    public int intValue(){
-        return value;
-    }
-
-    public long longValue(){
-        return cast(long)value;
-    }
-
-    public float floatValue(){
-        return cast(float)value;
-    }
-
-    public double doubleValue(){
-        return cast(double)value;
-    }
-
-    public override  hash_t toHash(){
-        return intValue();
-    }
-
-    public override int opEquals( Object obj ){
-        implMissing( __FILE__, __LINE__ );
-        return false;
-    }
-
-    public override char[] toString(){
-        return tango.text.convert.Integer.toString( value );
-    }
-}
-
-
--- a/dwt/dwthelper/ResourceBundle.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/dwthelper/ResourceBundle.d	Thu Apr 10 11:19:49 2008 +0200
@@ -6,6 +6,8 @@
 import tango.text.Util;
 import tango.io.Stdout;
 
+import dwt.DWT;
+import dwt.dwthelper.utils;
 
 class ResourceBundle {
 
@@ -34,7 +36,7 @@
         while( dataIndex < data.length ){
             //tango.io.Stdout.Stdout.formatln( "properties put {} startline", __LINE__ );
             readLine();
-            line = line.trim();
+            line = dwt.dwthelper.utils.trim(line);
             if( line.length is 0 ){
                 //tango.io.Stdout.Stdout.formatln( "properties put {} was 0 length", __LINE__ );
                 continue;
@@ -61,6 +63,7 @@
                     case 't': c = '\t'; break;
                     case 'n': c = '\n'; break;
                     case '\\': c = '\\'; break;
+                    case '\"': c = '\"'; break;
                     default: break;
                     }
                 }
@@ -89,11 +92,12 @@
                 }
             }
             if( iskeypart ){
-                //tango.io.Stdout.Stdout.formatln( "dwt.dwthelper.ResourceBundle ctor cannot find '='." );
+                // Cannot find '=' in record
+                DWT.error( __FILE__, __LINE__, DWT.ERROR_INVALID_ARGUMENT );
                 continue;
             }
-            key = key.trim();
-            value = value.trim();
+            key = dwt.dwthelper.utils.trim(key);
+            value = dwt.dwthelper.utils.trim(value);
             //tango.io.Stdout.Stdout.formatln( "properties put {}=>{}", key, value );
 
             map[ key.dup ] = value.dup;
@@ -109,7 +113,11 @@
         if( auto v = key in map ){
             return (*v).dup;
         }
-        return key;
+        throw new MissingResourceException( "key not found", this.classinfo.name, key );
+    }
+
+    public char[][] getKeys(){
+        return map.keys;
     }
 
     public static ResourceBundle getBundle( char[] name ){
--- a/dwt/dwthelper/System.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/dwthelper/System.d	Thu Apr 10 11:19:49 2008 +0200
@@ -128,6 +128,18 @@
     static void exit( int code ){
         .exit(code);
     }
+    public static int identityHashCode(Object x){
+        if( x is null ){
+            return 0;
+        }
+        return (*cast(Object *)&x).toHash();
+    }
 
+    public static char[] getProperty( char[] key ){
+        switch( key ){
+        case "os.name": return "windows";
+        default: return null;
+        }
+    }
 }
 
--- a/dwt/dwthelper/utils.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/dwthelper/utils.d	Thu Apr 10 11:19:49 2008 +0200
@@ -9,14 +9,31 @@
 public import tango.core.Exception : IllegalArgumentException, IOException;
 
 import tango.io.Stdout;
+import tango.io.Print;
 import tango.stdc.stringz;
 static import tango.text.Util;
+static import tango.text.Text;
 import tango.text.Unicode;
 import tango.text.convert.Utf;
 import tango.core.Exception;
 import tango.stdc.stdlib : exit;
 
 import tango.util.log.Trace;
+import tango.text.UnicodeData;
+static import tango.util.collection.model.Seq;
+// static import tango.util.collection.ArraySeq;
+// static import tango.util.collection.LinkSeq;
+// static import tango.util.collection.model.Map;
+// static import tango.util.collection.HashMap;
+//
+// alias tango.util.collection.model.Seq.Seq!(Object) List;
+// alias tango.util.collection.ArraySeq.ArraySeq!(Object) ArrayList;
+// alias tango.util.collection.LinkSeq.LinkSeq!(Object) LinkList;
+// alias tango.util.collection.model.Map.Map!(Object,Object) Map;
+// alias tango.util.collection.HashMap.HashMap!(Object,Object) HashMap;
+
+alias char[] String;
+alias tango.text.Text.Text!(char) StringBuffer;
 
 void implMissing( char[] file, uint line ){
     Stderr.formatln( "implementation missing in file {} line {}", file, line );
@@ -41,17 +58,264 @@
     public this( T data ){
         value = data;
     }
+    public int opEquals( T other ){
+        return value == other;
+    }
+    public int opEquals( Object other ){
+        if( auto o = cast(ValueWrapperT!(T))other ){
+            return value == o.value;
+        }
+        return false;
+    }
+}
+
+class Boolean : ValueWrapperT!(bool) {
+    public static Boolean TRUE;
+    public static Boolean FALSE;
+    public this( bool v ){
+        super(v);
+    }
+
+    alias ValueWrapperT!(bool).opEquals opEquals;
+    public int opEquals( int other ){
+        return value == ( other !is 0 );
+    }
+    public int opEquals( Object other ){
+        if( auto o = cast(Boolean)other ){
+            return value == o.value;
+        }
+        return false;
+    }
+    public bool booleanValue(){
+        return value;
+    }
 }
 
-alias ValueWrapperT!(bool)    ValueWrapperBool;
-alias ValueWrapperT!(int)     ValueWrapperInt;
-alias ValueWrapperT!(long)    ValueWrapperLong;
+alias Boolean    ValueWrapperBool;
+
+
+class Byte : ValueWrapperT!(byte) {
+    public static byte parseByte( char[] s ){
+        try{
+            int res = tango.text.convert.Integer.parse( s );
+            if( res < byte.min || res > byte.max ){
+                throw new NumberFormatException( "out of range" );
+            }
+            return res;
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
+    }
+    this( byte value ){
+        super( value );
+    }
+}
+alias Byte ValueWrapperByte;
+
+
+class Integer : ValueWrapperT!(int) {
+
+    public static int MIN_VALUE = 0x80000000;
+    public static int MAX_VALUE = 0x7fffffff;
+    public static int SIZE = 32;
+
+    public this ( int value ){
+        super( value );
+    }
+
+    public this ( char[] s ){
+            implMissing( __FILE__, __LINE__ );
+            super(0);
+    }
+
+    public static char[] toString( int i, int radix ){
+        switch( radix ){
+        case 2:
+            return toBinaryString(i);
+        case 8:
+            return toOctalString(i);
+        case 10:
+            return toString(i);
+        case 16:
+            return toHexString(i);
+        default:
+            implMissing( __FILE__, __LINE__ );
+            return null;
+        }
+    }
+
+    public static char[] toHexString( int i ){
+        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex );
+    }
+
+    public static char[] toOctalString( int i ){
+        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal );
+    }
+
+    public static char[] toBinaryString( int i ){
+        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary );
+    }
+
+    public static char[] toString( int i ){
+        return tango.text.convert.Integer.toString(i);
+    }
+
+    public static int parseInt( char[] s, int radix ){
+        try{
+            return tango.text.convert.Integer.parse( s, cast(uint)radix );
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
+    }
+
+    public static int parseInt( char[] s ){
+        try{
+            return tango.text.convert.Integer.parse( s );
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
+    }
+
+    public static Integer valueOf( char[] s, int radix ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+
+    public static Integer valueOf( char[] s ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+
+    public static Integer valueOf( int i ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+
+    public byte byteValue(){
+        return cast(byte)value;
+    }
+
+    public short shortValue(){
+        return cast(short)value;
+    }
+
+    public int intValue(){
+        return value;
+    }
+
+    public long longValue(){
+        return cast(long)value;
+    }
+
+    public float floatValue(){
+        return cast(float)value;
+    }
+
+    public double doubleValue(){
+        return cast(double)value;
+    }
+
+    public override  hash_t toHash(){
+        return intValue();
+    }
+
+    public override char[] toString(){
+        return tango.text.convert.Integer.toString( value );
+    }
+}
+alias Integer ValueWrapperInt;
+
+class Double : ValueWrapperT!(double) {
+    this( double value ){
+        super(value);
+    }
+    this( char[] str ){
+        implMissing( __FILE__, __LINE__ );
+        super(0.0);
+    }
+    public double doubleValue(){
+        return value;
+    }
+    public static char[] toString( double value ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+}
+
+class Float : ValueWrapperT!(float) {
+
+    public static float POSITIVE_INFINITY = (1.0f / 0.0f);
+    public static float NEGATIVE_INFINITY = ((-1.0f) / 0.0f);
+    public static float NaN = (0.0f / 0.0f);
+    public static float MAX_VALUE = 3.4028235e+38f;
+    public static float MIN_VALUE = 1.4e-45f;
+    public static int SIZE = 32;
+
+    this( float value ){
+        super(value);
+    }
+    this( char[] str ){
+        implMissing( __FILE__, __LINE__ );
+        super(0.0);
+    }
+    public float floatValue(){
+        return value;
+    }
+    public static char[] toString( float value ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+    public static float parseFloat( char[] s ){
+        try{
+            return tango.text.convert.Float.toFloat( s );
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
+    }
+
+}
+class Long : ValueWrapperT!(long) {
+    this( long value ){
+        super(value);
+    }
+    this( char[] str ){
+        implMissing( __FILE__, __LINE__ );
+        super(0);
+    }
+    public long longValue(){
+        return value;
+    }
+    public static long parseLong(char[] s){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+    public static char[] toString( double value ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+}
+alias Long ValueWrapperLong;
+
+
+// alias ValueWrapperT!(int)     ValueWrapperInt;
+
 alias ArrayWrapperT!(byte)    ArrayWrapperByte;
 alias ArrayWrapperT!(int)     ArrayWrapperInt;
 alias ArrayWrapperT!(Object)  ArrayWrapperObject;
 alias ArrayWrapperT!(char)    ArrayWrapperString;
 alias ArrayWrapperT!(char[])  ArrayWrapperString2;
 
+Object[] StringArrayToObjectArray( String[] strs ){
+    Object[] res = new Object[strs.length];
+    foreach( idx, str; strs ){
+        res[idx] = new ArrayWrapperString(str);
+    }
+    return res;
+}
 int codepointIndexToIndex( char[] str, int cpIndex ){
     int cps = cpIndex;
     int res = 0;
@@ -203,6 +467,9 @@
     return offset;
 }
 
+bool CharacterIsDefined( dchar ch ){
+    return (ch in tango.text.UnicodeData.unicodeData) !is null;
+}
 dchar CharacterFirstToLower( char[] str ){
     int consumed;
     return CharacterFirstToLower( str, consumed );
@@ -228,6 +495,12 @@
 bool CharacterIsDigit( dchar c ){
     return tango.text.Unicode.isDigit( c );
 }
+bool CharacterIsLetter( dchar c ){
+    return tango.text.Unicode.isLetter( c );
+}
+public char[] toUpperCase( char[] str ){
+    return tango.text.Unicode.toUpper( str );
+}
 
 public int indexOf( char[] str, char searched ){
     int res = tango.text.Util.locate( str, searched );
@@ -259,6 +532,14 @@
     if( res is str.length ) res = -1;
     return res;
 }
+public int lastIndexOf(char[] str, char[] ch ){
+    return lastIndexOf( str, ch, str.length );
+}
+public int lastIndexOf(char[] str, char[] ch, int start ){
+    int res = tango.text.Util.locatePatternPrior( str, ch, start );
+    if( res is str.length ) res = -1;
+    return res;
+}
 
 public char[] replace( char[] str, char from, char to ){
     return tango.text.Util.replace( str.dup, from, to );
@@ -313,6 +594,7 @@
     }
     return src[ 0 .. pattern.length ] == pattern;
 }
+
 public char[] toLowerCase( char[] src ){
     return tango.text.Unicode.toLower( src );
 }
@@ -324,6 +606,9 @@
 public char[] trim( char[] str ){
     return tango.text.Util.trim( str ).dup;
 }
+public char[] intern( char[] str ){
+    return str;
+}
 
 public char* toStringzValidPtr( char[] src ){
     if( src ){
@@ -346,6 +631,28 @@
             );
 }
 
+class RuntimeException : Exception {
+    this( char[] e = null){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+    }
+}
+class IndexOutOfBoundsException : Exception {
+    this( char[] e = null){
+        super(e);
+    }
+}
+
+class UnsupportedOperationException : RuntimeException {
+    this( char[] e = null){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+    }
+}
 class NumberFormatException : IllegalArgumentException {
     this( char[] e ){
         super(e);
@@ -354,6 +661,86 @@
         super(e.toString);
     }
 }
+class NullPointerException : Exception {
+    this( char[] e = null ){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+    }
+}
+class IllegalStateException : Exception {
+    this( char[] e = null ){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+    }
+}
+class InterruptedException : Exception {
+    this( char[] e = null ){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+    }
+}
+class InvocationTargetException : Exception {
+    Exception cause;
+    this( Exception e = null, char[] msg = null ){
+        super(msg);
+        cause = e;
+    }
+
+    alias getCause getTargetException;
+    Exception getCause(){
+        return cause;
+    }
+}
+class MissingResourceException : Exception {
+    char[] classname;
+    char[] key;
+    this( char[] msg, char[] classname, char[] key ){
+        super(msg);
+        this.classname = classname;
+        this.key = key;
+    }
+}
+class ParseException : Exception {
+    this( char[] e = null ){
+        super(e);
+    }
+}
+
+interface Cloneable{
+}
+
+interface Comparable {
+    int compareTo(Object o);
+}
+interface Comparator {
+    int compare(Object o1, Object o2);
+}
+interface EventListener{
+}
+
+class EventObject {
+    protected Object source;
+
+    public this(Object source) {
+        if (source is null)
+        throw new IllegalArgumentException( "null arg" );
+        this.source = source;
+    }
+
+    public Object getSource() {
+        return source;
+    }
+
+    public override char[] toString() {
+        return this.classinfo.name ~ "[source=" ~ source.toString() ~ "]";
+    }
+}
 
 private struct GCStats {
     size_t poolsize;        // total size of pool
@@ -370,5 +757,184 @@
 }
 
 
+void ExceptionPrintStackTrace( Exception e ){
+    ExceptionPrintStackTrace( e, Stderr );
+}
+void ExceptionPrintStackTrace( Exception e, Print!(char) print ){
+    print.formatln( "Exception in {}({}): {}", e.file, e.line, e.msg );
+}
+
+interface Reader{
+}
+interface Writer{
+}
+
+
+class Collator : Comparator {
+    public static Collator getInstance(){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+    private this(){
+    }
+    int compare(Object o1, Object o2){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+}
+
+interface Enumeration {
+    public bool hasMoreElements();
+    public Object nextElement();
+}
+
+
+template arraycast(T) {
+    T[] arraycast(U) (U[] u) {
+        static if (
+            (is (T == interface ) && is (U == interface )) ||
+            (is (T == class ) && is (U == class ))) {
+            return(cast(T[])u);
+        }
+        else {
+            int l = u.length;
+            T[] res;
+            res.length = l;
+            for (int i = 0; i < l; i++) {
+                res[i] = cast(T)u[i];
+            }
+            return(res);
+        }
+    }
+}
+
+char[] stringcast( Object o ){
+    if( auto str = cast(ArrayWrapperString) o ){
+        return str.array;
+    }
+    return null;
+}
+char[][] stringcast( Object[] objs ){
+    char[][] res = new char[][](objs.length);
+    foreach( idx, obj; objs ){
+        res[idx] = stringcast(obj);
+    }
+    return res;
+}
+ArrayWrapperString stringcast( char[] str ){
+    return new ArrayWrapperString( str );
+}
+ArrayWrapperString[] stringcast( char[][] strs ){
+    ArrayWrapperString[] res = new ArrayWrapperString[ strs.length ];
+    foreach( idx, str; strs ){
+        res[idx] = stringcast(str);
+    }
+    return res;
+}
 
 
+bool ArrayEquals(T)( T[] a, T[] b ){
+    if( a.length !is b.length ){
+        return false;
+    }
+    for( int i = 0; i < a.length; i++ ){
+        static if( is( T==class) || is(T==interface)){
+            if( a[i] !is null && b[i] !is null ){
+                if( a[i] != b[i] ){
+                    return false;
+                }
+            }
+            else if( a[i] is null && b[i] is null ){
+            }
+            else{
+                return false;
+            }
+        }
+        else{
+            if( a[i] != b[i] ){
+                return false;
+            }
+        }
+    }
+}
+
+class Arrays{
+    public static bool equals(Object[] a, Object[] b){
+        if( a.length !is b.length ){
+            return false;
+        }
+        for( int i = 0; i < a.length; i++ ){
+            if( a[i] is null && b[i] is null ){
+                continue;
+            }
+            if( a[i] !is null && b[i] !is null && a[i] == b[i] ){
+                continue;
+            }
+            return false;
+        }
+        return true;
+    }
+}
+
+int SeqIndexOf(T)( tango.util.collection.model.Seq.Seq!(T) s, T src ){
+    int idx;
+    foreach( e; s ){
+        if( e == src ){
+            return idx;
+        }
+        idx++;
+    }
+    return -1;
+}
+int arrayIndexOf(T)( T[] arr, T v ){
+    int res = -1;
+    int idx = 0;
+    foreach( p; arr ){
+        if( p == v){
+            res = idx;
+            break;
+        }
+        idx++;
+    }
+    return res;
+}
+
+int seqIndexOf( tango.util.collection.model.Seq.Seq!(Object) seq, Object v ){
+    int res = -1;
+    int idx = 0;
+    foreach( p; seq ){
+        if( p == v){
+            res = idx;
+            break;
+        }
+        idx++;
+    }
+    return res;
+}
+
+void PrintStackTrace(){
+    try{
+        throw new Exception( null );
+    }
+    catch( Exception e ){
+        foreach( msg; e.info ){
+            Trace.formatln( "trc: {}", msg );
+        }
+    }
+}
+
+struct ImportData{
+    void[] data;
+    char[] name;
+
+    public static ImportData opCall( void[] data, char[] name ){
+        ImportData res;
+        res.data = data;
+        res.name = name;
+        return res;
+    }
+}
+
+template getImportData(char[] name ){
+    const ImportData getImportData = ImportData( import(name), name );
+}
\ No newline at end of file
--- a/dwt/graphics/Color.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/graphics/Color.d	Thu Apr 10 11:19:49 2008 +0200
@@ -12,7 +12,6 @@
  *******************************************************************************/
 module dwt.graphics.Color;
 
-
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.internal.win32.OS;
@@ -85,7 +84,7 @@
 public this (Device device, int red, int green, int blue) {
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(device, red, green, blue);
+    init_(device, red, green, blue);
     if (device.tracking) device.new_Object(this);
 }
 
@@ -115,7 +114,7 @@
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     if (rgb is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(device, rgb.red, rgb.green, rgb.blue);
+    init_(device, rgb.red, rgb.green, rgb.blue);
     if (device.tracking) device.new_Object(this);
 }
 
@@ -249,7 +248,7 @@
  *
  * @see #dispose
  */
-void init(Device device, int red, int green, int blue) {
+void init_(Device device, int red, int green, int blue) {
     if (red > 255 || red < 0 || green > 255 || green < 0 || blue > 255 || blue < 0) {
         DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     }
--- a/dwt/graphics/Cursor.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/graphics/Cursor.d	Thu Apr 10 11:19:49 2008 +0200
@@ -347,7 +347,7 @@
         DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     }
     ImageData mask = source.getTransparencyMask();
-    int[] result = Image.init(device, null, source, mask);
+    int[] result = Image.init_(device, null, source, mask);
     auto hBitmap = cast(HBITMAP)result[0];
     auto hMask = cast(HBITMAP)result[1];
     /* Create the icon */
--- a/dwt/graphics/Device.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/graphics/Device.d	Thu Apr 10 11:19:49 2008 +0200
@@ -142,7 +142,7 @@
             tracking = data.tracking;
         }
         create (data);
-        init ();
+        init_ ();
         if (tracking) {
             errors = new Exception [128];
             objects = new Object [128];
@@ -655,7 +655,7 @@
  *
  * @see #create
  */
-protected void init () {
+protected void init_ () {
     if (debug_) {
         static if (!OS.IsWinCE) OS.GdiSetBatchLimit(1);
     }
--- a/dwt/graphics/Font.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/graphics/Font.d	Thu Apr 10 11:19:49 2008 +0200
@@ -80,7 +80,7 @@
 public this(Device device, FontData fd) {
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(device, fd);
+    init_(device, fd);
     if (device.tracking) device.new_Object(this);
 }
 
@@ -115,7 +115,7 @@
     for (int i=0; i<fds.length; i++) {
         if (fds[i] is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     }
-    init(device, fds[0]);
+    init_(device, fds[0]);
     if (device.tracking) device.new_Object(this);
 }
 
@@ -145,7 +145,7 @@
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(device, new FontData (name, height, style));
+    init_(device, new FontData (name, height, style));
     if (device.tracking) device.new_Object(this);
 }
 
@@ -153,7 +153,7 @@
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(device, new FontData (name, height, style));
+    init_(device, new FontData (name, height, style));
     if (device.tracking) device.new_Object(this);
 }
 
@@ -222,7 +222,7 @@
     return cast(hash_t)handle;
 }
 
-void init (Device device, FontData fd) {
+void init_ (Device device, FontData fd) {
     if (fd is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     this.device = device;
     LOGFONT* logFont = &fd.data;
--- a/dwt/graphics/FontData.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/graphics/FontData.d	Thu Apr 10 11:19:49 2008 +0200
@@ -17,8 +17,6 @@
 import dwt.internal.win32.OS;
 
 import dwt.dwthelper.utils;
-import dwt.dwthelper.Float;
-import dwt.dwthelper.Integer;
 static import tango.text.Text;
 import tango.util.Convert;
 alias tango.text.Text.Text!(char) StringBuffer;
--- a/dwt/graphics/GC.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/graphics/GC.d	Thu Apr 10 11:19:49 2008 +0200
@@ -12,22 +12,6 @@
  *******************************************************************************/
 module dwt.graphics.GC;
 
-
-
-/+
-//PORTING_TYPE
-class GC{
-    void dispose();
-    bool isDisposed();
-    void flush ();
-    GCData data;
-    HDC handle;
-public void drawImage(Image image, int x, int y) ;
-public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) ;
-void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) ;
-}
-+/
-
 import dwt.DWT;
 import dwt.DWTError;
 import dwt.DWTException;
@@ -196,7 +180,7 @@
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     this.device = data.device = device;
-    init (drawable, data, hDC);
+    init_ (drawable, data, hDC);
     if (device.tracking) device.new_Object(this);
 }
 
@@ -3699,7 +3683,7 @@
     return Gdip.Matrix_new(1, 0, 0, 1, 0, 0);
 }
 
-void init(Drawable drawable, GCData data, HDC hDC) {
+void init_(Drawable drawable, GCData data, HDC hDC) {
     auto foreground = data.foreground;
     if (foreground !is -1) {
         data.state &= ~(FOREGROUND | FOREGROUND_TEXT | PEN);
@@ -4870,7 +4854,7 @@
     GC gc = new GC();
     auto hDC = drawable.internal_new_GC(data);
     gc.device = data.device;
-    gc.init(drawable, data, hDC);
+    gc.init_(drawable, data, hDC);
     return gc;
 }
 
@@ -4892,7 +4876,7 @@
 public static GC win32_new(HDC hDC, GCData data) {
     GC gc = new GC();
     gc.device = data.device;
-    gc.init(null, data, hDC);
+    gc.init_(null, data, hDC);
     return gc;
 }
 
--- a/dwt/graphics/Image.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/graphics/Image.d	Thu Apr 10 11:19:49 2008 +0200
@@ -192,7 +192,7 @@
 public this(Device device, int width, int height) {
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(device, width, height);
+    init_(device, width, height);
     if (device.tracking) device.new_Object(this);
 }
 
@@ -269,7 +269,7 @@
                     break;
                 case DWT.ICON:
                     static if (OS.IsWinCE) {
-                        init(device, srcImage.data);
+                        init_(device, srcImage.data);
                     } else {
                         handle = OS.CopyImage(srcImage.handle, OS.IMAGE_ICON, rect.width, rect.height, 0);
                         if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
@@ -337,7 +337,7 @@
                     offset++;
                 }
             }
-            init (device, newData);
+            init_ (device, newData);
             if (device.tracking) device.new_Object(this);
             return;
         }
@@ -402,7 +402,7 @@
                     }
                 }
             }
-            init (device, newData);
+            init_ (device, newData);
             if (device.tracking) device.new_Object(this);
             return;
         }
@@ -445,7 +445,7 @@
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(device, bounds.width, bounds.height);
+    init_(device, bounds.width, bounds.height);
     if (device.tracking) device.new_Object(this);
 }
 
@@ -470,7 +470,7 @@
 public this(Device device, ImageData data) {
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(device, data);
+    init_(device, data);
     if (device.tracking) device.new_Object(this);
 }
 
@@ -508,7 +508,7 @@
         DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     }
     mask = ImageData.convertMask(mask);
-    init(device, this, source, mask);
+    init_(device, this, source, mask);
     if (device.tracking) device.new_Object(this);
 }
 
@@ -563,7 +563,7 @@
 public this (Device device, InputStream stream) {
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(device, new ImageData(stream));
+    init_(device, new ImageData(stream));
     if (device.tracking) device.new_Object(this);
 }
 
@@ -741,7 +741,7 @@
                                 ImageData img = new ImageData(width, height, depth, paletteData, scanlinePad, data);
                                 img.transparentPixel = transparentPixel;
                                 img.alphaData = alphaData;
-                                init(device, img);
+                                init_(device, img);
                             }
                         }
                     }
@@ -754,7 +754,7 @@
             }
         }
     } catch (DWTException e) {}
-    init(device, new ImageData(filename));
+    init_(device, new ImageData(filename));
     if(device.tracking) device.new_Object(this);
 }
 
@@ -1579,7 +1579,7 @@
     return cast(hash_t)handle;
 }
 
-void init(Device device, int width, int height) {
+void init_(Device device, int width, int height) {
     if (width <= 0 || height <= 0) {
         DWT.error (DWT.ERROR_INVALID_ARGUMENT);
     }
@@ -1660,12 +1660,12 @@
  * if the regular GetIconInfo had been used.
  */
 static void GetIconInfo(Image image, ICONINFO* info) {
-    int[] result = init(image.device, null, image.data);
+    int[] result = init_(image.device, null, image.data);
     info.hbmColor = cast(HBITMAP)result[0];
     info.hbmMask = cast(HBITMAP)result[1];
 }
 
-static int[] init(Device device, Image image, ImageData i) {
+static int[] init_(Device device, Image image, ImageData i) {
     if (image !is null) image.device = device;
 
     /*
@@ -1896,7 +1896,7 @@
     return result;
 }
 
-static int[] init(Device device, Image image, ImageData source, ImageData mask) {
+static int[] init_(Device device, Image image, ImageData source, ImageData mask) {
     /* Create a temporary image and locate the black pixel */
     ImageData imageData;
     int blackIndex = 0;
@@ -1967,11 +1967,11 @@
     }
     imageData.maskPad = mask.scanlinePad;
     imageData.maskData = mask.data;
-    return init(device, image, imageData);
+    return init_(device, image, imageData);
 }
-void init(Device device, ImageData i) {
+void init_(Device device, ImageData i) {
     if (i is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(device, this, i);
+    init_(device, this, i);
 }
 
 /**
--- a/dwt/internal/BidiUtil.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/internal/BidiUtil.d	Thu Apr 10 11:19:49 2008 +0200
@@ -19,7 +19,6 @@
 
 import tango.util.Convert;
 import dwt.dwthelper.utils;
-import dwt.dwthelper.Integer;
 import dwt.dwthelper.Runnable;
 
 /*
--- a/dwt/internal/DWTEventObject.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/internal/DWTEventObject.d	Thu Apr 10 11:19:49 2008 +0200
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 2004 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
@@ -15,9 +15,11 @@
 
 //import java.util.EventObject;
 import tango.core.Exception;
+import dwt.dwthelper.utils;
 
+/+
 ///PORTING_TYPE
-class EventObject {
+class EventObject : EventObject {
   protected Object source;
 
   public this(Object source) {
@@ -35,7 +37,7 @@
   }
 }
 
-
++/
 
 
 /**
--- a/dwt/internal/image/TIFFDirectory.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/internal/image/TIFFDirectory.d	Thu Apr 10 11:19:49 2008 +0200
@@ -21,7 +21,7 @@
 import dwt.graphics.PaletteData;
 import dwt.graphics.RGB;
 import dwt.DWT;
-import dwt.dwthelper.Integer;
+import dwt.dwthelper.utils;
 import dwt.dwthelper.System;
 
 final class TIFFDirectory {
--- a/dwt/layout/GridLayout.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/layout/GridLayout.d	Thu Apr 10 11:19:49 2008 +0200
@@ -22,7 +22,6 @@
 import dwt.widgets.Scrollable;
 
 import dwt.dwthelper.System;
-import dwt.dwthelper.Integer;
 
 import tango.text.Util;
 import tango.util.Convert;
--- a/dwt/program/Program.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/program/Program.d	Thu Apr 10 11:19:49 2008 +0200
@@ -18,7 +18,6 @@
 import dwt.internal.win32.OS;
 
 import dwt.dwthelper.utils;
-import dwt.dwthelper.Integer;
 static import tango.text.convert.Utf;
 
 /**
--- a/dwt/widgets/Display.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/widgets/Display.d	Thu Apr 10 11:19:49 2008 +0200
@@ -48,7 +48,6 @@
 import dwt.dwthelper.utils;
 import dwt.dwthelper.Runnable;
 import dwt.dwthelper.System;
-import dwt.dwthelper.Integer;
 import tango.core.Thread;
 import tango.stdc.stringz;
 import tango.util.Convert;
@@ -2490,8 +2489,8 @@
  *
  * @see #create
  */
-override protected void init () {
-    super.init ();
+override protected void init_ () {
+    super.init_ ();
 
     /* Create the callbacks */
     //windowCallback = new Callback (this, "windowProc", 4); //$NON-NLS-1$
--- a/dwt/widgets/Spinner.d	Mon Apr 07 13:08:57 2008 +0200
+++ b/dwt/widgets/Spinner.d	Thu Apr 10 11:19:49 2008 +0200
@@ -29,7 +29,6 @@
 
 
 import dwt.dwthelper.utils;
-import dwt.dwthelper.Integer;
 import tango.text.convert.Integer : toString;
 static import tango.text.Text;
 alias tango.text.Text.Text!(char) StringBuffer;