comparison org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet16.d @ 28:69b1fa94a4a8

Added SWT snippets
author Frank Benoit <benoit@tionex.de>
date Sun, 22 Mar 2009 15:17:04 +0100
parents
children 9f4c18c268b2
comparison
equal deleted inserted replaced
27:1bf55a6eb092 28:69b1fa94a4a8
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 * Thomas Demmer <t_demmer AT web DOT de>
12 *******************************************************************************/
13 module org.eclipse.swt.snippets.Snippet16;
14
15 /*
16 * Display example snippet: create one repeating timer (every 500 ms)
17 *
18 * For a list of all SWT example snippets see
19 * http://www.eclipse.org/swt/snippets/
20 */
21 import org.eclipse.swt.graphics.Point;
22 import org.eclipse.swt.graphics.Rectangle;
23 import org.eclipse.swt.widgets.Display;
24 import org.eclipse.swt.widgets.Shell;
25
26 import java.lang.all;
27
28 import tango.io.Stdout;
29
30 void main (String [] args) {
31 Display display = new Display ();
32 Shell shell = new Shell (display);
33 final int time = 500;
34 Runnable timer;
35 timer = dgRunnable( {
36 Point point = display.getCursorLocation ();
37 Rectangle rect = shell.getBounds ();
38 if (rect.contains (point)) {
39 Stdout("In\n");
40 } else {
41 Stdout("Out\n");
42 }
43 Stdout.flush();
44 display.timerExec (time, timer);
45 });
46 display.timerExec (time, timer);
47 shell.setSize (200, 200);
48 shell.open ();
49 while (!shell.isDisposed()) {
50 if (!display.readAndDispatch ()) display.sleep ();
51 }
52 display.dispose ();
53 }