Websites Navigation: Airbit | Shop | m-shell.net
Languages: EN | DE

Class abgui.Table

is abguibase.Widget
A table with rows and columns. The content (model) is always an array. Each array element corresponds to a row. If the array is one-dimensional, the table has one column. Otherwise, each array element contains the columns of the corresponding row.

Each array element is drawn by a Renderer. Replacing the default renderer by a subclass allows to draw custom table cells.

Constructor

function init(data=[], headers=null)
Overridesabguibase.Widget.init()
Initialize a new table.
Parameters:
data – the initially shown data.
headers – the table headers to show.

Fields

bordercolor The color of the borders.
data The data array, with one or two dimensions.
dx The current horizontal shift (pixels).
flags The flags. They have the following meaning:
LEFTdraw vertical border on the left of the leftmost column.
HCENTERdraw vertical border between all columns.
RIGHTdraw vertical border on the right of the righmost column.
TOPdraw horizontal border on top of the first row (or the header).
VCENTERdraw horizontal border between all rows.
BOTTOMdraw horizontal border below the last row.
HSELECTenable horizontal (column) selection.
VSELECTenable vertical (row) selection.
MARKenable marking the currently selected cell (for navigation).
By default, all flags except HSELECT and MARK are set.
font The font for the cell text. null for the default font.
headers The headers. May be null if no headers are desired. If set, there must be one header per column.
listeners The cell click listeners.
renderers The array renderers, per column. There must be as many renderes as the maximum number of columns.
rowHeight The height of all rows.
selColumn The selected column.
selRow The selected row.
start The first row currently shown.
widths The width of each column.

Functions

addListener(l) Add a cell click listener.
addRow(row) Append a row to the data array.
computeSizes(shrink=...) Adapt the dimensions from the data.
desiredSize() Get or compute the desired size.
doClick() Perform a cell click, i.e. notify the listeners.
draw() [Inherited comment] Draw this widget.
focusable() A Table is focusable if it allows selection.
getColumnCount() Get the number of columns this table has.
getRowCount() Get the number of rows this table has.
getSelectedRow() Get the currently selected row of data.
handled(event) [Inherited comment] Handle an ui.cmd() event.
insertRow(row, at) Insert a row into the data array.
pointToPos(dx, dy) Convert screen coordinates to row and column.
removeListener(l) Remove a listener.
removeRow(at) Remove a row from the data.
setColumnCount(count) Set the number of columns this table has.
setData(data) Set the data array.
showPos(row=-1, col=-1) Make sure a given cell is visible.
function getRowCount()
Get the number of rows this table has.
Returns:the number of rows, or -1 if the rows have not been defined yet.
function getColumnCount()
Get the number of columns this table has.
Returns:the number of columns, or -1 if the columns have not been defined yet.
function setColumnCount(count)
Set the number of columns this table has. This initializes the renderers and widths members.
Parameters:
count – the new column count.
function setData(data)
Set the data array. The number of columns is increased if required.
Parameters:
data – the array of rows.
function addRow(row)
Append a row to the data array.
Parameters:
row – the data row to append.
function insertRow(row, at)
Insert a row into the data array.
Parameters:
row – the data row to insert.
at – the row index to insert before.
function removeRow(at)
Remove a row from the data.
Parameters:
at – the row index to remove.
function getSelectedRow()
Get the currently selected row of data.
Returns:the row, or null if there is no selected row.
function computeSizes(shrink=true)
Adapt the dimensions from the data.
Parameters:
shrink – true if widths and heights can also be reduced to fit.
function focusable()
Overridesabguibase.Widget.focusable()
A Table is focusable if it allows selection.
Returns:true
function draw()
Overridesabguibase.Widget.draw()
[Inherited comment] Draw this widget. The clip rectangle is set to this widget's rectangle. Override in subclasses to draw their specific view. The default implementation draws the focus.
function desiredSize()
Overridesabguibase.Widget.desiredSize()
Get or compute the desired size. The default size depends on the widths, row height and number of rows.
Returns:the size, as [width, height].
function pointToPos(dx, dy)
Convert screen coordinates to row and column.
Parameters:
dx – the x coordinate relative to the left edge of the table.
dy – the y coordinate relative to the top edge of the table.
Returns:[row, column], or null if the position is outside the table. If row=-1 indicates the header row.
function showPos(row=-1, col=-1)
Make sure a given cell is visible.
Parameters:
row – the row to make visible. -1 to not scroll vertically.
col – the column to make visible. -1 to not scroll horizontally.
function addListener(l)
Add a cell click listener. This must be a function reference or an instance function reference, taking the arguments (this, row, column).
Parameters:
l – the listener to add.
function removeListener(l)
Remove a listener.
Parameters:
l – the listener to remove.
function doClick()
Perform a cell click, i.e. notify the listeners.
function handled(event)
Overridesabguibase.Widget.handled()
[Inherited comment] Handle an ui.cmd() event.
Parameters:
event – the event to handle, one of the values returned by ui.cmd(). Pointer events will also contain an array element "prevbuttons" to allow to check for button presses or releases.
Returns:true if this widget handled the event.
mShell Home  > Documentation  > mdoc