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);