78
|
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 snippets.tree.Snippet15;
|
|
14
|
|
15 /*
|
|
16 * Tree example snippet: create a tree
|
|
17 *
|
|
18 * For a list of all DWT example snippets see
|
|
19 * http://www.eclipse.org/swt/snippets/
|
|
20 */
|
|
21 import dwt.DWT;
|
|
22 import dwt.layout.FillLayout;
|
|
23 import dwt.widgets.Display;
|
|
24 import dwt.widgets.Shell;
|
|
25 import dwt.widgets.Tree;
|
|
26 import dwt.widgets.TreeItem;
|
|
27
|
|
28 import tango.util.Convert;
|
|
29
|
|
30 void main () {
|
|
31 auto display = new Display ();
|
|
32 auto shell = new Shell (display);
|
|
33 shell.setLayout(new FillLayout());
|
|
34 auto tree = new Tree (shell, DWT.BORDER);
|
|
35 for (int i=0; i<4; i++) {
|
|
36 auto iItem = new TreeItem (tree, 0);
|
|
37 iItem.setText ("TreeItem (0) -" ~ to!(char[])(i));
|
|
38 for (int j=0; j<4; j++) {
|
|
39 TreeItem jItem = new TreeItem (iItem, 0);
|
|
40 jItem.setText ("TreeItem (1) -" ~ to!(char[])(j));
|
|
41 for (int k=0; k<4; k++) {
|
|
42 TreeItem kItem = new TreeItem (jItem, 0);
|
|
43 kItem.setText ("TreeItem (2) -" ~ to!(char[])(k));
|
|
44 for (int l=0; l<4; l++) {
|
|
45 TreeItem lItem = new TreeItem (kItem, 0);
|
|
46 lItem.setText ("TreeItem (3) -" ~ to!(char[])(l));
|
|
47 }
|
|
48 }
|
|
49 }
|
|
50 }
|
|
51 shell.setSize (200, 200);
|
|
52 shell.open ();
|
|
53 while (!shell.isDisposed()) {
|
|
54 if (!display.readAndDispatch ()) display.sleep ();
|
|
55 }
|
|
56 display.dispose ();
|
|
57 }
|