comparison snippets/toolbar/Snippet47.d @ 78:4a04b6759f98

Clean up directory names
author John Reimer <terminal.node@gmail.com>
date Sat, 10 May 2008 13:32:45 -0700
parents
children 1f0a7a472680
comparison
equal deleted inserted replaced
76:04f122e90b0a 78:4a04b6759f98
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.toolbar.Snippet47;
14
15 /*
16 * ToolBar example snippet: create tool bar (normal, hot and disabled images)
17 *
18 * For a list of all SWT example snippets see
19 * http://www.eclipse.org/swt/snippets/
20 */
21 import dwt.DWT;
22 import dwt.graphics.GC;
23 import dwt.graphics.Color;
24 import dwt.graphics.Image;
25 import dwt.widgets.Display;
26 import dwt.widgets.Shell;
27 import dwt.widgets.ToolBar;
28 import dwt.widgets.ToolItem;
29
30 void main () {
31 Display display = new Display ();
32 Shell shell = new Shell (display);
33
34 Image image = new Image (display, 20, 20);
35 Color color = display.getSystemColor (DWT.COLOR_BLUE);
36 GC gc = new GC (image);
37 gc.setBackground (color);
38 gc.fillRectangle (image.getBounds ());
39 gc.dispose ();
40
41 Image disabledImage = new Image (display, 20, 20);
42 color = display.getSystemColor (DWT.COLOR_GREEN);
43 gc = new GC (disabledImage);
44 gc.setBackground (color);
45 gc.fillRectangle (disabledImage.getBounds ());
46 gc.dispose ();
47
48 Image hotImage = new Image (display, 20, 20);
49 color = display.getSystemColor (DWT.COLOR_RED);
50 gc = new GC (hotImage);
51 gc.setBackground (color);
52 gc.fillRectangle (hotImage.getBounds ());
53 gc.dispose ();
54
55 ToolBar bar = new ToolBar (shell, DWT.BORDER | DWT.FLAT);
56 bar.setSize (200, 32);
57 for (int i=0; i<12; i++) {
58 ToolItem item = new ToolItem (bar, 0);
59 item.setImage (image);
60 item.setDisabledImage (disabledImage);
61 item.setHotImage (hotImage);
62 if (i % 3 == 0) item.setEnabled (false);
63 }
64
65 shell.open ();
66 while (!shell.isDisposed ()) {
67 if (!display.readAndDispatch ()) display.sleep ();
68 }
69 image.dispose ();
70 disabledImage.dispose ();
71 hotImage.dispose ();
72 display.dispose ();
73 }
74