changeset 117:8cdaac0dc743

Added more snippets from TomD
author Frank Benoit <benoit@tionex.de>
date Sat, 12 Jul 2008 20:09:06 +0200
parents f53c6274734f
children 7b1c122b4128
files snippets/busyindicator/Snippet130.d snippets/busyindicator/Snippet130a.d snippets/button/Snippet108.d snippets/button/Snippet162.d snippets/button/Snippet169.d snippets/button/Snippet206.d snippets/button/Snippet224.d snippets/button/Snippet293.d snippets/button/Snippet294.d snippets/caret/Snippet43.d snippets/caret/Snippet74.d snippets/ccombo/Snippet39.d snippets/clipboard/Snippet122.d snippets/clipboard/Snippet282.d snippets/clipboard/Snippet94.d snippets/color/Snippet208.d snippets/dsss.conf
diffstat 17 files changed, 1169 insertions(+), 288 deletions(-) [+]
line wrap: on
line diff
--- a/snippets/busyindicator/Snippet130.d	Sat Jul 12 17:54:42 2008 +0200
+++ b/snippets/busyindicator/Snippet130.d	Sat Jul 12 20:09:06 2008 +0200
@@ -1,111 +1,129 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-/*
- * BusyIndicator example snippet: display busy cursor during long running task
- *
- * For a list of all SWT example snippets see
- * http://www.eclipse.org/swt/snippets/
- */
-module busyindicator.Snippet130;
-
-import dwt.DWT;
-import dwt.events.SelectionAdapter;
-import dwt.events.SelectionEvent;
-import dwt.layout.GridLayout;
-import dwt.layout.GridData;
-import dwt.widgets.Shell;
-import dwt.widgets.Button;
-import dwt.widgets.Display;
-import dwt.widgets.Shell;
-import dwt.widgets.Text;
-
-
-import dwt.custom.BusyIndicator;
-
-import dwt.dwthelper.utils;
-import dwt.dwthelper.Runnable;
-import dwt.dwthelper.System;
-
-import tango.core.Thread;
-import tango.util.Convert;
-import tango.util.log.Trace;
-
-void main(String[] args){
-    Snippet130.main(args);
-}
-
-public class Snippet130 {
-
-    public static void main(String[] args) {
-        Display display = new Display();
-        Shell shell = new Shell(display);
-        shell.setLayout(new GridLayout());
-        Text text = new Text(shell, DWT.MULTI | DWT.BORDER | DWT.V_SCROLL);
-        text.setLayoutData(new GridData(GridData.FILL_BOTH));
-        int[1] nextId;
-        Button b = new Button(shell, DWT.PUSH);
-        b.setText("invoke long running job");
-
-        b.addSelectionListener(new class() SelectionAdapter {
-            public void widgetSelected(SelectionEvent e) {
-                Runnable longJob = new class() Runnable {
-                    bool done = false;
-                    int id;
-                    private void runThread(){
-                        id = nextId[0]++;
-                        display.syncExec( dgRunnable( &printStart, text, id ));
-                        for (int i = 0; i < 6; i++) {
-                            if (display.isDisposed()) return;
-                            Trace.formatln("do task that takes a long time in a separate thread {} {}/6", id, i);
-                            Thread.sleep(0.500);
-                        }
-                        if (display.isDisposed()) return;
-                        display.syncExec( dgRunnable( &printEnd , text, id )); // display.syncExec
-                        done = true;
-                        display.wake();
-                    }
-                    public void run() {
-                        Thread thread = new Thread( &runThread );
-                        thread.start();
-
-                        while (!done && !shell.isDisposed()) {
-                            if (!display.readAndDispatch())
-                                display.sleep();
-                        }
-                    }
-                };  // Runnable longJob = ...
-                BusyIndicator.showWhile(display, longJob);
-            } // widgetSelected();
-        }); // addSelectionListener
-
-
-        shell.setSize(250, 150);
-        shell.open();
-        while (!shell.isDisposed()) {
-            if (!display.readAndDispatch())
-                display.sleep();
-        }
-        display.dispose();
-    }
-    private void printStart(Text text, int id ) {
-        if (text.isDisposed()) return;
-        Trace.formatln( "Start long running task {}", id );
-        text.append("\nStart long running task "~to!(char[])(id));
-    }
-    private void printEnd(Text text, int id ) {
-        if (text.isDisposed()) return;
-        Trace.formatln( "Completed long running task {}", id );
-        text.append("\nCompleted long running task "~to!(char[])(id));
-    }
-}
-
-
+/*******************************************************************************
+ * 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Thomas Demmer <t_demmer AT web DOT de>
+ *******************************************************************************/
+module busyindicator.Snippet130;
+/*
+ * BusyIndicator example snippet: display busy cursor during long running task
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import dwt.DWT;
+import dwt.events.SelectionAdapter;
+import dwt.events.SelectionEvent;
+import dwt.layout.GridLayout;
+import dwt.layout.GridData;
+import dwt.widgets.Shell;
+import dwt.widgets.Button;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+import dwt.widgets.Text;
+
+
+import dwt.custom.BusyIndicator;
+
+import dwt.dwthelper.utils;
+import dwt.dwthelper.Runnable;
+import dwt.dwthelper.System;
+
+import tango.core.Thread;
+import tango.io.Stdout;
+import tango.util.Convert;
+import tango.util.log.Trace;
+
+
+void main(String[] args){
+    Snippet130.main(args);
+}
+
+public class Snippet130 {
+
+    public static void main(String[] args) {
+        Display display = new Display();
+        Shell shell = new Shell(display);
+        shell.setLayout(new GridLayout());
+        Text text = new Text(shell, DWT.MULTI | DWT.BORDER | DWT.V_SCROLL);
+        text.setLayoutData(new GridData(GridData.FILL_BOTH));
+        int[] nextId = new int[1];
+        Button b = new Button(shell, DWT.PUSH);
+        b.setText("invoke long running job");
+
+        b.addSelectionListener(new class() SelectionAdapter {
+            public void widgetSelected(SelectionEvent e) {
+                Runnable longJob = new class() Runnable {
+                    bool done = false;
+                    int id;
+                    public void run() {
+                        Thread thread = new Thread({
+                            id = nextId[0]++;
+                            display.syncExec(new class() Runnable {
+                                public void run() {
+                                if (text.isDisposed()) return;
+                                text.append("\nStart long running task "~to!(char[])(id));
+                                }
+                                }); // display.syncExec
+                            /*
+                             * This crashes when more than 1 thread gets created. THD
+                             for (int i = 0; i < 100000; i++) {
+                             if (display.isDisposed()) return;
+                             Stdout.formatln("do task that takes a long time in a separate thread {}", id);
+                             }
+                             */
+                            // This runs fine
+                            for (int i = 0; i < 6; i++) {
+                                if (display.isDisposed()) return;
+                                Trace.formatln("do task that takes a long time in a separate thread {} {}/6", id, i);
+                                Thread.sleep(0.500);
+                            }
+
+                            if (display.isDisposed()) return;
+                            display.syncExec(new class() Runnable {
+                                public void run() {
+                                    if (text.isDisposed()) return;
+                                    text.append("\nCompleted long running task "~to!(char[])(id));
+                                }
+                            }); // display.syncExec
+                            done = true;
+                            display.wake();
+                        }); // thread = ...
+                        thread.start();
+
+                        while (!done && !shell.isDisposed()) {
+                            if (!display.readAndDispatch())
+                                display.sleep();
+                        }
+                    }
+                };  // Runnable longJob = ...
+                BusyIndicator.showWhile(display, longJob);
+            } // widgetSelected();
+        }); // addSelectionListener
+
+
+        shell.setSize(250, 150);
+        shell.open();
+        while (!shell.isDisposed()) {
+            if (!display.readAndDispatch())
+                display.sleep();
+        }
+        display.dispose();
+    }
+    private void printStart(Text text, int id ) {
+        if (text.isDisposed()) return;
+        Trace.formatln( "Start long running task {}", id );
+        text.append("\nStart long running task "~to!(char[])(id));
+    }
+    private void printEnd(Text text, int id ) {
+        if (text.isDisposed()) return;
+        Trace.formatln( "Completed long running task {}", id );
+        text.append("\nCompleted long running task "~to!(char[])(id));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/busyindicator/Snippet130a.d	Sat Jul 12 20:09:06 2008 +0200
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Thomas Demmer <t_demmer AT web DOT de>
+ *******************************************************************************/
+module busyindicator.Snippet130;
+/*
+ * BusyIndicator example snippet: display busy cursor during long running task
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import dwt.DWT;
+import dwt.events.SelectionAdapter;
+import dwt.events.SelectionEvent;
+import dwt.layout.GridLayout;
+import dwt.layout.GridData;
+import dwt.widgets.Shell;
+import dwt.widgets.Button;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+import dwt.widgets.Text;
+
+
+import dwt.custom.BusyIndicator;
+
+import dwt.dwthelper.utils;
+import dwt.dwthelper.Runnable;
+import dwt.dwthelper.System;
+
+import tango.core.Thread;
+import tango.io.Stdout;
+import tango.util.Convert;
+import tango.util.log.Trace;
+
+
+void main(String[] args){
+    Snippet130.main(args);
+}
+
+public class Snippet130 {
+
+    public static void main(String[] args) {
+        Display display = new Display();
+        Shell shell = new Shell(display);
+        shell.setLayout(new GridLayout());
+        Text text = new Text(shell, DWT.MULTI | DWT.BORDER | DWT.V_SCROLL);
+        text.setLayoutData(new GridData(GridData.FILL_BOTH));
+        int[] nextId = new int[1];
+        Button b = new Button(shell, DWT.PUSH);
+        b.setText("invoke long running job");
+
+        b.addSelectionListener(new class() SelectionAdapter {
+            public void widgetSelected(SelectionEvent e) {
+                Runnable longJob = new class() Runnable {
+                    bool done = false;
+                    int id;
+                    public void run() {
+                        Thread thread = new Thread({
+                            id = nextId[0]++;
+                            display.syncExec( dgRunnable( &printStart, text, id ));
+                            for (int i = 0; i < 6; i++) {
+                            if (display.isDisposed()) return;
+                            Trace.formatln("do task that takes a long time in a separate thread {} {}/6", id, i);
+                            Thread.sleep(0.500);
+                            }
+                            /*
+                            for (int i = 0; i < 100000; i++) {
+                                if (display.isDisposed()) return;
+                                Stdout.formatln("do task that takes a long time in a separate thread {}", id);
+                            }
+                            */
+                            if (display.isDisposed()) return;
+                            display.syncExec( dgRunnable( &printEnd, text, id ));
+                            done = true;
+                            display.wake();
+                        }); // thread = ...
+                        thread.start();
+
+                        while (!done && !shell.isDisposed()) {
+                            if (!display.readAndDispatch())
+                                display.sleep();
+                        }
+                    }
+                };  // Runnable longJob = ...
+                BusyIndicator.showWhile(display, longJob);
+            } // widgetSelected();
+        }); // addSelectionListener
+
+
+        shell.setSize(250, 150);
+        shell.open();
+        while (!shell.isDisposed()) {
+            if (!display.readAndDispatch())
+                display.sleep();
+        }
+        display.dispose();
+    }
+    private void printStart(Text text, int id ) {
+        if (text.isDisposed()) return;
+        Trace.formatln( "Start long running task {}", id );
+        text.append("\nStart long running task "~to!(char[])(id));
+    }
+    private void printEnd(Text text, int id ) {
+        if (text.isDisposed()) return;
+        Trace.formatln( "Completed long running task {}", id );
+        text.append("\nCompleted long running task "~to!(char[])(id));
+    }
+}
--- a/snippets/button/Snippet108.d	Sat Jul 12 17:54:42 2008 +0200
+++ b/snippets/button/Snippet108.d	Sat Jul 12 20:09:06 2008 +0200
@@ -32,39 +32,40 @@
 import tango.io.Stdout;
 
 void main(String[] args){
-  Snippet108.main(args);
+    Snippet108.main(args);
 }
 
 public class Snippet108 {
 
-  public static void main (String [] args) {
-    Display display = new Display ();
-    Shell shell = new Shell (display);
-    Label label = new Label (shell, DWT.NONE);
-    label.setText ("Enter your name:");
-    Text text = new Text (shell, DWT.BORDER);
-    text.setLayoutData (new RowData (100, DWT.DEFAULT));
-    Button ok = new Button (shell, DWT.PUSH);
-    ok.setText ("OK");
-    ok.addSelectionListener(new class() SelectionAdapter {
-        public void widgetSelected(SelectionEvent e) {
-	  Stdout.formatln("OK");
-	}
-			    });
-    Button cancel = new Button (shell, DWT.PUSH);
-    cancel.setText ("Cancel");
-    cancel.addSelectionListener(new class() SelectionAdapter {
-        public void widgetSelected(SelectionEvent e) {
-	  Stdout.formatln("Cancel");
-	}
-				});
-    shell.setDefaultButton (cancel);
-    shell.setLayout (new RowLayout ());
-    shell.pack ();
-    shell.open ();
-    while (!shell.isDisposed ()) {
-      if (!display.readAndDispatch ()) display.sleep ();
+    public static void main (String [] args) {
+        Display display = new Display ();
+        Shell shell = new Shell (display);
+        Label label = new Label (shell, DWT.NONE);
+        label.setText ("Enter your name:");
+        Text text = new Text (shell, DWT.BORDER);
+        text.setLayoutData (new RowData (100, DWT.DEFAULT));
+        Button ok = new Button (shell, DWT.PUSH);
+        ok.setText ("OK");
+        ok.addSelectionListener(new class() SelectionAdapter {
+            public void widgetSelected(SelectionEvent e) {
+                Stdout.formatln("OK");
+            }
+        });
+        Button cancel = new Button (shell, DWT.PUSH);
+        cancel.setText ("Cancel");
+        cancel.addSelectionListener(new class() SelectionAdapter {
+            public void widgetSelected(SelectionEvent e) {
+                Stdout.formatln("Cancel");
+            }
+        });
+        shell.setDefaultButton (cancel);
+        shell.setLayout (new RowLayout ());
+        shell.pack ();
+        shell.open ();
+        while (!shell.isDisposed ()) {
+            if (!display.readAndDispatch ()) display.sleep ();
+        }
+        display.dispose ();
     }
-    display.dispose ();
-  }
 }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/button/Snippet162.d	Sat Jul 12 20:09:06 2008 +0200
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Thomas Demmer <t_demmer AT web DOT de>
+ *******************************************************************************/
+module button.Snippet162;
+
+/*
+ * Adding an accessible listener to provide state information
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import dwt.DWT;
+import dwt.accessibility.ACC;
+import dwt.accessibility.Accessible;
+import dwt.accessibility.AccessibleAdapter;
+import dwt.accessibility.AccessibleControlListener;
+import dwt.accessibility.AccessibleControlAdapter;
+import dwt.accessibility.AccessibleControlEvent;
+import dwt.accessibility.AccessibleEvent;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+
+import dwt.layout.FillLayout;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+import dwt.widgets.Table;
+import dwt.widgets.TableColumn;
+import dwt.widgets.TableItem;
+
+import dwt.dwthelper.utils;
+
+
+void main(String[] args){
+    Snippet162.main(args);
+}
+
+public class Snippet162 {
+
+    final static String STATE = "CheckedIndices";
+
+    public static void main (String [] args) {
+        final Display display = new Display ();
+        Image checkedImage = getCheckedImage (display);
+        Image uncheckedImage = getUncheckedImage (display);
+        Shell shell = new Shell (display);
+        shell.setLayout (new FillLayout ());
+        final Table table = new Table (shell, DWT.BORDER);
+        TableColumn column1 = new TableColumn (table, DWT.NONE);
+        TableColumn column2 = new TableColumn (table, DWT.NONE);
+        TableColumn column3 = new TableColumn (table, DWT.NONE);
+        TableItem item1 = new TableItem (table, DWT.NONE);
+        item1.setText ( ["first item", "a", "b"]);
+        item1.setImage (1, uncheckedImage);
+        item1.setImage (2, uncheckedImage);
+        item1.setData (STATE, null);
+        TableItem item2 = new TableItem (table, DWT.NONE);
+        item2.setText ( ["second item", "c", "d"]);
+        item2.setImage (1, uncheckedImage);
+        item2.setImage (2, checkedImage);
+        item2.setData (STATE,  new ArrayWrapperInt([2]));
+        TableItem item3 = new TableItem (table, DWT.NONE);
+        item3.setText ( ["third", "e", "f"]);
+        item3.setImage (1, checkedImage);
+        item3.setImage (2, checkedImage);
+        item3.setData (STATE, new ArrayWrapperInt( [1, 2]));
+        column1.pack ();
+        column2.pack ();
+        column3.pack ();
+
+        Accessible accessible = table.getAccessible ();
+        accessible.addAccessibleListener( new class() AccessibleAdapter  {
+            public void getName (AccessibleEvent e) {
+                super.getName (e);
+                if (e.childID >= 0 && e.childID < table.getItemCount ()) {
+                    TableItem item = table.getItem (e.childID);
+                    Point pt = display.getCursorLocation ();
+                    pt = display.map (null, table, pt);
+                    for (int i = 0; i < table.getColumnCount (); i++) {
+                        if (item.getBounds (i).contains (pt)) {
+                            int [] data = (cast(ArrayWrapperInt)item.getData (STATE)).array;
+                            bool checked = false;
+                            if (data !is null) {
+                                for (int j = 0; j < data.length; j++) {
+                                    if (data [j] == i) {
+                                        checked = true;
+                                        break;
+                                    }
+                                }
+                            }
+                            e.result = item.getText (i) ~ " " ~ (checked ? "checked" : "unchecked");
+                            break;
+                        }
+                    }
+                }
+            }
+        });
+
+        accessible.addAccessibleControlListener (new class() AccessibleControlAdapter  {
+            public void getState (AccessibleControlEvent e) {
+                super.getState (e);
+                if (e.childID >= 0 && e.childID < table.getItemCount ()) {
+                    TableItem item = table.getItem (e.childID);
+                    int [] data =(cast(ArrayWrapperInt)item.getData (STATE)).array;
+                    if (data !is null) {
+                        Point pt = display.getCursorLocation ();
+                        pt = display.map (null, table, pt);
+                        for (int i = 0; i < data.length; i++) {
+                            if (item.getBounds (data [i]).contains (pt)) {
+                                e.detail |= ACC.STATE_CHECKED;
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+        });
+        shell.open ();
+        while (!shell.isDisposed ()) {
+            if (!display.readAndDispatch ()) display.sleep ();
+        }
+        checkedImage.dispose ();
+        uncheckedImage.dispose ();
+        display.dispose ();
+    }
+
+    static Image getCheckedImage (Display display) {
+        Image image = new Image (display, 16, 16);
+        GC gc = new GC (image);
+        gc.setBackground (display.getSystemColor (DWT.COLOR_YELLOW));
+        gc.fillOval (0, 0, 16, 16);
+        gc.setForeground (display.getSystemColor (DWT.COLOR_DARK_GREEN));
+        gc.drawLine (0, 0, 16, 16);
+        gc.drawLine (16, 0, 0, 16);
+        gc.dispose ();
+        return image;
+    }
+
+    static Image getUncheckedImage (Display display) {
+        Image image = new Image (display, 16, 16);
+        GC gc = new GC (image);
+        gc.setBackground (display.getSystemColor (DWT.COLOR_YELLOW));
+        gc.fillOval (0, 0, 16, 16);
+        gc.dispose ();
+        return image;
+    }
+}
--- a/snippets/button/Snippet169.d	Sat Jul 12 17:54:42 2008 +0200
+++ b/snippets/button/Snippet169.d	Sat Jul 12 20:09:06 2008 +0200
@@ -34,38 +34,38 @@
 import tango.util.Convert;
 
 void main(String[] args){
-  Snippet169.main(args);
+    Snippet169.main(args);
 }
 
 
 public class Snippet169 {
-  public static void main (String [] args) {
-    Display display = new Display ();
-    final Shell shell = new Shell (display);
-    shell.setLayout (new FillLayout ());
-    Listener listener = new class() Listener {
-      public void handleEvent (Event e) {
-	Control [] children = shell.getChildren ();
-	for (int i=0; i<children.length; i++) {
-	  Control child = children [i];
-	  if (e.widget !is child && cast(Button)child !is null && (child.getStyle () & DWT.TOGGLE) != 0) {
-	    (cast(Button) child).setSelection (false);
-	  }
-	}
-	(cast(Button) e.widget).setSelection (true);
-      }
-    };
-    for (int i=0; i<20; i++) {
-      Button button = new Button (shell, DWT.TOGGLE);
-      button.setText ("B" ~to!(char[])(i));
-      button.addListener (DWT.Selection, listener);
-      if (i == 0) button.setSelection (true);
+    public static void main (String [] args) {
+        Display display = new Display ();
+        final Shell shell = new Shell (display);
+        shell.setLayout (new FillLayout ());
+        Listener listener = new class() Listener {
+            public void handleEvent (Event e) {
+                Control [] children = shell.getChildren ();
+                for (int i=0; i<children.length; i++) {
+                    Control child = children [i];
+                    if (e.widget !is child && cast(Button)child !is null && (child.getStyle () & DWT.TOGGLE) != 0) {
+                        (cast(Button) child).setSelection (false);
+                    }
+                }
+                (cast(Button) e.widget).setSelection (true);
+            }
+        };
+        for (int i=0; i<20; i++) {
+            Button button = new Button (shell, DWT.TOGGLE);
+            button.setText ("B" ~to!(char[])(i));
+            button.addListener (DWT.Selection, listener);
+            if (i == 0) button.setSelection (true);
+        }
+        shell.pack ();
+        shell.open ();
+        while (!shell.isDisposed ()) {
+            if (!display.readAndDispatch ()) display.sleep ();
+        }
+        display.dispose ();
     }
-    shell.pack ();
-    shell.open ();
-    while (!shell.isDisposed ()) {
-      if (!display.readAndDispatch ()) display.sleep ();
-    }
-    display.dispose ();
-  }
-}
\ No newline at end of file
+}
--- a/snippets/button/Snippet206.d	Sat Jul 12 17:54:42 2008 +0200
+++ b/snippets/button/Snippet206.d	Sat Jul 12 20:09:06 2008 +0200
@@ -20,7 +20,6 @@
  *
  * @since 3.2
  */
-/* Port OK */
 
 import dwt.DWT;
 import dwt.graphics.Image;
@@ -32,23 +31,23 @@
 import dwt.dwthelper.utils;
 
 void main(String[] args){
-  Snippet206.main(args);
+    Snippet206.main(args);
 }
 
 public class Snippet206 {
-  public static void main(String[] args) {
-    Display display = new Display();
-    Image image = display.getSystemImage(DWT.ICON_QUESTION);
-    Shell shell = new Shell(display);
-    shell.setLayout (new GridLayout());
-    Button button = new Button(shell, DWT.PUSH);
-    button.setImage(image);
-    button.setText("Button");
-    shell.setSize(300, 300);
-    shell.open();
-    while (!shell.isDisposed ()) {
-      if (!display.readAndDispatch ()) display.sleep ();
+    public static void main(String[] args) {
+        Display display = new Display();
+        Image image = display.getSystemImage(DWT.ICON_QUESTION);
+        Shell shell = new Shell(display);
+        shell.setLayout (new GridLayout());
+        Button button = new Button(shell, DWT.PUSH);
+        button.setImage(image);
+        button.setText("Button");
+        shell.setSize(300, 300);
+        shell.open();
+        while (!shell.isDisposed ()) {
+            if (!display.readAndDispatch ()) display.sleep ();
+        }
+        display.dispose ();
     }
-    display.dispose ();
-  }
-}
\ No newline at end of file
+}
--- a/snippets/button/Snippet224.d	Sat Jul 12 17:54:42 2008 +0200
+++ b/snippets/button/Snippet224.d	Sat Jul 12 20:09:06 2008 +0200
@@ -34,40 +34,40 @@
 import tango.util.Convert;
 
 void main(String[] args){
-  Snippet224.main(args);
+    Snippet224.main(args);
 }
 
 
 public class Snippet224 {
-  public static void main (String [] args) {
-    Display display = new Display ();
-    Shell shell = new Shell (display);
-    shell.setLayout (new RowLayout (DWT.VERTICAL));
-    for (int i=0; i<8; i++) {
-      Button button = new Button (shell, DWT.RADIO);
-      button.setText ("B" ~ to!(char[])(i));
-      if (i == 0) button.setSelection (true);
+    public static void main (String [] args) {
+        Display display = new Display ();
+        Shell shell = new Shell (display);
+        shell.setLayout (new RowLayout (DWT.VERTICAL));
+        for (int i=0; i<8; i++) {
+            Button button = new Button (shell, DWT.RADIO);
+            button.setText ("B" ~ to!(char[])(i));
+            if (i == 0) button.setSelection (true);
+        }
+        Button button = new Button (shell, DWT.PUSH);
+        button.setText ("Set Selection to B4");
+        button.addListener (DWT.Selection, new class() Listener{
+            public void handleEvent (Event event) {
+                Control [] children = shell.getChildren ();
+                Button newButton = cast(Button) children [4];
+                for (int i=0; i<children.length; i++) {
+                    Control child = children [i];
+                    if ( cast(Button)child !is null && (child.getStyle () & DWT.RADIO) != 0) {
+                        (cast(Button)child).setSelection (false);
+                    }
+                }
+                newButton.setSelection (true);
+            }
+        });
+        shell.pack ();
+        shell.open ();
+        while (!shell.isDisposed ()) {
+            if (!display.readAndDispatch ()) display.sleep ();
+        }
+        display.dispose ();
     }
-    Button button = new Button (shell, DWT.PUSH);
-    button.setText ("Set Selection to B4");
-    button.addListener (DWT.Selection, new class() Listener{
-        public void handleEvent (Event event) {
-	  Control [] children = shell.getChildren ();
-	  Button newButton = cast(Button) children [4];
-	  for (int i=0; i<children.length; i++) {
-	    Control child = children [i];
-	    if ( cast(Button)child !is null && (child.getStyle () & DWT.RADIO) != 0) {
-	      (cast(Button)child).setSelection (false);
-	    }
-	  }
-	  newButton.setSelection (true);
-	}
-    });
-    shell.pack ();
-    shell.open ();
-    while (!shell.isDisposed ()) {
-      if (!display.readAndDispatch ()) display.sleep ();
-    }
-    display.dispose ();
-  }
-}
\ No newline at end of file
+}
--- a/snippets/button/Snippet293.d	Sat Jul 12 17:54:42 2008 +0200
+++ b/snippets/button/Snippet293.d	Sat Jul 12 20:09:06 2008 +0200
@@ -10,7 +10,7 @@
  * D Port:
  *     Jesse Phillips <Jesse.K.Phillips+D> gmail.com
  *******************************************************************************/
-module snippets.button.Snippet293;
+module button.Snippet293;
 
 /*
  * create a tri-state button.
@@ -25,30 +25,30 @@
 import dwt.widgets.Button;
 
 void main() {
-	auto display = new Display();
-	auto shell = new Shell(display);
-	shell.setLayout(new GridLayout());
-	
-	auto b1 = new Button (shell, DWT.CHECK);
-	b1.setText("State 1");
-	b1.setSelection(true);
-	
-	auto b2 = new Button (shell, DWT.CHECK);
-	b2.setText("State 2");
-	b2.setSelection(false);
-	
-	auto b3 = new Button (shell, DWT.CHECK);
-	b3.setText("State 3");
-	b3.setSelection(true);
+    auto display = new Display();
+    auto shell = new Shell(display);
+    shell.setLayout(new GridLayout());
+
+    auto b1 = new Button (shell, DWT.CHECK);
+    b1.setText("State 1");
+    b1.setSelection(true);
+
+    auto b2 = new Button (shell, DWT.CHECK);
+    b2.setText("State 2");
+    b2.setSelection(false);
 
-	// This function does not appear in the api for swt 3.3
-	//	b3.setGrayed(true);
-	
-	shell.pack();
-	shell.open();
-	while (!shell.isDisposed()) {
-		if (!display.readAndDispatch())
-			display.sleep();
-	}
-	display.dispose();
+    auto b3 = new Button (shell, DWT.CHECK);
+    b3.setText("State 3");
+    b3.setSelection(true);
+
+    // This function does not appear in the api for swt 3.3
+    //	b3.setGrayed(true);
+
+    shell.pack();
+    shell.open();
+    while (!shell.isDisposed()) {
+        if (!display.readAndDispatch())
+            display.sleep();
+    }
+    display.dispose();
 }
--- a/snippets/button/Snippet294.d	Sat Jul 12 17:54:42 2008 +0200
+++ b/snippets/button/Snippet294.d	Sat Jul 12 20:09:06 2008 +0200
@@ -27,7 +27,7 @@
 import tango.util.Convert;
 
 void main(String[] args){
-  Snippet294.main(args);
+    Snippet294.main(args);
 }
 
 /*
@@ -41,54 +41,54 @@
 
 public class Snippet294 {
 
-  static int[] circle(int r, int offsetX, int offsetY) {
-    int[] polygon = new int[8 * r + 4];
-    // x^2 + y^2 = r^2
-    for (int i = 0; i < 2 * r + 1; i++) {
-      int x = i - r;
-      int y = cast(int)Math.sqrt(cast(real)(r*r - x*x));
-      polygon[2*i] = offsetX + x;
-      polygon[2*i+1] = offsetY + y;
-      polygon[8*r - 2*i - 2] = offsetX + x;
-      polygon[8*r - 2*i - 1] = offsetY - y;
+    static int[] circle(int r, int offsetX, int offsetY) {
+        int[] polygon = new int[8 * r + 4];
+        // x^2 + y^2 = r^2
+        for (int i = 0; i < 2 * r + 1; i++) {
+            int x = i - r;
+            int y = cast(int)Math.sqrt(cast(real)(r*r - x*x));
+            polygon[2*i] = offsetX + x;
+            polygon[2*i+1] = offsetY + y;
+            polygon[8*r - 2*i - 2] = offsetX + x;
+            polygon[8*r - 2*i - 1] = offsetY - y;
+        }
+        return polygon;
     }
-    return polygon;
-  }
 
-  public static void main(String[] args) {
-    Display display = new Display();
-    Shell shell = new Shell(display);
-    shell.setText("Regions on a Control");
-    shell.setLayout(new FillLayout());
-    shell.setBackground(display.getSystemColor(DWT.COLOR_DARK_RED));
+    public static void main(String[] args) {
+        Display display = new Display();
+        Shell shell = new Shell(display);
+        shell.setText("Regions on a Control");
+        shell.setLayout(new FillLayout());
+        shell.setBackground(display.getSystemColor(DWT.COLOR_DARK_RED));
 
-    Button b2 = new Button(shell, DWT.PUSH);
-    b2.setText("Button with Regions");
+        Button b2 = new Button(shell, DWT.PUSH);
+        b2.setText("Button with Regions");
 
-    // define a region that looks like a circle with two holes in ot
-    Region region = new Region();
-    region.add(circle(67, 87, 77));
-    region.subtract(circle(20, 87, 47));
-    region.subtract(circle(20, 87, 113));
+        // define a region that looks like a circle with two holes in ot
+        Region region = new Region();
+        region.add(circle(67, 87, 77));
+        region.subtract(circle(20, 87, 47));
+        region.subtract(circle(20, 87, 113));
 
-    // define the shape of the button using setRegion
-    b2.setRegion(region);
-    b2.setLocation(100,50);
+        // define the shape of the button using setRegion
+        b2.setRegion(region);
+        b2.setLocation(100,50);
 
-    b2.addListener(DWT.Selection, new class() Listener {
-        public void handleEvent(Event e) {
-	  shell.close();
-	}
-		   });
+        b2.addListener(DWT.Selection, new class() Listener {
+                public void handleEvent(Event e) {
+                shell.close();
+                }
+                });
 
-    shell.setSize(200,200);
-    shell.open();
+        shell.setSize(200,200);
+        shell.open();
 
-    while (!shell.isDisposed()) {
-      if (!display.readAndDispatch())
-	display.sleep();
+        while (!shell.isDisposed()) {
+            if (!display.readAndDispatch())
+                display.sleep();
+        }
+        region.dispose();
+        display.dispose();
     }
-    region.dispose();
-    display.dispose();
-  }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/caret/Snippet43.d	Sat Jul 12 20:09:06 2008 +0200
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Thomas Demmer <t_demmer AT web DOT de>
+ *******************************************************************************/
+module caret.Snippet43;
+/*
+ * Caret example snippet: create a caret (using an image)
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import dwt.DWT;
+import dwt.graphics.Color;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+
+import dwt.widgets.Caret;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+
+import dwt.dwthelper.utils;
+
+void main (String [] args) {
+    Display display = new Display ();
+    Shell shell = new Shell (display);
+    shell.open ();
+    Caret caret = new Caret (shell, DWT.NONE);
+    Color white = display.getSystemColor (DWT.COLOR_WHITE);
+    Color black = display.getSystemColor (DWT.COLOR_BLACK);
+    Image image = new Image (display, 20, 20);
+    GC gc = new GC (image);
+    gc.setBackground (black);
+    gc.fillRectangle (0, 0, 20, 20);
+    gc.setForeground (white);
+    gc.drawLine (0, 0, 19, 19);
+    gc.drawLine (19, 0, 0, 19);
+    gc.dispose ();
+    caret.setLocation (10, 10);
+    caret.setImage (image);
+    gc = new GC (shell);
+    gc.drawImage (image, 10, 64);
+    caret.setVisible (false);
+    gc.drawString ("Test", 12, 12);
+    caret.setVisible (true);
+    gc.dispose ();
+    while (!shell.isDisposed ()) {
+        if (!display.readAndDispatch ()) display.sleep ();
+    }
+    image.dispose ();
+    display.dispose ();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/caret/Snippet74.d	Sat Jul 12 20:09:06 2008 +0200
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Thomas Demmer <t_demmer AT web DOT de>
+ *******************************************************************************/
+module caret.Snippet74;
+
+/*
+ * Caret example snippet: create a caret
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import dwt.DWT;
+import dwt.widgets.Caret;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+
+import dwt.dwthelper.utils;
+
+void main (String [] args) {
+    Display display = new Display ();
+    Shell shell = new Shell (display);
+    Caret caret = new Caret (shell, DWT.NONE);
+    caret.setBounds (10, 10, 2, 32);
+    shell.open ();
+    while (!shell.isDisposed ()) {
+        if (!display.readAndDispatch ()) display.sleep ();
+    }
+    display.dispose ();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/ccombo/Snippet39.d	Sat Jul 12 20:09:06 2008 +0200
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Thomas Demmer <t_demmer AT web DOT de>
+ *******************************************************************************/
+module combo.Snippet39;
+
+/*
+ * CCombo example snippet: create a CCombo
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import dwt.DWT;
+import dwt.custom.CCombo;
+import dwt.events.SelectionAdapter;
+import dwt.events.SelectionListener;
+import dwt.layout.GridData;
+import dwt.layout.GridLayout;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+
+import dwt.dwthelper.utils;
+import tango.util.Convert;
+import tango.io.Stdout;
+public static void main(String[] args) {
+    Display display = new Display();
+    Shell shell = new Shell(display);
+    shell.setLayout(new GridLayout());
+
+    CCombo combo = new CCombo(shell, DWT.FLAT | DWT.BORDER);
+    combo.setLayoutData(new GridData(DWT.FILL, DWT.CENTER, true, false));
+    for (int i = 0; i < 5; i++) {
+        combo.add("item" ~ to!(char[])(i));
+    }
+    combo.setText("item0");
+
+    combo.addSelectionListener(new class() SelectionAdapter {
+        public void widgetSelected(SelectionEvent e) {
+            Stdout.formatln("Item selected");
+        };
+    });
+
+    shell.pack();
+    shell.open();
+    while (!shell.isDisposed()) {
+        if (!display.readAndDispatch()) display.sleep();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/clipboard/Snippet122.d	Sat Jul 12 20:09:06 2008 +0200
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Thomas Demmer <t_demmer AT web DOT de>
+ *******************************************************************************/
+module clipboard.Snippet122;
+/*
+ * Clipboard example snippet: enable/disable menu depending on clipboard content availability
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ *
+ * @since 3.0
+ */
+import dwt.DWT;
+import dwt.dnd.Clipboard;
+import dwt.dnd.TextTransfer;
+import dwt.dnd.Transfer;
+import dwt.dnd.TransferData;
+import dwt.events.MenuAdapter;
+import dwt.events.MenuEvent;
+import dwt.events.SelectionAdapter;
+import dwt.events.SelectionListener;
+import dwt.layout.FillLayout;
+import dwt.widgets.Display;
+import dwt.widgets.Menu;
+import dwt.widgets.MenuItem;
+import dwt.widgets.Shell;
+import dwt.widgets.Text;
+
+import dwt.dwthelper.utils;
+
+public static void main(String[] args) {
+    Display display = new Display();
+    Clipboard cb = new Clipboard(display);
+    Shell shell = new Shell(display);
+    shell.setLayout(new FillLayout());
+    Text text = new Text(shell, DWT.BORDER | DWT.MULTI | DWT.WRAP);
+    Menu menu = new Menu(shell, DWT.POP_UP);
+    MenuItem copyItem = new MenuItem(menu, DWT.PUSH);
+    copyItem.setText("Copy");
+    copyItem.addSelectionListener(new class() SelectionAdapter{
+        public void widgetSelected(SelectionEvent e) {
+            String selection = text.getSelectionText();
+            if (selection.length == 0) return;
+            Object[] data = [ new ArrayWrapperString(selection) ];
+            Transfer[] types = [ TextTransfer.getInstance() ];
+            cb.setContents(data, types);
+        }
+    });
+    MenuItem pasteItem = new MenuItem(menu, DWT.PUSH);
+    pasteItem.setText ("Paste");
+    pasteItem.addSelectionListener(new class() SelectionAdapter{
+        public void widgetSelected(SelectionEvent e) {
+            String string = stringcast(cb.getContents(TextTransfer.getInstance()));
+            if (string !is null) text.insert(string);
+        }
+    });
+    menu.addMenuListener(new class() MenuAdapter{
+        public void menuShown(MenuEvent e) {
+            // is copy valid?
+            String selection = text.getSelectionText();
+            copyItem.setEnabled(selection.length > 0);
+            // is paste valid?
+            TransferData[] available = cb.getAvailableTypes();
+            bool enabled = false;
+            for (int i = 0; i < available.length; i++) {
+                if (TextTransfer.getInstance().isSupportedType(available[i])) {
+                    enabled = true;
+                    break;
+                }
+            }
+            pasteItem.setEnabled(enabled);
+        }
+    });
+
+    text.setMenu (menu);
+    shell.setSize(200, 200);
+    shell.open();
+    while (!shell.isDisposed()) {
+        if (!display.readAndDispatch())
+            display.sleep();
+    }
+    cb.dispose();
+    display.dispose();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/clipboard/Snippet282.d	Sat Jul 12 20:09:06 2008 +0200
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Thomas Demmer <t_demmer AT web DOT de>
+ *******************************************************************************/
+module clipboard.Snippets282;
+
+/*
+ * Copy/paste image to/from clipboard.
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+
+import dwt.DWT;
+import dwt.dnd.Clipboard;
+import dwt.dnd.ImageTransfer;
+import dwt.dnd.Transfer;
+import dwt.graphics.Image;
+import dwt.graphics.ImageData;
+import dwt.layout.GridLayout;
+import dwt.layout.GridData;
+
+import dwt.widgets.Button;
+import dwt.widgets.Composite;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.FileDialog;
+import dwt.widgets.Listener;
+import dwt.widgets.Shell;
+
+import dwt.dwthelper.utils;
+
+public static void main(String[] args) {
+    Display display = new Display();
+    Clipboard clipboard = new Clipboard(display);
+    Shell shell = new Shell(display, DWT.SHELL_TRIM);
+    shell.setLayout(new GridLayout());
+    shell.setText("Clipboard ImageTransfer");
+
+    Button imageButton = new Button(shell, DWT.NONE );
+    GridData gd = new GridData(DWT.FILL, DWT.FILL, true, true);
+    gd.minimumHeight = 400;
+    gd.minimumWidth = 600;
+    imageButton.setLayoutData(gd);
+
+    Composite buttons = new Composite(shell, DWT.NONE);
+    buttons.setLayout(new GridLayout(4, true));
+    Button button = new Button(buttons, DWT.PUSH);
+    button.setText("Open");
+    button.addListener(DWT.Selection, new class() Listener {
+            public void handleEvent(Event event) {
+            FileDialog dialog = new FileDialog (shell, DWT.OPEN);
+            dialog.setText("Open an image file or cancel");
+            String string = dialog.open ();
+            if (string !is null) {
+            Image image = imageButton.getImage();
+            if (image !is null) image.dispose();
+            image = new Image(display, string);
+            imageButton.setImage(image);
+            }
+            }
+            });
+
+    button = new Button(buttons, DWT.PUSH);
+    button.setText("Copy");
+    button.addListener(DWT.Selection, new class() Listener {
+            public void handleEvent(Event event) {
+            Image image = imageButton.getImage();
+            if (image !is null) {
+            ImageTransfer transfer = ImageTransfer.getInstance();
+
+            Transfer[] xfer = [ transfer ];
+            Object[] td = [ image.getImageData ];
+
+            clipboard.setContents(td,xfer);
+            }
+            }
+            });
+    button = new Button(buttons, DWT.PUSH);
+    button.setText("Paste");
+    button.addListener(DWT.Selection, new class() Listener {
+            public void handleEvent(Event event) {
+            ImageTransfer transfer = ImageTransfer.getInstance();
+            ImageData imageData = cast(ImageData)clipboard.getContents(transfer);
+            if (imageData !is null) {
+            imageButton.setText("");
+            Image image = imageButton.getImage();
+            if (image !is null) image.dispose();
+            image = new Image(display, imageData);
+            imageButton.setImage(image);
+            } else {
+            imageButton.setText("No image");
+            }
+            }
+            });
+
+    button = new Button(buttons, DWT.PUSH);
+    button.setText("Clear");
+    button.addListener(DWT.Selection, new class() Listener {
+            public void handleEvent(Event event) {
+            imageButton.setText("");
+            Image image = imageButton.getImage();
+            if (image !is null) image.dispose();
+            imageButton.setImage(null);
+            }
+            });
+    shell.pack();
+    shell.open();
+    while (!shell.isDisposed()) {
+        if (!display.readAndDispatch())
+            display.sleep();
+    }
+    display.dispose();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/clipboard/Snippet94.d	Sat Jul 12 20:09:06 2008 +0200
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Thomas Demmer <t_demmer AT web DOT de>
+ *******************************************************************************/
+module clipboard.Snippet94;
+/*
+ * Clipboard example snippet: copy and paste data with the clipboard
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import dwt.DWT;
+import dwt.dnd.Clipboard;
+import dwt.dnd.Transfer;
+import dwt.dnd.TextTransfer;
+
+import dwt.layout.FormAttachment;
+import dwt.layout.FormData;
+import dwt.layout.FormLayout;
+
+import dwt.widgets.Button;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Listener;
+import dwt.widgets.Shell;
+import dwt.widgets.Text;
+
+import dwt.dwthelper.utils;
+
+
+public static void main( String[] args) {
+    Display display = new Display ();
+    Clipboard cb = new Clipboard(display);
+    Shell shell = new Shell (display);
+    shell.setLayout(new FormLayout());
+    Text text = new Text(shell, DWT.BORDER | DWT.MULTI | DWT.V_SCROLL | DWT.H_SCROLL);
+
+    Button copy = new Button(shell, DWT.PUSH);
+    copy.setText("Copy");
+    copy.addListener (DWT.Selection, new class() Listener {
+        public void handleEvent (Event e) {
+            String textData = text.getSelectionText();
+            if (textData.length > 0) {
+                TextTransfer textTransfer = TextTransfer.getInstance();
+                // this is ugly, but works.
+                Transfer[] xfer = [ textTransfer];
+                Object[] td = [ new ArrayWrapperString(textData) ];
+                cb.setContents(td,xfer);
+            }
+        }
+    });
+
+    Button paste = new Button(shell, DWT.PUSH);
+    paste.setText("Paste");
+    paste.addListener (DWT.Selection, new class() Listener {
+        public void handleEvent (Event e) {
+            TextTransfer transfer = TextTransfer.getInstance();
+            String data = stringcast(cb.getContents(transfer));
+            if (data !is null) {
+                text.insert(data);
+            }
+        }
+    });
+
+    FormData data = new FormData();
+    data.left = new FormAttachment(paste, 0, DWT.LEFT);
+    data.right = new FormAttachment(100, -5);
+    data.top = new FormAttachment(0, 5);
+    copy.setLayoutData(data);
+
+    data = new FormData();
+    data.right = new FormAttachment(100, -5);
+    data.top = new FormAttachment(copy, 5);
+    paste.setLayoutData(data);
+
+    data = new FormData();
+    data.left = new FormAttachment(0, 5);
+    data.top = new FormAttachment(0, 5);
+    data.right = new FormAttachment(paste, -5);
+    data.bottom = new FormAttachment(100, -5);
+    text.setLayoutData(data);
+
+    shell.setSize(200, 200);
+    shell.open();
+    while (!shell.isDisposed ()) {
+        if (!display.readAndDispatch ()) display.sleep ();
+    }
+    cb.dispose();
+    display.dispose();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/color/Snippet208.d	Sat Jul 12 20:09:06 2008 +0200
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Thomas Demmer <t_demmer AT web DOT de>
+ *******************************************************************************/
+module color.Snippet208;
+
+/*
+ * Change hue, saturation and brightness of a color
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ *
+ * @since 3.2
+ */
+import dwt.DWT;
+import dwt.graphics.Image;
+import dwt.graphics.ImageData;
+import dwt.graphics.RGB;
+import dwt.graphics.PaletteData;
+import dwt.layout.GridData;
+import dwt.layout.GridLayout;
+import dwt.widgets.Display;
+import dwt.widgets.Label;
+import dwt.widgets.Shell;
+
+import dwt.dwthelper.utils;
+
+void main (String [] args) {
+    PaletteData palette = new PaletteData(0xff, 0xff00, 0xff0000);
+
+    // ImageData showing variations of hue
+    ImageData hueData = new ImageData(360, 100, 24, palette);
+    float hue = 0;
+    for (int x = 0; x < hueData.width; x++) {
+        for (int y = 0; y < hueData.height; y++) {
+            int pixel = palette.getPixel(new RGB(hue, 1f, 1f));
+            hueData.setPixel(x, y, pixel);
+        }
+        hue += 360f / hueData.width;
+    }
+
+    // ImageData showing saturation on x axis and brightness on y axis
+    ImageData saturationBrightnessData = new ImageData(360, 360, 24, palette);
+    float saturation = 0f;
+    float brightness = 1f;
+    for (int x = 0; x < saturationBrightnessData.width; x++) {
+        brightness = 1f;
+        for (int y = 0; y < saturationBrightnessData.height; y++) {
+            int pixel = palette.getPixel(new RGB(360f, saturation, brightness));
+            saturationBrightnessData.setPixel(x, y, pixel);
+            brightness -= 1f / saturationBrightnessData.height;
+        }
+        saturation += 1f / saturationBrightnessData.width;
+    }
+
+    Display display = new Display();
+    Image hueImage = new Image(display, hueData);
+    Image saturationImage = new Image(display, saturationBrightnessData);
+    Shell shell = new Shell(display);
+    shell.setText("Hue, Saturation, Brightness");
+    GridLayout gridLayout = new GridLayout(2, false);
+    gridLayout.verticalSpacing = 10;
+    gridLayout.marginWidth = gridLayout.marginHeight = 16;
+    shell.setLayout(gridLayout);
+
+    Label label = new Label(shell, DWT.CENTER);
+    label.setImage(hueImage);
+    GridData data = new GridData(DWT.RIGHT, DWT.CENTER, false, false, 2, 1);
+    label.setLayoutData(data);
+
+    label = new Label(shell, DWT.CENTER); //spacer
+    label = new Label(shell, DWT.CENTER);
+    label.setText("Hue");
+    data = new GridData(DWT.CENTER, DWT.CENTER, false, false);
+    label.setLayoutData(data);
+    label = new Label(shell, DWT.CENTER); //spacer
+    data = new GridData(DWT.CENTER, DWT.CENTER, false, false, 2, 1);
+    label.setLayoutData(data);
+
+    label = new Label(shell, DWT.LEFT);
+    label.setText("Brightness");
+    data = new GridData(DWT.LEFT, DWT.CENTER, false, false);
+    label.setLayoutData(data);
+
+    label = new Label(shell, DWT.CENTER);
+    label.setImage(saturationImage);
+    data = new GridData(DWT.CENTER, DWT.CENTER, false, false);
+    label.setLayoutData (data);
+
+    label = new Label(shell, DWT.CENTER); //spacer
+    label = new Label(shell, DWT.CENTER);
+    label.setText("Saturation");
+    data = new GridData(DWT.CENTER, DWT.CENTER, false, false);
+    label.setLayoutData(data);
+
+    shell.pack();
+    shell.open();
+    while (!shell.isDisposed()) {
+        if (!display.readAndDispatch()) {
+            display.sleep();
+        }
+    }
+    hueImage.dispose();
+    saturationImage.dispose();
+    display.dispose();
+}
--- a/snippets/dsss.conf	Sat Jul 12 17:54:42 2008 +0200
+++ b/snippets/dsss.conf	Sat Jul 12 20:09:06 2008 +0200
@@ -17,7 +17,9 @@
 
 
 [busyindicator/Snippet130.d]
+[busyindicator/Snippet130a.d]
 [button/Snippet108.d]
+[button/Snippet162.d]
 [button/Snippet169.d]
 [button/Snippet206.d]
 [button/Snippet224.d]
@@ -28,6 +30,13 @@
 [canvas/Snippet245.d]
 [canvas/Snippet275.d]
 [canvas/Snippet290.d]
+[caret/Snippet43.d]
+[caret/Snippet74.d]
+[ccombo/Snippet39.d]
+[clipboard/Snippet94.d]
+[clipboard/Snippet122.d]
+[clipboard/Snippet282.d]
+[color/Snippet208.d]
 [control/Snippet25.d]
 [control/Snippet62.d]
 [combo/Snippet26.d]