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
215 class FL_EXPORT IntVector {
222 void copy(
int *newarr,
unsigned int newsize) {
224 memcpy(arr, newarr, newsize *
sizeof(
int));
227 IntVector() { init(); }
228 ~IntVector() {
if ( arr ) free(arr); arr = NULL; }
229 IntVector(IntVector&o) { init(); copy(o.arr, o._size); }
230 IntVector& operator=(IntVector&o) {
232 copy(o.arr, o._size);
235 int operator[](
int x)
const {
return(arr[x]); }
236 int& operator[](
int x) {
return(arr[x]); }
237 unsigned int size() {
return(_size); }
238 void size(
unsigned int count) {
239 if ( count != _size ) {
240 arr = (
int*)realloc(arr, count *
sizeof(
int));
244 int pop_back() {
int tmp = arr[_size-1]; _size--;
return(tmp); }
245 void push_back(
int val) {
unsigned int x = _size; size(_size+1); arr[x] = val; }
246 int back() {
return(arr[_size-1]); }
249 IntVector _colwidths;
250 IntVector _rowheights;
255 TableContext _callback_context;
256 int _callback_row, _callback_col;
269 void _redraw_cell(TableContext context,
int R,
int C);
271 void _start_auto_drag();
272 void _stop_auto_drag();
273 void _auto_drag_cb();
274 static void _auto_drag_cb2(
void *d);
280 RESIZE_COL_RIGHT = 2,
281 RESIZE_ROW_ABOVE = 3,
285 int table_w, table_h;
286 int toprow, botrow, leftcol, rightcol;
289 int current_row, current_col;
290 int select_row, select_col;
293 int toprow_scrollpos;
294 int leftcol_scrollpos;
297 int tix, tiy, tiw, tih;
298 int tox, toy, tow, toh;
299 int wix, wiy, wiw, wih;
309 void recalc_dimensions();
310 void table_resized();
311 void table_scrolled();
312 void get_bounds(TableContext context,
313 int &X,
int &Y,
int &W,
int &H);
315 TableContext cursor2rowcol(
int &R,
int &C, ResizeFlag &resizeflag);
317 int find_cell(TableContext context,
318 int R,
int C,
int &X,
int &Y,
int &W,
int &H);
319 int row_col_clamp(TableContext context,
int &R,
int &C);
433 int X=0,
int Y=0,
int W=0,
int H=0)
436 long row_scroll_position(
int row);
437 long col_scroll_position(
int col);
439 int is_fltk_container() {
445 void damage_zone(
int r1,
int c1,
int r2,
int c2,
int r3 = 0,
int c3 = 0);
447 void redraw_range(
int topRow,
int botRow,
int leftCol,
int rightCol) {
448 if ( _redraw_toprow == -1 ) {
450 _redraw_toprow = topRow;
451 _redraw_botrow = botRow;
452 _redraw_leftcol = leftCol;
453 _redraw_rightcol = rightCol;
456 if ( topRow < _redraw_toprow ) _redraw_toprow = topRow;
457 if ( botRow > _redraw_botrow ) _redraw_botrow = botRow;
458 if ( leftCol < _redraw_leftcol ) _redraw_leftcol = leftCol;
459 if ( rightCol > _redraw_rightcol ) _redraw_rightcol = rightCol;
472 Fl_Table(
int X,
int Y,
int W,
int H,
const char *l=0);
485 virtual void clear() { rows(0); cols(0); table->clear(); }
503 return(table->box());
509 virtual void rows(
int val);
521 virtual void cols(
int val);
570 return(_resizing_row != -1 || _resizing_col != -1);
612 return(_col_resize_min);
619 _col_resize_min = ( val < 1 ) ? 1 : val;
626 return(_row_resize_min);
635 _row_resize_min = ( val < 1 ) ? 1 : val;
676 _col_header_h = height;
685 return(_col_header_h);
692 _row_header_w = width;
701 return(_row_header_w);
708 _row_header_color = val;
716 return(_row_header_color);
723 _col_header_color = val;
731 return(_col_header_color);
740 void row_height(
int row,
int height);
746 return((row<0 || row>=(
int)_rowheights.size()) ? 0 : _rowheights[row]);
754 void col_width(
int col,
int width);
760 return((col<0 || col>=(
int)_colwidths.size()) ? 0 : _colwidths[col]);
768 for (
int r=0; r<rows(); r++ ) {
769 row_height(r, height);
778 for (
int c=0; c<cols(); c++ ) {
786 void row_position(
int row);
791 void col_position(
int col);
797 return(_row_position);
804 return(_col_position);
821 return(row_position());
823 int is_selected(
int r,
int c);
824 void get_selection(
int &row_top,
int &col_left,
int &row_bot,
int &col_right);
825 void set_selection(
int row_top,
int col_left,
int row_bot,
int col_right);
826 int move_cursor(
int R,
int C);
831 void resize(
int X,
int Y,
int W,
int H);
852 if ( table->children() > 2 ) {
862 table->insert(wgt,n);
865 table->insert(wgt,w2);
878 if ( table->children() > 2 ) {
886 return(table->array());
904 return(table->child(n));
916 return(table->children()-2);
919 return(table->find(wgt));
922 return(table->find(wgt));
932 return(_callback_row);
941 return(_callback_col);
950 return(_callback_context);
953 void do_callback(TableContext context,
int row,
int col) {
954 _callback_context = context;
1073 #if FLTK_ABI_VERSION >= 10301
1084 int scrollbar_size()
const {
1085 return(_scrollbar_size);
1105 void scrollbar_size(
int newSize) {
1106 if ( newSize != _scrollbar_size ) redraw();
1107 _scrollbar_size = newSize;