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;
void col_resize(int flag)
Allows/disallows column resizing by the user.
Definition: Fl_Table.H:610
int row_resize_min()
Returns the current row minimum resize value.
Definition: Fl_Table.H:633
A table of widgets or other content.
Definition: Fl_Table.H:181
Fl_Boxtype table_box(void)
Returns the current box type used for the data table.
Definition: Fl_Table.H:510
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition: Enumerations.H:882
int rows()
Returns the number of rows in the table.
Definition: Fl_Table.H:522
int row_header()
Returns the value of this flag.
Definition: Fl_Table.H:649
int col_header_height()
Gets the column header height.
Definition: Fl_Table.H:692
int callback_col()
Returns the current column the event occurred on.
Definition: Fl_Table.H:943
Fl_Widget * child(int n) const
Returns the child widget by an index.
Definition: Fl_Table.H:906
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:502
void col_header_height(int height)
Sets the height in pixels for column headers and redraws the table.
Definition: Fl_Table.H:683
virtual void clear()
Clears the table to zero rows, zero columns.
Definition: Fl_Table.H:493
int col_header()
Returns if column headers are enabled or not.
Definition: Fl_Table.H:666
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:785
Fl_When
These constants determine when a callback is performed.
Definition: Enumerations.H:305
Fl_Color row_header_color()
Returns the current row header color.
Definition: Fl_Table.H:723
TableContext
The context bit flags for Fl_Table related callbacks (eg.
Definition: Fl_Table.H:186
void row_resize_min(int val)
Sets the current row minimum resize value.
Definition: Fl_Table.H:642
A child needs to be redrawn.
Definition: Enumerations.H:938
Fl_Color col_header_color()
Gets the color for column headers.
Definition: Fl_Table.H:738
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:566
Fl_Boxtype
Definition: Enumerations.H:464
int cols()
Get the number of columns in the table.
Definition: Fl_Table.H:534
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:775
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:45
int is_interactive_resize()
Returns 1 if someone is interactively resizing a row or column.
Definition: Fl_Table.H:577
void row_header_color(Fl_Color val)
Sets the row header color and causes the screen to redraw.
Definition: Fl_Table.H:715
int col_width(int col)
Returns the current width of the specified column in pixels.
Definition: Fl_Table.H:767
int row_position()
Returns the current row scroll position as a row number.
Definition: Fl_Table.H:804
void col_header(int flag)
Enable or disable column headers.
Definition: Fl_Table.H:674
void row_resize(int flag)
Allows/disallows row resizing by the user.
Definition: Fl_Table.H:594
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:440
int col_resize()
Returns the current value of this flag.
Definition: Fl_Table.H:601
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:820
int row_height(int row)
Returns the current height of the specified row as a value in pixels.
Definition: Fl_Table.H:753
void col_header_color(Fl_Color val)
Sets the color for column headers and redraws the table.
Definition: Fl_Table.H:730
int children() const
Returns how many child widgets the group has.
Definition: Fl_Group.H:79
int top_row()
Returns the current top row shown in the table.
Definition: Fl_Table.H:828
int row_header_width()
Returns the current row header width (in pixels).
Definition: Fl_Table.H:708
void col_resize_min(int val)
Returns the current column minimum resize value.
Definition: Fl_Table.H:626
unsigned int Fl_Color
an FLTK color value
Definition: Enumerations.H:769
int children() const
Returns the number of children in the table.
Definition: Fl_Table.H:918
int callback_row()
Returns the current row the event occurred on.
Definition: Fl_Table.H:934
int col_resize_min()
Sets the current column minimum resize value.
Definition: Fl_Table.H:619
int row_resize()
Returns the current value of this flag.
Definition: Fl_Table.H:584
int col_position()
Returns the current column scroll position as a column number.
Definition: Fl_Table.H:811
TableContext callback_context()
Returns the current 'table context'.
Definition: Fl_Table.H:952
void row_header_width(int width)
Sets the row header width to n and causes the screen to redraw.
Definition: Fl_Table.H:699
static Fl_Group * current()
Returns the currently active group.
Definition: Fl_Group.cxx:89
void row_header(int flag)
Enables/disables showing the row headers.
Definition: Fl_Table.H:657