Mercurial > projects > dwt-samples
comparison snippets/display/Snippet16.d @ 132:104f5ed240fc
More snippets from TomD, thanks!
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 29 Jul 2008 01:50:10 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
130:5c1906bfc206 | 132:104f5ed240fc |
---|---|
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 display.Snippet16; | |
14 | |
15 /* | |
16 * Display example snippet: create one repeating timer (every 500 ms) | |
17 * | |
18 * For a list of all DWT example snippets see | |
19 * http://www.eclipse.org/swt/snippets/ | |
20 */ | |
21 import dwt.graphics.Point; | |
22 import dwt.graphics.Rectangle; | |
23 import dwt.widgets.Display; | |
24 import dwt.widgets.Shell; | |
25 | |
26 import dwt.dwthelper.utils; | |
27 import dwt.dwthelper.Runnable; | |
28 | |
29 import tango.io.Stdout; | |
30 | |
31 void main (String [] args) { | |
32 Display display = new Display (); | |
33 Shell shell = new Shell (display); | |
34 final int time = 500; | |
35 Runnable timer; | |
36 timer = dgRunnable( { | |
37 Point point = display.getCursorLocation (); | |
38 Rectangle rect = shell.getBounds (); | |
39 if (rect.contains (point)) { | |
40 Stdout("In\n"); | |
41 } else { | |
42 Stdout("Out\n"); | |
43 } | |
44 Stdout.flush(); | |
45 display.timerExec (time, timer); | |
46 }); | |
47 display.timerExec (time, timer); | |
48 shell.setSize (200, 200); | |
49 shell.open (); | |
50 while (!shell.isDisposed()) { | |
51 if (!display.readAndDispatch ()) display.sleep (); | |
52 } | |
53 display.dispose (); | |
54 } |