view novocode/InternalShellExample.d @ 174:c58389a70da3

Added novocode internal shell example, thanks WasserDragoon
author Frank Benoit <benoit@tionex.de>
date Sun, 26 Oct 2008 14:53:47 +0100
parents
children
line wrap: on
line source

module InternalShellExample;

import dwt.std;
import dwt.dwthelper.ByteArrayInputStream;
import dwtx.novocode.ScaledImage;
import dwtx.novocode.ishell.DesktopForm;
import dwtx.novocode.ishell.InternalShell;

const char[] res_prefix = "novocode.InternalShellExample.";
void main() {
    Display display = new Display();
    Shell shell = new Shell( display );
    shell.setLayout( new FillLayout() );
    shell.setImage( new Image( display, new ImageData( new ByteArrayInputStream( cast( byte[] ) import( res_prefix~"ishell.png" ) ) ) ) );
    shell.setText( "Internal Shell Example" );

    DesktopForm desktop = new DesktopForm( shell, DWT.NONE );

    ScaledImage si = new ScaledImage( desktop, DWT.NONE );
    si.setImage( new Image( display, new ImageData( new ByteArrayInputStream( cast( byte[] ) import( res_prefix~"bg.jpg" ) ) ) ) );
    si.setImagePlacement( ScaledImage.IMAGE_PLACEMENT_TILE );
    si.setLocation( 0, 0 );
    si.setSize( desktop.getSize() );

    desktop.addListener( DWT.Resize, new class( si ) Listener {
        ScaledImage si;
        this( ScaledImage si ) {
            this.si = si;
        }
        public void handleEvent(Event event) {
            si.setSize(desktop.getSize());
        }
    });

    InternalShell ishell = new InternalShell( desktop, DWT.SHELL_TRIM );
    ishell.setText( "Internal Shell" );

    shell.pack();
    shell.open();
    ishell.open();

    while ( !shell.isDisposed ) {
        if ( !display.readAndDispatch() )
            display.sleep();
    }

    display.dispose();
}