comparison snippets/menu/Snippet29.d @ 78:4a04b6759f98

Clean up directory names
author John Reimer <terminal.node@gmail.com>
date Sat, 10 May 2008 13:32:45 -0700
parents
children 1f0a7a472680
comparison
equal deleted inserted replaced
76:04f122e90b0a 78:4a04b6759f98
1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 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 * D Port:
11 * Jesse Phillips <Jesse.K.Phillips+D> gmail.com
12 *******************************************************************************/
13 module snippets.menu.Snippet29;
14
15 /*
16 * Menu example snippet: create a bar and pull down menu (accelerators, mnemonics)
17 *
18 * For a list of all SWT example snippets see
19 * http://www.eclipse.org/swt/snippets/
20 */
21 import dwt.DWT;
22 import dwt.widgets.Display;
23 import dwt.widgets.Event;
24 import dwt.widgets.Listener;
25 import dwt.widgets.Menu;
26 import dwt.widgets.MenuItem;
27 import dwt.widgets.Shell;
28
29 import tango.io.Stdout;
30
31 void main () {
32 auto display = new Display ();
33 auto shell = new Shell (display);
34 auto bar = new Menu (shell, DWT.BAR);
35 shell.setMenuBar (bar);
36 auto fileItem = new MenuItem (bar, DWT.CASCADE);
37 fileItem.setText ("&File");
38 auto submenu = new Menu (shell, DWT.DROP_DOWN);
39 fileItem.setMenu (submenu);
40 auto item = new MenuItem (submenu, DWT.PUSH);
41 item.addListener (DWT.Selection, new class Listener {
42 public void handleEvent (Event e) {
43 Stdout("Select All").newline;
44 }
45 });
46 item.setText ("Select &All\tCtrl+A");
47 item.setAccelerator (DWT.CTRL + 'A');
48 shell.setSize (200, 200);
49 shell.open ();
50 while (!shell.isDisposed()) {
51 if (!display.readAndDispatch ()) display.sleep ();
52 }
53 display.dispose ();
54 }