Mercurial > projects > dwt2
annotate org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet20.d @ 29:4e5843b771cc
First snippets buildable on windows
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 22 Mar 2009 19:55:00 +0100 |
parents | 69b1fa94a4a8 |
children | 9f4c18c268b2 |
rev | line source |
---|---|
28 | 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 org.eclipse.swt.snippets.Snippet20; | |
14 | |
15 /* | |
16 * CoolBar example snippet: create a cool bar | |
17 * | |
18 * For a list of all SWT example snippets see | |
19 * http://www.eclipse.org/swt/snippets/ | |
20 */ | |
21 import org.eclipse.swt.SWT; | |
22 import org.eclipse.swt.graphics.Point; | |
23 import org.eclipse.swt.widgets.Button; | |
24 import org.eclipse.swt.widgets.Display; | |
25 import org.eclipse.swt.widgets.CoolBar; | |
26 import org.eclipse.swt.widgets.CoolItem; | |
27 import org.eclipse.swt.widgets.Shell; | |
28 | |
29 import tango.util.Convert; | |
30 | |
31 void main () { | |
32 auto display = new Display (); | |
33 auto shell = new Shell (display); | |
34 auto bar = new CoolBar (shell, SWT.BORDER); | |
35 for (int i=0; i<2; i++) { | |
36 auto item = new CoolItem (bar, SWT.NONE); | |
37 auto button = new Button (bar, SWT.PUSH); | |
38 button.setText ("Button " ~ to!(char[])(i)); | |
29
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
39 auto size = button.computeSize (SWT.DEFAULT, SWT.DEFAULT); |
28 | 40 item.setPreferredSize (item.computeSize (size.x, size.y)); |
41 item.setControl (button); | |
42 } | |
43 bar.pack (); | |
44 shell.setSize(300, 100); | |
45 shell.open (); | |
46 while (!shell.isDisposed ()) { | |
47 if (!display.readAndDispatch ()) display.sleep (); | |
48 } | |
49 display.dispose (); | |
50 } |