comparison snippets/tree/Snippet170.d @ 94:799099686955

New tree snippet ports
author Bill Baxter <bill@billbaxter.com>
date Thu, 22 May 2008 13:47:53 +0900
parents
children 1f0a7a472680
comparison
equal deleted inserted replaced
91:961ca8a76cad 94:799099686955
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 snippets.tree.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 dwt.DWT;
25 import dwt.widgets.Display;
26 import dwt.widgets.Shell;
27 import dwt.widgets.Tree;
28 import dwt.widgets.TreeItem;
29 import dwt.widgets.TreeColumn;
30 import dwt.layout.FillLayout;
31
32 import tango.util.Convert;
33
34 import dwt.dwthelper.utils;
35
36 void main() {
37 Display display = new Display();
38 final Shell shell = new Shell(display);
39 shell.setLayout(new FillLayout());
40 Tree tree = new Tree(shell, DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL);
41 tree.setHeaderVisible(true);
42 TreeColumn column1 = new TreeColumn(tree, DWT.LEFT);
43 column1.setText("Column 1");
44 column1.setWidth(200);
45 TreeColumn column2 = new TreeColumn(tree, DWT.CENTER);
46 column2.setText("Column 2");
47 column2.setWidth(200);
48 TreeColumn column3 = new TreeColumn(tree, DWT.RIGHT);
49 column3.setText("Column 3");
50 column3.setWidth(200);
51 for (int i = 0; i < 4; i++) {
52 TreeItem item = new TreeItem(tree, DWT.NONE);
53 item.setText([ "item " ~ to!(String)(i), "abc", "defghi" ]);
54 for (int j = 0; j < 4; j++) {
55 TreeItem subItem = new TreeItem(item, DWT.NONE);
56 subItem.setText([ "subitem " ~ to!(String)(j), "jklmnop", "qrs" ]);
57 for (int k = 0; k < 4; k++) {
58 TreeItem subsubItem = new TreeItem(subItem, DWT.NONE);
59 subsubItem.setText([ "subsubitem " ~ to!(String)(k), "tuv", "wxyz" ]);
60 }
61 }
62 }
63 shell.pack();
64 shell.open();
65 while (!shell.isDisposed()) {
66 if (!display.readAndDispatch()) {
67 display.sleep();
68 }
69 }
70 display.dispose();
71 }