Mercurial > projects > dwt2
comparison org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet62.d @ 112:9f4c18c268b2
Update to compile and execute with dmd 2.052.
author | kntroh |
---|---|
date | Wed, 16 Mar 2011 21:53:53 +0900 |
parents | 69b1fa94a4a8 |
children | 536e43f63c81 |
comparison
equal
deleted
inserted
replaced
111:b6e9904989ed | 112:9f4c18c268b2 |
---|---|
23 import org.eclipse.swt.SWT; | 23 import org.eclipse.swt.SWT; |
24 import org.eclipse.swt.widgets.Display; | 24 import org.eclipse.swt.widgets.Display; |
25 import org.eclipse.swt.widgets.Shell; | 25 import org.eclipse.swt.widgets.Shell; |
26 import org.eclipse.swt.widgets.Listener; | 26 import org.eclipse.swt.widgets.Listener; |
27 import org.eclipse.swt.widgets.Event; | 27 import org.eclipse.swt.widgets.Event; |
28 import java.lang.all; | |
28 | 29 |
29 import tango.io.Stdout; | 30 version(Tango){ |
30 import tango.util.Convert; | 31 import tango.io.Stdout; |
32 import tango.util.Convert; | |
33 } else { // Phobos | |
34 import std.stdio; | |
35 import std.conv; | |
36 } | |
31 | 37 |
32 static char[] stateMask (int stateMask) { | 38 static String stateMask (int stateMask) { |
33 char[] str = ""; | 39 String str = ""; |
34 if ((stateMask & SWT.CTRL) != 0) str ~= " CTRL"; | 40 if ((stateMask & SWT.CTRL) != 0) str ~= " CTRL"; |
35 if ((stateMask & SWT.ALT) != 0) str ~= " ALT"; | 41 if ((stateMask & SWT.ALT) != 0) str ~= " ALT"; |
36 if ((stateMask & SWT.SHIFT) != 0) str ~= " SHIFT"; | 42 if ((stateMask & SWT.SHIFT) != 0) str ~= " SHIFT"; |
37 if ((stateMask & SWT.COMMAND) != 0) str ~= " COMMAND"; | 43 if ((stateMask & SWT.COMMAND) != 0) str ~= " COMMAND"; |
38 return str; | 44 return str; |
39 } | 45 } |
40 | 46 |
41 void main () { | 47 void main () { |
42 Display display = new Display (); | 48 Display display = new Display (); |
43 final Shell shell = new Shell (display); | 49 Shell shell = new Shell (display); |
44 Listener listener = new class Listener { | 50 Listener listener = new class Listener { |
45 public void handleEvent (Event e) { | 51 public void handleEvent (Event e) { |
46 char[] str = "Unknown"; | 52 String str = "Unknown"; |
47 switch (e.type) { | 53 switch (e.type) { |
48 case SWT.MouseDown: str = "DOWN"; break; | 54 case SWT.MouseDown: str = "DOWN"; break; |
49 case SWT.MouseMove: str = "MOVE"; break; | 55 case SWT.MouseMove: str = "MOVE"; break; |
50 case SWT.MouseUp: str = "UP"; break; | 56 case SWT.MouseUp: str = "UP"; break; |
51 } | 57 } |
52 str ~=": button: " ~ to!(char[])(e.button) ~ ", "; | 58 str ~=": button: " ~ to!(String)(e.button) ~ ", "; |
53 str ~= "stateMask=0x" ~ to!(char[])(e.stateMask) | 59 str ~= "stateMask=0x" ~ to!(String)(e.stateMask) |
54 ~ stateMask (e.stateMask) | 60 ~ stateMask (e.stateMask) |
55 ~ ", x=" ~ to!(char[])(e.x) ~ ", y=" ~ to!(char[])(e.y); | 61 ~ ", x=" ~ to!(String)(e.x) ~ ", y=" ~ to!(String)(e.y); |
56 if ((e.stateMask & SWT.BUTTON1) != 0) str ~= " BUTTON1"; | 62 if ((e.stateMask & SWT.BUTTON1) != 0) str ~= " BUTTON1"; |
57 if ((e.stateMask & SWT.BUTTON2) != 0) str ~= " BUTTON2"; | 63 if ((e.stateMask & SWT.BUTTON2) != 0) str ~= " BUTTON2"; |
58 if ((e.stateMask & SWT.BUTTON3) != 0) str ~= " BUTTON3"; | 64 if ((e.stateMask & SWT.BUTTON3) != 0) str ~= " BUTTON3"; |
59 if ((e.stateMask & SWT.BUTTON4) != 0) str ~= " BUTTON4"; | 65 if ((e.stateMask & SWT.BUTTON4) != 0) str ~= " BUTTON4"; |
60 if ((e.stateMask & SWT.BUTTON5) != 0) str ~= " BUTTON5"; | 66 if ((e.stateMask & SWT.BUTTON5) != 0) str ~= " BUTTON5"; |
61 Stdout.formatln (str); | 67 version(Tango){ |
68 Stdout.formatln (str); | |
69 } else { // Phobos | |
70 writeln(str); | |
71 } | |
62 } | 72 } |
63 }; | 73 }; |
64 shell.addListener (SWT.MouseDown, listener); | 74 shell.addListener (SWT.MouseDown, listener); |
65 shell.addListener (SWT.MouseMove, listener); | 75 shell.addListener (SWT.MouseMove, listener); |
66 shell.addListener (SWT.MouseUp, listener); | 76 shell.addListener (SWT.MouseUp, listener); |