Hello,

I have a reasonable amount of experience using various X11-based GUI libraries 
in C++ including FLTK. IMO there is no clear winner for C++, they all seem to 
have their pluses and minuses. FLTK is one of my favourites (I think if I was 
forced to pick a winner it would be GTK at the moment). But I have a problem 
when it comes to GUI programming in java.

I am new to java programming and have just tried using swing.  This business of 
swing will not work unless the graphics calls are made on the event-dispatching 
thread (EDT) is such a PITA. Another related PITA is that one is advised not to 
perform potentially expensive non-GUI work (such as database lookups) in the 
EDT. I have even seen projects to get around this on sourceforge. Then there is 
the competing SWT which uses JNI to wrap X11 calls. I think this is a better 
way to go because I think it is much better to go to X11. You sidestep the 
whole EDT issue and it makes the application automatically networked, it looks 
nice etc etc etc. But SWT has a way to go. So I was wondering, how do people 
feel about using SWIG to wrap FLTK? SWIG is a code generator that generates 
three kinds of output file:

1) a java class with just what you want
2) a java class that implements (1) by calling JNI routines
3) a C++ module that implements the native java calls from (2)

The idea is you create a shared library containing (3), which in the case of 
FLTK would also link in the FLTK routines being wrapped, then your java program 
loads that shared library and calls (1) to do any FLTK work.

SWIG is given an interface file (".i" suffix) which normally contains #include 
directives for the public interfaces to be wrapped. Projects that use SWIG tend 
to have to be a bit careful about the division of labour amonsg their header 
files otherwise nested inclusion can result in SWIG generating unwanted class 
wrappers. So projects that allow themselves to be SWIG'd tend to need some 
work. I have had a brief look at how FLTK is in this respect and some work 
would be required. How useful do people think this would be?

Here is an example of a SWIG interface file for wrapping the routines needed 
for the message test program that comes with FLTK:

%javaconst(1);
%module FlktWrapper
%include "typemaps.i"

%{
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/fl_ask.H>
%}

%include <FL/Fl.H>
%include <FL/Fl_Window.H>
%include <FL/fl_ask.H>

Regards,

Andrew Marlow

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to