Mercurial > projects > dwt-addons
annotate dwtx/jface/viewers/ViewerRow.d @ 90:7ffeace6c47f
Update 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 23:30:07 +0200 |
parents | 5df4896124c7 |
children |
rev | line source |
---|---|
10 | 1 /******************************************************************************* |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
2 * Copyright (c) 2006, 2008 IBM Corporation and others. |
10 | 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 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
10 * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation |
90 | 11 * - fix in bug: 166346,167325,174355,195908,198035,215069,227421 |
10 | 12 * Port to the D programming language: |
13 * Frank Benoit <benoit@tionex.de> | |
14 *******************************************************************************/ | |
15 | |
16 module dwtx.jface.viewers.ViewerRow; | |
17 | |
18 import dwtx.jface.viewers.ViewerCell; | |
19 import dwtx.jface.viewers.ViewerRow; | |
20 import dwtx.jface.viewers.TreePath; | |
21 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
22 import dwt.custom.StyleRange; |
10 | 23 import dwt.graphics.Color; |
24 import dwt.graphics.Font; | |
25 import dwt.graphics.Image; | |
26 import dwt.graphics.Point; | |
27 import dwt.graphics.Rectangle; | |
28 import dwt.widgets.Control; | |
29 import dwt.widgets.Widget; | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
30 import dwtx.jface.util.Policy; |
10 | 31 |
32 import dwt.dwthelper.utils; | |
72
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
33 import tango.util.Convert; |
10 | 34 |
35 /** | |
36 * ViewerRow is the abstract superclass of the part that represents items in a | |
37 * Table or Tree. Implementors of {@link ColumnViewer} have to provide a | |
38 * concrete implementation for the underlying widget | |
39 * | |
40 * @since 3.3 | |
41 * | |
42 */ | |
43 public abstract class ViewerRow : Cloneable { | |
44 | |
45 /** | |
46 * Constant denoting the row above the current one (value is 1). | |
47 * | |
48 * @see #getNeighbor(int, bool) | |
49 */ | |
50 public static const int ABOVE = 1; | |
51 | |
52 /** | |
53 * Constant denoting the row below the current one (value is 2). | |
54 * | |
55 * @see #getNeighbor(int, bool) | |
56 */ | |
57 public static const int BELOW = 2; | |
71 | 58 |
72
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
59 private static const String KEY_TEXT_LAYOUT = Policy.JFACE ~ "styled_label_key_"; //$NON-NLS-1$ |
10 | 60 |
61 /** | |
62 * Get the bounds of the entry at the columnIndex, | |
63 * | |
64 * @param columnIndex | |
65 * @return {@link Rectangle} | |
66 */ | |
67 public abstract Rectangle getBounds(int columnIndex); | |
68 | |
69 /** | |
70 * Return the bounds for the whole item. | |
71 * | |
72 * @return {@link Rectangle} | |
73 */ | |
74 public abstract Rectangle getBounds(); | |
75 | |
76 /** | |
77 * Return the item for the receiver. | |
78 * | |
79 * @return {@link Widget} | |
80 */ | |
81 public abstract Widget getItem(); | |
82 | |
83 /** | |
84 * Return the number of columns for the receiver. | |
85 * | |
86 * @return the number of columns | |
87 */ | |
88 public abstract int getColumnCount(); | |
89 | |
90 /** | |
91 * Return the image at the columnIndex. | |
92 * | |
93 * @param columnIndex | |
94 * @return {@link Image} or <code>null</code> | |
95 */ | |
96 public abstract Image getImage(int columnIndex); | |
97 | |
98 /** | |
99 * Set the image at the columnIndex | |
100 * | |
101 * @param columnIndex | |
102 * @param image | |
103 */ | |
104 public abstract void setImage(int columnIndex, Image image); | |
105 | |
106 /** | |
107 * Get the text at the columnIndex. | |
108 * | |
109 * @param columnIndex | |
110 * @return {@link String} | |
111 */ | |
112 public abstract String getText(int columnIndex); | |
113 | |
114 /** | |
115 * Set the text at the columnIndex | |
116 * | |
117 * @param columnIndex | |
118 * @param text | |
119 */ | |
120 public abstract void setText(int columnIndex, String text); | |
121 | |
122 /** | |
123 * Get the background at the columnIndex, | |
124 * | |
125 * @param columnIndex | |
126 * @return {@link Color} or <code>null</code> | |
127 */ | |
128 public abstract Color getBackground(int columnIndex); | |
129 | |
130 /** | |
131 * Set the background at the columnIndex. | |
132 * | |
133 * @param columnIndex | |
134 * @param color | |
135 */ | |
136 public abstract void setBackground(int columnIndex, Color color); | |
137 | |
138 /** | |
139 * Get the foreground at the columnIndex. | |
140 * | |
141 * @param columnIndex | |
142 * @return {@link Color} or <code>null</code> | |
143 */ | |
144 public abstract Color getForeground(int columnIndex); | |
145 | |
146 /** | |
147 * Set the foreground at the columnIndex. | |
148 * | |
149 * @param columnIndex | |
150 * @param color | |
151 */ | |
152 public abstract void setForeground(int columnIndex, Color color); | |
153 | |
154 /** | |
155 * Get the font at the columnIndex. | |
156 * | |
157 * @param columnIndex | |
158 * @return {@link Font} or <code>null</code> | |
159 */ | |
160 public abstract Font getFont(int columnIndex); | |
161 | |
162 /** | |
163 * Set the {@link Font} at the columnIndex. | |
164 * | |
165 * @param columnIndex | |
166 * @param font | |
167 */ | |
168 public abstract void setFont(int columnIndex, Font font); | |
169 | |
170 /** | |
171 * Get the ViewerCell at point. | |
172 * | |
173 * @param point | |
174 * @return {@link ViewerCell} | |
175 */ | |
176 public ViewerCell getCell(Point point) { | |
177 int index = getColumnIndex(point); | |
178 return getCell(index); | |
179 } | |
180 | |
181 /** | |
182 * Get the columnIndex of the point. | |
183 * | |
184 * @param point | |
185 * @return int or -1 if it cannot be found. | |
186 */ | |
187 public int getColumnIndex(Point point) { | |
188 int count = getColumnCount(); | |
189 | |
190 // If there are no columns the column-index is 0 | |
191 if (count is 0) { | |
192 return 0; | |
193 } | |
194 | |
195 for (int i = 0; i < count; i++) { | |
196 if (getBounds(i).contains(point)) { | |
197 return i; | |
198 } | |
199 } | |
200 | |
201 return -1; | |
202 } | |
203 | |
204 /** | |
205 * Get a ViewerCell for the column at index. | |
206 * | |
207 * @param column | |
208 * @return {@link ViewerCell} or <code>null</code> if the index is | |
209 * negative. | |
210 */ | |
211 public ViewerCell getCell(int column) { | |
212 if (column >= 0) | |
213 return new ViewerCell(cast(ViewerRow) clone(), column, getElement()); | |
214 | |
215 return null; | |
216 } | |
217 | |
218 /** | |
219 * Get the Control for the receiver. | |
220 * | |
221 * @return {@link Control} | |
222 */ | |
223 public abstract Control getControl(); | |
224 | |
225 /** | |
226 * Returns a neighboring row, or <code>null</code> if no neighbor exists | |
227 * in the given direction. If <code>sameLevel</code> is <code>true</code>, | |
228 * only sibling rows (under the same parent) will be considered. | |
229 * | |
230 * @param direction | |
231 * the direction {@link #BELOW} or {@link #ABOVE} | |
232 * | |
233 * @param sameLevel | |
234 * if <code>true</code>, search only within sibling rows | |
235 * @return the row above/below, or <code>null</code> if not found | |
236 */ | |
237 public abstract ViewerRow getNeighbor(int direction, bool sameLevel); | |
238 | |
239 /** | |
240 * The tree path used to identify an element by the unique path | |
241 * | |
242 * @return the path | |
243 */ | |
244 public abstract TreePath getTreePath(); | |
245 | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
246 public /+override+/ abstract Object clone(); |
10 | 247 |
248 /** | |
249 * @return the model element | |
250 */ | |
251 public abstract Object getElement(); | |
252 | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
253 public override hash_t toHash() { |
10 | 254 final int prime = 31; |
255 int result = 1; | |
256 result = prime * result | |
257 + ((getItem() is null) ? 0 : getItem().toHash()); | |
258 return result; | |
259 } | |
260 | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
261 public override int opEquals(Object obj) { |
10 | 262 if (this is obj) |
263 return true; | |
264 if (obj is null) | |
265 return false; | |
266 if (this.classinfo !is obj.classinfo) | |
267 return false; | |
268 ViewerRow other = cast(ViewerRow) obj; | |
269 if (getItem() is null) { | |
270 if (other.getItem() !is null) | |
271 return false; | |
272 } else if (!getItem().opEquals(other.getItem())) | |
273 return false; | |
274 return true; | |
275 } | |
276 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
277 /** |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
278 * The cell at the current index (as shown in the UI). This can be different |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
279 * to the original index when columns are reordered. |
71 | 280 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
281 * @param visualIndex |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
282 * the current index (as shown in the UI) |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
283 * @return the cell at the currently visible index |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
284 */ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
285 ViewerCell getCellAtVisualIndex(int visualIndex) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
286 return getCell(getCreationIndex(visualIndex)); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
287 } |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
288 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
289 /** |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
290 * Translate the original column index to the actual one. |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
291 * <p> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
292 * <b>Because of backwards API compatibility the default implementation |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
293 * returns the original index. Implementators of {@link ColumnViewer} should |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
294 * overwrite this method if their widget supports reordered columns</b> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
295 * </p> |
71 | 296 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
297 * @param creationIndex |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
298 * the original index |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
299 * @return the current index (as shown in the UI) |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
300 * @since 3.4 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
301 */ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
302 protected int getVisualIndex(int creationIndex) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
303 return creationIndex; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
304 } |
72
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
305 package int getVisualIndex_package(int creationIndex) { |
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
306 return getVisualIndex(creationIndex); |
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
307 } |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
308 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
309 /** |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
310 * Translate the current column index (as shown in the UI) to the original |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
311 * one. |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
312 * <p> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
313 * <b>Because of backwards API compatibility the default implementation |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
314 * returns the original index. Implementators of {@link ColumnViewer} should |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
315 * overwrite this method if their widget supports reordered columns</b> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
316 * </p> |
71 | 317 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
318 * @param visualIndex |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
319 * the current index (as shown in the UI) |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
320 * @return the original index |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
321 * @since 3.4 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
322 */ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
323 protected int getCreationIndex(int visualIndex) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
324 return visualIndex; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
325 } |
72
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
326 package int getCreationIndex_package(int visualIndex) { |
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
327 return getCreationIndex(visualIndex); |
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
328 } |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
329 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
330 /** |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
331 * The location and bounds of the area where the text is drawn depends on |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
332 * various things (image displayed, control with DWT.CHECK) |
71 | 333 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
334 * @param index |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
335 * the column index |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
336 * @return the bounds of the of the text area. May return <code>null</code> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
337 * if the underlying widget implementation doesn't provide this |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
338 * information |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
339 * @since 3.4 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
340 */ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
341 public Rectangle getTextBounds(int index) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
342 return null; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
343 } |
71 | 344 |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
345 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
346 /** |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
347 * Returns the location and bounds of the area where the image is drawn. |
71 | 348 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
349 * @param index |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
350 * the column index |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
351 * @return the bounds of the of the image area. May return <code>null</code> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
352 * if the underlying widget implementation doesn't provide this |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
353 * information |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
354 * @since 3.4 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
355 */ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
356 public Rectangle getImageBounds(int index) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
357 return null; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
358 } |
71 | 359 |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
360 /** |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
361 * Set the style ranges to be applied on the text label at the column index |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
362 * Note: Requires {@link StyledCellLabelProvider} with owner draw enabled. |
71 | 363 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
364 * @param columnIndex the index of the column |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
365 * @param styleRanges the styled ranges |
71 | 366 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
367 * @since 3.4 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
368 */ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
369 public void setStyleRanges(int columnIndex, StyleRange[] styleRanges) { |
72
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
370 getItem().setData(KEY_TEXT_LAYOUT ~ to!(String)(columnIndex), new ArrayWrapperT!(StyleRange)(styleRanges)); |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
371 } |
71 | 372 |
373 | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
374 /** |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
375 * Returns the style ranges to be applied on the text label at the column index or <code>null</code> if no |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
376 * style ranges have been set. |
71 | 377 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
378 * @param columnIndex the index of the column |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
379 * @return styleRanges the styled ranges |
71 | 380 * |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
381 * @since 3.4 |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
382 */ |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
383 public StyleRange[] getStyleRanges(int columnIndex) { |
72
5df4896124c7
JFace and its examples do compile
Frank Benoit <benoit@tionex.de>
parents:
71
diff
changeset
|
384 return (cast(ArrayWrapperT!(StyleRange)) getItem().getData(KEY_TEXT_LAYOUT ~ to!(String)(columnIndex))).array; |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
43
diff
changeset
|
385 } |
90 | 386 |
387 int getWidth(int columnIndex) { | |
388 return getBounds(columnIndex).width; | |
389 } | |
10 | 390 } |