// Find X/Y/W/H for cell at R/C // If R or C are out of range, returns -1 // with X/Y/W/H set to zero. // int Fl_Table_Copy::find_cell(TableContext context, int R, int C, int &X, int &Y, int &W, int &H) { if ( row_col_clamp(context, R, C) ) { // row or col out of range? error X=Y=W=H=0; return(-1); } X = col_scroll_position(C) - hscrollbar->value() + tix; Y = row_scroll_position(R) - vscrollbar->value() + tiy; W = col_width(C); H = row_height(R); switch ( context ) { case CONTEXT_COL_HEADER: Y = wiy; H = col_header_height(); return(0); case CONTEXT_ROW_HEADER: X = wix; W = row_header_width(); return(0); case CONTEXT_CELL: return(0); case CONTEXT_TABLE: return(0); // TODO -- HANDLE OTHER CONTEXTS default: fprintf(stderr, "Fl_Table_Copy::find_cell: unknown context %d\n", (int)context); return(-1); } //NOTREACHED }
// Table resized: recalc internal data // Call this whenever the window is resized. // Recalculates the scrollbar sizes. // Makes no assumptions about any pre-initialized data. // void Fl_Table_Copy::table_resized() { table_h = row_scroll_position(rows()); table_w = col_scroll_position(cols()); recalc_dimensions(); // Recalc scrollbar sizes // Clamp scrollbar value() after a resize. // Resize scrollbars to enforce a constant trough width after a window resize. // { // Vertical scrollbar float vscrolltab = ( table_h == 0 || tih > table_h ) ? 1 : (float)tih / table_h; float hscrolltab = ( table_w == 0 || tiw > table_w ) ? 1 : (float)tiw / table_w; #if FLTK_ABI_VERSION >= 10301 // NEW int scrollsize = _scrollbar_size ? _scrollbar_size : Fl::scrollbar_size(); #else // OLD int scrollsize = Fl::scrollbar_size(); #endif //if( _showVScrollbar ) { vscrollbar->bounds(0, table_h-tih); vscrollbar->precision(10); vscrollbar->slider_size(vscrolltab); vscrollbar->resize(wix+wiw-scrollsize, wiy, scrollsize, wih - ((hscrollbar->visible())?scrollsize:0)); vscrollbar->Fl_Valuator::value(vscrollbar->clamp(vscrollbar->value())); /*} else { vscrollbar->bounds(0, 0); vscrollbar->resize(wix+wiw, wiy, 0, 0 ); }*/ // Horizontal scrollbar hscrollbar->bounds(0, table_w-tiw); hscrollbar->precision(10); hscrollbar->slider_size(hscrolltab); hscrollbar->resize(wix, wiy+wih-scrollsize, wiw - ((vscrollbar->visible())?scrollsize:0), scrollsize); hscrollbar->Fl_Valuator::value(hscrollbar->clamp(hscrollbar->value())); } // Tell FLTK child widgets were resized Fl_Group::init_sizes(); // Recalc top/bot/left/right table_scrolled(); // DO *NOT* REDRAW -- LEAVE THIS UP TO THE CALLER // redraw(); }
// Scroll display so 'row' is at top void Fl_Table_Copy::row_position(int row) { if ( _row_position == row ) return; // OPTIMIZATION: no change? avoid redraw if ( row < 0 ) row = 0; else if ( row >= rows() ) row = rows() - 1; if ( table_h <= tih ) return; // don't scroll if table smaller than window double newtop = row_scroll_position(row); if ( newtop > vscrollbar->maximum() ) { newtop = vscrollbar->maximum(); } vscrollbar->Fl_Slider::value(newtop); table_scrolled(); redraw(); _row_position = row; // HACK: override what table_scrolled() came up with }
// Table resized: recalc internal data // Call this whenever the window is resized. // Recalculates the scrollbar sizes. // Makes no assumptions about any pre-initialized data. // void Fl_Table::table_resized() { table_h = row_scroll_position(rows()); table_w = col_scroll_position(cols()); recalc_dimensions(); // Recalc scrollbar sizes // Clamp scrollbar value() after a resize. // Resize scrollbars to enforce a constant trough width after a window resize. // { float vscrolltab = ( table_h == 0 || tih > table_h ) ? 1 : (float)tih / table_h; float hscrolltab = ( table_w == 0 || tiw > table_w ) ? 1 : (float)tiw / table_w; vscrollbar->bounds(0, table_h-tih); vscrollbar->precision(10); vscrollbar->slider_size(vscrolltab); vscrollbar->resize(wix+wiw-SCROLLBAR_SIZE, wiy, SCROLLBAR_SIZE, wih - ((hscrollbar->visible())?SCROLLBAR_SIZE:0)); vscrollbar->Fl_Valuator::value(vscrollbar->clamp(vscrollbar->value())); hscrollbar->bounds(0, table_w-tiw); hscrollbar->precision(10); hscrollbar->slider_size(hscrolltab); hscrollbar->resize(wix, wiy+wih-SCROLLBAR_SIZE, wiw - ((vscrollbar->visible())?SCROLLBAR_SIZE:0), SCROLLBAR_SIZE); hscrollbar->Fl_Valuator::value(hscrollbar->clamp(hscrollbar->value())); } // Tell FLTK child widgets were resized Fl_Group::init_sizes(); // Recalc top/bot/left/right table_scrolled(); // DO *NOT* REDRAW -- LEAVE THIS UP TO THE CALLER // redraw(); }