Mercurial > projects > dwt-mac
comparison dwt/widgets/ExpandItem.d @ 67:a47b2ee8cbde
Ported dwt.widgets.ExpandItem
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Tue, 23 Dec 2008 23:04:31 +0100 |
parents | d8635bb48c7c |
children | 63a09873578e |
comparison
equal
deleted
inserted
replaced
66:51015bbcb4c6 | 67:a47b2ee8cbde |
---|---|
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.ExpandItem; | 14 module dwt.widgets.ExpandItem; |
12 | 15 |
13 import dwt.dwthelper.utils; | 16 import dwt.dwthelper.utils; |
14 | 17 |
16 import dwt.DWTException; | 19 import dwt.DWTException; |
17 import dwt.graphics.GC; | 20 import dwt.graphics.GC; |
18 import dwt.graphics.Image; | 21 import dwt.graphics.Image; |
19 import dwt.graphics.Point; | 22 import dwt.graphics.Point; |
20 import dwt.graphics.Rectangle; | 23 import dwt.graphics.Rectangle; |
24 | |
25 import dwt.widgets.Control; | |
26 import dwt.widgets.Display; | |
27 import dwt.widgets.ExpandBar; | |
28 import dwt.widgets.Item; | |
21 | 29 |
22 /** | 30 /** |
23 * Instances of this class represent a selectable user interface object | 31 * Instances of this class represent a selectable user interface object |
24 * that represents a expandable item in a expand bar. | 32 * that represents a expandable item in a expand bar. |
25 * <p> | 33 * <p> |
42 ExpandBar parent; | 50 ExpandBar parent; |
43 Control control; | 51 Control control; |
44 bool expanded; | 52 bool expanded; |
45 int x, y, width, height; | 53 int x, y, width, height; |
46 int imageHeight, imageWidth; | 54 int imageHeight, imageWidth; |
47 static final int TEXT_INSET = 6; | 55 static const int TEXT_INSET = 6; |
48 static final int BORDER = 1; | 56 static const int BORDER = 1; |
49 static final int CHEVRON_SIZE = 24; | 57 static const int CHEVRON_SIZE = 24; |
50 | 58 |
51 /** | 59 /** |
52 * Constructs a new instance of this class given its parent | 60 * Constructs a new instance of this class given its parent |
53 * and a style value describing its behavior and appearance. | 61 * and a style value describing its behavior and appearance. |
54 * <p> | 62 * <p> |
132 void drawChevron (GC gc, int x, int y) { | 140 void drawChevron (GC gc, int x, int y) { |
133 int [] polyline1, polyline2; | 141 int [] polyline1, polyline2; |
134 if (expanded) { | 142 if (expanded) { |
135 int px = x + 4 + 5; | 143 int px = x + 4 + 5; |
136 int py = y + 4 + 7; | 144 int py = y + 4 + 7; |
137 polyline1 = new int [] { | 145 polyline1 = [ |
138 px,py, px+1,py, px+1,py-1, px+2,py-1, px+2,py-2, px+3,py-2, px+3,py-3, | 146 px,py, px+1,py, px+1,py-1, px+2,py-1, px+2,py-2, px+3,py-2, px+3,py-3, |
139 px+3,py-2, px+4,py-2, px+4,py-1, px+5,py-1, px+5,py, px+6,py}; | 147 px+3,py-2, px+4,py-2, px+4,py-1, px+5,py-1, px+5,py, px+6,py]; |
140 py += 4; | 148 py += 4; |
141 polyline2 = new int [] { | 149 polyline2 = [ |
142 px,py, px+1,py, px+1,py-1, px+2,py-1, px+2,py-2, px+3,py-2, px+3,py-3, | 150 px,py, px+1,py, px+1,py-1, px+2,py-1, px+2,py-2, px+3,py-2, px+3,py-3, |
143 px+3,py-2, px+4,py-2, px+4,py-1, px+5,py-1, px+5,py, px+6,py}; | 151 px+3,py-2, px+4,py-2, px+4,py-1, px+5,py-1, px+5,py, px+6,py]; |
144 } else { | 152 } else { |
145 int px = x + 4 + 5; | 153 int px = x + 4 + 5; |
146 int py = y + 4 + 4; | 154 int py = y + 4 + 4; |
147 polyline1 = new int[] { | 155 polyline1 = [ |
148 px,py, px+1,py, px+1,py+1, px+2,py+1, px+2,py+2, px+3,py+2, px+3,py+3, | 156 px,py, px+1,py, px+1,py+1, px+2,py+1, px+2,py+2, px+3,py+2, px+3,py+3, |
149 px+3,py+2, px+4,py+2, px+4,py+1, px+5,py+1, px+5,py, px+6,py}; | 157 px+3,py+2, px+4,py+2, px+4,py+1, px+5,py+1, px+5,py, px+6,py]; |
150 py += 4; | 158 py += 4; |
151 polyline2 = new int [] { | 159 polyline2 = [ |
152 px,py, px+1,py, px+1,py+1, px+2,py+1, px+2,py+2, px+3,py+2, px+3,py+3, | 160 px,py, px+1,py, px+1,py+1, px+2,py+1, px+2,py+2, px+3,py+2, px+3,py+3, |
153 px+3,py+2, px+4,py+2, px+4,py+1, px+5,py+1, px+5,py, px+6,py}; | 161 px+3,py+2, px+4,py+2, px+4,py+1, px+5,py+1, px+5,py, px+6,py]; |
154 } | 162 } |
155 gc.setForeground (display.getSystemColor (DWT.COLOR_TITLE_FOREGROUND)); | 163 gc.setForeground (display.getSystemColor (DWT.COLOR_TITLE_FOREGROUND)); |
156 gc.drawPolyline (polyline1); | 164 gc.drawPolyline (polyline1); |
157 gc.drawPolyline (polyline2); | 165 gc.drawPolyline (polyline2); |
158 } | 166 } |