Mercurial > projects > dwt-addons
comparison dwtx/jface/viewers/ViewerRow.d @ 70:46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 22 May 2008 01:36:46 +0200 |
parents | ea8ff534f622 |
children | 4878bef4a38e |
comparison
equal
deleted
inserted
replaced
69:07b9d96fd764 | 70:46a6e0e6ccd4 |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2006, 2007 IBM Corporation and others. | 2 * Copyright (c) 2006, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
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 * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation | 10 * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation |
11 * fix for bug 166346, bug 167325s | 11 * - fix in bug: 166346,167325,174355,195908,198035,215069 |
12 * - Fix for bug 174355 | |
13 * Port to the D programming language: | 12 * Port to the D programming language: |
14 * Frank Benoit <benoit@tionex.de> | 13 * Frank Benoit <benoit@tionex.de> |
15 *******************************************************************************/ | 14 *******************************************************************************/ |
16 | 15 |
17 module dwtx.jface.viewers.ViewerRow; | 16 module dwtx.jface.viewers.ViewerRow; |
18 | 17 |
19 import dwtx.jface.viewers.ViewerCell; | 18 import dwtx.jface.viewers.ViewerCell; |
20 import dwtx.jface.viewers.ViewerRow; | 19 import dwtx.jface.viewers.ViewerRow; |
21 import dwtx.jface.viewers.TreePath; | 20 import dwtx.jface.viewers.TreePath; |
22 | 21 |
22 import dwt.custom.StyleRange; | |
23 import dwt.graphics.Color; | 23 import dwt.graphics.Color; |
24 import dwt.graphics.Font; | 24 import dwt.graphics.Font; |
25 import dwt.graphics.Image; | 25 import dwt.graphics.Image; |
26 import dwt.graphics.Point; | 26 import dwt.graphics.Point; |
27 import dwt.graphics.Rectangle; | 27 import dwt.graphics.Rectangle; |
28 import dwt.widgets.Control; | 28 import dwt.widgets.Control; |
29 import dwt.widgets.Widget; | 29 import dwt.widgets.Widget; |
30 import dwtx.jface.util.Policy; | |
30 | 31 |
31 import dwt.dwthelper.utils; | 32 import dwt.dwthelper.utils; |
32 | 33 |
33 /** | 34 /** |
34 * ViewerRow is the abstract superclass of the part that represents items in a | 35 * ViewerRow is the abstract superclass of the part that represents items in a |
51 * Constant denoting the row below the current one (value is 2). | 52 * Constant denoting the row below the current one (value is 2). |
52 * | 53 * |
53 * @see #getNeighbor(int, bool) | 54 * @see #getNeighbor(int, bool) |
54 */ | 55 */ |
55 public static const int BELOW = 2; | 56 public static const int BELOW = 2; |
57 | |
58 private static final String KEY_TEXT_LAYOUT = Policy.JFACE + "styled_label_key_"; //$NON-NLS-1$ | |
56 | 59 |
57 /** | 60 /** |
58 * Get the bounds of the entry at the columnIndex, | 61 * Get the bounds of the entry at the columnIndex, |
59 * | 62 * |
60 * @param columnIndex | 63 * @param columnIndex |
268 } else if (!getItem().opEquals(other.getItem())) | 271 } else if (!getItem().opEquals(other.getItem())) |
269 return false; | 272 return false; |
270 return true; | 273 return true; |
271 } | 274 } |
272 | 275 |
276 /** | |
277 * The cell at the current index (as shown in the UI). This can be different | |
278 * to the original index when columns are reordered. | |
279 * | |
280 * @param visualIndex | |
281 * the current index (as shown in the UI) | |
282 * @return the cell at the currently visible index | |
283 */ | |
284 ViewerCell getCellAtVisualIndex(int visualIndex) { | |
285 return getCell(getCreationIndex(visualIndex)); | |
286 } | |
287 | |
288 /** | |
289 * Translate the original column index to the actual one. | |
290 * <p> | |
291 * <b>Because of backwards API compatibility the default implementation | |
292 * returns the original index. Implementators of {@link ColumnViewer} should | |
293 * overwrite this method if their widget supports reordered columns</b> | |
294 * </p> | |
295 * | |
296 * @param creationIndex | |
297 * the original index | |
298 * @return the current index (as shown in the UI) | |
299 * @since 3.4 | |
300 */ | |
301 protected int getVisualIndex(int creationIndex) { | |
302 return creationIndex; | |
303 } | |
304 | |
305 /** | |
306 * Translate the current column index (as shown in the UI) to the original | |
307 * one. | |
308 * <p> | |
309 * <b>Because of backwards API compatibility the default implementation | |
310 * returns the original index. Implementators of {@link ColumnViewer} should | |
311 * overwrite this method if their widget supports reordered columns</b> | |
312 * </p> | |
313 * | |
314 * @param visualIndex | |
315 * the current index (as shown in the UI) | |
316 * @return the original index | |
317 * @since 3.4 | |
318 */ | |
319 protected int getCreationIndex(int visualIndex) { | |
320 return visualIndex; | |
321 } | |
322 | |
323 /** | |
324 * The location and bounds of the area where the text is drawn depends on | |
325 * various things (image displayed, control with DWT.CHECK) | |
326 * | |
327 * @param index | |
328 * the column index | |
329 * @return the bounds of the of the text area. May return <code>null</code> | |
330 * if the underlying widget implementation doesn't provide this | |
331 * information | |
332 * @since 3.4 | |
333 */ | |
334 public Rectangle getTextBounds(int index) { | |
335 return null; | |
336 } | |
337 | |
338 | |
339 /** | |
340 * Returns the location and bounds of the area where the image is drawn. | |
341 * | |
342 * @param index | |
343 * the column index | |
344 * @return the bounds of the of the image area. May return <code>null</code> | |
345 * if the underlying widget implementation doesn't provide this | |
346 * information | |
347 * @since 3.4 | |
348 */ | |
349 public Rectangle getImageBounds(int index) { | |
350 return null; | |
351 } | |
352 | |
353 /** | |
354 * Set the style ranges to be applied on the text label at the column index | |
355 * Note: Requires {@link StyledCellLabelProvider} with owner draw enabled. | |
356 * | |
357 * @param columnIndex the index of the column | |
358 * @param styleRanges the styled ranges | |
359 * | |
360 * @since 3.4 | |
361 */ | |
362 public void setStyleRanges(int columnIndex, StyleRange[] styleRanges) { | |
363 getItem().setData(KEY_TEXT_LAYOUT + columnIndex, styleRanges); | |
364 } | |
365 | |
366 | |
367 /** | |
368 * Returns the style ranges to be applied on the text label at the column index or <code>null</code> if no | |
369 * style ranges have been set. | |
370 * | |
371 * @param columnIndex the index of the column | |
372 * @return styleRanges the styled ranges | |
373 * | |
374 * @since 3.4 | |
375 */ | |
376 public StyleRange[] getStyleRanges(int columnIndex) { | |
377 return (StyleRange[]) getItem().getData(KEY_TEXT_LAYOUT + columnIndex); | |
378 } | |
273 } | 379 } |