de.kupzog.ktable.renderers
Class CheckableCellRenderer

java.lang.Object
  extended by de.kupzog.ktable.renderers.DefaultCellRenderer
      extended by de.kupzog.ktable.renderers.CheckableCellRenderer
All Implemented Interfaces:
KTableCellRenderer
Direct Known Subclasses:
FixedCheckableCellRenderer

public class CheckableCellRenderer
extends DefaultCellRenderer

Cell renderer that expects a Boolean as content of a cell. It then represents the value by a checked or unchecked box.

It accepts the following style bits:

Author:
Lorenz Maierhofer
See Also:
KTableCellEditorCheckbox, KTableCellEditorCheckbox2

Field Summary
static org.eclipse.swt.graphics.Color BORDER_DARK
           
static org.eclipse.swt.graphics.Color BORDER_LIGHT
           
static org.eclipse.swt.graphics.Color COLOR_FILL
           
static org.eclipse.swt.graphics.Image IMAGE_CHECKED
          Indicator for a checked entry / true boolean decision
static org.eclipse.swt.graphics.Image IMAGE_CHECKED_CLICKED
          Indicator for an checked entry / true boolean decision that is currently clicked.
static org.eclipse.swt.graphics.Image IMAGE_UNCHECKED
          Indicator for an unchecked entry / false boolean decision
static org.eclipse.swt.graphics.Image IMAGE_UNCHECKED_CLICKED
          Indicator for an unchecked entry / false boolean decision that is currently clicked.
static int SIGN_CHECK
          Makes the renterer draw a check sign as the symbol that signals the value true.
static int SIGN_IMAGE
          Style bit that forces that the renderer paints images instead of directly painting.
static int SIGN_X
          Makes the renderer draw an X as the symbol that signals the value is true.
 
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
CheckableCellRenderer(int style)
          Creates a cellrenderer that shows boolean values with the given style.
 
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)
          Paint a box with or without a checked symbol.
 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
 

Field Detail

SIGN_IMAGE

public static final int SIGN_IMAGE
Style bit that forces that the renderer paints images instead of directly painting. The images used for painting can be found in the folder /icons/ and are named checked.gif, unchecked.gif, checked_clicked.gif and unchecked_clicked.gif.

Note that when using images, drawing is 2-3 times slower than when using direct painting. It might be visible if many cells should be rendered that way. So this is not default.

See Also:
Constant Field Values

SIGN_X

public static final int SIGN_X
Makes the renderer draw an X as the symbol that signals the value is true. This has only an effect if the style SIGN_IMAGE is not active.

See Also:
Constant Field Values

SIGN_CHECK

public static final int SIGN_CHECK
Makes the renterer draw a check sign as the symbol that signals the value true. THIS IS DEFAULT.

See Also:
Constant Field Values

IMAGE_CHECKED

public static final org.eclipse.swt.graphics.Image IMAGE_CHECKED
Indicator for a checked entry / true boolean decision


IMAGE_UNCHECKED

public static final org.eclipse.swt.graphics.Image IMAGE_UNCHECKED
Indicator for an unchecked entry / false boolean decision


IMAGE_CHECKED_CLICKED

public static final org.eclipse.swt.graphics.Image IMAGE_CHECKED_CLICKED
Indicator for an checked entry / true boolean decision that is currently clicked.


IMAGE_UNCHECKED_CLICKED

public static final org.eclipse.swt.graphics.Image IMAGE_UNCHECKED_CLICKED
Indicator for an unchecked entry / false boolean decision that is currently clicked.


COLOR_FILL

public static final org.eclipse.swt.graphics.Color COLOR_FILL

BORDER_DARK

public static final org.eclipse.swt.graphics.Color BORDER_DARK

BORDER_LIGHT

public static final org.eclipse.swt.graphics.Color BORDER_LIGHT
Constructor Detail

CheckableCellRenderer

public CheckableCellRenderer(int style)
Creates a cellrenderer that shows boolean values with the given style.

Parameters:
style - Honored style bits are:
- INDICATION_CLICKED
- INDICATION_FOCUS
- INDICATION_FOCUS_ROW
- INDICATION_COMMENT

Styles that influence the sign painted when cell value is true:
- SIGN_IMAGE
- SIGN_X
- SIGN_CHECK (default)

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)
Paint a box with or without a checked symbol.

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.