changeset 206:cca980503056

sync with dwt-linux, removed the simple.d
author Frank Benoit <benoit@tionex.de>
date Wed, 16 Apr 2008 20:36:50 +0200
parents 6d1762e7ebb7
children db56f777e914
files dwt/DWTError.d dwt/DWTException.d dwt/dwthelper/Runnable.d dwt/dwthelper/utils.d simple.d
diffstat 5 files changed, 54 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/DWTError.d	Wed Apr 16 20:36:33 2008 +0200
+++ b/dwt/DWTError.d	Wed Apr 16 20:36:50 2008 +0200
@@ -44,7 +44,6 @@
  */
 
 public class DWTError : PlatformException {
-
     /**
      * The DWT error code, one of DWT.ERROR_*.
      */
@@ -54,7 +53,13 @@
      * The underlying throwable that caused the problem,
      * or null if this information is not available.
      */
-    public Exception throwable;
+    public Exception throwable( Exception e ){
+        this.next = e;
+        return this.next;
+    }
+    public Exception throwable(){
+        return this.next;
+    }
 
     //static final long serialVersionUID = 3833467327105808433L;
 
@@ -129,7 +134,7 @@
  */
 public char[] getMessage () {
     if (throwable is null)
-        return super.toString ();
+        return super.toString();
     return super.toString () ~ " (" ~ throwable.toString () ~ ")"; //$NON-NLS-1$ //$NON-NLS-2$
 }
 
@@ -152,9 +157,6 @@
             Stderr.formatln( "{}", msg );
         }
     }
+}
 
 }
-}
-
-
-
--- a/dwt/DWTException.d	Wed Apr 16 20:36:33 2008 +0200
+++ b/dwt/DWTException.d	Wed Apr 16 20:36:50 2008 +0200
@@ -35,7 +35,6 @@
  */
 
 public class DWTException : Exception {
-
     /**
      * The DWT error code, one of DWT.ERROR_*.
      */
@@ -45,7 +44,14 @@
      * The underlying throwable that caused the problem,
      * or null if this information is not available.
      */
-    public Exception throwable;
+    public Exception throwable( Exception e ){
+        this.next = e;
+        return this.next;
+    }
+    public Exception throwable(){
+        return this.next;
+    }
+
 
     //static final long serialVersionUID = 3257282552304842547L;
 
@@ -119,8 +125,7 @@
  *  @return the error message string of this DWTException object
  */
 public char[] getMessage () {
-    if (throwable is null)
-        return super.toString ();
+    if (throwable is null) return super.toString ();
     return super.toString () ~ " (" ~ throwable.toString () ~ ")"; //$NON-NLS-1$ //$NON-NLS-2$
 }
 
@@ -147,3 +152,4 @@
 
 }
 
+
--- a/dwt/dwthelper/Runnable.d	Wed Apr 16 20:36:33 2008 +0200
+++ b/dwt/dwthelper/Runnable.d	Wed Apr 16 20:36:50 2008 +0200
@@ -3,10 +3,37 @@
  */
 module dwt.dwthelper.Runnable;
 
+
+import tango.core.Tuple;
+import tango.core.Traits;
+
 public interface Runnable  {
 
     public abstract void run();
 
 }
 
+class _DgRunnableT(Dg,T...) : Runnable {
 
+    alias ParameterTupleOf!(Dg) DgArgs;
+    static assert( is(DgArgs == Tuple!(T)),
+                "Delegate args not correct" );
+
+    Dg dg;
+    T t;
+
+    private this( Dg dg, T t ){
+        this.dg = dg;
+        static if( T.length > 0 ){
+            this.t = t;
+        }
+    }
+
+    void run( ){
+        dg(t);
+    }
+}
+
+_DgRunnableT!(Dg,T) dgRunnable(Dg,T...)( Dg dg, T args ){
+    return new _DgRunnableT!(Dg,T)(dg,args);
+}
\ No newline at end of file
--- a/dwt/dwthelper/utils.d	Wed Apr 16 20:36:33 2008 +0200
+++ b/dwt/dwthelper/utils.d	Wed Apr 16 20:36:50 2008 +0200
@@ -777,7 +777,14 @@
     ExceptionPrintStackTrace( e, Stderr );
 }
 void ExceptionPrintStackTrace( Exception e, Print!(char) print ){
-    print.formatln( "Exception in {}({}): {}", e.file, e.line, e.msg );
+    Exception exception = e;
+    while( exception !is null ){
+        print.formatln( "Exception in {}({}): {}", exception.file, exception.line, exception.msg );
+        foreach( msg; exception.info ){
+            print.formatln( "trc {}", msg );
+        }
+        exception = exception.next;
+    }
 }
 
 interface Reader{
--- a/simple.d	Wed Apr 16 20:36:33 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-module simple;
-
-import dwt.DWT;
-import dwt.widgets.Display;
-import dwt.widgets.Shell;
-import dwt.widgets.Button;
-import dwt.widgets.Text;
-
-import tango.io.Stdout;
-import tango.util.log.Trace;
-import tango.math.Math;
-import tango.text.convert.Format;
-import tango.util.Convert;
-import tango.util.PathUtil;
-import dwt.events.SelectionListener;
-import dwt.events.SelectionEvent;
-
-
-import dwt.DWT;
-import dwt.widgets.Display;
-
-void main(){
-
-    try{
-        Display display = new Display();
-        Shell shell = new Shell(display);
-        shell.setSize(300, 200);
-        shell.setText("Simple DWT Sample");
-        auto btn = new Button( shell, DWT.PUSH );
-        btn.setBounds(40, 50, 100, 50);
-        btn.setText( "hey" );
-
-        auto txt = new Text(shell, DWT.BORDER);
-        txt.setBounds(170, 50, 100, 40);
-
-        btn.addSelectionListener(new class () SelectionListener {
-            public void widgetSelected(SelectionEvent event) {
-                txt.setText("No problem");
-            }
-            public void widgetDefaultSelected(SelectionEvent event) {
-                txt.setText("No worries!");
-            }
-        });
-
-        shell.open();
-        while (!shell.isDisposed()) {
-            if (!display.readAndDispatch()) {
-                display.sleep();
-            }
-        }
-    }
-    catch (Exception e) {
-        Stdout.formatln ( "'{}', {}:{}", e.toString, e.file, e.line );
-    }
-}
-