>
> FWIW, here's a (compilable) test program similar to your
> code snippet I was using to test your issue.
>
> Note the "<--" comment below, as well as the additional
> calls to col_width_all() and row_height_all(), which I'd
> recommend you use, so that the table knows the width/height
> of your child widgets.
>
> -----------------------------------------------------------------
>
> #include <stdio.h>
> #include <FL/Fl.H>
> #include <FL/Fl_Double_Window.H>
> #include <FL/Fl_Button.H>
> #include <FL/Fl_Table.H>
>
> class MyTable : public Fl_Table {
> protected:
> void draw_cell(TableContext context, int R=0, int C=0, int X=0, int Y=0,
> int W=0, int H=0) {
> switch ( context ) {
> case CONTEXT_STARTPAGE:
> break;
> case CONTEXT_RC_RESIZE: {
> int X, Y, W, H;
> int index = 0;
> for ( int r = 0; r<rows(); r++ ) {
> for ( int c = 0; c<cols(); c++ ) {
> if ( index >= children() ) break;
> find_cell(CONTEXT_TABLE, r, c, X, Y, W, H);
> child(index++)->resize(X,Y,W,H);
> }
> }
> init_sizes(); // tell group children resized
> return;
> }
> case CONTEXT_CELL:
> return; // fltk handles drawing the widgets
> default:
> return;
> }
> }
> public:
> MyTable(int x, int y, int w, int h, const char *l=0) : Fl_Table(x,y,w,h,l) {
> end();
> }
> ~MyTable() { }
> };
>
> int main() {
> Fl_Double_Window win(800, 600, "Window");
> win.end();
>
> MyTable *t = new MyTable(400, 0, 400, 600);
> t->end();
> win.add(t);
>
> t->cols(2);
> t->rows(10);
> t->col_width_all(200); // set column widths
> t->row_height_all(25); // set row heights
>
> for ( int c = 0; c < t->cols(); c++ ) {
> for ( int r = 0; r < t->rows(); r++ ) {
> int X,Y,W,H;
> W = t->col_width(c);
> H = t->row_height(r);
> X = t->x() + (c * W);
> Y = t->y() + (r * H);
> Fl_Button *b = new Fl_Button(X, Y, W, H, "Table Widget");
> t->add(b);
> }
> }
> t->show(); // <-- IF ABOVE PATCH IS APPLIED, CAN COMMENT THIS OUT
> win.resizable(t);
> win.show();
> return(Fl::run());
> }
>
Ahh, thanks. It sounds like that might have fixed it. And this is the class I
made:
class MyTable : public Fl_Table
{
public:
MyTable( int x, int y, int w, int h, const char* l = NULL ) : Fl_Table(
x, y, w, h, l )
{
col_resize( 1 );
row_resize( 1 );
};
~MyTable() {};
void cell_dimensions( int r, int c, int &X, int &Y, int &W, int &H )
{
find_cell( CONTEXT_TABLE, r, c, X, Y, W, H );
};
protected:
void draw_cell( TableContext context, int R, int C, int X, int Y, int
W, int H )
{
if ( context == CONTEXT_STARTPAGE )
fl_font( FL_HELVETICA, 12 );
else if ( context == CONTEXT_RC_RESIZE )
{
int X, Y, W, H, index = 0;
for ( int r = 0; r<rows(); r++ )
{
for ( int c = 0; c<cols(); c++ )
{
if ( index >= children() )
break;
find_cell( CONTEXT_TABLE, r, c, X, Y,
W, H );
child( index++ )->resize( X,Y,W,H );
}
}
// tell group children resized
init_sizes();
}
};
};
Is there any reason why find_cell isn't public?
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk