comparison org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet21.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
26 import org.eclipse.swt.widgets.Event; 26 import org.eclipse.swt.widgets.Event;
27 import org.eclipse.swt.widgets.Button; 27 import org.eclipse.swt.widgets.Button;
28 import org.eclipse.swt.widgets.Text; 28 import org.eclipse.swt.widgets.Text;
29 import org.eclipse.swt.widgets.Canvas; 29 import org.eclipse.swt.widgets.Canvas;
30 30
31 import tango.io.Stdout; 31 version(Tango){
32 import tango.io.Stdout;
33 } else { // Phobos
34 import std.stdio;
35 }
32 36
33 import java.lang.all; 37 import java.lang.all;
34 38
35 void main () { 39 void main () {
36 Display display = new Display (); 40 Display display = new Display ();
37 final Color red = display.getSystemColor (SWT.COLOR_RED); 41 Color red = display.getSystemColor (SWT.COLOR_RED);
38 final Color blue = display.getSystemColor (SWT.COLOR_BLUE); 42 Color blue = display.getSystemColor (SWT.COLOR_BLUE);
39 Shell shell = new Shell (display); 43 Shell shell = new Shell (display);
40 Button b = new Button (shell, SWT.PUSH); 44 Button b = new Button (shell, SWT.PUSH);
41 b.setBounds (10, 10, 100, 32); 45 b.setBounds (10, 10, 100, 32);
42 b.setText ("Button"); 46 b.setText ("Button");
43 shell.setDefaultButton (b); 47 shell.setDefaultButton (b);
44 final Canvas c = new Canvas (shell, SWT.BORDER); 48 Canvas c = new Canvas (shell, SWT.BORDER);
45 c.setBounds (10, 50, 100, 32); 49 c.setBounds (10, 50, 100, 32);
46 50
47 void onTraverse(Event e, Canvas c) { 51 void onTraverse(Event e, Canvas c) {
48 switch (e.detail) { 52 switch (e.detail) {
49 /* Do tab group traversal */ 53 /* Do tab group traversal */
65 void onFocusOut(Event e, Canvas c) { 69 void onFocusOut(Event e, Canvas c) {
66 c.setBackground (blue); 70 c.setBackground (blue);
67 } 71 }
68 72
69 void onKeyDown (Event e, Canvas c) { 73 void onKeyDown (Event e, Canvas c) {
70 Stdout("KEY").newline; 74 version(Tango){
75 Stdout("KEY").newline;
76 } else { // Phobos
77 writeln("KEY");
78 }
71 for (int i=0; i<64; i++) { 79 for (int i=0; i<64; i++) {
72 Color c1 = red, c2 = blue; 80 Color c1 = red, c2 = blue;
73 if (c.isFocusControl ()) { 81 if (c.isFocusControl ()) {
74 c1 = blue; c2 = red; 82 c1 = blue; c2 = red;
75 } 83 }