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 * 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
|
112
|
28 version(Tango){
|
|
29 import tango.io.Stdout;
|
|
30 } else { // Phobos
|
|
31 import std.stdio;
|
|
32 }
|
28
|
33
|
|
34 void main (String [] args) {
|
|
35 Display display = new Display ();
|
|
36 Shell shell = new Shell (display);
|
112
|
37 int time = 500;
|
28
|
38 Runnable timer;
|
|
39 timer = dgRunnable( {
|
|
40 Point point = display.getCursorLocation ();
|
|
41 Rectangle rect = shell.getBounds ();
|
112
|
42 version(Tango){
|
|
43 if (rect.contains (point)) {
|
|
44 Stdout("In\n");
|
|
45 } else {
|
|
46 Stdout("Out\n");
|
|
47 }
|
|
48 Stdout.flush();
|
|
49 } else { // Phobos
|
|
50 if (rect.contains (point)) {
|
|
51 writeln("In");
|
|
52 } else {
|
|
53 writeln("Out");
|
|
54 }
|
28
|
55 }
|
|
56 display.timerExec (time, timer);
|
|
57 });
|
|
58 display.timerExec (time, timer);
|
|
59 shell.setSize (200, 200);
|
|
60 shell.open ();
|
|
61 while (!shell.isDisposed()) {
|
|
62 if (!display.readAndDispatch ()) display.sleep ();
|
|
63 }
|
|
64 display.dispose ();
|
|
65 }
|