Mercurial > projects > dwt2
annotate org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet39.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 | 536e43f63c81 |
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 * Thomas Demmer <t_demmer AT web DOT de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.swt.snippets.Snippet39; | |
14 | |
15 /* | |
16 * CCombo example snippet: create a CCombo | |
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.custom.CCombo; | |
23 import org.eclipse.swt.events.SelectionAdapter; | |
24 import org.eclipse.swt.events.SelectionListener; | |
25 import org.eclipse.swt.layout.GridData; | |
26 import org.eclipse.swt.layout.GridLayout; | |
27 import org.eclipse.swt.widgets.Display; | |
28 import org.eclipse.swt.widgets.Shell; | |
29 | |
30 import java.lang.all; | |
112 | 31 version(Tango){ |
32 import tango.io.Stdout; | |
33 import tango.util.Convert; | |
34 } else { // Phobos | |
35 import std.stdio; | |
36 import std.conv; | |
37 } | |
28 | 38 public static void main(String[] args) { |
39 Display display = new Display(); | |
40 Shell shell = new Shell(display); | |
41 shell.setLayout(new GridLayout()); | |
42 | |
29
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
43 CCombo combo = new CCombo(shell, SWT.FLAT | SWT.BORDER); |
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
44 combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
28 | 45 for (int i = 0; i < 5; i++) { |
112 | 46 combo.add("item" ~ to!(String)(i)); |
28 | 47 } |
48 combo.setText("item0"); | |
49 | |
50 combo.addSelectionListener(new class() SelectionAdapter { | |
51 public void widgetSelected(SelectionEvent e) { | |
112 | 52 version(Tango){ |
53 Stdout.formatln("Item selected"); | |
54 } else { // Phobos | |
55 writeln("Item selected"); | |
56 } | |
28 | 57 }; |
58 }); | |
59 | |
60 shell.pack(); | |
61 shell.open(); | |
62 while (!shell.isDisposed()) { | |
63 if (!display.readAndDispatch()) display.sleep(); | |
64 } | |
65 } |