Mercurial > projects > dwt2
annotate org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet20.d @ 112:9f4c18c268b2
Update to compile and execute with dmd 2.052.
author | kntroh |
---|---|
date | Wed, 16 Mar 2011 21:53:53 +0900 |
parents | 4e5843b771cc |
children |
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; | |
112 | 28 import java.lang.all; |
28 | 29 |
112 | 30 version(Tango){ |
31 import tango.util.Convert; | |
32 } else { // Phobos | |
33 import std.conv; | |
34 } | |
28 | 35 |
36 void main () { | |
37 auto display = new Display (); | |
38 auto shell = new Shell (display); | |
39 auto bar = new CoolBar (shell, SWT.BORDER); | |
40 for (int i=0; i<2; i++) { | |
41 auto item = new CoolItem (bar, SWT.NONE); | |
42 auto button = new Button (bar, SWT.PUSH); | |
112 | 43 button.setText ("Button " ~ to!(String)(i)); |
29
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
44 auto size = button.computeSize (SWT.DEFAULT, SWT.DEFAULT); |
28 | 45 item.setPreferredSize (item.computeSize (size.x, size.y)); |
46 item.setControl (button); | |
47 } | |
48 bar.pack (); | |
49 shell.setSize(300, 100); | |
50 shell.open (); | |
51 while (!shell.isDisposed ()) { | |
52 if (!display.readAndDispatch ()) display.sleep (); | |
53 } | |
54 display.dispose (); | |
55 } |