78
|
1 module simple;
|
|
2
|
|
3 import dwt.DWT;
|
|
4 import dwt.widgets.Display;
|
|
5 import dwt.widgets.Shell;
|
|
6 import dwt.widgets.Button;
|
|
7 import dwt.widgets.Text;
|
|
8
|
|
9 import tango.io.Stdout;
|
82
|
10 import tango.util.log.Trace;
|
78
|
11 import tango.math.Math;
|
|
12 import tango.text.convert.Format;
|
|
13 import tango.util.Convert;
|
|
14 import tango.util.PathUtil;
|
|
15 import dwt.events.SelectionListener;
|
|
16 import dwt.events.SelectionEvent;
|
|
17
|
|
18
|
|
19 import dwt.DWT;
|
|
20 import dwt.widgets.Display;
|
|
21
|
|
22 void main(){
|
|
23
|
|
24 try{
|
|
25 Display display = new Display();
|
|
26 Shell shell = new Shell(display);
|
|
27 shell.setSize(300, 200);
|
|
28 shell.setText("Simple DWT Sample");
|
|
29 auto btn = new Button( shell, DWT.PUSH );
|
|
30 btn.setBounds(40, 50, 100, 50);
|
|
31 btn.setText( "hey" );
|
|
32
|
|
33 auto txt = new Text(shell, DWT.BORDER);
|
|
34 txt.setBounds(170, 50, 100, 40);
|
|
35
|
|
36 btn.addSelectionListener(new class () SelectionListener {
|
|
37 public void widgetSelected(SelectionEvent event) {
|
|
38 txt.setText("No problem");
|
|
39 }
|
|
40 public void widgetDefaultSelected(SelectionEvent event) {
|
|
41 txt.setText("No worries!");
|
|
42 }
|
|
43 });
|
|
44
|
|
45 shell.open();
|
|
46 while (!shell.isDisposed()) {
|
|
47 if (!display.readAndDispatch()) {
|
|
48 display.sleep();
|
|
49 }
|
|
50 }
|
|
51 }
|
|
52 catch (Exception e) {
|
82
|
53 Stdout.formatln ( "'{}', {}:{}", e.toString, e.file, e.line );
|
78
|
54 }
|
|
55 }
|
|
56
|