23 #include <sys/types.h>
32 #include <FL/Fl_Group.H>
33 #include <FL/Fl_Scroll.H>
34 #include <FL/Fl_Box.H>
35 #include <FL/Fl_Scrollbar.H>
177 CONTEXT_STARTPAGE = 0x01,
178 CONTEXT_ENDPAGE = 0x02,
179 CONTEXT_ROW_HEADER = 0x04,
180 CONTEXT_COL_HEADER = 0x08,
182 CONTEXT_TABLE = 0x20,
183 CONTEXT_RC_RESIZE = 0x40
204 int _redraw_rightcol;
210 #if FLTK_ABI_VERSION >= 10301
213 #if FLTK_ABI_VERSION >= 10303
221 class FL_EXPORT IntVector {
228 void copy(
int *newarr,
unsigned int newsize) {
230 memcpy(arr, newarr, newsize *
sizeof(
int));
233 IntVector() { init(); }
234 ~IntVector() {
if ( arr ) free(arr); arr = NULL; }
235 IntVector(IntVector&o) { init(); copy(o.arr, o._size); }
236 IntVector& operator=(IntVector&o) {
238 copy(o.arr, o._size);
241 int operator[](
int x)
const {
return(arr[x]); }
242 int& operator[](
int x) {
return(arr[x]); }
243 unsigned int size() {
return(_size); }
244 void size(
unsigned int count) {
245 if ( count != _size ) {
246 arr = (
int*)realloc(arr, count *
sizeof(
int));
250 int pop_back() {
int tmp = arr[_size-1]; _size--;
return(tmp); }
251 void push_back(
int val) {
unsigned int x = _size; size(_size+1); arr[x] = val; }
252 int back() {
return(arr[_size-1]); }
255 IntVector _colwidths;
256 IntVector _rowheights;
261 TableContext _callback_context;
262 int _callback_row, _callback_col;
275 void _redraw_cell(TableContext context,
int R,
int C);
277 void _start_auto_drag();
278 void _stop_auto_drag();
279 void _auto_drag_cb();
280 static void _auto_drag_cb2(
void *d);
286 RESIZE_COL_RIGHT = 2,
287 RESIZE_ROW_ABOVE = 3,
291 int table_w, table_h;
292 int toprow, botrow, leftcol, rightcol;
295 int current_row, current_col;
296 int select_row, select_col;
299 int toprow_scrollpos;
300 int leftcol_scrollpos;
303 int tix, tiy, tiw, tih;
304 int tox, toy, tow, toh;
305 int wix, wiy, wiw, wih;
315 void recalc_dimensions();
316 void table_resized();
317 void table_scrolled();
318 void get_bounds(TableContext context,
319 int &X,
int &Y,
int &W,
int &H);
321 TableContext cursor2rowcol(
int &R,
int &C, ResizeFlag &resizeflag);
323 int find_cell(TableContext context,
324 int R,
int C,
int &X,
int &Y,
int &W,
int &H);
325 int row_col_clamp(TableContext context,
int &R,
int &C);
439 int X=0,
int Y=0,
int W=0,
int H=0)
442 long row_scroll_position(
int row);
443 long col_scroll_position(
int col);
445 int is_fltk_container() {
451 void damage_zone(
int r1,
int c1,
int r2,
int c2,
int r3 = 0,
int c3 = 0);
453 void redraw_range(
int topRow,
int botRow,
int leftCol,
int rightCol) {
454 if ( _redraw_toprow == -1 ) {
456 _redraw_toprow = topRow;
457 _redraw_botrow = botRow;
458 _redraw_leftcol = leftCol;
459 _redraw_rightcol = rightCol;
462 if ( topRow < _redraw_toprow ) _redraw_toprow = topRow;
463 if ( botRow > _redraw_botrow ) _redraw_botrow = botRow;
464 if ( leftCol < _redraw_leftcol ) _redraw_leftcol = leftCol;
465 if ( rightCol > _redraw_rightcol ) _redraw_rightcol = rightCol;
478 Fl_Table(
int X,
int Y,
int W,
int H,
const char *l=0);
491 virtual void clear() { rows(0); cols(0); table->clear(); }
509 return(table->box());
515 virtual void rows(
int val);
527 virtual void cols(
int val);
576 return(_resizing_row != -1 || _resizing_col != -1);
618 return(_col_resize_min);
625 _col_resize_min = ( val < 1 ) ? 1 : val;
632 return(_row_resize_min);
641 _row_resize_min = ( val < 1 ) ? 1 : val;
682 _col_header_h = height;
691 return(_col_header_h);
698 _row_header_w = width;
707 return(_row_header_w);
714 _row_header_color = val;
722 return(_row_header_color);
729 _col_header_color = val;
737 return(_col_header_color);
746 void row_height(
int row,
int height);
752 return((row<0 || row>=(
int)_rowheights.size()) ? 0 : _rowheights[row]);
760 void col_width(
int col,
int width);
766 return((col<0 || col>=(
int)_colwidths.size()) ? 0 : _colwidths[col]);
774 for (
int r=0; r<rows(); r++ ) {
775 row_height(r, height);
784 for (
int c=0; c<cols(); c++ ) {
792 void row_position(
int row);
797 void col_position(
int col);
803 return(_row_position);
810 return(_col_position);
827 return(row_position());
829 int is_selected(
int r,
int c);
830 void get_selection(
int &row_top,
int &col_left,
int &row_bot,
int &col_right);
831 void set_selection(
int row_top,
int col_left,
int row_bot,
int col_right);
832 int move_cursor(
int R,
int C,
int shiftselect);
833 int move_cursor(
int R,
int C);
838 void resize(
int X,
int Y,
int W,
int H);
859 if ( table->children() > 2 ) {
869 table->insert(wgt,n);
872 table->insert(wgt,w2);
885 if ( table->children() > 2 ) {
893 return(table->array());
911 return(table->child(n));
923 return(table->children()-2);
926 return(table->find(wgt));
929 return(table->find(wgt));
939 return(_callback_row);
948 return(_callback_col);
957 return(_callback_context);
960 void do_callback(TableContext context,
int row,
int col) {
961 _callback_context = context;
1080 #if FLTK_ABI_VERSION >= 10301
1091 int scrollbar_size()
const {
1092 return(_scrollbar_size);
1112 void scrollbar_size(
int newSize) {
1113 if ( newSize != _scrollbar_size ) redraw();
1114 _scrollbar_size = newSize;
1117 #if FLTK_ABI_VERSION >= 10303
1131 void tab_cell_nav(
int val) {
1132 if ( val ) flags_ |= TABCELLNAV;
1133 else flags_ &= ~TABCELLNAV;
1143 int tab_cell_nav()
const {
1144 return(flags_ & TABCELLNAV ? 1 : 0);
void col_resize(int flag)
Allows/disallows column resizing by the user.
Definition: Fl_Table.H:608
int row_resize_min()
Returns the current row minimum resize value.
Definition: Fl_Table.H:631
A table of widgets or other content.
Definition: Fl_Table.H:170
Fl_Boxtype table_box(void)
Returns the current box type used for the data table.
Definition: Fl_Table.H:508
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition: Enumerations.H:910
int rows()
Returns the number of rows in the table.
Definition: Fl_Table.H:520
int row_header()
Returns the value of this flag.
Definition: Fl_Table.H:647
int col_header_height()
Gets the column header height.
Definition: Fl_Table.H:690
int callback_col()
Returns the current column the event occurred on.
Definition: Fl_Table.H:947
Fl_Widget * child(int n) const
Returns the child widget by an index.
Definition: Fl_Table.H:910
void table_box(Fl_Boxtype val)
Sets the kind of box drawn around the data table, the default being FL_NO_BOX.
Definition: Fl_Table.H:500
void col_header_height(int height)
Sets the height in pixels for column headers and redraws the table.
Definition: Fl_Table.H:681
virtual void clear()
Clears the table to zero rows (rows(0)), zero columns (cols(0)), and clears any widgets (table->clear...
Definition: Fl_Table.H:491
int col_header()
Returns if column headers are enabled or not.
Definition: Fl_Table.H:664
void col_width_all(int width)
Convenience method to set the width of all columns to the same value, in pixels.
Definition: Fl_Table.H:783
Fl_When
These constants determine when a callback is performed.
Definition: Enumerations.H:309
Fl_Color row_header_color()
Returns the current row header color.
Definition: Fl_Table.H:721
TableContext
The context bit flags for Fl_Table related callbacks (eg.
Definition: Fl_Table.H:175
void row_resize_min(int val)
Sets the current row minimum resize value.
Definition: Fl_Table.H:640
A child needs to be redrawn.
Definition: Enumerations.H:967
Fl_Color col_header_color()
Gets the color for column headers.
Definition: Fl_Table.H:736
void visible_cells(int &r1, int &r2, int &c1, int &c2)
Returns the range of row and column numbers for all visible and partially visible cells in the table...
Definition: Fl_Table.H:564
Fl_Boxtype
Definition: Enumerations.H:473
int cols()
Get the number of columns in the table.
Definition: Fl_Table.H:532
void row_height_all(int height)
Convenience method to set the height of all rows to the same value, in pixels.
Definition: Fl_Table.H:773
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:41
int is_interactive_resize()
Returns 1 if someone is interactively resizing a row or column.
Definition: Fl_Table.H:575
void row_header_color(Fl_Color val)
Sets the row header color and causes the screen to redraw.
Definition: Fl_Table.H:713
int col_width(int col)
Returns the current width of the specified column in pixels.
Definition: Fl_Table.H:765
int row_position()
Returns the current row scroll position as a row number.
Definition: Fl_Table.H:802
void col_header(int flag)
Enable or disable column headers.
Definition: Fl_Table.H:672
void row_resize(int flag)
Allows/disallows row resizing by the user.
Definition: Fl_Table.H:592
virtual void draw_cell(TableContext context, int R=0, int C=0, int X=0, int Y=0, int W=0, int H=0)
Subclass should override this method to handle drawing the cells.
Definition: Fl_Table.H:438
int col_resize()
Returns the current value of this flag.
Definition: Fl_Table.H:599
void top_row(int row)
Sets which row should be at the top of the table, scrolling as necessary, and the table is redrawn...
Definition: Fl_Table.H:818
int row_height(int row)
Returns the current height of the specified row as a value in pixels.
Definition: Fl_Table.H:751
void col_header_color(Fl_Color val)
Sets the color for column headers and redraws the table.
Definition: Fl_Table.H:728
int children() const
Returns how many child widgets the group has.
Definition: Fl_Group.H:75
int top_row()
Returns the current top row shown in the table.
Definition: Fl_Table.H:826
int row_header_width()
Returns the current row header width (in pixels).
Definition: Fl_Table.H:706
void col_resize_min(int val)
Returns the current column minimum resize value.
Definition: Fl_Table.H:624
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:796
int children() const
Returns the number of children in the table.
Definition: Fl_Table.H:922
int callback_row()
Returns the current row the event occurred on.
Definition: Fl_Table.H:938
int col_resize_min()
Sets the current column minimum resize value.
Definition: Fl_Table.H:617
int row_resize()
Returns the current value of this flag.
Definition: Fl_Table.H:582
int col_position()
Returns the current column scroll position as a column number.
Definition: Fl_Table.H:809
TableContext callback_context()
Returns the current 'table context'.
Definition: Fl_Table.H:956
void row_header_width(int width)
Sets the row header width to n and causes the screen to redraw.
Definition: Fl_Table.H:697
static Fl_Group * current()
Returns the currently active group.
Definition: Fl_Group.cxx:84
void row_header(int flag)
Enables/disables showing the row headers.
Definition: Fl_Table.H:655