Mercurial > projects > dwt2
comparison org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet144.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 |
comparison
equal
deleted
inserted
replaced
111:b6e9904989ed | 112:9f4c18c268b2 |
---|---|
29 import org.eclipse.swt.widgets.Shell; | 29 import org.eclipse.swt.widgets.Shell; |
30 import org.eclipse.swt.widgets.Table; | 30 import org.eclipse.swt.widgets.Table; |
31 import org.eclipse.swt.widgets.TableItem; | 31 import org.eclipse.swt.widgets.TableItem; |
32 import org.eclipse.swt.layout.RowLayout; | 32 import org.eclipse.swt.layout.RowLayout; |
33 import org.eclipse.swt.layout.RowData; | 33 import org.eclipse.swt.layout.RowData; |
34 import java.lang.all; | |
34 | 35 |
35 import tango.io.Stdout; | 36 version(Tango){ |
36 import tango.time.StopWatch; | 37 import tango.io.Stdout; |
37 import tango.util.Convert; | 38 import tango.time.StopWatch; |
39 import tango.util.Convert; | |
40 } else { | |
41 import std.stdio; | |
42 import std.datetime; | |
43 import std.conv; | |
44 } | |
38 | 45 |
39 const int COUNT = 1000000; | 46 const int COUNT = 1000000; |
40 | 47 |
41 void main() { | 48 void main() { |
42 auto display = new Display (); | 49 auto display = new Display (); |
45 auto table = new Table (shell, SWT.VIRTUAL | SWT.BORDER); | 52 auto table = new Table (shell, SWT.VIRTUAL | SWT.BORDER); |
46 table.addListener (SWT.SetData, new class Listener { | 53 table.addListener (SWT.SetData, new class Listener { |
47 public void handleEvent (Event event) { | 54 public void handleEvent (Event event) { |
48 auto item = cast(TableItem) event.item; | 55 auto item = cast(TableItem) event.item; |
49 auto index = table.indexOf (item); | 56 auto index = table.indexOf (item); |
50 item.setText ("Item " ~ to!(char[])(index)); | 57 item.setText ("Item " ~ to!(String)(index)); |
51 Stdout(item.getText ()).newline; | 58 version(Tango){ |
59 Stdout(item.getText ()).newline; | |
60 } else { // Phobos | |
61 writeln(item.getText ()); | |
62 } | |
52 } | 63 } |
53 }); | 64 }); |
54 table.setLayoutData (new RowData (200, 200)); | 65 table.setLayoutData (new RowData (200, 200)); |
55 auto button = new Button (shell, SWT.PUSH); | 66 auto button = new Button (shell, SWT.PUSH); |
56 button.setText ("Add Items"); | 67 button.setText ("Add Items"); |
57 auto label = new Label(shell, SWT.NONE); | 68 auto label = new Label(shell, SWT.NONE); |
58 button.addListener (SWT.Selection, new class Listener { | 69 button.addListener (SWT.Selection, new class Listener { |
59 public void handleEvent (Event event) { | 70 public void handleEvent (Event event) { |
60 StopWatch elapsed; | 71 version(Tango){ |
61 elapsed.start; | 72 StopWatch elapsed; |
62 table.setItemCount (COUNT); | 73 elapsed.start; |
63 auto t = elapsed.stop; | 74 table.setItemCount (COUNT); |
64 label.setText ("Items: " ~ to!(char[])(COUNT) ~ | 75 auto t = elapsed.stop; |
65 ", Time: " ~ to!(char[])(t) ~ " (sec)"); | 76 } else { // Phobos |
77 StopWatch elapsed; | |
78 elapsed.start; | |
79 table.setItemCount (COUNT); | |
80 elapsed.stop; | |
81 auto t = elapsed.peek.msecs; | |
82 } | |
83 label.setText ("Items: " ~ to!(String)(COUNT) ~ | |
84 ", Time: " ~ to!(String)(t) ~ " (sec)"); | |
66 shell.layout (); | 85 shell.layout (); |
67 } | 86 } |
68 }); | 87 }); |
69 shell.pack (); | 88 shell.pack (); |
70 shell.open (); | 89 shell.open (); |