Mercurial > projects > dwt-samples
annotate snippets/menu/Snippet286.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 | 4a04b6759f98 |
children |
rev | line source |
---|---|
78 | 1 /******************************************************************************* |
2 * Copyright (c) 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 *******************************************************************************/ | |
120
1f0a7a472680
fix rm snippets from module statements.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
11 module menu.Snippet286; |
78 | 12 |
13 /* | |
14 * use a menu item's armListener to update a status line. | |
15 * | |
16 * For a list of all SWT example snippets see | |
17 * http://www.eclipse.org/swt/snippets/ | |
18 */ | |
19 import dwt.DWT; | |
20 import dwt.events.ArmEvent; | |
21 import dwt.events.ArmListener; | |
22 import dwt.layout.GridLayout; | |
23 import dwt.layout.GridData; | |
24 import dwt.widgets.Display; | |
25 import dwt.widgets.Shell; | |
26 import dwt.widgets.Canvas; | |
27 import dwt.widgets.Label; | |
28 import dwt.widgets.Menu; | |
29 import dwt.widgets.MenuItem; | |
30 | |
31 import tango.util.Convert; | |
32 | |
33 | |
34 void main() { | |
35 Display display = new Display(); | |
36 Shell shell = new Shell(display); | |
37 shell.setLayout(new GridLayout()); | |
38 | |
39 Canvas blankCanvas = new Canvas(shell, DWT.BORDER); | |
40 blankCanvas.setLayoutData(new GridData(200, 200)); | |
41 Label statusLine = new Label(shell, DWT.NONE); | |
42 statusLine.setLayoutData(new GridData(DWT.FILL, DWT.CENTER, true, false)); | |
43 | |
44 Menu bar = new Menu (shell, DWT.BAR); | |
45 shell.setMenuBar (bar); | |
46 | |
47 MenuItem menuItem = new MenuItem (bar, DWT.CASCADE); | |
48 menuItem.setText ("Test"); | |
49 Menu menu = new Menu(bar); | |
50 menuItem.setMenu (menu); | |
51 | |
52 for (int i = 0; i < 5; i++) { | |
53 MenuItem item = new MenuItem (menu, DWT.PUSH); | |
54 item.setText ("Item " ~ to!(char[])(i)); | |
55 item.addArmListener(new class ArmListener { | |
56 public void widgetArmed(ArmEvent e) { | |
57 statusLine.setText((cast(MenuItem)e.getSource()).getText()); | |
58 } | |
59 }); | |
60 } | |
61 | |
62 shell.pack(); | |
63 shell.open(); | |
64 | |
65 while(!shell.isDisposed()) { | |
66 if(!display.readAndDispatch()) display.sleep(); | |
67 } | |
68 } |