1 #!/usr/bin/env dub 2 /+ 3 dub.sdl: 4 name "snippet223" 5 dependency "dwt" path="../../../../../../" 6 stringImportPaths "../../../../../res" 7 libs \ 8 "atk-1.0" \ 9 "cairo" \ 10 "dl" \ 11 "fontconfig" \ 12 "gdk-x11-2.0" \ 13 "gdk_pixbuf-2.0" \ 14 "glib-2.0" \ 15 "gmodule-2.0" \ 16 "gnomeui-2" \ 17 "gnomevfs-2" \ 18 "gobject-2.0" \ 19 "gthread-2.0" \ 20 "gtk-x11-2.0" \ 21 "pango-1.0" \ 22 "pangocairo-1.0" \ 23 "X11" \ 24 "Xcomposite" \ 25 "Xcursor" \ 26 "Xdamage" \ 27 "Xext" \ 28 "Xfixes" \ 29 "Xi" \ 30 "Xinerama" \ 31 "Xrandr" \ 32 "Xrender" \ 33 "Xtst" \ 34 platform="linux" 35 +/ 36 37 /******************************************************************************* 38 * Copyright (c) 2000, 2006 IBM Corporation and others. 39 * All rights reserved. This program and the accompanying materials 40 * are made available under the terms of the Eclipse Public License v1.0 41 * which accompanies this distribution, and is available at 42 * http://www.eclipse.org/legal/epl-v10.html 43 * 44 * Contributors: 45 * IBM Corporation - initial API and implementation 46 * D Port: 47 * Jesse Phillips <Jesse.K.Phillips+D> gmail.com 48 *******************************************************************************/ 49 module org.eclipse.swt.snippets.Snippet223; 50 /* 51 * example snippet: ExpandBar example 52 * 53 * For a list of all SWT example snippets see 54 * http://www.eclipse.org/swt/snippets/ 55 * 56 * @since 3.2 57 */ 58 59 import org.eclipse.swt.SWT; 60 import java.io.ByteArrayInputStream; 61 import org.eclipse.swt.graphics.Image; 62 import org.eclipse.swt.graphics.ImageData; 63 import org.eclipse.swt.layout.FillLayout; 64 import org.eclipse.swt.layout.GridLayout; 65 import org.eclipse.swt.widgets.Button; 66 import org.eclipse.swt.widgets.Composite; 67 import org.eclipse.swt.widgets.Display; 68 import org.eclipse.swt.widgets.ExpandBar; 69 import org.eclipse.swt.widgets.ExpandItem; 70 import org.eclipse.swt.widgets.Label; 71 import org.eclipse.swt.widgets.Shell; 72 import org.eclipse.swt.widgets.Scale; 73 import org.eclipse.swt.widgets.Spinner; 74 import org.eclipse.swt.widgets.Slider; 75 76 void main () { 77 auto display = new Display (); 78 auto shell = new Shell (display); 79 shell.setLayout(new FillLayout()); 80 shell.setText("ExpandBar Example"); 81 auto bar = new ExpandBar (shell, SWT.V_SCROLL); 82 auto image = new Image(display, new ImageData(new ByteArrayInputStream( cast(byte[]) import("eclipse.png")))); 83 84 // First item 85 Composite composite = new Composite (bar, SWT.NONE); 86 GridLayout layout = new GridLayout (); 87 layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10; 88 layout.verticalSpacing = 10; 89 composite.setLayout(layout); 90 Button button = new Button (composite, SWT.PUSH); 91 button.setText("SWT.PUSH"); 92 button = new Button (composite, SWT.RADIO); 93 button.setText("SWT.RADIO"); 94 button = new Button (composite, SWT.CHECK); 95 button.setText("SWT.CHECK"); 96 button = new Button (composite, SWT.TOGGLE); 97 button.setText("SWT.TOGGLE"); 98 ExpandItem item0 = new ExpandItem (bar, SWT.NONE, 0); 99 item0.setText("What is your favorite button"); 100 item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); 101 item0.setControl(composite); 102 item0.setImage(image); 103 104 // Second item 105 composite = new Composite (bar, SWT.NONE); 106 layout = new GridLayout (2, false); 107 layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10; 108 layout.verticalSpacing = 10; 109 composite.setLayout(layout); 110 Label label = new Label (composite, SWT.NONE); 111 label.setImage(display.getSystemImage(SWT.ICON_ERROR)); 112 label = new Label (composite, SWT.NONE); 113 label.setText("SWT.ICON_ERROR"); 114 label = new Label (composite, SWT.NONE); 115 label.setImage(display.getSystemImage(SWT.ICON_INFORMATION)); 116 label = new Label (composite, SWT.NONE); 117 label.setText("SWT.ICON_INFORMATION"); 118 label = new Label (composite, SWT.NONE); 119 label.setImage(display.getSystemImage(SWT.ICON_WARNING)); 120 label = new Label (composite, SWT.NONE); 121 label.setText("SWT.ICON_WARNING"); 122 label = new Label (composite, SWT.NONE); 123 label.setImage(display.getSystemImage(SWT.ICON_QUESTION)); 124 label = new Label (composite, SWT.NONE); 125 label.setText("SWT.ICON_QUESTION"); 126 ExpandItem item1 = new ExpandItem (bar, SWT.NONE, 1); 127 item1.setText("What is your favorite icon"); 128 item1.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); 129 item1.setControl(composite); 130 item1.setImage(image); 131 132 // Third item 133 composite = new Composite (bar, SWT.NONE); 134 layout = new GridLayout (2, true); 135 layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10; 136 layout.verticalSpacing = 10; 137 composite.setLayout(layout); 138 label = new Label (composite, SWT.NONE); 139 label.setText("Scale"); 140 new Scale (composite, SWT.NONE); 141 label = new Label (composite, SWT.NONE); 142 label.setText("Spinner"); 143 new Spinner (composite, SWT.BORDER); 144 label = new Label (composite, SWT.NONE); 145 label.setText("Slider"); 146 new Slider (composite, SWT.NONE); 147 ExpandItem item2 = new ExpandItem (bar, SWT.NONE, 2); 148 item2.setText("What is your favorite range widget"); 149 item2.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y); 150 item2.setControl(composite); 151 item2.setImage(image); 152 153 item1.setExpanded(true); 154 bar.setSpacing(8); 155 shell.setSize(400, 350); 156 shell.open(); 157 while (!shell.isDisposed ()) { 158 if (!display.readAndDispatch ()) { 159 display.sleep (); 160 } 161 } 162 image.dispose(); 163 display.dispose(); 164 }