annotate snippets/composite/Snippet115.d @ 120:1f0a7a472680

fix rm snippets from module statements.
author Frank Benoit <benoit@tionex.de>
date Sun, 20 Jul 2008 19:17:23 +0200
parents 9a1be6ff19a2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
119
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /*******************************************************************************
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 *
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
8 * Contributors:
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
10 * D Port:
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
11 * Thomas Demmer <t_demmer AT web DOT de>
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
12 *******************************************************************************/
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
13 module composite.Snippet115;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
14
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
15 /*
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16 * Composite example snippet: force radio behavior on two different composites
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
17 *
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
18 * For a list of all SWT example snippets see
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19 * http://www.eclipse.org/swt/snippets/
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 */
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21 import dwt.DWT;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22 import dwt.widgets.Button;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23 import dwt.widgets.Composite;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
24 import dwt.widgets.Control;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 import dwt.widgets.Display;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
26 import dwt.widgets.Event;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27 import dwt.widgets.Listener;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28 import dwt.widgets.Shell;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29 import dwt.layout.RowLayout;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
31 import dwt.dwthelper.utils;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
32 import tango.util.Convert;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
33
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
34 void main (String [] args) {
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 Display display = new Display ();
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 Shell shell = new Shell (display);
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 shell.setLayout (new RowLayout (DWT.VERTICAL));
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 Composite c1 = new Composite (shell, DWT.BORDER | DWT.NO_RADIO_GROUP);
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39 c1.setLayout (new RowLayout ());
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
40 Composite c2 = new Composite (shell, DWT.BORDER | DWT.NO_RADIO_GROUP);
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41 c2.setLayout (new RowLayout ());
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
42 Composite [] composites = [c1, c2];
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43 Listener radioGroup = new class() Listener{
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 public void handleEvent (Event event) {
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
45 for (int i=0; i<composites.length; i++) {
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
46 Composite composite = composites [i];
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
47 Control [] children = composite.getChildren ();
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
48 for (int j=0; j<children.length; j++) {
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
49 Control child = children [j];
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
50 if (cast(Button)child !is null) {
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
51 Button button = cast(Button) child;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
52 if ((button.getStyle () & DWT.RADIO) != 0) button.setSelection (false);
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
53 }
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
54 }
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
55 }
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
56 Button button = cast(Button) event.widget;
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
57 button.setSelection (true);
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
58 }
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
59 };
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
60 for (int i=0; i<4; i++) {
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 Button button = new Button (c1, DWT.RADIO);
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62 button.setText ("Button " ~ to!(char[])(i));
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
63 button.addListener (DWT.Selection, radioGroup);
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64 }
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65 for (int i=0; i<4; i++) {
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
66 Button button = new Button (c2, DWT.RADIO);
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
67 button.setText ("Button " ~to!(char[])(i + 4));
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
68 button.addListener (DWT.Selection, radioGroup);
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
69 }
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70 shell.pack ();
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 shell.open ();
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
72 while (!shell.isDisposed()) {
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73 if (!display.readAndDispatch ()) display.sleep ();
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74 }
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
75 display.dispose ();
9a1be6ff19a2 More snippets, thanks to Tom D.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
76 }