Mercurial > projects > dwt-samples
comparison snippets/cursor/Snippet242.d @ 119:9a1be6ff19a2
More snippets, thanks to Tom D.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 20 Jul 2008 15:26:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
118:7b1c122b4128 | 119:9a1be6ff19a2 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2006 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 cursor.Snippet242; | |
14 | |
15 /* | |
16 * Cursor snippet: Hide the Cursor over a control. | |
17 * | |
18 * For a list of all SWT example snippets see | |
19 * http://www.eclipse.org/swt/snippets/ | |
20 */ | |
21 | |
22 import dwt.DWT; | |
23 import dwt.events.PaintEvent; | |
24 import dwt.events.PaintListener; | |
25 import dwt.graphics.Color; | |
26 import dwt.graphics.Cursor; | |
27 import dwt.graphics.ImageData; | |
28 import dwt.graphics.PaletteData; | |
29 import dwt.widgets.Canvas; | |
30 import dwt.widgets.Display; | |
31 import dwt.widgets.Shell; | |
32 | |
33 import dwt.dwthelper.utils; | |
34 | |
35 void main(String [] args) { | |
36 Display display = new Display(); | |
37 Shell shell = new Shell(display); | |
38 shell.setBounds(10, 10, 200, 200); | |
39 Canvas canvas = new Canvas(shell, DWT.BORDER); | |
40 canvas.setBounds(10,50,150,100); | |
41 canvas.addPaintListener(new class() PaintListener{ | |
42 public void paintControl(PaintEvent e) { | |
43 e.gc.drawString("hide Cursor here", 10, 10); | |
44 } | |
45 }); | |
46 | |
47 // create a cursor with a transparent image | |
48 Color white = display.getSystemColor (DWT.COLOR_WHITE); | |
49 Color black = display.getSystemColor (DWT.COLOR_BLACK); | |
50 PaletteData palette = new PaletteData ([white.getRGB(), black.getRGB()]); | |
51 ImageData sourceData = new ImageData (16, 16, 1, palette); | |
52 sourceData.transparentPixel = 0; | |
53 Cursor cursor = new Cursor(display, sourceData, 0, 0); | |
54 | |
55 shell.open(); | |
56 canvas.setCursor(cursor); | |
57 while (!shell.isDisposed()) { | |
58 if (!display.readAndDispatch()) display.sleep(); | |
59 } | |
60 cursor.dispose(); | |
61 display.dispose(); | |
62 } | |
63 |