Mercurial > projects > dwt-samples
comparison user/doob_test1/draw.d @ 4:8d49c4eb4800
Added user examples
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 10 Feb 2008 04:28:56 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:6e0b2c96d1fd | 4:8d49c4eb4800 |
---|---|
1 module user.doob_test1.draw; | |
2 | |
3 private import dwt.DWT; | |
4 private import dwt.events.SelectionListener; | |
5 private import dwt.events.SelectionEvent; | |
6 private import dwt.layout.FillLayout; | |
7 private import dwt.widgets.Canvas; | |
8 private import dwt.widgets.Control; | |
9 private import dwt.widgets.Display; | |
10 private import dwt.widgets.Shell; | |
11 private import dwt.events.PaintListener; | |
12 private import dwt.events.MouseListener; | |
13 private import dwt.events.MouseMoveListener; | |
14 | |
15 private import tango.io.Stdout; | |
16 | |
17 private import user.doob_test1.MouseHandler; | |
18 private import user.doob_test1.PaintHandler; | |
19 | |
20 | |
21 import tango.io.Stdout; | |
22 import tango.math.Math; | |
23 import tango.text.convert.Format; | |
24 import tango.util.Convert; | |
25 import tango.util.PathUtil; | |
26 import dwt.events.SelectionListener; | |
27 import dwt.events.SelectionEvent; | |
28 | |
29 void main(){ | |
30 try{ | |
31 auto display = new Display(); | |
32 auto shell = new Shell(display); | |
33 | |
34 auto canvas = new Canvas(shell,DWT.NO_REDRAW_RESIZE); | |
35 auto hPaint= new PaintHandler(canvas, display); | |
36 auto hMouse = new MouseHandler(hPaint); | |
37 | |
38 shell.setText("Draw window"); | |
39 shell.setSize(500, 500); | |
40 shell.setLayout(new FillLayout()); | |
41 | |
42 canvas.addPaintListener(hPaint); | |
43 canvas.addMouseListener(hMouse); | |
44 canvas.addMouseMoveListener(hMouse); | |
45 shell.layout(); | |
46 shell.open(); | |
47 while (!shell.isDisposed()) { | |
48 if (!display.readAndDispatch()) { | |
49 display.sleep(); | |
50 } | |
51 } | |
52 Stdout("Stop").newline.flush; | |
53 } catch (Exception e) { | |
54 Stdout.formatln (e.toString); | |
55 } | |
56 } |