Mercurial > projects > dwt-samples
annotate dwtsnippets/shell/Snippet138.d @ 55:b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
author | Bill Baxter <bill@billbaxter.com> |
---|---|
date | Mon, 07 Apr 2008 11:02:46 +0900 |
parents | |
children |
rev | line source |
---|---|
55
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
1 /******************************************************************************* |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
2 * Copyright (c) 2000, 2004 IBM Corporation and others. |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
7 * |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
8 * Contributors: |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
10 * Port to the D programming language: |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
11 * Bill Baxter <bill@billbaxter.com> |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
12 *******************************************************************************/ |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
13 module dwtsnippets.shell.Snippet138; |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
14 |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
15 /* |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
16 * example snippet: set icons with different resolutions |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
17 * |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
18 * For a list of all SWT example snippets see |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
19 * http://www.eclipse.org/swt/snippets/ |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
20 * |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
21 * @since 3.0 |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
22 */ |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
23 import dwt.DWT; |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
24 import dwt.graphics.GC; |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
25 import dwt.graphics.Image; |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
26 import dwt.widgets.Display; |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
27 import dwt.widgets.Shell; |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
28 |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
29 void main() { |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
30 Display display = new Display(); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
31 |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
32 Image small = new Image(display, 16, 16); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
33 GC gc = new GC(small); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
34 gc.setBackground(display.getSystemColor(DWT.COLOR_RED)); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
35 gc.fillArc(0, 0, 16, 16, 45, 270); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
36 gc.dispose(); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
37 |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
38 Image large = new Image(display, 32, 32); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
39 gc = new GC(large); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
40 gc.setBackground(display.getSystemColor(DWT.COLOR_RED)); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
41 gc.fillArc(0, 0, 32, 32, 45, 270); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
42 gc.dispose(); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
43 |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
44 /* Provide different resolutions for icons to get |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
45 * high quality rendering wherever the OS needs |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
46 * large icons. For example, the ALT+TAB window |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
47 * on certain systems uses a larger icon. |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
48 */ |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
49 Shell shell = new Shell(display); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
50 shell.setText("Small and Large icons"); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
51 shell.setImages([small, large]); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
52 |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
53 /* No large icon: the OS will scale up the |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
54 * small icon when it needs a large one. |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
55 */ |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
56 Shell shell2 = new Shell(display); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
57 shell2.setText("Small icon"); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
58 shell2.setImage(small); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
59 |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
60 shell.open(); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
61 shell2.open(); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
62 while (!shell.isDisposed()) { |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
63 if (!display.readAndDispatch()) |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
64 display.sleep(); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
65 } |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
66 small.dispose(); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
67 large.dispose(); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
68 display.dispose(); |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
69 } |
b0d5061ec21c
Port of Snippet 138. Shows how to set the app icon.
Bill Baxter <bill@billbaxter.com>
parents:
diff
changeset
|
70 |