Mercurial > projects > dwt-samples
annotate snippets/table/Snippet38.d @ 120:1f0a7a472680
fix rm snippets from module statements.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 20 Jul 2008 19:17:23 +0200 |
parents | 4a04b6759f98 |
children |
rev | line source |
---|---|
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 *******************************************************************************/ | |
120
1f0a7a472680
fix rm snippets from module statements.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
13 module table.Snippet38; |
78 | 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 int[] styles = [DWT.NONE, DWT.LEFT, DWT.RIGHT, DWT.CENTER, DWT.NONE, DWT.NONE, DWT.NONE]; | |
38 foreach (i,title; titles) { | |
39 auto column = new TableColumn (table, styles[i]); | |
40 column.setText (title); | |
41 } | |
42 int count = 128; | |
43 for (int i=0; i<count; i++) { | |
44 auto item = new TableItem (table, DWT.NONE); | |
45 item.setText (0, "x"); | |
46 item.setText (1, "y"); | |
47 item.setText (2, "!"); | |
48 item.setText (3, "this stuff behaves the way I expect"); | |
49 item.setText (4, "almost everywhere"); | |
50 item.setText (5, "some.folder"); | |
51 item.setText (6, "line " ~ to!(char[])(i) ~ " in nowhere"); | |
52 } | |
53 for (int i=0; i<titles.length; i++) { | |
54 table.getColumn (i).pack (); | |
55 } | |
56 table.setSize (table.computeSize (DWT.DEFAULT, 200)); | |
57 shell.pack (); | |
58 shell.open (); | |
59 while (!shell.isDisposed ()) { | |
60 if (!display.readAndDispatch ()) display.sleep (); | |
61 } | |
62 display.dispose (); | |
63 } |