1 #!/usr/bin/env dub
2 /+
3 dub.sdl:
4     name "snippet75"
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, 2004 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  *     Thomas Demmer <t_demmer AT web DOT de>
47  *******************************************************************************/
48 module org.eclipse.swt.snippets.Snippet75;
49 
50 /*
51  * Composite example snippet: set the tab traversal order of children
52  * In this example, composite1 (i.e. c1) tab order is set to: B2, B1, B3, and
53  * shell tab order is set to: c1, B7, toolBar1, (c4: no focusable children), c2, L2
54  *
55  * For a list of all SWT example snippets see
56  * http://www.eclipse.org/swt/snippets/
57  */
58 import org.eclipse.swt.SWT;
59 import org.eclipse.swt.widgets.Button;
60 import org.eclipse.swt.widgets.Combo;
61 import org.eclipse.swt.widgets.Composite;
62 import org.eclipse.swt.widgets.Control;
63 import org.eclipse.swt.widgets.Display;
64 import org.eclipse.swt.widgets.Label;
65 import org.eclipse.swt.widgets.List;
66 import org.eclipse.swt.widgets.Shell;
67 import org.eclipse.swt.widgets.ToolBar;
68 import org.eclipse.swt.widgets.ToolItem;
69 import org.eclipse.swt.layout.FillLayout;
70 import org.eclipse.swt.layout.RowLayout;
71 
72 import java.lang.all;
73 
74 
75 void main () {
76     Display display = new Display ();
77     Shell shell = new Shell (display);
78     shell.setLayout (new RowLayout ());
79 
80     Composite c1 = new Composite (shell, SWT.BORDER);
81     c1.setLayout (new RowLayout ());
82     Button b1 = new Button (c1, SWT.PUSH);
83     b1.setText ("B&1");
84     Button r1 = new Button (c1, SWT.RADIO);
85     r1.setText ("R1");
86     Button r2 = new Button (c1, SWT.RADIO);
87     r2.setText ("R&2");
88     Button r3 = new Button (c1, SWT.RADIO);
89     r3.setText ("R3");
90     Button b2 = new Button (c1, SWT.PUSH);
91     b2.setText ("B2");
92     List l1 = new List (c1, SWT.SINGLE | SWT.BORDER);
93     l1.setItems (["L1"]);
94     Button b3 = new Button (c1, SWT.PUSH);
95     b3.setText ("B&3");
96     Button b4 = new Button (c1, SWT.PUSH);
97     b4.setText ("B&4");
98 
99     Composite c2 = new Composite (shell, SWT.BORDER);
100     c2.setLayout (new RowLayout ());
101     Button b5 = new Button (c2, SWT.PUSH);
102     b5.setText ("B&5");
103     Button b6 = new Button (c2, SWT.PUSH);
104     b6.setText ("B&6");
105 
106     List l2 = new List (shell, SWT.SINGLE | SWT.BORDER);
107     l2.setItems ( ["L2"] );
108 
109     ToolBar tb1 = new ToolBar (shell, SWT.FLAT | SWT.BORDER);
110     ToolItem i1 = new ToolItem (tb1, SWT.RADIO);
111     i1.setText ("I1");
112     ToolItem i2 = new ToolItem (tb1, SWT.RADIO);
113     i2.setText ("I2");
114     Combo combo1 = new Combo (tb1, SWT.READ_ONLY | SWT.BORDER);
115     combo1.setItems (["C1"]);
116     combo1.setText ("C1");
117     combo1.pack ();
118     ToolItem i3 = new ToolItem (tb1, SWT.SEPARATOR);
119     i3.setWidth (combo1.getSize ().x);
120     i3.setControl (combo1);
121     ToolItem i4 = new ToolItem (tb1, SWT.PUSH);
122     i4.setText ("I&4");
123     ToolItem i5 = new ToolItem (tb1, SWT.CHECK);
124     i5.setText ("I5");
125 
126     Button b7 = new Button (shell, SWT.PUSH);
127     b7.setText ("B&7");
128 
129     Composite c4 = new Composite (shell, SWT.BORDER);
130     Composite c5 = new Composite (c4, SWT.BORDER);
131     c5.setLayout(new FillLayout());
132     (new Label(c5, SWT.NONE)).setText("No");
133     c5.pack();
134 
135 
136     Control [] tabList1 = [cast(Control)b2, b1, b3];
137     c1.setTabList (tabList1);
138     Control [] tabList2 = [cast(Control)c1, b7, tb1, c4, c2, l2];
139     shell.setTabList (tabList2);
140     shell.pack ();
141     shell.open ();
142 
143     while (!shell.isDisposed ()) {
144         if (!display.readAndDispatch ()) display.sleep ();
145     }
146     display.dispose ();
147 }