view 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
line wrap: on
line source

/*******************************************************************************
 * Copyright (c) 2000, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 * D Port:
 *     Thomas Demmer <t_demmer AT web DOT de>
 *******************************************************************************/
module display.Snippet16;
 
/*
 * Display example snippet: create one repeating timer (every 500 ms)
 *
 * For a list of all DWT example snippets see
 * http://www.eclipse.org/swt/snippets/
 */
import dwt.graphics.Point;
import dwt.graphics.Rectangle;
import dwt.widgets.Display;
import dwt.widgets.Shell;

import dwt.dwthelper.utils;
import dwt.dwthelper.Runnable;

import tango.io.Stdout;

void main (String [] args) {
    Display display = new Display ();
    Shell shell = new Shell (display);
    final int time = 500;
    Runnable timer;
    timer = dgRunnable( {
        Point point = display.getCursorLocation ();
        Rectangle rect = shell.getBounds ();
        if (rect.contains (point)) {
            Stdout("In\n");
        } else {
            Stdout("Out\n");
        }
        Stdout.flush();
        display.timerExec (time, timer);
    });
    display.timerExec (time, timer);
    shell.setSize (200, 200);
    shell.open ();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose (); 
}