comparison dwtsnippets/table/Snippet38.d @ 27:580d6cc14afd

Added tree and table snippets. Cleaned up .hgignore.
author Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
date Sun, 02 Mar 2008 11:11:34 -0800
parents
children 3b18f03b2f41
comparison
equal deleted inserted replaced
26:ff27e8ad465c 27:580d6cc14afd
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 dwtsnippets.table.Snippet38;
14
15 /*
16 * Table example snippet: create a table (columns, headers, lines)
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.widgets.Display;
23 import dwt.widgets.Shell;
24 import dwt.widgets.Table;
25 import dwt.widgets.TableColumn;
26 import dwt.widgets.TableItem;
27
28 import tango.util.Convert;
29
30 void main () {
31 auto display = new Display ();
32 auto shell = new Shell (display);
33 auto table = new Table (shell, DWT.MULTI | DWT.BORDER | DWT.FULL_SELECTION);
34 table.setLinesVisible (true);
35 table.setHeaderVisible (true);
36 char[][] titles = [" ", "C", "!", "Description", "Resource", "In Folder", "Location"];
37 foreach (title; titles) {
38 auto column = new TableColumn (table, DWT.NONE);
39 column.setText (title);
40 }
41 int count = 128;
42 for (int i=0; i<count; i++) {
43 auto item = new TableItem (table, DWT.NONE);
44 item.setText (0, "x");
45 item.setText (1, "y");
46 item.setText (2, "!");
47 item.setText (3, "this stuff behaves the way I expect");
48 item.setText (4, "almost everywhere");
49 item.setText (5, "some.folder");
50 item.setText (6, "line " ~ to!(char[])(i) ~ " in nowhere");
51 }
52 for (int i=0; i<titles.length; i++) {
53 table.getColumn (i).pack ();
54 }
55 table.setSize (table.computeSize (DWT.DEFAULT, 200));
56 shell.pack ();
57 shell.open ();
58 while (!shell.isDisposed ()) {
59 if (!display.readAndDispatch ()) display.sleep ();
60 }
61 display.dispose ();
62 }