Mercurial > projects > dwt2
annotate org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet170.d @ 125:c43718956f21 default tip
Updated the snippets status.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Thu, 11 Aug 2011 19:55:14 +0200 |
parents | 9f4c18c268b2 |
children |
rev | line source |
---|---|
28 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2005 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 * Bill Baxter <wbaxter@gmail.com> | |
12 *******************************************************************************/ | |
13 module org.eclipse.swt.snippets.Snippet170; | |
14 | |
15 /* | |
16 * Tree example snippet: Create a Tree with columns | |
17 * | |
18 * For a list of all SWT example snippets see | |
19 * http://www.eclipse.org/swt/snippets/ | |
20 * | |
21 * @since 3.1 | |
22 */ | |
23 | |
24 import org.eclipse.swt.SWT; | |
25 import org.eclipse.swt.widgets.Display; | |
26 import org.eclipse.swt.widgets.Shell; | |
27 import org.eclipse.swt.widgets.Tree; | |
28 import org.eclipse.swt.widgets.TreeItem; | |
29 import org.eclipse.swt.widgets.TreeColumn; | |
30 import org.eclipse.swt.layout.FillLayout; | |
31 | |
112 | 32 version(Tango){ |
33 import tango.util.Convert; | |
34 } else { // Phobos | |
35 import std.conv; | |
36 } | |
28 | 37 |
38 import java.lang.all; | |
39 | |
40 void main() { | |
41 Display display = new Display(); | |
112 | 42 Shell shell = new Shell(display); |
28 | 43 shell.setLayout(new FillLayout()); |
29
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
44 Tree tree = new Tree(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); |
28 | 45 tree.setHeaderVisible(true); |
46 TreeColumn column1 = new TreeColumn(tree, SWT.LEFT); | |
47 column1.setText("Column 1"); | |
48 column1.setWidth(200); | |
49 TreeColumn column2 = new TreeColumn(tree, SWT.CENTER); | |
50 column2.setText("Column 2"); | |
51 column2.setWidth(200); | |
52 TreeColumn column3 = new TreeColumn(tree, SWT.RIGHT); | |
53 column3.setText("Column 3"); | |
54 column3.setWidth(200); | |
55 for (int i = 0; i < 4; i++) { | |
56 TreeItem item = new TreeItem(tree, SWT.NONE); | |
57 item.setText([ "item " ~ to!(String)(i), "abc", "defghi" ]); | |
58 for (int j = 0; j < 4; j++) { | |
59 TreeItem subItem = new TreeItem(item, SWT.NONE); | |
60 subItem.setText([ "subitem " ~ to!(String)(j), "jklmnop", "qrs" ]); | |
61 for (int k = 0; k < 4; k++) { | |
62 TreeItem subsubItem = new TreeItem(subItem, SWT.NONE); | |
63 subsubItem.setText([ "subsubitem " ~ to!(String)(k), "tuv", "wxyz" ]); | |
64 } | |
65 } | |
66 } | |
67 shell.pack(); | |
68 shell.open(); | |
69 while (!shell.isDisposed()) { | |
70 if (!display.readAndDispatch()) { | |
71 display.sleep(); | |
72 } | |
73 } | |
74 display.dispose(); | |
75 } |