annotate examples/helloworld/HelloWorld5.d @ 161:eb84f9418bbf

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