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.
License
Copyright
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.
Draw cell callback delegate type for Table.
Called when a table cell needs to be drawn.
Parameters
context | Table context indicating what is being drawn |
row | Row number (0-based, -1 for headers) |
col | Column number (0-based, -1 for headers) |
x | X coordinate of cell |
y | Y coordinate of cell |
w | Width of cell |
h | Height of cell |
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
}
};DrawCellDelegate _drawCellDelegatevoid drawCellCallbackBridge(
TablePtr table, int context, int row, int col,
int x, int y, int w, int h, void * userdata) nothrowvoid drawCellCallback(DrawCellDelegate dg)Sets the draw cell callback delegate.void rows(int count)Sets the number of rows in the table.void cols(int count)Sets the number of columns in the table.void rowHeight(int row, int height)Sets 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.void colWidthAll(int width)Sets the width of all columns.void rowHeader(bool enabled)Enables or disables row headers.void colHeader(bool enabled)Enables or disables column headers.void rowHeaderWidth(int width)Sets the row header width.void colHeaderHeight(int height)Sets the column header height.void rowHeaderColor(uint color)Sets the row header color.void colHeaderColor(uint color)Sets the column header color.void rowResize(bool enabled)Enables or disables row resizing.void colResize(bool enabled)Enables or disables column resizing.void rowResizeMin(int val)Sets the minimum row resize height.void colResizeMin(int val)Sets the minimum column resize width.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.void colPosition(int col)Sets the column scroll position.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.this(int x, int y, int w, int h, string label = null)Creates a new Table widget.~thisDestroys the Table widget.Draw cell callback delegate type for TableRow.
Called when a table cell needs to be drawn.
Parameters
context | Table context indicating what is being drawn |
row | Row number (0-based, -1 for headers) |
col | Column number (0-based, -1 for headers) |
x | X coordinate of cell |
y | Y coordinate of cell |
w | Width of cell |
h | Height 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
}
};DrawCellDelegate _drawCellDelegatevoid drawCellCallbackBridge(
TableRowPtr table, int context, int row, int col,
int x, int y, int w, int h, void * userdata) nothrowvoid drawCellCallback(DrawCellDelegate dg)Sets the draw cell callback delegate.void rows(int count)Sets the number of rows.void cols(int count)Sets the number of columns.void setRowHeight(int row, int height)Sets 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.void colWidthAll(int width)Sets the width of all columns.void rowHeader(bool enabled)Enables or disables row headers.void colHeader(bool enabled)Enables or disables column headers.void rowHeaderWidth(int width)Sets the row header width.void colHeaderHeight(int height)Sets the column header height.void rowHeaderColor(Color color)Sets the row header color.void colHeaderColor(Color color)Sets the column header color.void rowResize(bool enabled)Enables or disables row resizing by the user.void colResize(bool enabled)Enables or disables column resizing by the user.void selectMode(TableSelectMode mode)Sets the selection mode.bool selectRow(int row, bool selected = true)Selects or deselects a row.void selectAllRows()Selects all rows.void deselectAllRows()Deselects all rows.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.void colPosition(int col)Sets the column scroll position.void rowResizeMin(int val)Sets the minimum row resize height.void colResizeMin(int val)Sets the minimum column resize width.bool isInteractiveResize() constReturns whether the user is currently interactively resizing a row or column.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.this(int x, int y, int w, int h, string label = null)Creates a new TableRow widget.~thisDestroys the TableRow widget.