> My main is generated with FLUID and renders a fullscreen window with the
> following code:
Sometimes it can be more useful to state what you are trying to achieve, rather than showing us what you have done.
So; what *are* you trying to achieve with this?
> If the user types a key, I want to display a grid on the fullscreen
> window.
A grid? As in a grid of cells? Or just a Cartesian grid, or...? I guess a grid of entry cells, looking at the code.
> I've cobbled a function from here:
>
http://seriss.com/people/erco/fltk/#CellTable as follows:
Good start... But, um... would an Fl_table not be easier for this sort of thing?
> Fl_Scroll *dbaseGrid;
> Fl_Tile *tile;
> Fl_Box *box;
> Fl_Input *in;
> void *cells;
> void databaseGrid(int rows, int cols, string headers[]){
> void *cell[rows][cols];
> int cellw=64;
> int cellh=32;
> int xx=5;
> int yy=5;
> int w=cellw*cols+cellw;
> int h=cellh*rows+cellw;
> canvas->begin();
> {
> dbaseGrid=new Fl_Scroll(0,0,w,h);
To be honest, once I've made a Fl_Scroll, the first thing I usually do is put an Fl_Group inside it, then parent all the other widgets to that group. Maybe that's just me...
> {
> tile = new Fl_Tile(5, 5, w-10, h-10);
What's the Fl_tile for?
> for(int r=0; r<rows; r++){
> printf("Buck here\n");
> for(int c=0; c<cols;c++){
> if(r==0){
> {
> box = new Fl_Box(xx,yy,cellw,cellh,headers[c].c_str());
> box->box(FL_BORDER_BOX);
> }
> cell[r][c]=(void *)box;
> }else{
> {
> Fl_Input *in = new Fl_Input(xx,yy,cellw,cellh);
> in->box(FL_BORDER_BOX);
> in->value("");
> }
> cell[r][c]=(void *)in;
> }
> xx += cellw;
> }
> xx = 5;
> yy += cellh;
> }
> cells=cell;
> tile->end();
> }
> dbaseGrid->end();
> }// Fl_Tile* dbaseGrid
> canvas->end();
> }
> How can I get my grid to display. I was hoping to add my grid to my
> 'canvas' box, but this hasn't worked.
What does your canvas derive from? We do not know what type an "event_grp" is. I guess if it derives from Fl_Group, then you'd expect to be able to add widgets to that and see them displayed.
> Also, I am cavalierly assuming that my array of void * cells will allow
> me to access the contents of my grid, but I suspect that the integrity
> of the data is suspect once the function ends.
That'll not work; your "void *cell[rows][cols];" goes out of scope when the function exits (the fact that you have assigned it to "cells" makes no difference here) as it will be stack automatic.
So once your function returns, "cells" will be pointing at random data on the stack, which is unlikely to be what you want.
That may be all that is wrong, perhaps?
Also, your "cell" array probably wants to be an array of "Fl_Widget*" rather than of "void*", since that will save casting and etc., and make other things simpler. (Most fltk classes derive from Fl_Widget, to casting them to Fl_Widget is "trivial".)
Selex ES Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************