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.Snippet15;
|
|
14
|
|
15 /*
|
|
16 * Tree example snippet: create a tree
|
|
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.layout.FillLayout;
|
|
23 import org.eclipse.swt.widgets.Display;
|
|
24 import org.eclipse.swt.widgets.Shell;
|
|
25 import org.eclipse.swt.widgets.Tree;
|
|
26 import org.eclipse.swt.widgets.TreeItem;
|
112
|
27 import java.lang.all;
|
28
|
28
|
112
|
29 version(Tango){
|
|
30 import tango.util.Convert;
|
|
31 } else { // Phobos
|
|
32 import std.conv;
|
|
33 }
|
28
|
34
|
|
35 void main () {
|
|
36 auto display = new Display ();
|
|
37 auto shell = new Shell (display);
|
|
38 shell.setLayout(new FillLayout());
|
|
39 auto tree = new Tree (shell, SWT.BORDER);
|
|
40 for (int i=0; i<4; i++) {
|
|
41 auto iItem = new TreeItem (tree, 0);
|
112
|
42 iItem.setText ("TreeItem (0) -" ~ to!(String)(i));
|
28
|
43 for (int j=0; j<4; j++) {
|
|
44 TreeItem jItem = new TreeItem (iItem, 0);
|
112
|
45 jItem.setText ("TreeItem (1) -" ~ to!(String)(j));
|
28
|
46 for (int k=0; k<4; k++) {
|
|
47 TreeItem kItem = new TreeItem (jItem, 0);
|
112
|
48 kItem.setText ("TreeItem (2) -" ~ to!(String)(k));
|
28
|
49 for (int l=0; l<4; l++) {
|
|
50 TreeItem lItem = new TreeItem (kItem, 0);
|
112
|
51 lItem.setText ("TreeItem (3) -" ~ to!(String)(l));
|
28
|
52 }
|
|
53 }
|
|
54 }
|
|
55 }
|
|
56 shell.setSize (200, 200);
|
|
57 shell.open ();
|
|
58 while (!shell.isDisposed()) {
|
|
59 if (!display.readAndDispatch ()) display.sleep ();
|
|
60 }
|
|
61 display.dispose ();
|
|
62 }
|