comparison examples/helloworld/HelloWorld5.d @ 78:4a04b6759f98

Clean up directory names
author John Reimer <terminal.node@gmail.com>
date Sat, 10 May 2008 13:32:45 -0700
parents
children eb84f9418bbf
comparison
equal deleted inserted replaced
76:04f122e90b0a 78:4a04b6759f98
1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 module examples.helloworld.HelloWorld5;
12
13
14 import dwt.events.DisposeEvent;
15 import dwt.events.DisposeListener;
16 import dwt.events.PaintEvent;
17 import dwt.events.PaintListener;
18 import dwt.graphics.Color;
19 import dwt.graphics.GC;
20 import dwt.graphics.Rectangle;
21 import dwt.widgets.Display;
22 import dwt.widgets.Shell;
23
24 /*
25 * This example builds on HelloWorld1 and demonstrates how to draw directly
26 * on an DWT Control.
27 */
28
29 void main () {
30 Display display = new Display ();
31 final Color red = new Color(display, 0xFF, 0, 0);
32 final Shell shell = new Shell (display);
33 shell.addPaintListener(new class() PaintListener {
34 public void paintControl(PaintEvent event){
35 GC gc = event.gc;
36 gc.setForeground(red);
37 Rectangle rect = shell.getClientArea();
38 gc.drawRectangle(rect.x + 10, rect.y + 10, rect.width - 20, rect.height - 20);
39 gc.drawString("Hello_world", rect.x + 20, rect.y + 20);
40 }
41 });
42 shell.addDisposeListener (new class() DisposeListener {
43 public void widgetDisposed (DisposeEvent e) {
44 red.dispose();
45 }
46 });
47 shell.open ();
48 while (!shell.isDisposed ()) {
49 if (!display.readAndDispatch ()) display.sleep ();
50 }
51 display.dispose ();
52 }