comparison snippets/button/Snippet224.d @ 117:8cdaac0dc743

Added more snippets from TomD
author Frank Benoit <benoit@tionex.de>
date Sat, 12 Jul 2008 20:09:06 +0200
parents 0de3dab4d6e1
children
comparison
equal deleted inserted replaced
116:f53c6274734f 117:8cdaac0dc743
32 32
33 import dwt.dwthelper.utils; 33 import dwt.dwthelper.utils;
34 import tango.util.Convert; 34 import tango.util.Convert;
35 35
36 void main(String[] args){ 36 void main(String[] args){
37 Snippet224.main(args); 37 Snippet224.main(args);
38 } 38 }
39 39
40 40
41 public class Snippet224 { 41 public class Snippet224 {
42 public static void main (String [] args) { 42 public static void main (String [] args) {
43 Display display = new Display (); 43 Display display = new Display ();
44 Shell shell = new Shell (display); 44 Shell shell = new Shell (display);
45 shell.setLayout (new RowLayout (DWT.VERTICAL)); 45 shell.setLayout (new RowLayout (DWT.VERTICAL));
46 for (int i=0; i<8; i++) { 46 for (int i=0; i<8; i++) {
47 Button button = new Button (shell, DWT.RADIO); 47 Button button = new Button (shell, DWT.RADIO);
48 button.setText ("B" ~ to!(char[])(i)); 48 button.setText ("B" ~ to!(char[])(i));
49 if (i == 0) button.setSelection (true); 49 if (i == 0) button.setSelection (true);
50 }
51 Button button = new Button (shell, DWT.PUSH);
52 button.setText ("Set Selection to B4");
53 button.addListener (DWT.Selection, new class() Listener{
54 public void handleEvent (Event event) {
55 Control [] children = shell.getChildren ();
56 Button newButton = cast(Button) children [4];
57 for (int i=0; i<children.length; i++) {
58 Control child = children [i];
59 if ( cast(Button)child !is null && (child.getStyle () & DWT.RADIO) != 0) {
60 (cast(Button)child).setSelection (false);
61 }
62 }
63 newButton.setSelection (true);
64 }
65 });
66 shell.pack ();
67 shell.open ();
68 while (!shell.isDisposed ()) {
69 if (!display.readAndDispatch ()) display.sleep ();
70 }
71 display.dispose ();
50 } 72 }
51 Button button = new Button (shell, DWT.PUSH);
52 button.setText ("Set Selection to B4");
53 button.addListener (DWT.Selection, new class() Listener{
54 public void handleEvent (Event event) {
55 Control [] children = shell.getChildren ();
56 Button newButton = cast(Button) children [4];
57 for (int i=0; i<children.length; i++) {
58 Control child = children [i];
59 if ( cast(Button)child !is null && (child.getStyle () & DWT.RADIO) != 0) {
60 (cast(Button)child).setSelection (false);
61 }
62 }
63 newButton.setSelection (true);
64 }
65 });
66 shell.pack ();
67 shell.open ();
68 while (!shell.isDisposed ()) {
69 if (!display.readAndDispatch ()) display.sleep ();
70 }
71 display.dispose ();
72 }
73 } 73 }