1999-01-13 22:28:54 +03:00
|
|
|
<HTML><BODY>
|
|
|
|
<H1 ALIGN=RIGHT><A NAME=forms>E - Forms Compatibility</A></H1>
|
2001-11-29 22:24:00 +03:00
|
|
|
This appendix describes the Forms compatibility included with FLTK.
|
1999-01-07 19:36:11 +03:00
|
|
|
<H2>Importing Forms Layout Files</H2>
|
2001-11-29 22:24:00 +03:00
|
|
|
<A href=fluid.html#FLUID>FLUID</A> can read the .fd files put out by
|
|
|
|
all versions of Forms and XForms fdesign. However, it will mangle them
|
|
|
|
a bit, but it prints a warning message about anything it does not
|
|
|
|
understand. FLUID cannot write fdesign files, so you should save to a
|
|
|
|
new name so you don't write over the old one.
|
|
|
|
<P>You will need to edit your main code considerably to get it to link
|
|
|
|
with the output from FLUID. If you are not interested in this you may
|
1999-01-13 22:28:54 +03:00
|
|
|
have more immediate luck with the forms compatibility header, <TT>
|
|
|
|
<FL/forms.H></TT>. </P>
|
1999-01-07 19:36:11 +03:00
|
|
|
<H2>Using the Compatibility Header File</H2>
|
2001-11-29 22:24:00 +03:00
|
|
|
You should be able to compile existing Forms or XForms source code by
|
1999-01-13 22:28:54 +03:00
|
|
|
changing the include directory switch to your compiler so that the <TT>
|
|
|
|
forms.h</TT> file supplied with FLTK is included. Take a look at <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
forms.h</TT> to see how it works, but the basic trick is lots of inline
|
|
|
|
functions. Most of the XForms demo programs work without changes.
|
|
|
|
<P>You will also have to compile your Forms or XForms program using a
|
|
|
|
C++ compiler. The FLTK library does not provide C bindings or header
|
1999-01-13 22:28:54 +03:00
|
|
|
files. </P>
|
2004-07-27 20:02:21 +04:00
|
|
|
<P>Although FLTK was designed to be compatible with the GL Forms
|
2001-11-29 22:24:00 +03:00
|
|
|
library (version 0.3 or so), XForms has bloated severely and it's
|
|
|
|
interface is X-specific. Therefore, XForms compatibility is no longer
|
|
|
|
a goal of FLTK. Compatibility was limited to things that were free, or
|
|
|
|
that would add code that would not be linked in if the feature is
|
1999-01-13 22:28:54 +03:00
|
|
|
unused, or that was not X-specific. </P>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P>To use any new features of FLTK, you should rewrite your code to not
|
|
|
|
use the inline functions and instead use "pure" FLTK. This will make
|
|
|
|
it a lot cleaner and make it easier to figure out how to call the FLTK
|
|
|
|
functions. Unfortunately this conversion is harder than expected and
|
1999-01-13 22:28:54 +03:00
|
|
|
even Digital Domain's inhouse code still uses <TT>forms.H</TT> a lot. </P>
|
1999-01-13 23:55:40 +03:00
|
|
|
<H2>Problems You Will Encounter</H2>
|
1999-01-13 22:28:54 +03:00
|
|
|
<P>Many parts of XForms use X-specific structures like <TT>XEvent</TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
in their interface. I did not emulate these! Unfortunately these
|
|
|
|
features (such as the "canvas" widget) are needed by most large
|
1999-01-13 22:28:54 +03:00
|
|
|
programs. You will need to rewrite these to use FLTK subclasses. </P>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P><A href=Fl_Free.html#Fl_Free><TT>Fl_Free</TT></A> widgets emulate
|
|
|
|
the <I>old</I> Forms "free" widget. It may be useful for porting
|
|
|
|
programs that change the <TT>handle()</TT> function on widgets, but you
|
1999-01-13 22:28:54 +03:00
|
|
|
will still need to rewrite things. </P>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P><A href=Fl_Timer.html#Fl_Timer><TT>Fl_Timer</TT></A> widgets are
|
|
|
|
provided to emulate the XForms timer. These work, but are quite
|
2002-01-15 05:17:19 +03:00
|
|
|
inefficient and inaccurate compared to using <A href="Fl.html#Fl.add_timeout">
|
1999-01-13 22:28:54 +03:00
|
|
|
<TT>Fl::add_timeout()</TT></A>. </P>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P><I>All instance variables are hidden.</I> If you directly refer to
|
|
|
|
the x, y, w, h, label, or other fields of your Forms widgets you will
|
|
|
|
have to add empty parenthesis after each reference. The easiest way to
|
|
|
|
do this is to globally replace "->x" with "->x()", etc. Replace
|
1999-01-13 22:28:54 +03:00
|
|
|
"boxtype" with "box()". </P>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P><TT>const char *</TT> arguments to most FLTK methods are simply
|
|
|
|
stored, while Forms would <TT>strdup()</TT> the passed string. This is
|
|
|
|
most noticable with the label of widgets. Your program must always
|
1999-01-13 22:28:54 +03:00
|
|
|
pass static data such as a string constant or malloc'd buffer to <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
label()</TT>. If you are using labels to display program output you
|
1999-01-13 22:28:54 +03:00
|
|
|
may want to try the <A href=Fl_Output.html#Fl_Output><TT>Fl_Output</TT></A>
|
|
|
|
widget. </P>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P>The default fonts and sizes are matched to the older GL version of
|
|
|
|
Forms, so all labels will draw somewhat larger than an XForms program
|
1999-01-13 22:28:54 +03:00
|
|
|
does. </P>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P>fdesign outputs a setting of a "fdui" instance variable to the main
|
|
|
|
window. I did not emulate this because I wanted all instance variables
|
1999-01-13 22:28:54 +03:00
|
|
|
to be hidden. You can store the same information in the <TT>user_data()</TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
field of a window. To do this, search through the fdesign output for
|
|
|
|
all occurances of "->fdui" and edit to use "->user_data()" instead.
|
1999-01-13 22:28:54 +03:00
|
|
|
This will require casts and is not trivial. </P>
|
|
|
|
<P>The prototype for the functions passed to <TT>fl_add_timeout()</TT>
|
|
|
|
and <TT>fl_set_idle_callback()</TT> callback are different. </P>
|
|
|
|
<P><B>All the following XForms calls are missing:</B></P>
|
|
|
|
<UL>
|
|
|
|
<LI><TT>FL_REVISION</TT>, <TT>fl_library_version()</TT></LI>
|
|
|
|
<LI><TT>FL_RETURN_DBLCLICK</TT> (use <TT>Fl::event_clicks()</TT>) </LI>
|
|
|
|
<LI><TT>fl_add_signal_callback()</TT></LI>
|
|
|
|
<LI><TT>fl_set_form_atactivate()</TT> <TT>fl_set_form_atdeactivate()</TT>
|
|
|
|
</LI>
|
|
|
|
<LI><TT>fl_set_form_property()</TT></LI>
|
|
|
|
<LI><TT>fl_set_app_mainform()</TT>, <TT>fl_get_app_mainform()</TT></LI>
|
|
|
|
<LI><TT>fl_set_form_minsize()</TT>, <TT>fl_set_form_maxsize()</TT></LI>
|
|
|
|
<LI><TT>fl_set_form_event_cmask()</TT>, <TT>fl_get_form_event_cmask()</TT>
|
|
|
|
</LI>
|
|
|
|
<LI><TT>fl_set_form_dblbuffer()</TT>, <TT>fl_set_object_dblbuffer()</TT>
|
|
|
|
(use an <TT>Fl_Double_Window</TT> instead) </LI>
|
|
|
|
<LI><TT>fl_adjust_form_size()</TT></LI>
|
|
|
|
<LI><TT>fl_register_raw_callback()</TT></LI>
|
|
|
|
<LI><TT>fl_set_object_bw()</TT>, <TT>fl_set_border_width()</TT></LI>
|
|
|
|
<LI><TT>fl_set_object_resize()</TT>, <TT>fl_set_object_gravity()</TT></LI>
|
|
|
|
<LI><TT>fl_set_object_shortcutkey()</TT></LI>
|
|
|
|
<LI><TT>fl_set_object_automatic()</TT></LI>
|
|
|
|
<LI><TT>fl_get_object_bbox()</TT> (maybe FLTK should do this) </LI>
|
|
|
|
<LI><TT>fl_set_object_prehandler()</TT>, <TT>fl_set_object_posthandler()</TT>
|
|
|
|
</LI>
|
|
|
|
<LI><TT>fl_enumerate_fonts()</TT></LI>
|
|
|
|
<LI>Most drawing functions </LI>
|
|
|
|
<LI><TT>fl_set_coordunit()</TT> (FLTK uses pixels all the time) </LI>
|
|
|
|
<LI><TT>fl_ringbell()</TT></LI>
|
|
|
|
<LI><TT>fl_gettime()</TT></LI>
|
|
|
|
<LI><TT>fl_win*()</TT> (all these functions) </LI>
|
|
|
|
<LI><TT>fl_initialize(argc,argv,x,y,z)</TT> ignores last 3 arguments </LI>
|
|
|
|
<LI><TT>fl_read_bitmapfile()</TT>, <TT>fl_read_pixmapfile()</TT></LI>
|
|
|
|
<LI><TT>fl_addto_browser_chars()</TT></LI>
|
|
|
|
<LI><TT>FL_MENU_BUTTON</TT> just draws normally </LI>
|
|
|
|
<LI><TT>fl_set_bitmapbutton_file()</TT>, <TT>fl_set_pixmapbutton_file()</TT>
|
|
|
|
</LI>
|
|
|
|
<LI><TT>FL_CANVAS</TT> objects </LI>
|
|
|
|
<LI><TT>FL_DIGITAL_CLOCK</TT> (comes out analog) </LI>
|
|
|
|
<LI><TT>fl_create_bitmap_cursor()</TT>, <TT>fl_set_cursor_color()</TT></LI>
|
|
|
|
<LI><TT>fl_set_dial_angles()</TT></LI>
|
|
|
|
<LI><TT>fl_show_oneliner()</TT></LI>
|
|
|
|
<LI><TT>fl_set_choice_shortcut(a,b,c) </TT></LI>
|
|
|
|
<LI>command log </LI>
|
|
|
|
<LI>Only some of file selector is emulated </LI>
|
|
|
|
<LI><TT>FL_DATE_INPUT</TT></LI>
|
|
|
|
<LI><TT>fl_pup*()</TT> (all these functions) </LI>
|
|
|
|
<LI>textbox object (should be easy but I had no sample programs) </LI>
|
|
|
|
<LI>xyplot object </LI>
|
|
|
|
</UL>
|
|
|
|
<H2>Additional Notes</H2>
|
2001-11-29 22:24:00 +03:00
|
|
|
These notes were written for porting programs written with the older
|
|
|
|
IRISGL version of Forms. Most of these problems are the same ones
|
|
|
|
encountered when going from old Forms to XForms:
|
1999-01-13 22:28:54 +03:00
|
|
|
<H3>Does Not Run In Background</H3>
|
2001-11-29 22:24:00 +03:00
|
|
|
The IRISGL library always forked when you created the first window,
|
|
|
|
unless "foreground()" was called. FLTK acts like "foreground()" is
|
|
|
|
called all the time. If you really want the fork behavior do "if
|
|
|
|
(fork()) exit(0)" right at the start of your program.
|
1999-01-13 23:55:40 +03:00
|
|
|
<H3>You Cannot Use IRISGL Windows or fl_queue</H3>
|
2001-11-29 22:24:00 +03:00
|
|
|
If a Forms (not XForms) program if you wanted your own window for
|
|
|
|
displaying things you would create a IRISGL window and draw in it,
|
|
|
|
periodically calling Forms to check if the user hit buttons on the
|
|
|
|
panels. If the user did things to the IRISGL window, you would find
|
|
|
|
this out by having the value FL_EVENT returned from the call to Forms.
|
|
|
|
<P>None of this works with FLTK. Nor will it compile, the necessary
|
1999-01-13 22:28:54 +03:00
|
|
|
calls are not in the interface. </P>
|
|
|
|
<P>You have to make a subclass of <A href=Fl_Gl_Window.html#Fl_Gl_Window>
|
|
|
|
<TT>Fl_Gl_Window</TT></A> and write a <TT>draw()</TT> method and <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
handle()</TT> method. This may require anywhere from a trivial to a
|
1999-01-13 22:28:54 +03:00
|
|
|
major rewrite. </P>
|
|
|
|
<P>If you draw into the overlay planes you will have to also write a <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
draw_overlay()</TT> method and call <TT>redraw_overlay()</TT> on the
|
1999-01-13 22:28:54 +03:00
|
|
|
OpenGL window. </P>
|
|
|
|
<P>One easy way to hack your program so it works is to make the <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
draw()</TT> and <TT>handle()</TT> methods on your window set some
|
|
|
|
static variables, storing what event happened. Then in the main loop
|
|
|
|
of your program, call <TT>Fl::wait()</TT> and then check these
|
1999-01-13 22:28:54 +03:00
|
|
|
variables, acting on them as though they are events read from <TT>
|
|
|
|
fl_queue</TT>. </P>
|
|
|
|
<H3>You Must Use OpenGL to Draw Everything</H3>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P>The file <TT><FL/gl.h></TT> defines replacements for a lot of IRISGL
|
|
|
|
calls, translating them to OpenGL. There are much better translators
|
1999-01-13 22:28:54 +03:00
|
|
|
available that you might want to investigate. </P>
|
|
|
|
<H3>You Cannot Make Forms Subclasses</H3>
|
2001-11-29 22:24:00 +03:00
|
|
|
Programs that call <TT>fl_make_object</TT> or directly setting the
|
|
|
|
handle routine will not compile. You have to rewrite them to use a
|
1999-01-13 22:28:54 +03:00
|
|
|
subclass of <TT>Fl_Widget</TT>. It is important to note that the <TT>
|
|
|
|
handle()</TT> method is not exactly the same as the <TT>handle()</TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
function of Forms. Where a Forms <TT>handle()</TT> returned non-zero,
|
1999-01-13 22:28:54 +03:00
|
|
|
your <TT>handle()</TT> must call <TT>do_callback()</TT>. And your <TT>
|
2001-11-29 22:24:00 +03:00
|
|
|
handle()</TT> must return non-zero if it "understood" the event.
|
|
|
|
<P>An attempt has been made to emulate the "free" widget. This appears
|
|
|
|
to work quite well. It may be quicker to modify your subclass into a
|
1999-01-13 22:28:54 +03:00
|
|
|
"free" widget, since the "handle" functions match. </P>
|
2001-11-29 22:24:00 +03:00
|
|
|
<P>If your subclass draws into the overlay you are in trouble and will
|
1999-01-13 22:28:54 +03:00
|
|
|
have to rewrite things a lot. </P>
|
|
|
|
<H3>You Cannot Use <device.h></H3>
|
2001-11-29 22:24:00 +03:00
|
|
|
If you have written your own "free" widgets you will probably get a
|
|
|
|
lot of errors about "getvaluator". You should substitute:
|
2001-05-06 20:25:05 +04:00
|
|
|
<CENTER><TABLE border=1 WIDTH=90% summary="Mapping of Forms valuators to FLTK.">
|
1999-01-13 22:28:54 +03:00
|
|
|
<TR><TH align=center>Forms</TH><TH align=center>FLTK</TH></TR>
|
|
|
|
<TR><TD>MOUSE_X</TD><TD>Fl::event_x_root()</TD></TR>
|
|
|
|
<TR><TD>MOUSE_Y</TD><TD>Fl::event_y_root()</TD></TR>
|
|
|
|
<TR><TD>LEFTSHIFTKEY,RIGHTSHIFTKEY</TD><TD>Fl::event_shift()</TD></TR>
|
|
|
|
<TR><TD>CAPSLOCKKEY</TD><TD>Fl::event_capslock()</TD></TR>
|
|
|
|
<TR><TD>LEFTCTRLKEY,RIGHTCTRLKEY</TD><TD>Fl::event_ctrl()</TD></TR>
|
|
|
|
<TR><TD>LEFTALTKEY,RIGHTALTKEY</TD><TD>Fl::event_alt()</TD></TR>
|
|
|
|
<TR><TD>MOUSE1,RIGHTMOUSE</TD><TD>Fl::event_state()</TD></TR>
|
|
|
|
<TR><TD>MOUSE2,MIDDLEMOUSE</TD><TD>Fl::event_state()</TD></TR>
|
|
|
|
<TR><TD>MOUSE3,LEFTMOUSE</TD><TD>Fl::event_state()</TD></TR>
|
1999-01-15 01:14:01 +03:00
|
|
|
</TABLE></CENTER>
|
2001-11-29 22:24:00 +03:00
|
|
|
Anything else in <TT>getvaluator</TT> and you are on your own...
|
1999-01-13 22:28:54 +03:00
|
|
|
<H3>Font Numbers Are Different</H3>
|
2001-11-29 22:24:00 +03:00
|
|
|
The "style" numbers have been changed because I wanted to insert
|
|
|
|
bold-italic versions of the normal fonts. If you use Times, Courier,
|
|
|
|
or Bookman to display any text you will get a different font out of
|
|
|
|
FLTK. If you are really desperate to fix this use the following code:
|
1999-01-13 22:28:54 +03:00
|
|
|
<UL>
|
|
|
|
<PRE>
|
|
|
|
fl_font_name(3,"*courier-medium-r-no*");
|
|
|
|
fl_font_name(4,"*courier-bold-r-no*");
|
|
|
|
fl_font_name(5,"*courier-medium-o-no*");
|
|
|
|
fl_font_name(6,"*times-medium-r-no*");
|
|
|
|
fl_font_name(7,"*times-bold-r-no*");
|
|
|
|
fl_font_name(8,"*times-medium-i-no*");
|
|
|
|
fl_font_name(9,"*bookman-light-r-no*");
|
|
|
|
fl_font_name(10,"*bookman-demi-r-no*");
|
|
|
|
fl_font_name(11,"*bookman-light-i-no*");
|
|
|
|
</PRE>
|
|
|
|
</UL>
|
1999-01-13 23:55:40 +03:00
|
|
|
</BODY></HTML>
|