From 87dd7f0d23eba5c09e71ec6efeb34c6844f5e95f Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Tue, 29 Dec 1998 14:21:17 +0000 Subject: Revised documentation files. git-svn-id: file:///fltk/svn/fltk/trunk@177 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- documentation/forms.html | 230 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 documentation/forms.html (limited to 'documentation/forms.html') diff --git a/documentation/forms.html b/documentation/forms.html new file mode 100644 index 000000000..1d6614581 --- /dev/null +++ b/documentation/forms.html @@ -0,0 +1,230 @@ + + + +

E - Forms Compatibility

+ +Fluid (the Fast Light User Interface Designer) +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. + +

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 +have more immediate luck with the forms compatability header, +<FL/forms.H>. + +

You should be able to compile existing Forms or XForms source code +by changing the -I switch to your compiler so that the forms.h file +supplied with FLTK is included. Take a look at forms.h to see how it +works, but the basic trick is lots of inline functions. +Most of the XForms demo programs work without changes. + +

Although FLTK was designed to be compatable with the GL Forms library +(version 0.3 or so), XForms has bloated severely and it's interface is +X specific. Therefore, XForms compatability is no longer a goal of +FLTK. Compatability was limited to things that were free, or that +would add code that would not be linked in if the feature is unused. +I did not add anything that would make the FLTK widgets bigger, or that +used X types as arguments. + +

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 I +expeceted and even our inhouse code still uses forms.H a lot. + +

Problems you will encounter

+ + + +

Additional notes for porting old Forms programs

+ +

These notes were written for porting programs written with the +older GL version of Forms. Most of these problems are the same ones +encountered when going from old Forms to XForms: + +

Does not go into background

+ +The GL 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. + +

You cannot use GL windows or fl_queue

+ +

If a Forms (not XForms) program if you wanted your own window for +displaying things you would create a GL 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 GL window, you would find this +out by having the value FL_EVENT returned from the call to Forms. + +

None of this works with FLTK. Nor will it compile, the necessary +calls are not in the interface. + +

You have to make a subclass of Fl_Gl_Window and write a draw() method and +handle() method. This may require anywhere from a trivial to a major +rewrite. See the example program shape.C for +how this is structured. + +

If you draw into the overlay planes you will have to also write a +draw_overlay() routine and call redraw_overlay() on the gl window. + +

One easy way to hack your program so it works is to make the draw() +and handle() methods on your window set some static variables, storing +what event happened. Then in the main loop of your program, call +Fl::wait() and then check these variables, acting on them as +though they are events read from fl_queue. + +

You must use OpenGL to draw everything

+ +

The file <FL/gl.h> defines replacements for a lot of gl calls, +translating them to OpenGL. There are much better translators +available that you might want to investigate. + +

You cannot make Forms subclasses

+ +Programs that call fl_make_object or directly setting the handle +routine will not compile. You have to rewrite them to use a subclass +of Fl_Widget. It is important to note that the handle() method is not +exactly the same as the handle() function of Forms. Where a Forms +handle() returned non-zero, your handle() must call do_callback(). +And your handle() must return non-zero if it "understood" the event. + +

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 "free" widget, since the "handle" functions match. + +

If your subclass draws into the overlay you are in trouble and will +have to rewrite things a lot. + +

You cannot use <device.h>

+ +If you have written your own "free" widgets you will probably get a +lot of errors about "getvaluator". You should substitute: + + +
Forms FLTK +
MOUSE_X Fl::event_x_root() +
MOUSE_Y Fl::event_y_root() +
LEFTSHIFTKEY,RIGHTSHIFTKEY Fl::event_shift() +
CAPSLOCKKEY Fl::event_capslock() +
LEFTCTRLKEY,RIGHTCTRLKEY Fl::event_ctrl() +
LEFTALTKEY,RIGHTALTKEY Fl::event_alt() +
MOUSE1,RIGHTMOUSE Fl::event_state()&(1<<10) +
MOUSE2,MIDDLEMOUSE Fl::event_state()&(1<<9) +
MOUSE3,LEFTMOUSE Fl::event_state()&(1<<8) +
+ +

Anything else in getvaluator and you are on your own... + +

Font numbers are different

+ +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: + + + -- cgit v1.2.3