Mercurial > projects > dwt2
annotate org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet7.d @ 112:9f4c18c268b2
Update to compile and execute with dmd 2.052.
author | kntroh |
---|---|
date | Wed, 16 Mar 2011 21:53:53 +0900 |
parents | 4e5843b771cc |
children | 536e43f63c81 |
rev | line source |
---|---|
28 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2004 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * D Port: | |
11 * Thomas Demmer <t_demmer AT web DOT de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.swt.snippets.Snippet7; | |
14 | |
15 /* | |
16 * example snippet: create a table (lazy) | |
17 * | |
18 * For a list of all SWT example snippets see | |
19 * http://www.eclipse.org/swt/snippets/ | |
20 */ | |
21 import org.eclipse.swt.SWT; | |
22 import org.eclipse.swt.layout.FillLayout; | |
23 import org.eclipse.swt.graphics.GC; | |
24 import org.eclipse.swt.graphics.Image; | |
25 import org.eclipse.swt.widgets.Display; | |
26 import org.eclipse.swt.widgets.Item; | |
27 import org.eclipse.swt.widgets.Shell; | |
28 import org.eclipse.swt.widgets.Table; | |
29 import org.eclipse.swt.widgets.TableItem; | |
30 | |
31 import java.lang.all; | |
32 | |
112 | 33 version(Tango){ |
34 import T = tango.core.Thread; | |
35 import tango.util.Convert; | |
36 } else { // Phobos | |
37 import T = core.thread; | |
38 import std.conv; | |
39 } | |
28 | 40 |
41 void main (String [] args) { | |
42 Display display = new Display (); | |
43 Image image = new Image (display, 16, 16); | |
44 GC gc = new GC (image); | |
45 gc.setBackground (display.getSystemColor (SWT.COLOR_RED)); | |
46 gc.fillRectangle (image.getBounds ()); | |
47 gc.dispose (); | |
48 | |
49 Shell shell = new Shell (display); | |
50 shell.setText ("Lazy Table"); | |
51 shell.setLayout (new FillLayout ()); | |
29
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
52 Table table = new Table (shell, SWT.BORDER | SWT.MULTI); |
28 | 53 table.setSize (200, 200); |
112 | 54 T.Thread thread = new T.Thread({ |
28 | 55 for(int i=0; i< 20000; i++){ |
56 if (table.isDisposed ()) return; | |
57 | |
58 int [] index = [i]; | |
59 display.syncExec (new class() Runnable{ | |
60 public void run () { | |
61 if (table.isDisposed ()) return; | |
62 TableItem item = new TableItem (table, SWT.NONE); | |
63 item.setText ("Table Item " ~ to!(String)(index [0])); | |
64 item.setImage (image); | |
65 } | |
66 }); | |
67 } | |
68 }); | |
69 | |
70 thread.start (); | |
71 shell.setSize (200, 200); | |
72 shell.open (); | |
73 while (!shell.isDisposed ()) { | |
74 if (!display.readAndDispatch ()) display.sleep (); | |
75 } | |
76 image.dispose (); | |
77 display.dispose (); | |
78 } |