comparison org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet268.d @ 112:9f4c18c268b2

Update to compile and execute with dmd 2.052.
author kntroh
date Wed, 16 Mar 2011 21:53:53 +0900
parents 8ae65ae167f5
children 536e43f63c81
comparison
equal deleted inserted replaced
111:b6e9904989ed 112:9f4c18c268b2
30 30
31 import org.eclipse.swt.custom.StyledText; 31 import org.eclipse.swt.custom.StyledText;
32 import org.eclipse.swt.graphics.Point; 32 import org.eclipse.swt.graphics.Point;
33 import org.eclipse.swt.layout.FillLayout; 33 import org.eclipse.swt.layout.FillLayout;
34 34
35 import tango.io.Stdout; 35 version(Tango){
36 import tango.util.Convert; 36 import tango.io.Stdout;
37 //import tango.core.Thread; 37 import tango.util.Convert;
38 //import tango.core.Thread;
39 } else { // Phobos
40 import std.stdio;
41 import std.conv;
42 }
38 43
39 void main(String[] args) { 44 void main(String[] args) {
40 Display display = new Display(); 45 Display display = new Display();
41 Shell shell = new Shell(display); 46 Shell shell = new Shell(display);
42 shell.setLayout(new FillLayout()); 47 shell.setLayout(new FillLayout());
48 } 53 }
49 styledText.setText(multiLineString); 54 styledText.setText(multiLineString);
50 shell.setSize(styledText.computeSize(SWT.DEFAULT, 400)); 55 shell.setSize(styledText.computeSize(SWT.DEFAULT, 400));
51 shell.open(); 56 shell.open();
52 styledText.addListener(SWT.MouseWheel, dgListener( (Event e){ 57 styledText.addListener(SWT.MouseWheel, dgListener( (Event e){
53 Stdout.formatln("Mouse Wheel event \n"); //" + e); 58 version(Tango){
54 Stdout.flush(); 59 Stdout.formatln("Mouse Wheel event \n"); //" + e);
60 Stdout.flush();
61 } else {
62 writeln("Mouse Wheel event "); //" + e);
63 }
55 })); 64 }));
56 final Point pt = display.map(shell, null, 50, 50); 65 Point pt = display.map(shell, null, 50, 50);
57 Thread thread = new Thread({ 66 Thread thread = new Thread({
58 Event event; 67 Event event;
59 for (int i = 0; i < 50; i++) { 68 for (int i = 0; i < 50; i++) {
60 event = new Event(); 69 event = new Event();
61 event.type = SWT.MouseWheel; 70 event.type = SWT.MouseWheel;
66 display.post(event); 75 display.post(event);
67 try { 76 try {
68 Thread.sleep(400); 77 Thread.sleep(400);
69 } catch (InterruptedException e) {} 78 } catch (InterruptedException e) {}
70 } 79 }
71 Stdout("Thread done\n").flush(); 80 version(Tango){
81 Stdout("Thread done\n").flush();
82 } else {
83 writeln("Thread done");
84 }
72 }); 85 });
73 86
74 thread.start(); 87 thread.start();
75 while (!shell.isDisposed()) { 88 while (!shell.isDisposed()) {
76 if (!display.readAndDispatch()) display.sleep(); 89 if (!display.readAndDispatch()) display.sleep();