comparison snippets/toolbar/Snippet153.d @ 78:4a04b6759f98

Clean up directory names
author John Reimer <terminal.node@gmail.com>
date Sat, 10 May 2008 13:32:45 -0700
parents
children 1f0a7a472680
comparison
equal deleted inserted replaced
76:04f122e90b0a 78:4a04b6759f98
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 snippets.toolbar.Snippet153;
14
15 /*
16 * ToolBar example snippet: update a status line when the pointer enters a ToolItem
17 *
18 * For a list of all SWT example snippets see
19 * http://www.eclipse.org/swt/snippets/
20 */
21 import dwt.DWT;
22 import dwt.events.MouseEvent;
23 import dwt.events.MouseMoveListener;
24 import dwt.graphics.Point;
25 import dwt.widgets.Display;
26 import dwt.widgets.Shell;
27 import dwt.widgets.ToolBar;
28 import dwt.widgets.ToolItem;
29 import dwt.widgets.Label;
30
31 static char[] statusText = "";
32 void main() {
33 Display display = new Display();
34 Shell shell = new Shell(display);
35 shell.setBounds(10, 10, 200, 200);
36 ToolBar bar = new ToolBar(shell, DWT.BORDER);
37 bar.setBounds(10, 10, 150, 50);
38 Label statusLine = new Label(shell, DWT.BORDER);
39 statusLine.setBounds(10, 90, 150, 30);
40 (new ToolItem(bar, DWT.NONE)).setText("item 1");
41 (new ToolItem(bar, DWT.NONE)).setText("item 2");
42 (new ToolItem(bar, DWT.NONE)).setText("item 3");
43 bar.addMouseMoveListener(new class MouseMoveListener {
44 void mouseMove(MouseEvent e) {
45 ToolItem item = bar.getItem(new Point(e.x, e.y));
46 char[] name = "";
47 if (item !is null) {
48 name = item.getText();
49 }
50 if (statusText != name) {
51 statusLine.setText(name);
52 statusText = name;
53 }
54 }
55 });
56 shell.open();
57 while (!shell.isDisposed()) {
58 if (!display.readAndDispatch()) display.sleep();
59 }
60 display.dispose();
61 }
62