fltk.table

FLTK Table Widgets

This module provides table widgets for tabular data display:

  • Table: Base table widget with custom cell drawing
  • TableRow: Table widget with row selection support

Both widgets display data in a grid format with optional row and column headers. They support custom cell drawing through a callback mechanism.

Authors

Dejan Lekić

License

BSD-3-Clause

Types 6

Table context values for draw_cell callback.

These values indicate what part of the table is being drawn.

Table row selection mode.

These values control how rows can be selected in a TableRow.

aliasDrawCellDelegate = void delegate(TableContext context, int row, int col, int x, int y, int w, int h)

Draw cell callback delegate type for Table.

Called when a table cell needs to be drawn.

Parameters

contextTable context indicating what is being drawn
rowRow number (0-based, -1 for headers)
colColumn number (0-based, -1 for headers)
xX coordinate of cell
yY coordinate of cell
wWidth of cell
hHeight of cell
classTable : Widget

Base table widget for displaying tabular data.

Table provides a grid for displaying tabular data with optional row and column headers. It supports custom cell drawing through a callback mechanism.

Use Table when you need basic table functionality without row selection. For row selection support, use TableRow instead.

Example:

auto table = new Table(10, 10, 400, 300);
table.rows = 10;
table.cols = 5;
table.rowHeader = true;
table.colHeader = true;
table.drawCellCallback = (context, row, col, x, y, w, h) {
    if (context == TableContext.CELL) {
        // Draw cell content
    }
};

Fields
DrawCellDelegate _drawCellDelegate
Methods
void drawCellCallbackBridge( TablePtr table, int context, int row, int col, int x, int y, int w, int h, void * userdata) nothrow
TablePtr tableHandle() @trusted nothrow @nogcReturns the underlying table handle.
bool isValid() const @safe nothrow @nogcChecks if the table handle is valid.
void drawCellCallback(DrawCellDelegate dg)Sets the draw cell callback delegate.
void rows(int count)Sets the number of rows in the table.
int rows() constGets the number of rows in the table.
void cols(int count)Sets the number of columns in the table.
int cols() constGets the number of columns in the table.
void rowHeight(int row, int height)Sets the height of a specific row.
int rowHeight(int row) constGets the height of a specific row.
void rowHeightAll(int height)Sets the height of all rows.
void colWidth(int col, int width)Sets the width of a specific column.
int colWidth(int col) constGets the width of a specific column.
void colWidthAll(int width)Sets the width of all columns.
void rowHeader(bool enabled)Enables or disables row headers.
bool rowHeader() constGets whether row headers are enabled.
void colHeader(bool enabled)Enables or disables column headers.
bool colHeader() constGets whether column headers are enabled.
void rowHeaderWidth(int width)Sets the row header width.
int rowHeaderWidth() constGets the row header width.
void colHeaderHeight(int height)Sets the column header height.
int colHeaderHeight() constGets the column header height.
void rowHeaderColor(uint color)Sets the row header color.
uint rowHeaderColor() constGets the row header color.
void colHeaderColor(uint color)Sets the column header color.
uint colHeaderColor() constGets the column header color.
void rowResize(bool enabled)Enables or disables row resizing.
bool rowResize() constGets whether row resizing is enabled.
void colResize(bool enabled)Enables or disables column resizing.
bool colResize() constGets whether column resizing is enabled.
void rowResizeMin(int val)Sets the minimum row resize height.
int rowResizeMin() constGets the minimum row resize height.
void colResizeMin(int val)Sets the minimum column resize width.
int colResizeMin() constGets the minimum column resize width.
bool isInteractiveResize() constReturns whether the user is currently interactively resizing.
void tableBox(Boxtype boxtype)Sets the box type for the table.
Boxtype tableBox() constGets the box type for the table.
void clear()Clears the table (sets rows and columns to 0).
void redraw()Redraws the table.
void rowPosition(int row)Sets the row scroll position.
int rowPosition() constGets the current row scroll position.
void colPosition(int col)Sets the column scroll position.
int colPosition() constGets the current column scroll position.
bool isCellSelected(int row, int col) constChecks if a cell is selected.
void getSelection(out int rowTop, out int colLeft, out int rowBot, out int colRight) constGets the current selection range.
void setSelection(int rowTop, int colLeft, int rowBot, int colRight)Sets the selection range.
bool moveCursor(int row, int col, bool shiftSelect = false)Moves the cursor to a specified cell.
void visibleCells(out int topRow, out int botRow, out int leftCol, out int rightCol) constGets the range of visible cells.
int callbackRow() constGets the row that triggered the callback.
int callbackCol() constGets the column that triggered the callback.
TableContext callbackContext() constGets the context of the callback.
Constructors
this(int x, int y, int w, int h, string label = null)Creates a new Table widget.
Destructors
~thisDestroys the Table widget.
aliasDrawCellRowDelegate = void delegate(TableContext context, int row, int col, int x, int y, int w, int h)

Draw cell callback delegate type for TableRow.

Called when a table cell needs to be drawn.

Parameters

contextTable context indicating what is being drawn
rowRow number (0-based, -1 for headers)
colColumn number (0-based, -1 for headers)
xX coordinate of cell
yY coordinate of cell
wWidth of cell
hHeight of cell

Table widget with row selection support.

TableRow provides a grid for displaying tabular data with optional row and column headers. It supports single or multiple row selection and custom cell drawing.

Example:

auto table = new TableRow(10, 10, 400, 300);
table.rows = 10;
table.cols = 5;
table.rowHeader = true;
table.colHeader = true;
table.drawCellCallback = (context, row, col, x, y, w, h) {
    if (context == TableContext.CELL) {
        // Draw cell content
    }
};

Fields
DrawCellDelegate _drawCellDelegate
Methods
void drawCellCallbackBridge( TableRowPtr table, int context, int row, int col, int x, int y, int w, int h, void * userdata) nothrow
TableRowPtr tableRowHandle() @trusted nothrow @nogcReturns the underlying table handle.
bool isValid() const @safe nothrow @nogcChecks if this table is valid.
void drawCellCallback(DrawCellDelegate dg)Sets the draw cell callback delegate.
DrawCellDelegate drawCellCallback() @safe nothrow @nogcGets the draw cell callback delegate.
void rows(int count)Sets the number of rows.
int rows() constGets the number of rows.
void cols(int count)Sets the number of columns.
int cols() constGets the number of columns.
void setRowHeight(int row, int height)Sets the height of a specific row.
int getRowHeight(int row) constGets the height of a specific row.
void rowHeightAll(int height)Sets the height of all rows.
void setColWidth(int col, int width)Sets the width of a specific column.
int getColWidth(int col) constGets the width of a specific column.
void colWidthAll(int width)Sets the width of all columns.
void rowHeader(bool enabled)Enables or disables row headers.
bool rowHeader() constGets whether row headers are enabled.
void colHeader(bool enabled)Enables or disables column headers.
bool colHeader() constGets whether column headers are enabled.
void rowHeaderWidth(int width)Sets the row header width.
int rowHeaderWidth() constGets the row header width.
void colHeaderHeight(int height)Sets the column header height.
int colHeaderHeight() constGets the column header height.
void rowHeaderColor(Color color)Sets the row header color.
Color rowHeaderColor() constGets the row header color.
void colHeaderColor(Color color)Sets the column header color.
Color colHeaderColor() constGets the column header color.
void rowResize(bool enabled)Enables or disables row resizing by the user.
bool rowResize() constGets whether row resizing is enabled.
void colResize(bool enabled)Enables or disables column resizing by the user.
bool colResize() constGets whether column resizing is enabled.
void selectMode(TableSelectMode mode)Sets the selection mode.
TableSelectMode selectMode() constGets the selection mode.
bool isRowSelected(int row) constChecks if a row is selected.
bool selectRow(int row, bool selected = true)Selects or deselects a row.
void selectAllRows()Selects all rows.
void deselectAllRows()Deselects all rows.
void tableBox(Boxtype boxtype)Sets the box type for the table.
Boxtype tableBox() constGets the box type for the table.
void clear()Clears the table (sets rows and columns to 0).
void redraw()Redraws the table.
void rowPosition(int row)Sets the row scroll position.
int rowPosition() constGets the current row scroll position.
void colPosition(int col)Sets the column scroll position.
int colPosition() constGets the current column scroll position.
void rowResizeMin(int val)Sets the minimum row resize height.
int rowResizeMin() constGets the minimum row resize height.
void colResizeMin(int val)Sets the minimum column resize width.
int colResizeMin() constGets the minimum column resize width.
bool isInteractiveResize() constReturns whether the user is currently interactively resizing a row or column.
bool isCellSelected(int row, int col) constChecks if a cell is selected.
void getSelection(out int rowTop, out int colLeft, out int rowBot, out int colRight) constGets the current selection range.
void setSelection(int rowTop, int colLeft, int rowBot, int colRight)Sets the selection range.
bool moveCursor(int row, int col, bool shiftSelect = false)Moves the cursor to a specified cell.
void visibleCells(out int topRow, out int botRow, out int leftCol, out int rightCol) constGets the range of visible cells.
int callbackRow() constGets the row that triggered the callback.
int callbackCol() constGets the column that triggered the callback.
TableContext callbackContext() constGets the context of the callback.
Constructors
this(int x, int y, int w, int h, string label = null)Creates a new TableRow widget.
Destructors
~thisDestroys the TableRow widget.