78
|
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 * Port to the D programming language:
|
|
11 * Bill Baxter <bill@billbaxter.com>
|
|
12 *******************************************************************************/
|
|
13 module snippets.shell.Snippet138;
|
|
14
|
|
15 /*
|
|
16 * example snippet: set icons with different resolutions
|
|
17 *
|
|
18 * For a list of all SWT example snippets see
|
|
19 * http://www.eclipse.org/swt/snippets/
|
|
20 *
|
|
21 * @since 3.0
|
|
22 */
|
|
23 import dwt.DWT;
|
|
24 import dwt.graphics.GC;
|
|
25 import dwt.graphics.Image;
|
|
26 import dwt.widgets.Display;
|
|
27 import dwt.widgets.Shell;
|
|
28
|
|
29 void main() {
|
|
30 Display display = new Display();
|
|
31
|
|
32 Image small = new Image(display, 16, 16);
|
|
33 GC gc = new GC(small);
|
|
34 gc.setBackground(display.getSystemColor(DWT.COLOR_RED));
|
|
35 gc.fillArc(0, 0, 16, 16, 45, 270);
|
|
36 gc.dispose();
|
|
37
|
|
38 Image large = new Image(display, 32, 32);
|
|
39 gc = new GC(large);
|
|
40 gc.setBackground(display.getSystemColor(DWT.COLOR_RED));
|
|
41 gc.fillArc(0, 0, 32, 32, 45, 270);
|
|
42 gc.dispose();
|
|
43
|
|
44 /* Provide different resolutions for icons to get
|
|
45 * high quality rendering wherever the OS needs
|
|
46 * large icons. For example, the ALT+TAB window
|
|
47 * on certain systems uses a larger icon.
|
|
48 */
|
|
49 Shell shell = new Shell(display);
|
|
50 shell.setText("Small and Large icons");
|
|
51 shell.setImages([small, large]);
|
|
52
|
|
53 /* No large icon: the OS will scale up the
|
|
54 * small icon when it needs a large one.
|
|
55 */
|
|
56 Shell shell2 = new Shell(display);
|
|
57 shell2.setText("Small icon");
|
|
58 shell2.setImage(small);
|
|
59
|
|
60 shell.open();
|
|
61 shell2.open();
|
|
62 while (!shell.isDisposed()) {
|
|
63 if (!display.readAndDispatch())
|
|
64 display.sleep();
|
|
65 }
|
|
66 small.dispose();
|
|
67 large.dispose();
|
|
68 display.dispose();
|
|
69 }
|
|
70
|