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);
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);
886 return(table->
array());
904 return(table->
child(n));
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;
void col_resize(int flag)
Allows/disallows column resizing by the user.
Definition: Fl_Table.H:602
int row_resize_min()
Returns the current row minimum resize value.
Definition: Fl_Table.H:625
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:502
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition: Enumerations.H:888
int rows()
Returns the number of rows in the table.
Definition: Fl_Table.H:514
int row_header()
Returns the value of this flag.
Definition: Fl_Table.H:641
int col_header_height()
Gets the column header height.
Definition: Fl_Table.H:684
int callback_col()
Returns the current column the event occurred on.
Definition: Fl_Table.H:940
Fl_Widget * child(int n) const
Returns the child widget by an index.
Definition: Fl_Table.H:903
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:494
void col_header_height(int height)
Sets the height in pixels for column headers and redraws the table.
Definition: Fl_Table.H:675
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:485
int col_header()
Returns if column headers are enabled or not.
Definition: Fl_Table.H:658
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:777
void remove(int index)
Removes the widget at index from the group but does not delete it.
Definition: Fl_Group.cxx:501
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:715
void init_sizes()
Resets the internal array of widget sizes and positions.
Definition: Fl_Group.cxx:570
TableContext
The context bit flags for Fl_Table related callbacks (eg.
Definition: Fl_Table.H:175
Fl_Widget * child(int n) const
Returns array()[n].
Definition: Fl_Group.H:74
void end()
Exactly the same as current(this->parent()).
Definition: Fl_Group.cxx:75
void row_resize_min(int val)
Sets the current row minimum resize value.
Definition: Fl_Table.H:634
A child needs to be redrawn.
Definition: Enumerations.H:945
Fl_Color col_header_color()
Gets the color for column headers.
Definition: Fl_Table.H:730
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:558
Fl_Boxtype
Definition: Enumerations.H:469
int cols()
Get the number of columns in the table.
Definition: Fl_Table.H:526
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:767
void insert(Fl_Widget &, int i)
The widget is removed from its current group (if any) and then inserted into this group...
Definition: Fl_Group.cxx:456
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:36
int is_interactive_resize()
Returns 1 if someone is interactively resizing a row or column.
Definition: Fl_Table.H:569
void add(Fl_Widget &)
The widget is removed from its current group (if any) and then added to the end of this group...
Definition: Fl_Group.cxx:489
int find(const Fl_Widget *) const
Searches the child array for the widget and returns the index.
Definition: Fl_Group.cxx:52
void row_header_color(Fl_Color val)
Sets the row header color and causes the screen to redraw.
Definition: Fl_Table.H:707
int col_width(int col)
Returns the current width of the specified column in pixels.
Definition: Fl_Table.H:759
int row_position()
Returns the current row scroll position as a row number.
Definition: Fl_Table.H:796
void begin()
Sets the current group so you can build the widget tree by just constructing the widgets.
Definition: Fl_Group.cxx:69
void col_header(int flag)
Enable or disable column headers.
Definition: Fl_Table.H:666
void row_resize(int flag)
Allows/disallows row resizing by the user.
Definition: Fl_Table.H:586
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:432
int col_resize()
Returns the current value of this flag.
Definition: Fl_Table.H:593
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:812
int row_height(int row)
Returns the current height of the specified row as a value in pixels.
Definition: Fl_Table.H:745
void col_header_color(Fl_Color val)
Sets the color for column headers and redraws the table.
Definition: Fl_Table.H:722
int children() const
Returns how many child widgets the group has.
Definition: Fl_Group.H:70
int top_row()
Returns the current top row shown in the table.
Definition: Fl_Table.H:820
int row_header_width()
Returns the current row header width (in pixels).
Definition: Fl_Table.H:700
void col_resize_min(int val)
Returns the current column minimum resize value.
Definition: Fl_Table.H:618
unsigned int Fl_Color
an FLTK color value
Definition: Enumerations.H:774
Fl_Widget *const * array() const
Returns a pointer to the array of children.
Definition: Fl_Group.cxx:44
int children() const
Returns the number of children in the table.
Definition: Fl_Table.H:915
int callback_row()
Returns the current row the event occurred on.
Definition: Fl_Table.H:931
int col_resize_min()
Sets the current column minimum resize value.
Definition: Fl_Table.H:611
int row_resize()
Returns the current value of this flag.
Definition: Fl_Table.H:576
int col_position()
Returns the current column scroll position as a column number.
Definition: Fl_Table.H:803
TableContext callback_context()
Returns the current 'table context'.
Definition: Fl_Table.H:949
void row_header_width(int width)
Sets the row header width to n and causes the screen to redraw.
Definition: Fl_Table.H:691
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:649