34 #include <sys/types.h>
43 #include <FL/Fl_Group.H>
44 #include <FL/Fl_Scroll.H>
45 #include <FL/Fl_Box.H>
46 #include <FL/Fl_Scrollbar.H>
188 CONTEXT_STARTPAGE = 0x01,
189 CONTEXT_ENDPAGE = 0x02,
190 CONTEXT_ROW_HEADER = 0x04,
191 CONTEXT_COL_HEADER = 0x08,
193 CONTEXT_TABLE = 0x20,
194 CONTEXT_RC_RESIZE = 0x40
215 int _redraw_rightcol;
223 class FL_EXPORT IntVector {
230 void copy(
int *newarr,
unsigned int newsize) {
232 memcpy(arr, newarr, newsize *
sizeof(
int));
235 IntVector() { init(); }
236 ~IntVector() {
if ( arr ) free(arr); arr = NULL; }
237 IntVector(IntVector&o) { init(); copy(o.arr, o._size); }
238 IntVector& operator=(IntVector&o) {
240 copy(o.arr, o._size);
243 int operator[](
int x)
const {
return(arr[x]); }
244 int& operator[](
int x) {
return(arr[x]); }
245 unsigned int size() {
return(_size); }
246 void size(
unsigned int count) {
247 if ( count != _size ) {
248 arr = (
int*)realloc(arr, count *
sizeof(
int));
252 int pop_back() {
int tmp = arr[_size-1]; _size--;
return(tmp); }
253 void push_back(
int val) {
unsigned int x = _size; size(_size+1); arr[x] = val; }
254 int back() {
return(arr[_size-1]); }
257 IntVector _colwidths;
258 IntVector _rowheights;
263 TableContext _callback_context;
264 int _callback_row, _callback_col;
277 void _redraw_cell(TableContext context,
int R,
int C);
279 void _start_auto_drag();
280 void _stop_auto_drag();
281 void _auto_drag_cb();
282 static void _auto_drag_cb2(
void *d);
288 RESIZE_COL_RIGHT = 2,
289 RESIZE_ROW_ABOVE = 3,
293 int table_w, table_h;
294 int toprow, botrow, leftcol, rightcol;
297 int current_row, current_col;
298 int select_row, select_col;
301 int toprow_scrollpos;
302 int leftcol_scrollpos;
305 int tix, tiy, tiw, tih;
306 int tox, toy, tow, toh;
307 int wix, wiy, wiw, wih;
317 void recalc_dimensions();
318 void table_resized();
319 void table_scrolled();
320 void get_bounds(TableContext context,
321 int &X,
int &Y,
int &W,
int &H);
323 TableContext cursor2rowcol(
int &R,
int &C, ResizeFlag &resizeflag);
325 int find_cell(TableContext context,
326 int R,
int C,
int &X,
int &Y,
int &W,
int &H);
327 int row_col_clamp(TableContext context,
int &R,
int &C);
441 int X=0,
int Y=0,
int W=0,
int H=0)
444 long row_scroll_position(
int row);
445 long col_scroll_position(
int col);
447 int is_fltk_container() {
453 void damage_zone(
int r1,
int c1,
int r2,
int c2,
int r3 = 0,
int c3 = 0);
455 void redraw_range(
int toprow,
int botrow,
int leftcol,
int rightcol) {
456 if ( _redraw_toprow == -1 ) {
458 _redraw_toprow = toprow;
459 _redraw_botrow = botrow;
460 _redraw_leftcol = leftcol;
461 _redraw_rightcol = rightcol;
464 if ( toprow < _redraw_toprow ) _redraw_toprow = toprow;
465 if ( botrow > _redraw_botrow ) _redraw_botrow = botrow;
466 if ( leftcol < _redraw_leftcol ) _redraw_leftcol = leftcol;
467 if ( rightcol > _redraw_rightcol ) _redraw_rightcol = rightcol;
480 Fl_Table(
int X,
int Y,
int W,
int H,
const char *l=0);
493 virtual void clear() { rows(0); cols(0); }
511 return(table->box());
517 virtual void rows(
int val);
529 virtual void cols(
int val);
578 return(_resizing_row != -1 || _resizing_col != -1);
620 return(_col_resize_min);
627 _col_resize_min = ( val < 1 ) ? 1 : val;
634 return(_row_resize_min);
643 _row_resize_min = ( val < 1 ) ? 1 : val;
684 _col_header_h = height;
693 return(_col_header_h);
700 _row_header_w = width;
709 return(_row_header_w);
716 _row_header_color = val;
724 return(_row_header_color);
731 _col_header_color = val;
739 return(_col_header_color);
748 void row_height(
int row,
int height);
754 return((row<0 || row>=(
int)_rowheights.size()) ? 0 : _rowheights[row]);
762 void col_width(
int col,
int width);
768 return((col<0 || col>=(
int)_colwidths.size()) ? 0 : _colwidths[col]);
776 for (
int r=0; r<rows(); r++ ) {
777 row_height(r, height);
786 for (
int c=0; c<cols(); c++ ) {
794 void row_position(
int row);
799 void col_position(
int col);
805 return(_row_position);
812 return(_col_position);
829 return(row_position());
831 int is_selected(
int r,
int c);
832 void get_selection(
int &row_top,
int &col_left,
int &row_bot,
int &col_right);
833 void set_selection(
int row_top,
int col_left,
int row_bot,
int col_right);
834 int move_cursor(
int R,
int C);
839 void resize(
int X,
int Y,
int W,
int H);
881 if ( table->children() > 2 ) {
889 return(table->array());
907 return(table->child(n));
919 return(table->children()-2);
922 return(table->find(w));
925 return(table->find(w));
935 return(_callback_row);
944 return(_callback_col);
953 return(_callback_context);
956 void do_callback(TableContext context,
int row,
int col) {
957 _callback_context = context;