Mercurial > projects > dwt-mac
comparison dwt/widgets/CoolItem.d @ 63:a3f5118c8b37
Ported CoolBar and CoolItem
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Tue, 23 Dec 2008 22:38:33 +0100 |
parents | d8635bb48c7c |
children | c7f7f4d7091a |
comparison
equal
deleted
inserted
replaced
62:10eaa644646f | 63:a3f5118c8b37 |
---|---|
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | |
11 * Port to the D programming language: | |
12 * Jacob Carlborg <doob@me.com> | |
10 *******************************************************************************/ | 13 *******************************************************************************/ |
11 module dwt.widgets.CoolItem; | 14 module dwt.widgets.CoolItem; |
12 | 15 |
13 import dwt.dwthelper.utils; | 16 import dwt.dwthelper.utils; |
14 | 17 |
23 import dwt.graphics.ImageData; | 26 import dwt.graphics.ImageData; |
24 import dwt.graphics.PaletteData; | 27 import dwt.graphics.PaletteData; |
25 import dwt.graphics.Point; | 28 import dwt.graphics.Point; |
26 import dwt.graphics.RGB; | 29 import dwt.graphics.RGB; |
27 import dwt.graphics.Rectangle; | 30 import dwt.graphics.Rectangle; |
31 | |
32 import dwt.widgets.Control; | |
33 import dwt.widgets.CoolBar; | |
34 import dwt.widgets.Event; | |
35 import dwt.widgets.Item; | |
36 import dwt.widgets.ToolBar; | |
37 import dwt.widgets.ToolItem; | |
38 import dwt.widgets.TypedListener; | |
28 | 39 |
29 /** | 40 /** |
30 * Instances of this class are selectable user interface | 41 * Instances of this class are selectable user interface |
31 * objects that represent the dynamically positionable | 42 * objects that represent the dynamically positionable |
32 * areas of a <code>CoolBar</code>. | 43 * areas of a <code>CoolBar</code>. |
259 height = point.y; | 270 height = point.y; |
260 Color foreground = parent.getForeground (); | 271 Color foreground = parent.getForeground (); |
261 Color black = display.getSystemColor (DWT.COLOR_BLACK); | 272 Color black = display.getSystemColor (DWT.COLOR_BLACK); |
262 Color background = parent.getBackground (); | 273 Color background = parent.getBackground (); |
263 | 274 |
264 PaletteData palette = new PaletteData (new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()}); | 275 PaletteData palette = new PaletteData ([foreground.getRGB(), background.getRGB(), black.getRGB()]); |
265 ImageData imageData = new ImageData (width, height, 4, palette); | 276 ImageData imageData = new ImageData (width, height, 4, palette); |
266 imageData.transparentPixel = 1; | 277 imageData.transparentPixel = 1; |
267 Image image = new Image (display, imageData); | 278 Image image = new Image (display, imageData); |
268 | 279 |
269 GC gc = new GC (image, parent.getStyle() & DWT.RIGHT_TO_LEFT); | 280 GC gc = new GC (image, parent.getStyle() & DWT.RIGHT_TO_LEFT); |
622 int width = itemBounds.width; | 633 int width = itemBounds.width; |
623 if ((style & DWT.DROP_DOWN) !is 0 && width < preferredWidth) { | 634 if ((style & DWT.DROP_DOWN) !is 0 && width < preferredWidth) { |
624 if (chevron is null) { | 635 if (chevron is null) { |
625 chevron = new ToolBar (parent, DWT.FLAT | DWT.NO_FOCUS); | 636 chevron = new ToolBar (parent, DWT.FLAT | DWT.NO_FOCUS); |
626 ToolItem toolItem = new ToolItem (chevron, DWT.PUSH); | 637 ToolItem toolItem = new ToolItem (chevron, DWT.PUSH); |
627 toolItem.addListener (DWT.Selection, new Listener() { | 638 toolItem.addListener (DWT.Selection, new class () Listener { |
628 public void handleEvent (Event event) { | 639 public void handleEvent (Event event) { |
629 CoolItem.this.onSelection (event); | 640 CoolItem.outer.onSelection (event); |
630 } | 641 } |
631 }); | 642 }); |
632 } | 643 } |
633 int controlHeight, currentImageHeight = 0; | 644 int controlHeight, currentImageHeight = 0; |
634 if ((parent.style & DWT.VERTICAL) !is 0) { | 645 if ((parent.style & DWT.VERTICAL) !is 0) { |