Mercurial > projects > dwt-samples
annotate snippets/toolbar/Snippet49.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) 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 * Port to the D programming language: | |
11 * Bill Baxter <bill@billbaxter.com> | |
12 *******************************************************************************/ | |
120
1f0a7a472680
fix rm snippets from module statements.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
13 module toolbar.Snippet49; |
78 | 14 |
15 /* | |
16 * ToolBar example snippet: create tool bar (wrap on resize) | |
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.graphics.Rectangle; | |
23 import dwt.graphics.Point; | |
24 import dwt.widgets.Display; | |
25 import dwt.widgets.Shell; | |
26 import dwt.widgets.ToolBar; | |
27 import dwt.widgets.ToolItem; | |
28 import dwt.widgets.Event; | |
29 import dwt.widgets.Listener; | |
30 | |
31 import tango.util.Convert; | |
32 | |
33 void main () { | |
34 Display display = new Display (); | |
35 Shell shell = new Shell (display); | |
36 ToolBar toolBar = new ToolBar (shell, DWT.WRAP); | |
37 for (int i=0; i<12; i++) { | |
38 ToolItem item = new ToolItem (toolBar, DWT.PUSH); | |
39 item.setText ("Item " ~ to!(char[])(i)); | |
40 } | |
41 shell.addListener (DWT.Resize, new class Listener { | |
42 void handleEvent (Event e) { | |
43 Rectangle rect = shell.getClientArea (); | |
44 Point size = toolBar.computeSize (rect.width, DWT.DEFAULT); | |
45 toolBar.setSize (size); | |
46 } | |
47 }); | |
48 toolBar.pack (); | |
49 shell.pack (); | |
50 shell.open (); | |
51 while (!shell.isDisposed ()) { | |
52 if (!display.readAndDispatch ()) display.sleep (); | |
53 } | |
54 display.dispose (); | |
55 } | |
56 |