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 * Port to the D programming language:
|
|
11 * Bill Baxter <bill@billbaxter.com>
|
|
12 *******************************************************************************/
|
|
13 module org.eclipse.swt.snippets.Snippet58;
|
|
14
|
|
15 /*
|
|
16 * ToolBar example snippet: place a combo box in a tool bar
|
|
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.ToolBar;
|
|
25 import org.eclipse.swt.widgets.ToolItem;
|
|
26 import org.eclipse.swt.widgets.Combo;
|
112
|
27 import java.lang.all;
|
28
|
28
|
112
|
29 version(Tango){
|
|
30 import tango.util.Convert;
|
|
31 } else { // Phobos
|
|
32 import std.conv;
|
|
33 }
|
28
|
34
|
|
35 void main () {
|
|
36 Display display = new Display ();
|
|
37 Shell shell = new Shell (display);
|
|
38 ToolBar bar = new ToolBar (shell, SWT.BORDER);
|
|
39 for (int i=0; i<4; i++) {
|
|
40 ToolItem item = new ToolItem (bar, 0);
|
112
|
41 item.setText ("Item " ~ to!(String)(i));
|
28
|
42 }
|
|
43 ToolItem sep = new ToolItem (bar, SWT.SEPARATOR);
|
|
44 int start = bar.getItemCount ();
|
|
45 for (int i=start; i<start+4; i++) {
|
|
46 ToolItem item = new ToolItem (bar, 0);
|
112
|
47 item.setText ("Item " ~ to!(String)(i));
|
28
|
48 }
|
|
49 Combo combo = new Combo (bar, SWT.READ_ONLY);
|
|
50 for (int i=0; i<4; i++) {
|
112
|
51 combo.add ("Item " ~ to!(String)(i));
|
28
|
52 }
|
|
53 combo.pack ();
|
|
54 sep.setWidth (combo.getSize ().x);
|
|
55 sep.setControl (combo);
|
|
56 bar.pack ();
|
|
57 shell.pack ();
|
|
58 shell.open ();
|
|
59 while (!shell.isDisposed ()) {
|
|
60 if (!display.readAndDispatch ()) display.sleep ();
|
|
61 }
|
|
62 display.dispose ();
|
|
63 }
|
|
64
|