Package org.eclipse.nebula.widgets.grid
Class DefaultCellRenderer
- java.lang.Object
-
- org.eclipse.nebula.widgets.grid.AbstractRenderer
-
- org.eclipse.nebula.widgets.grid.AbstractInternalWidget
-
- org.eclipse.nebula.widgets.grid.GridCellRenderer
-
- org.eclipse.nebula.widgets.grid.DefaultCellRenderer
-
- All Implemented Interfaces:
IInternalWidget,IRenderer
public class DefaultCellRenderer extends GridCellRenderer
The renderer for a cell in Grid.- Since:
- 2.0.0
-
-
Field Summary
Fields Modifier and Type Field Description (package private) intbottomMarginprivate BranchRendererbranchRendererprivate CheckBoxRenderercheckRendererprivate intinsideMargin(package private) intleftMargin(package private) intrightMargin(package private) inttextBottomMarginprivate org.eclipse.swt.graphics.TextLayouttextLayout(package private) inttextTopMarginprivate ToggleRenderertoggleRenderer(package private) inttopMargin(package private) inttreeIndent-
Fields inherited from class org.eclipse.nebula.widgets.grid.GridCellRenderer
truncationStyle
-
Fields inherited from class org.eclipse.nebula.widgets.grid.AbstractInternalWidget
hoverDetail
-
Fields inherited from interface org.eclipse.nebula.widgets.grid.IInternalWidget
LeftMouseButtonDown, MouseMove
-
-
Constructor Summary
Constructors Constructor Description DefaultCellRenderer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.eclipse.swt.graphics.PointcomputeSize(org.eclipse.swt.graphics.GC gc, int wHint, int hHint, java.lang.Object value)Returns the size of the given value's visual representation.private int[]getBranches(GridItem item)Calculates the sequence of branch lines which should be rendered for the provided itemorg.eclipse.swt.graphics.RectanglegetTextBounds(GridItem item, boolean preferred)Returns the bounds of the text in the cell.private intgetToggleIndent(GridItem item)private intgetVerticalAlignmentAdjustment(int textHeight, int cellHeight)private booleanisCenteredCheckBoxOnly(GridItem item)booleannotify(int event, org.eclipse.swt.graphics.Point point, java.lang.Object value)Mechanism used to notify the light weight widgets that an event occurred that it might be interested in.private booleanoverCheck(GridItem item, org.eclipse.swt.graphics.Point point)private booleanoverToggle(GridItem item, org.eclipse.swt.graphics.Point point)voidpaint(org.eclipse.swt.graphics.GC gc, java.lang.Object value)Paints the visual representation of the given value on the given GC.voidsetCheck(boolean check)voidsetTree(boolean tree)-
Methods inherited from class org.eclipse.nebula.widgets.grid.GridCellRenderer
getAlignment, getColumn, getRow, getTruncationStyle, getVerticalAlignment, isCellFocus, isCellSelected, isCheck, isColumnHover, isDragging, isRowFocus, isRowHover, isTree, isWordWrap, setAlignment, setCellFocus, setCellSelected, setColumn, setColumnHover, setDragging, setRow, setRowFocus, setRowHover, setTruncationStyle, setVerticalAlignment, setWordWrap
-
Methods inherited from class org.eclipse.nebula.widgets.grid.AbstractInternalWidget
getHoverDetail, setHoverDetail
-
Methods inherited from class org.eclipse.nebula.widgets.grid.AbstractRenderer
getBounds, getDisplay, getSize, isExpanded, isFocus, isHover, isMouseDown, isSelected, setBounds, setBounds, setDisplay, setExpanded, setFocus, setHover, setLocation, setLocation, setMouseDown, setSelected, setSize, setSize
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.nebula.widgets.grid.IRenderer
setBounds, setBounds, setDisplay, setExpanded, setFocus, setHover, setLocation, setLocation, setMouseDown, setSelected, setSize, setSize
-
-
-
-
Field Detail
-
leftMargin
int leftMargin
-
rightMargin
int rightMargin
-
topMargin
int topMargin
-
bottomMargin
int bottomMargin
-
textTopMargin
int textTopMargin
-
textBottomMargin
int textBottomMargin
-
insideMargin
private final int insideMargin
- See Also:
- Constant Field Values
-
treeIndent
int treeIndent
-
toggleRenderer
private ToggleRenderer toggleRenderer
-
branchRenderer
private BranchRenderer branchRenderer
-
checkRenderer
private CheckBoxRenderer checkRenderer
-
textLayout
private org.eclipse.swt.graphics.TextLayout textLayout
-
-
Method Detail
-
paint
public void paint(org.eclipse.swt.graphics.GC gc, java.lang.Object value)Paints the visual representation of the given value on the given GC. The actual class of the value object is determined by the use of the implementing class.Implementors need to respect the bounds values that may have been specified. The bounds values may affect the x and y values for all drawing operations as well as the width and heights. Implementors may use a
Transformto translate the coordinates of all the drawing operations, otherwise they will need to offset each draw.- Parameters:
gc- GC to paint withvalue- the value being painted
-
getVerticalAlignmentAdjustment
private int getVerticalAlignmentAdjustment(int textHeight, int cellHeight)
-
getBranches
private int[] getBranches(GridItem item)
Calculates the sequence of branch lines which should be rendered for the provided item- Parameters:
item-- Returns:
- an array of integers composed using the constants in
BranchRenderer
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(org.eclipse.swt.graphics.GC gc, int wHint, int hHint, java.lang.Object value)Returns the size of the given value's visual representation.- Parameters:
gc- convenience GC for string and text extentswHint- given width (or SWT.DEFAULT)hHint- given height (or SWT.DEFAULT)value- value to be sized- Returns:
- the size
-
notify
public boolean notify(int event, org.eclipse.swt.graphics.Point point, java.lang.Object value)Mechanism used to notify the light weight widgets that an event occurred that it might be interested in.- Parameters:
event- Event type.point- Location of event.value- New value.- Returns:
- widget handled the event.
-
overCheck
private boolean overCheck(GridItem item, org.eclipse.swt.graphics.Point point)
-
getToggleIndent
private int getToggleIndent(GridItem item)
-
overToggle
private boolean overToggle(GridItem item, org.eclipse.swt.graphics.Point point)
-
setTree
public void setTree(boolean tree)
- Overrides:
setTreein classGridCellRenderer- Parameters:
tree- The tree to set.
-
setCheck
public void setCheck(boolean check)
- Overrides:
setCheckin classGridCellRenderer- Parameters:
check- The check to set.
-
getTextBounds
public org.eclipse.swt.graphics.Rectangle getTextBounds(GridItem item, boolean preferred)
Returns the bounds of the text in the cell. This is used when displaying in-place tooltips. Ifnullis returned here, in-place tooltips will not be displayed. If thepreferredargument istruethen the returned bounds should be large enough to show the entire text. Ifpreferredisfalsethen the returned bounds should be be relative to the current bounds.- Overrides:
getTextBoundsin classGridCellRenderer- Parameters:
item- item to calculate text bounds.preferred- true if the preferred width of the text should be returned.- Returns:
- bounds of the text.
-
isCenteredCheckBoxOnly
private boolean isCenteredCheckBoxOnly(GridItem item)
-
-