Hi all,
I more or less cracked it over the weekend to the point where i can work with
fluid and i got about a weeks work of hand coding into a single days ouput,
magic! i mean hand coding writing and drawing everything from scratch with a
graphics API, FLTK as a whole is superb and i just am chuffed to bits, now that
i can manage FLUID more effectively its just easier again, i estimate my exe
will not be much over 2mb even as debug which is nice also. thanks everybody
for all the great and patient advice received on these pages.
So a couple of things i would appreciate feedback on >
(Working with FLUID throughout)
One bug i got which mystified me and took a fair bit of digging out:
Everything worked perfectly, no issues, then i added a help window, rebuilt and
suddenly, on callback, my start button label (which switches between
start/stop/continue) was 'overwritten', not refreshed correctly so that the
previous label was still visible underneath also, like the label had been
redrawn but the button face had not.
It turned out nothing to do with additional window but that i had also messed
around with different frames and boxes for the button, when it was set to a
different frame the problem occured.
I reset to a 'default' mask, same as the other buttons and the problem stopped.
Would this be system specific? And if so can i expect portability issues even
with 'safer' default buttons on other systems?
The other thing concerned my ability to access callbacks in the derived FLUID
class, or rather, have a button callback execute my callback implementation,
and not the FLUID implementation.
My solution after looking through all the advice i printed out from the forum
was:
//example with one of the widgets used:
//FLUID generated header excerpt
class MainWindow {
public:
MainWindow();
Fl_Window *mainWin;
Fl_Button *startBtn;
//more widgets
//...
static void StartCB(Fl_Widget* wgt, void* v);
virtual void StartCB_i(Fl_Widget* wgt, void* v) {};
//more functions
//....
};
//FLUID cxx file excerpt
MainWindow::MainWindow() {
{ mainWin = new Fl_Window(447, 529, "Wheel Generator");
mainWin->box(FL_EMBOSSED_BOX);
mainWin->labelcolor((Fl_Color)184);
mainWin->user_data((void*)(this));
{ startBtn = new Fl_Button(290, 65, 105, 25, "Start");
startBtn->down_box(FL_THIN_DOWN_BOX);
startBtn->callback((Fl_Callback*)StartCB, (void*)(this));
startBtn->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
startBtn->deactivate();
} // Fl_Button* startBtn
mainWin->end();
} // Fl_Window* mainWin
mainWin->show(); //i actually moved this to a seperate function but takes no
args so seemed pointless
}
//My header file excerpt:
class DataGenerator : public MainWindow
{
public:
//stuff
//....
static void StartCB(Fl_Widget* wgt, void* v);
void StartCB_i(Fl_Widget* wgt, void* v);
//stuff
//....
DataGenerator();
};
//My source excerpts:
DataGenerator::DataGenerator() : MainWindow()
{
//my vars initialised
//no references to MainWindow members are stated
}
//my callback functions:
void DataGenerator::StartCB(Fl_Widget* wgt, void* v)
{
DataGenerator* dg = (DataGenerator*)v;
dg->StartCB_i(wgt, v);
}
void DataGenerator::StartCB_i(Fl_Widget* wgt, void* v)
{
Fl_Button* button = (Fl_Button*)w;
if(state)
{
state = false;
if(startBtn->label() == "Continue")
{
startBtn->label("Stop");
startBtn->redraw();
//other stuff
//other stuff
RunDataGenerator();
}
else
{
startBtn->label("Stop"); //label was previously
initialised to 'Start' in
startBtn->redraw(); //fluid constructor or set as
by functions in the program
//other stuff
//other stuff
RunDataGenerator();
}
}
else
{
state = true;
startBtn->label("Continue");
startBtn->redraw();
}
}
Have i over egged the pudding here? Is there a more recommended or 'safer'
solution?
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk