annotate snippets/canvas/Snippet245.d @ 120:1f0a7a472680

fix rm snippets from module statements.
author Frank Benoit <benoit@tionex.de>
date Sun, 20 Jul 2008 19:17:23 +0200
parents 29bf9ba4756b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
1 /*******************************************************************************
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
2 * Copyright (c) 2000, 2006 IBM Corporation and others.
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
7 *
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
8 * Contributors:
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
10 * D Port:
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
11 * Bill Baxter <wbaxter> at gmail com
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
12 *******************************************************************************/
120
1f0a7a472680 fix rm snippets from module statements.
Frank Benoit <benoit@tionex.de>
parents: 90
diff changeset
13 module canvas.Snippet245;
90
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
14
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
15 /*
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
16 * Canvas snippet: paint a circle in a canvas
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
17 *
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
18 * For a list of all SWT example snippets see
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
19 * http://www.eclipse.org/swt/snippets/
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
20 */
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
21
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
22 import dwt.graphics.Rectangle;
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
23 import dwt.widgets.Display;
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
24 import dwt.widgets.Shell;
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
25 import dwt.events.PaintListener;
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
26 import dwt.events.PaintEvent;
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
27
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
28 void main()
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
29 {
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
30 final Display display = new Display();
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
31 final Shell shell = new Shell(display);
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
32 shell.addPaintListener(new class(shell) PaintListener {
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
33 Shell shell;
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
34 this(Shell s) { this.shell = s; }
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
35 public void paintControl(PaintEvent event) {
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
36 Rectangle rect = shell.getClientArea();
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
37 event.gc.drawOval(0, 0, rect.width - 1, rect.height - 1);
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
38 }
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
39 });
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
40 shell.setBounds(10, 10, 200, 200);
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
41 shell.open ();
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
42 while (!shell.isDisposed()) {
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
43 if (!display.readAndDispatch()) display.sleep();
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
44 }
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
45 display.dispose();
29bf9ba4756b Port of all canvas snippets
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
46 }