Package totalcross.ui
Class Grid.CellController
- java.lang.Object
-
- totalcross.ui.Grid.CellController
-
- Enclosing class:
- Grid
public abstract static class Grid.CellController extends java.lang.ObjectAbstract class that must be implemented if you want to get a fine control of each cell in the grid. Note that you must keep track of the state of each cell in your code. How to proceed:- Create a class that extends CellController and implement each of the methods. Then call grid.setCellController passing an instance of the created class.
- Each time a cell is drawn, the getForeColor, getBackColor and getFont methods are called.
If you want to use the default values, return
null. - If a column has choices activated (with setColumnChoices), each time the ComboBox
will be opened, the getChoices method is called. This way, you can dynamically change the
choices for each cell. If you want to use the default values, return
null. - Each time a cell is clicked, the isEnabled method is called. If you return false to it, the event is not generated; also, when trying to open the ComboBox or the Edit assigned to the column, the control will not be activated. This is valid for a check column too.
grid.disableSort = true.
-
-
Constructor Summary
Constructors Constructor Description CellController()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intgetBackColor(int row, int col)Must return the background color for the given cell, or -1 if none.abstract java.lang.String[]getChoices(int row, int col)Must return the choices for a given line and column, if setColumnChoices was set to this column.FontgetFont(int row, int col)Must return the font to be used in this cell, or null to use the default control's font.abstract intgetForeColor(int row, int col)Must return the foreground color for the given cell, or -1 if none.abstract booleanisEnabled(int row, int col)Must return if the given cell is enabled, ie, can have input and can be selected.
-
-
-
Method Detail
-
getForeColor
public abstract int getForeColor(int row, int col)Must return the foreground color for the given cell, or -1 if none.
-
getBackColor
public abstract int getBackColor(int row, int col)Must return the background color for the given cell, or -1 if none. Note that if the grid has a check, the back color of the check cell will be requested passing col value as -1.
-
getChoices
public abstract java.lang.String[] getChoices(int row, int col)Must return the choices for a given line and column, if setColumnChoices was set to this column.
-
isEnabled
public abstract boolean isEnabled(int row, int col)Must return if the given cell is enabled, ie, can have input and can be selected. If the grid has a check column, returning false will disable the check state change.
-
getFont
public Font getFont(int row, int col)
Must return the font to be used in this cell, or null to use the default control's font. Note: if you plan to use a font bigger than in the rest of the grid, be sure to follow these steps:- Construct the grid and set the grid's font to be the one with bigger size
- Call add/setRect
- Restore the grid's default font
- Since:
- TotalCross 1.0
-
-