de.kupzog.examples
Class PaletteExampleRenderer

java.lang.Object
  extended by de.kupzog.examples.PaletteExampleRenderer
All Implemented Interfaces:
KTableCellRenderer

public class PaletteExampleRenderer
extends java.lang.Object
implements KTableCellRenderer

Author:
Friederich Kupzog

Field Summary
 
Fields inherited from interface de.kupzog.ktable.KTableCellRenderer
defaultRenderer
 
Constructor Summary
PaletteExampleRenderer()
           
 
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)
          This method is called from KTable to draw a table cell.
 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)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PaletteExampleRenderer

public PaletteExampleRenderer()
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
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)
Description copied from interface: KTableCellRenderer
This method is called from KTable to draw a table cell.

Note that there are several helper methods that can do specified things for you.

Specified by:
drawCell in interface KTableCellRenderer
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.