Mercurial > projects > dwt-samples
annotate snippets/coolbar/Snippet150.d @ 120:1f0a7a472680
fix rm snippets from module statements.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 20 Jul 2008 19:17:23 +0200 |
parents | 4a04b6759f98 |
children |
rev | line source |
---|---|
78 | 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 * D Port: | |
11 * Bill Baxter | |
12 *******************************************************************************/ | |
120
1f0a7a472680
fix rm snippets from module statements.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
13 module coolbar.Snippet150; |
78 | 14 |
15 /* | |
16 * CoolBar example snippet: create a coolbar (relayout when resized) | |
17 * | |
18 * For a list of all SWT example snippets see | |
19 * http://www.eclipse.org/swt/snippets/ | |
20 * | |
21 * @since 3.0 | |
22 */ | |
23 import dwt.DWT; | |
24 import dwt.graphics.Point; | |
25 import dwt.widgets.Button; | |
26 import dwt.widgets.Display; | |
27 import dwt.widgets.CoolBar; | |
28 import dwt.widgets.CoolItem; | |
29 import dwt.widgets.ToolBar; | |
30 import dwt.widgets.ToolItem; | |
31 import dwt.widgets.Shell; | |
32 import dwt.widgets.Text; | |
33 import dwt.widgets.Event; | |
34 import dwt.widgets.Listener; | |
35 import dwt.layout.FormLayout; | |
36 import dwt.layout.FormData; | |
37 import dwt.layout.FormAttachment; | |
38 | |
39 import tango.util.Convert; | |
40 | |
41 int itemCount; | |
42 CoolItem createItem(CoolBar coolBar, int count) { | |
43 ToolBar toolBar = new ToolBar(coolBar, DWT.FLAT); | |
44 for (int i = 0; i < count; i++) { | |
45 ToolItem item = new ToolItem(toolBar, DWT.PUSH); | |
46 item.setText(to!(char[])(itemCount++) ~""); | |
47 } | |
48 toolBar.pack(); | |
49 Point size = toolBar.getSize(); | |
50 CoolItem item = new CoolItem(coolBar, DWT.NONE); | |
51 item.setControl(toolBar); | |
52 Point preferred = item.computeSize(size.x, size.y); | |
53 item.setPreferredSize(preferred); | |
54 return item; | |
55 } | |
56 | |
57 void main () { | |
58 | |
59 Display display = new Display(); | |
60 final Shell shell = new Shell(display); | |
61 CoolBar coolBar = new CoolBar(shell, DWT.NONE); | |
62 createItem(coolBar, 3); | |
63 createItem(coolBar, 2); | |
64 createItem(coolBar, 3); | |
65 createItem(coolBar, 4); | |
66 int style = DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL; | |
67 Text text = new Text(shell, style); | |
68 FormLayout layout = new FormLayout(); | |
69 shell.setLayout(layout); | |
70 FormData coolData = new FormData(); | |
71 coolData.left = new FormAttachment(0); | |
72 coolData.right = new FormAttachment(100); | |
73 coolData.top = new FormAttachment(0); | |
74 coolBar.setLayoutData(coolData); | |
75 coolBar.addListener(DWT.Resize, new class() Listener { | |
76 void handleEvent(Event event) { | |
77 shell.layout(); | |
78 } | |
79 }); | |
80 FormData textData = new FormData(); | |
81 textData.left = new FormAttachment(0); | |
82 textData.right = new FormAttachment(100); | |
83 textData.top = new FormAttachment(coolBar); | |
84 textData.bottom = new FormAttachment(100); | |
85 text.setLayoutData(textData); | |
86 shell.open(); | |
87 while (!shell.isDisposed()) { | |
88 if (!display.readAndDispatch()) display.sleep(); | |
89 } | |
90 display.dispose(); | |
91 | |
120
1f0a7a472680
fix rm snippets from module statements.
Frank Benoit <benoit@tionex.de>
parents:
78
diff
changeset
|
92 } |