Mercurial > projects > dwt2
annotate org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet38.d @ 104:88652073d1c2
More work on icu
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 02 May 2009 11:27:24 +0200 |
parents | 4e5843b771cc |
children | 9f4c18c268b2 |
rev | line source |
---|---|
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.Snippet38; | |
14 | |
15 /* | |
16 * Table example snippet: create a table (columns, headers, lines) | |
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.widgets.Display; | |
23 import org.eclipse.swt.widgets.Shell; | |
24 import org.eclipse.swt.widgets.Table; | |
25 import org.eclipse.swt.widgets.TableColumn; | |
26 import org.eclipse.swt.widgets.TableItem; | |
27 | |
28 import tango.util.Convert; | |
29 | |
30 void main () { | |
31 auto display = new Display (); | |
32 auto shell = new Shell (display); | |
29
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
33 auto table = new Table (shell, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); |
28 | 34 table.setLinesVisible (true); |
35 table.setHeaderVisible (true); | |
36 char[][] titles = [" ", "C", "!", "Description", "Resource", "In Folder", "Location"]; | |
29
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
37 int[] styles = [SWT.NONE, SWT.LEFT, SWT.RIGHT, SWT.CENTER, SWT.NONE, SWT.NONE, SWT.NONE]; |
28 | 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, SWT.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 (SWT.DEFAULT, 200)); | |
57 shell.pack (); | |
58 shell.open (); | |
59 while (!shell.isDisposed ()) { | |
60 if (!display.readAndDispatch ()) display.sleep (); | |
61 } | |
62 display.dispose (); | |
63 } |