FltkCallback++

What FC++ is?

FltkCallback++ (FC++) is small add on to fltk which enables you to use nonstatic member functions as callbacks. With this add-on your code will be much nicer and understandable. You can now pass as callback following functions and member functions:

Offcorse FC++ is compatible with fltk callbacks so you will not need to change your current code.

Word about beckcompatibility between FC++-0.1.0 and FC++-0.0.x

FC++0.1.0 is not beckcompatible with FC++0.0.x. There are many reasons for that and the main is that as add-on not complete new fltk callback system there is no need for all features FC++0.0.x have. I mainly think here on number of supported function and member functions types. Now we have much simpler FC++ with same possibilities so I think that this is direction FC++ should go.

Releases

Current

0.1.0

FltkCallback++0.1.0.tar.gz - see README.fc for release changes and installation info. It works with fltk-1.1.0rc3.

Old

0.0.x

See FltkCallback-0.0.x web page.

Documentation

Note: This only refers to FC++-0.1.0 or newer.

You create callback as normal fltk callback but using fl_create_callback function. For example:

 w->callback(fl_create_callback(object, &class::method));

As you can use normal nonstatic function members you can use class data members in your callback which is much simpler and more OO.

Here are fl_create_callback function definitions:

Fl_Callback_ *fl_create_callback(Fl_Global_Function_St::func g_func);

Fl_Callback_ *fl_create_callback(Fl_Global_Function::func g_func);

template <typename c>
Fl_Callback_ *fl_create_callback(c &obj, Fl_Member_Function_St::member m_func){
        return new Fl_Member_Function_St(obj, m_func);
}

template <typename c>
Fl_Callback_ *fl_create_callback(c &obj, Fl_Member_Function::member m_func){
        return new Fl_Member_Function(obj, m_func);
}

For more information on FC++ usage check examples in test directory (fctest1, fctest2 and fctest3)