edelib
2.1.0
|
A base class for table widgets. More...
#include <edelib/TableBase.h>
Public Types | |
enum | TableContext { CONTEXT_NONE = 0, CONTEXT_STARTPAGE = 0x01, CONTEXT_ENDPAGE = 0x02, CONTEXT_ROW_HEADER = 0x04, CONTEXT_COL_HEADER = 0x08, CONTEXT_CELL = 0x10, CONTEXT_TABLE = 0x20, CONTEXT_RC_RESIZE = 0x40 } |
What happened in table callback. More... | |
Public Member Functions | |
TableBase (int X, int Y, int W, int H, const char *l=0) | |
~TableBase () | |
virtual void | clear () |
void | table_box (Fl_Boxtype val) |
Fl_Boxtype | table_box (void) |
virtual void | rows (int val) |
int | rows () |
virtual void | cols (int val) |
int | cols () |
void | visible_cells (int &r1, int &r2, int &c1, int &c2) |
int | is_interactive_resize () |
void | row_resize (int flag) |
int | row_resize () |
void | col_resize (int flag) |
int | col_resize () |
void | col_resize_min (int val) |
int | col_resize_min () |
void | row_resize_min (int val) |
int | row_resize_min () |
void | row_header (int flag) |
int | row_header () |
void | col_header (int flag) |
int | col_header () |
void | col_header_height (int height) |
int | col_header_height () |
void | row_header_width (int width) |
int | row_header_width () |
void | row_header_color (Fl_Color val) |
Fl_Color | row_header_color () |
void | col_header_color (Fl_Color val) |
Fl_Color | col_header_color () |
void | row_height (int row, int height) |
int | row_height (int row) |
void | col_width (int col, int width) |
int | col_width (int col) |
void | row_height_all (int height) |
void | col_width_all (int width) |
void | row_position (int row) |
int | row_position () |
void | col_position (int col) |
int | col_position () |
void | top_row (int row) |
int | top_row () |
int | is_selected (int r, int c) |
void | get_selection (int &s_top, int &s_left, int &s_bottom, int &s_right) |
void | set_selection (int s_top, int s_left, int s_bottom, int s_right) |
int | move_cursor (int R, int C) |
void | resize (int X, int Y, int W, int H) |
void | draw (void) |
void | init_sizes () |
void | add (Fl_Widget &widget) |
void | add (Fl_Widget *widget) |
void | insert (Fl_Widget &widget, int n) |
void | insert (Fl_Widget &widget1, Fl_Widget *widget2) |
void | remove (Fl_Widget &widget) |
void | begin () |
void | end () |
int | callback_row () |
int | callback_col () |
TableContext | callback_context () |
void | do_callback (TableContext context, int row, int col) |
A base class for table widgets.
TableBase is incarnation of excelent Fl_Table widget, written by Greg Ercolano. To be useful, it must be subclassed and several virtual functions defined.
This widget does not handle the data in the table. draw_cell() must be overridden by a subclass to manage drawing the content of the cells.
Drawing (and callbacks, later explained) are done via contexts. Contexts shows what parts should be redrawn or are changed by user when callbacks are used.
Here is the simple table implementation:
Since TableBase is inherited from Fl_Group, it can be container for FLTK widgets too. In that case there is no need to use CONTEXT_CELL in draw_cell() and draw widgets: they will be drawn by itself. The only thing you should use is to add() them, as any other widget is addet to Fl_Group.
enum TableContext |
What happened in table callback.
TableBase | ( | int | X, |
int | Y, | ||
int | W, | ||
int | H, | ||
const char * | l = 0 |
||
) |
The constructor that creates empty table with no rows or columns. Resizing of rows or columns is disabled. Header is not drawn too.
~TableBase | ( | ) |
Destroys the table and associated widgets
|
inline |
Append widget to the table
|
inline |
Append widget to the table
|
inline |
Same as Fl_Group::begin()
|
inline |
Returns the current column event occured on. This function should be used from user's callback set with callback()
|
inline |
Returns current TableContext
|
inline |
Returns the current row event occured on. This function should be used from user's callback set with callback()
|
inlinevirtual |
Clears the table
|
inline |
Enable or disable showing column headers. 1 will enable them and 0 will disable them. Table will be redrawn after this call
|
inline |
Returns 1 if column headers are shown or 0 if not
|
inline |
Sets the column header color. Table will be then redrawn
|
inline |
Returns the current column header color
|
inline |
Sets the column header heights. Table will be then redrawn
|
inline |
Returns the column header heights
void col_position | ( | int | col | ) |
Sets the table's current column scroll position
|
inline |
Returns the current columnscroll position
|
inline |
Allow or disallow column resizing. If 1 is used, column will be resized; 0 is for opposite. Since interactive resizing is done via the column headers, col_header() must also be enabled to allow resizing
|
inline |
Returns 1 if column can be resized or 0 if not
|
inline |
Sets the current column minimum resize value. Must be a value >= 1
|
inline |
Returns the current column minimum resize value
void col_width | ( | int | col, |
int | width | ||
) |
Sets the width of the specified column in pixels and table is redrawn. callback() will be invoked with CONTEXT_RC_RESIZE if the column's width was actually changed and when() is FL_WHEN_CHANGED
|
inline |
Returns the current height of specified column
|
inline |
Sets the width of all columns to the same value. Table is redrawn then
|
virtual |
Sets the number of columns in the table. Table is redraw
|
inline |
Returns the number of columns in the table
|
inline |
Execute user's callback with given TableContext, row and column
void draw | ( | void | ) |
Draw the table (called by FLTK)
|
inline |
Same as Fl_Group::end()
void get_selection | ( | int & | s_top, |
int & | s_left, | ||
int & | s_bottom, | ||
int & | s_right | ||
) |
Returns selected rows and columns. Values will be leftmost/rightmost column and topmost/bottommost rows
This function is used to return bounds of multiple selected cells
|
inline |
Calls Fl_Group::init_sizes(). Table will be redrawn
|
inline |
Same as Fl_Group::insert()
|
inline |
Same as Fl_Group::insert()
|
inline |
Returns 1 if row or column is interactively resized or 0 if not
int is_selected | ( | int | r, |
int | c | ||
) |
Returns 1 if the cell with the given row and column values is selected
int move_cursor | ( | int | R, |
int | C | ||
) |
Selects cell at the given row/column position
|
inline |
Remove a widget from the table
void resize | ( | int | X, |
int | Y, | ||
int | W, | ||
int | H | ||
) |
Resize table. Table is redrawn
|
inline |
Enable or disable showing row headers. 1 will enable them and 0 will disable them. Table will be redrawn after this call
|
inline |
Returns 1 if row headers are shown or 0 if not
|
inline |
Sets the row header color. Table will be then redrawn
|
inline |
Returns the current row header color
|
inline |
Sets the row header heights. Table will be then redrawn
|
inline |
Returns the row header heights
void row_height | ( | int | row, |
int | height | ||
) |
Sets the height of the specified row in pixels and table is redrawn. callback() will be invoked with CONTEXT_RC_RESIZE if the row's height was actually changed and when() is FL_WHEN_CHANGED
|
inline |
Returns the current height of specified row
|
inline |
Sets the height of all rows to the same value. Table is redrawn then
void row_position | ( | int | row | ) |
Sets the table's current row scroll position
|
inline |
Returns the current row scroll position
|
inline |
Allow or disallow row resizing. If 1 is used, row will be resized; 0 is for opposite. Since interactive resizing is done via the row headers, row_header() must also be enabled to allow resizing
|
inline |
Returns 1 if rows can be resized or 0 if not
|
inline |
Sets the current row minimum resize value. Must be a value >= 1
|
inline |
Returns the current row minimum resize value
|
virtual |
Sets the number of rows in the table. Table is redrawn
|
inline |
Returns the number of rows in the table
void set_selection | ( | int | s_top, |
int | s_left, | ||
int | s_bottom, | ||
int | s_right | ||
) |
Select's rows and columns. Values should be leftmost/rightmost column and topmost/bottommost rows
This function is used to select multiple cells
|
inline |
Sets a kind of box around the table (default is FL_NO_BOX). Calling this function will redraw table
|
inline |
Returns the current box type used for the data table
|
inline |
Sets which row should be at the top of the table, scrolling as necessary. Table is redrawn
|
inline |
Returns the current top row. This row may be partially obscured
|
inline |
Returns the range of row and column numbers for all the visible and partially visible cells in the table.
These values can be used e.g. by draw_cell() during CONTEXT_STARTPAGE to figure out what cells are about to be redrawn, for the purposes of locking the data from a database befire it's drawn