de.kupzog.ktable.renderers
Class TextCellRenderer

java.lang.Object
  extended by de.kupzog.ktable.renderers.DefaultCellRenderer
      extended by de.kupzog.ktable.renderers.TextCellRenderer
All Implemented Interfaces:
KTableCellRenderer

public class TextCellRenderer
extends DefaultCellRenderer

Simply draws a text to the cell.

Honored style bits are:

Author:
Lorenz Maierhofer

Field Summary
 
Fields inherited from class de.kupzog.ktable.renderers.DefaultCellRenderer
COLOR_BACKGROUND, COLOR_BGFOCUS, COLOR_BGROWFOCUS, COLOR_COMMENTSIGN, COLOR_FGROWFOCUS, COLOR_FIXEDHIGHLIGHT, COLOR_LINE_DARKGRAY, COLOR_LINE_LIGHTGRAY, COLOR_TEXT, INDICATION_CLICKED, INDICATION_COMMENT, INDICATION_FOCUS, INDICATION_FOCUS_ROW, INDICATION_GRADIENT, INDICATION_SORT, STYLE_FLAT, STYLE_PUSH
 
Fields inherited from interface de.kupzog.ktable.KTableCellRenderer
defaultRenderer
 
Constructor Summary
TextCellRenderer(int style)
          Creates a cellrenderer that prints text in the cell.
 
Method Summary
 void drawCell(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect, int col, int row, java.lang.Object content, boolean focus, boolean fixed, boolean clicked, KTableModel model)
          A default implementation that paints cells in a way that is more or less Excel-like.
 int getOptimalWidth(org.eclipse.swt.graphics.GC gc, int col, int row, java.lang.Object content, boolean fixed, KTableModel model)
          Returns the optimal width of the given cell (used by column resizing)
 void setCommentIndication(boolean value)
           
 
Methods inherited from class de.kupzog.ktable.renderers.DefaultCellRenderer
getAlignment, getBackground, getFont, getForeground, getStyle, setAlignment, setBackground, setDefaultBackground, setDefaultForeground, setFont, setForeground, setStyle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextCellRenderer

public TextCellRenderer(int style)
Creates a cellrenderer that prints text in the cell.

Parameters:
style - Honored style bits are:
- INDICATION_FOCUS makes the cell that has the focus have a different background color and a selection border.
- INDICATION_FOCUS_ROW makes the cell show a selection indicator as it is often seen in row selection mode. A deep blue background and white content.
- INDICATION_COMMENT lets the renderer paint a small triangle to the right top corner of the cell.
- SWT.BOLD Makes the renderer draw bold text.
- SWT.ITALIC Makes the renderer draw italic text
Method Detail

getOptimalWidth

public int getOptimalWidth(org.eclipse.swt.graphics.GC gc,
                           int col,
                           int row,
                           java.lang.Object content,
                           boolean fixed,
                           KTableModel model)
Description copied from interface: KTableCellRenderer
Returns the optimal width of the given cell (used by column resizing)

Specified by:
getOptimalWidth in interface KTableCellRenderer
Overrides:
getOptimalWidth in class DefaultCellRenderer
Returns:
int

drawCell

public void drawCell(org.eclipse.swt.graphics.GC gc,
                     org.eclipse.swt.graphics.Rectangle rect,
                     int col,
                     int row,
                     java.lang.Object content,
                     boolean focus,
                     boolean fixed,
                     boolean clicked,
                     KTableModel model)
A default implementation that paints cells in a way that is more or less Excel-like. Only the cell with focus looks very different.

Specified by:
drawCell in interface KTableCellRenderer
Overrides:
drawCell in class DefaultCellRenderer
Parameters:
gc - The gc to draw on
rect - The coordinates and size of the cell (add 1 to width and hight to include the borders)
col - The column
row - The row
content - The content of the cell (as given by the table model)
focus - True if the cell is selected
fixed - True if the cell is an unscrollable header cell (not an unscrollable body cell!)
clicked - True if the cell is currently clicked (useful e.g. to paint a pressed button) the case when fixed row and column elements should be highlighted because a cell in that row and column has focus.
model - The KTableModel that holds the data for the cell. Note that this is only included into the parameter list to allow more flexible cell renderers. Models might provide additional information that can be requested when rendering.
See Also:
KTableCellRenderer.drawCell(GC, Rectangle, int, int, Object, boolean, boolean, boolean, KTableModel)

setCommentIndication

public void setCommentIndication(boolean value)
Parameters:
value - If true, the comment sign is painted. Else it is omitted.