[..]
> Since my callbacks are outside of my classes (I have seen a video where the
> author encapsulated them in the class, but I couldn't compile that way, but
> let's forget about this), which forces my to declare variables globally (or
> in a namespace) and generally clutter up the .cpp source,
[..]
This is sort of a FAQ, I guess. The way many folks cut down on
clutter is to organize things the following way. You end
up having 2 methods for every callback (one static and one
non-static), which is unfortunate, but you avoid the
global state variables that rightly concern you.
class MyClass : publc Fl_SomethingOrOther {
public:
MyClass( ... )
{
// whatever goes here
btn->callback(btn_callback, this);
}
private:
static void btn_callback(Fl_Widget*, void* self)
{
// forward to member function
static_cast<MyClass*>(self)->btn_callback();
}
void btn_callback()
{
// do the work here
}
Fl_Button* btn; // for example
};
HTH,
Stan
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk