comparison 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
comparison
equal deleted inserted replaced
173:33d9146198b2 174:c58389a70da3
1 module InternalShellExample;
2
3 import dwt.std;
4 import dwt.dwthelper.ByteArrayInputStream;
5 import dwtx.novocode.ScaledImage;
6 import dwtx.novocode.ishell.DesktopForm;
7 import dwtx.novocode.ishell.InternalShell;
8
9 const char[] res_prefix = "novocode.InternalShellExample.";
10 void main() {
11 Display display = new Display();
12 Shell shell = new Shell( display );
13 shell.setLayout( new FillLayout() );
14 shell.setImage( new Image( display, new ImageData( new ByteArrayInputStream( cast( byte[] ) import( res_prefix~"ishell.png" ) ) ) ) );
15 shell.setText( "Internal Shell Example" );
16
17 DesktopForm desktop = new DesktopForm( shell, DWT.NONE );
18
19 ScaledImage si = new ScaledImage( desktop, DWT.NONE );
20 si.setImage( new Image( display, new ImageData( new ByteArrayInputStream( cast( byte[] ) import( res_prefix~"bg.jpg" ) ) ) ) );
21 si.setImagePlacement( ScaledImage.IMAGE_PLACEMENT_TILE );
22 si.setLocation( 0, 0 );
23 si.setSize( desktop.getSize() );
24
25 desktop.addListener( DWT.Resize, new class( si ) Listener {
26 ScaledImage si;
27 this( ScaledImage si ) {
28 this.si = si;
29 }
30 public void handleEvent(Event event) {
31 si.setSize(desktop.getSize());
32 }
33 });
34
35 InternalShell ishell = new InternalShell( desktop, DWT.SHELL_TRIM );
36 ishell.setText( "Internal Shell" );
37
38 shell.pack();
39 shell.open();
40 ishell.open();
41
42 while ( !shell.isDisposed ) {
43 if ( !display.readAndDispatch() )
44 display.sleep();
45 }
46
47 display.dispose();
48 }