1 #!/usr/bin/env dub 2 /+ 3 dub.sdl: 4 name "snippet5" 5 dependency "dwt" path="../../../../../../" version="*" 6 libs \ 7 "atk-1.0" \ 8 "cairo" \ 9 "dl" \ 10 "fontconfig" \ 11 "gdk-x11-2.0" \ 12 "gdk_pixbuf-2.0" \ 13 "gio-2.0" \ 14 "glib-2.0" \ 15 "gmodule-2.0" \ 16 "gobject-2.0" \ 17 "gthread-2.0" \ 18 "gtk-x11-2.0" \ 19 "pango-1.0" \ 20 "pangocairo-1.0" \ 21 "X11" \ 22 "Xcomposite" \ 23 "Xcursor" \ 24 "Xdamage" \ 25 "Xext" \ 26 "Xfixes" \ 27 "Xi" \ 28 "Xinerama" \ 29 "Xrandr" \ 30 "Xrender" \ 31 "Xtst" \ 32 platform="linux" 33 +/ 34 /******************************************************************************* 35 * Copyright (c) 2000, 2008 IBM Corporation and others. 36 * All rights reserved. This program and the accompanying materials 37 * are made available under the terms of the Eclipse Public License v1.0 38 * which accompanies this distribution, and is available at 39 * http://www.eclipse.org/legal/epl-v10.html 40 * 41 * Contributors: 42 * IBM Corporation - initial API and implementation 43 * D Port: 44 * alice <stigma@disroot.org> 45 *******************************************************************************/ 46 module org.eclipse.swt.snippets.Snippet5; 47 48 /* 49 * ScrolledComposite example snippet: scroll a control in a scrolled composite 50 * 51 * For a list of all SWT example snippets see 52 * http://www.eclipse.org/swt/snippets/ 53 */ 54 import org.eclipse.swt.all; 55 import org.eclipse.swt.custom.all; 56 import org.eclipse.swt.layout.all; 57 import org.eclipse.swt.widgets.all; 58 59 void main(string[] args) { 60 Display display = new Display(); 61 Shell shell = new Shell(display); 62 shell.setLayout(new FillLayout()); 63 64 // this button is always 400 x 400. Scrollbars appear if the window is resized to be 65 // too small to show part of the button 66 ScrolledComposite c1 = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); 67 Button b1 = new Button(c1, SWT.PUSH); 68 b1.setText("fixed size button"); 69 b1.setSize(400, 400); 70 c1.setContent(b1); 71 72 // this button has a minimum size of 400 x 400. If the window is resized to be big 73 // enough to show more than 400 x 400, the button will grow in size. If the window 74 // is made too small to show 400 x 400, scrollbars will appear. 75 ScrolledComposite c2 = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); 76 Button b2 = new Button(c2, SWT.PUSH); 77 b2.setText("expanding button"); 78 c2.setContent(b2); 79 c2.setExpandHorizontal(true); 80 c2.setExpandVertical(true); 81 c2.setMinSize(400, 400); 82 83 shell.setSize(600, 300); 84 shell.open(); 85 while (!shell.isDisposed()) { 86 if (!display.readAndDispatch()) display.sleep(); 87 } 88 display.dispose(); 89 }