Mercurial > projects > dwt-addons
diff 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 |
line wrap: on
line diff
--- a/dwtx/jface/viewers/ViewerRow.d Mon May 19 13:41:06 2008 +0200 +++ b/dwtx/jface/viewers/ViewerRow.d Thu May 22 01:36:46 2008 +0200 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,9 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Tom Shindl <tom.schindl@bestsolution.at> - initial API and implementation - * fix for bug 166346, bug 167325s - * - Fix for bug 174355 + * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation + * - fix in bug: 166346,167325,174355,195908,198035,215069 * Port to the D programming language: * Frank Benoit <benoit@tionex.de> *******************************************************************************/ @@ -20,6 +19,7 @@ import dwtx.jface.viewers.ViewerRow; import dwtx.jface.viewers.TreePath; +import dwt.custom.StyleRange; import dwt.graphics.Color; import dwt.graphics.Font; import dwt.graphics.Image; @@ -27,6 +27,7 @@ import dwt.graphics.Rectangle; import dwt.widgets.Control; import dwt.widgets.Widget; +import dwtx.jface.util.Policy; import dwt.dwthelper.utils; @@ -53,6 +54,8 @@ * @see #getNeighbor(int, bool) */ public static const int BELOW = 2; + + private static final String KEY_TEXT_LAYOUT = Policy.JFACE + "styled_label_key_"; //$NON-NLS-1$ /** * Get the bounds of the entry at the columnIndex, @@ -270,4 +273,107 @@ return true; } + /** + * The cell at the current index (as shown in the UI). This can be different + * to the original index when columns are reordered. + * + * @param visualIndex + * the current index (as shown in the UI) + * @return the cell at the currently visible index + */ + ViewerCell getCellAtVisualIndex(int visualIndex) { + return getCell(getCreationIndex(visualIndex)); + } + + /** + * Translate the original column index to the actual one. + * <p> + * <b>Because of backwards API compatibility the default implementation + * returns the original index. Implementators of {@link ColumnViewer} should + * overwrite this method if their widget supports reordered columns</b> + * </p> + * + * @param creationIndex + * the original index + * @return the current index (as shown in the UI) + * @since 3.4 + */ + protected int getVisualIndex(int creationIndex) { + return creationIndex; + } + + /** + * Translate the current column index (as shown in the UI) to the original + * one. + * <p> + * <b>Because of backwards API compatibility the default implementation + * returns the original index. Implementators of {@link ColumnViewer} should + * overwrite this method if their widget supports reordered columns</b> + * </p> + * + * @param visualIndex + * the current index (as shown in the UI) + * @return the original index + * @since 3.4 + */ + protected int getCreationIndex(int visualIndex) { + return visualIndex; + } + + /** + * The location and bounds of the area where the text is drawn depends on + * various things (image displayed, control with DWT.CHECK) + * + * @param index + * the column index + * @return the bounds of the of the text area. May return <code>null</code> + * if the underlying widget implementation doesn't provide this + * information + * @since 3.4 + */ + public Rectangle getTextBounds(int index) { + return null; + } + + + /** + * Returns the location and bounds of the area where the image is drawn. + * + * @param index + * the column index + * @return the bounds of the of the image area. May return <code>null</code> + * if the underlying widget implementation doesn't provide this + * information + * @since 3.4 + */ + public Rectangle getImageBounds(int index) { + return null; + } + + /** + * Set the style ranges to be applied on the text label at the column index + * Note: Requires {@link StyledCellLabelProvider} with owner draw enabled. + * + * @param columnIndex the index of the column + * @param styleRanges the styled ranges + * + * @since 3.4 + */ + public void setStyleRanges(int columnIndex, StyleRange[] styleRanges) { + getItem().setData(KEY_TEXT_LAYOUT + columnIndex, styleRanges); + } + + + /** + * Returns the style ranges to be applied on the text label at the column index or <code>null</code> if no + * style ranges have been set. + * + * @param columnIndex the index of the column + * @return styleRanges the styled ranges + * + * @since 3.4 + */ + public StyleRange[] getStyleRanges(int columnIndex) { + return (StyleRange[]) getItem().getData(KEY_TEXT_LAYOUT + columnIndex); + } }