comparison snippets/caret/Snippet43.d @ 117:8cdaac0dc743

Added more snippets from TomD
author Frank Benoit <benoit@tionex.de>
date Sat, 12 Jul 2008 20:09:06 +0200
parents
children
comparison
equal deleted inserted replaced
116:f53c6274734f 117:8cdaac0dc743
1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 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 * D Port:
11 * Thomas Demmer <t_demmer AT web DOT de>
12 *******************************************************************************/
13 module caret.Snippet43;
14 /*
15 * Caret example snippet: create a caret (using an image)
16 *
17 * For a list of all SWT example snippets see
18 * http://www.eclipse.org/swt/snippets/
19 */
20 import dwt.DWT;
21 import dwt.graphics.Color;
22 import dwt.graphics.GC;
23 import dwt.graphics.Image;
24
25 import dwt.widgets.Caret;
26 import dwt.widgets.Display;
27 import dwt.widgets.Shell;
28
29 import dwt.dwthelper.utils;
30
31 void main (String [] args) {
32 Display display = new Display ();
33 Shell shell = new Shell (display);
34 shell.open ();
35 Caret caret = new Caret (shell, DWT.NONE);
36 Color white = display.getSystemColor (DWT.COLOR_WHITE);
37 Color black = display.getSystemColor (DWT.COLOR_BLACK);
38 Image image = new Image (display, 20, 20);
39 GC gc = new GC (image);
40 gc.setBackground (black);
41 gc.fillRectangle (0, 0, 20, 20);
42 gc.setForeground (white);
43 gc.drawLine (0, 0, 19, 19);
44 gc.drawLine (19, 0, 0, 19);
45 gc.dispose ();
46 caret.setLocation (10, 10);
47 caret.setImage (image);
48 gc = new GC (shell);
49 gc.drawImage (image, 10, 64);
50 caret.setVisible (false);
51 gc.drawString ("Test", 12, 12);
52 caret.setVisible (true);
53 gc.dispose ();
54 while (!shell.isDisposed ()) {
55 if (!display.readAndDispatch ()) display.sleep ();
56 }
57 image.dispose ();
58 display.dispose ();
59 }