view dwtexamples/helloworld/HelloWorld3.d @ 0:052c3aebd1d3

initial import
author Frank Benoit <benoit@tionex.de>
date Fri, 01 Feb 2008 21:46:26 +0100
parents
children b61e7baf0574
line wrap: on
line source

/*******************************************************************************
 * Copyright (c) 2000, 2003 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
 *******************************************************************************/
module dwtexamples.helloworld.HelloWorld3;

import dwt.DWT;
import dwt.events.ControlAdapter;
import dwt.events.ControlEvent;
import dwt.widgets.Display;
import dwt.widgets.Label;
import dwt.widgets.Shell;

/*
 * This example builds on HelloWorld2 and demonstrates how to resize the
 * Label when the Shell resizes using a Listener mechanism.
 */

void main () {
    Display display = new Display ();
    final Shell shell = new Shell (display);
    final Label label = new Label (shell, DWT.CENTER);
    label.setText ("Hello_world");
    label.pack();
    shell.addControlListener(new class() ControlAdapter {
        public void controlResized(ControlEvent e) {
            label.setBounds (shell.getClientArea ());
        }
    });
    shell.pack();
    shell.open ();
    while (!shell.isDisposed ()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();
}

// for unknown reason, there are linker errors. These imports are the workaround
import tango.io.Stdout;
import tango.math.Math;
import tango.text.convert.Format;
import tango.util.Convert;
import tango.util.PathUtil;