Hi Folks,
I'm new to fltk, also to c++. I'm trying to make a callback that will
work for all instances of a float input, not just the last one. I'm
trying to put together ideas from the manual, Erco's cheat page and
Robert Arkiletian's tutorial, but I'm at a loss as to how to get it
working. Any assistance would be very much appreciated. The code that
doesn't do what I want it to is below. What I would like is a single
callback that will put the value of each input into output.
Thanks in advance,
Jonathan.
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Output.H>
#include <FL/Fl_Float_Input.H>
#define COLS 8
#define ROWS 16
class Table : public Fl_Scroll
{
public:
Table(int X, int Y, int W, int H, const char*L);
~Table();
Fl_Float_Input *in;
int r, c;
private:
static void in_cb(Fl_Widget*, void*);
inline void in_cb_i();
};
Fl_Double_Window *win;
Fl_Output *out;
Table::Table *table;
Table::Table(int X, int Y, int W, int H, const char*L) : Fl_Scroll(X,Y,W,H,L)
{
int cellw = 60;
int cellh = 20;
int xx = X, yy = Y;
for (r=0; r<ROWS; r++ )
{
for (c=0; c<COLS; c++ )
{
{
in = new Fl_Float_Input(xx,yy,cellw,cellh);
in->box(FL_PLASTIC_UP_BOX);
in->value("0.00");
}
xx += cellw;
}
xx = X;
yy += cellh;
}
in->callback(in_cb, this);
end();
}
Table::~Table(){}
void Table::in_cb(Fl_Widget* o, void* v)
{
((Table*)v)->in_cb_i();
}
void Table::in_cb_i()
{
out->value(in->value());
}
int main()
{
Fl::scheme("plastic");
win = new Fl_Double_Window(480, 380);
table = new Table(0, 0, 480, 320, "");
out = new Fl_Output(200, 340, 80, 20, "");
win->resizable();
win->show();
return(Fl::run());
}
_______________________________________________
fltk mailing list
[EMAIL PROTECTED]
http://lists.easysw.com/mailman/listinfo/fltk