1 #!/usr/bin/env dub 2 /+ 3 dub.sdl: 4 name "snippet170" 5 dependency "dwt" path="../../../../../../" 6 libs \ 7 "atk-1.0" \ 8 "cairo" \ 9 "dl" \ 10 "fontconfig" \ 11 "gdk-x11-2.0" \ 12 "gdk_pixbuf-2.0" \ 13 "glib-2.0" \ 14 "gmodule-2.0" \ 15 "gnomeui-2" \ 16 "gnomevfs-2" \ 17 "gobject-2.0" \ 18 "gthread-2.0" \ 19 "gtk-x11-2.0" \ 20 "pango-1.0" \ 21 "pangocairo-1.0" \ 22 "X11" \ 23 "Xcomposite" \ 24 "Xcursor" \ 25 "Xdamage" \ 26 "Xext" \ 27 "Xfixes" \ 28 "Xi" \ 29 "Xinerama" \ 30 "Xrandr" \ 31 "Xrender" \ 32 "Xtst" \ 33 platform="linux" 34 +/ 35 36 /******************************************************************************* 37 * Copyright (c) 2000, 2005 IBM Corporation and others. 38 * All rights reserved. This program and the accompanying materials 39 * are made available under the terms of the Eclipse Public License v1.0 40 * which accompanies this distribution, and is available at 41 * http://www.eclipse.org/legal/epl-v10.html 42 * 43 * Contributors: 44 * IBM Corporation - initial API and implementation 45 * D Port: 46 * Bill Baxter <wbaxter@gmail.com> 47 *******************************************************************************/ 48 module org.eclipse.swt.snippets.Snippet170; 49 50 /* 51 * Tree example snippet: Create a Tree with columns 52 * 53 * For a list of all SWT example snippets see 54 * http://www.eclipse.org/swt/snippets/ 55 * 56 * @since 3.1 57 */ 58 59 import org.eclipse.swt.SWT; 60 import org.eclipse.swt.widgets.Display; 61 import org.eclipse.swt.widgets.Shell; 62 import org.eclipse.swt.widgets.Tree; 63 import org.eclipse.swt.widgets.TreeItem; 64 import org.eclipse.swt.widgets.TreeColumn; 65 import org.eclipse.swt.layout.FillLayout; 66 67 version(Tango){ 68 import tango.util.Convert; 69 } else { // Phobos 70 import std.conv; 71 } 72 73 import java.lang.all; 74 75 void main() { 76 Display display = new Display(); 77 Shell shell = new Shell(display); 78 shell.setLayout(new FillLayout()); 79 Tree tree = new Tree(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); 80 tree.setHeaderVisible(true); 81 TreeColumn column1 = new TreeColumn(tree, SWT.LEFT); 82 column1.setText("Column 1"); 83 column1.setWidth(200); 84 TreeColumn column2 = new TreeColumn(tree, SWT.CENTER); 85 column2.setText("Column 2"); 86 column2.setWidth(200); 87 TreeColumn column3 = new TreeColumn(tree, SWT.RIGHT); 88 column3.setText("Column 3"); 89 column3.setWidth(200); 90 for (int i = 0; i < 4; i++) { 91 TreeItem item = new TreeItem(tree, SWT.NONE); 92 item.setText([ "item " ~ to!(String)(i), "abc", "defghi" ]); 93 for (int j = 0; j < 4; j++) { 94 TreeItem subItem = new TreeItem(item, SWT.NONE); 95 subItem.setText([ "subitem " ~ to!(String)(j), "jklmnop", "qrs" ]); 96 for (int k = 0; k < 4; k++) { 97 TreeItem subsubItem = new TreeItem(subItem, SWT.NONE); 98 subsubItem.setText([ "subsubitem " ~ to!(String)(k), "tuv", "wxyz" ]); 99 } 100 } 101 } 102 shell.pack(); 103 shell.open(); 104 while (!shell.isDisposed()) { 105 if (!display.readAndDispatch()) { 106 display.sleep(); 107 } 108 } 109 display.dispose(); 110 }