fltk/forms.h File Reference


Defines

#define FALSE
#define FL_ALIGN_BESIDE
#define FL_AUTO
#define FL_BOLD_STYLE
#define FL_BOLDITALIC_STYLE
#define FL_BOTTOM_BCOL
#define FL_BOUND_WIDTH
#define fl_calloc
#define FL_CANCEL
#define FL_CLOSE
#define FL_CMD_OPT
#define FL_COL1
#define FL_DARKCYAN
#define FL_DARKGOLD
#define FL_DARKTOMATO
#define FL_DEFAULT_CURSOR
#define FL_DEFAULT_FONT
#define FL_DEFAULT_SIZE
#define FL_DIAL_COL1
#define FL_DIAL_COL2
#define FL_DROPLIST_CHOICE
#define FL_EMBOSSED_STYLE
#define FL_ENGRAVED_STYLE
#define FL_FIXED_STYLE
#define FL_FIXEDBOLD_STYLE
#define FL_FIXEDBOLDITALIC_STYLE
#define FL_FIXEDITALIC_STYLE
#define fl_free
#define FL_FREE_COL1
#define FL_FREE_COL10
#define FL_FREE_COL11
#define FL_FREE_COL12
#define FL_FREE_COL13
#define FL_FREE_COL14
#define FL_FREE_COL15
#define FL_FREE_COL16
#define FL_FREE_COL2
#define FL_FREE_COL3
#define FL_FREE_COL4
#define FL_FREE_COL5
#define FL_FREE_COL6
#define FL_FREE_COL7
#define FL_FREE_COL8
#define FL_FREE_COL9
#define FL_HIDDEN_RET_BUTTON
#define FL_HOR_BROWSER_SLIDER
#define FL_HUGE_FONT
#define FL_HUGE_SIZE
#define FL_IGNORE
#define FL_INACTIVE
#define FL_INACTIVE_COL
#define FL_INDIANRED
#define FL_INOUT_BUTTON
#define FL_INVALID
#define FL_INVALID_STYLE
#define FL_INVISIBLE_CURSOR
#define FL_ITALIC_STYLE
#define FL_LARGE_FONT
#define FL_LARGE_SIZE
#define FL_LCOL
#define FL_LEFT_BCOL
#define FL_LEFTMOUSE
#define fl_malloc
#define FL_MBUTTON1
#define FL_MBUTTON2
#define FL_MBUTTON3
#define FL_MBUTTON4
#define FL_MBUTTON5
#define FL_MCOL
#define FL_MEDIUM_FONT
#define FL_MEDIUM_SIZE
#define FL_MENU_BUTTON
#define FL_MIDDLEMOUSE
#define fl_mousebutton
#define FL_NO_FRAME
#define FL_NONE
#define FL_NORMAL_BITMAP
#define FL_NORMAL_BUTTON
#define FL_NORMAL_CHOICE
#define FL_NORMAL_CHOICE2
#define FL_NORMAL_FONT
#define FL_NORMAL_FONT1
#define FL_NORMAL_FONT2
#define FL_NORMAL_PIXMAP
#define FL_NORMAL_POSITIONER
#define FL_NORMAL_SIZE
#define FL_NORMAL_STYLE
#define FL_NORMAL_TEXT
#define FL_OFF
#define FL_OK
#define FL_ON
#define FL_ORCHID
#define FL_OVAL3D_DOWNBOX
#define FL_OVAL3D_UPBOX
#define FL_PALEGREEN
#define FL_PLACE_CENTERFREE
#define FL_PLACE_FREE_CENTER
#define FL_PREEMPT
#define fl_prepare_form_window
#define FL_PULLDOWN_MENU
#define FL_PUP_INACTIVE
#define FL_PUP_TOGGLE
#define FL_PUSH_BUTTON
#define FL_PUSH_MENU
#define fl_realloc
#define FL_RETURN_ALWAYS
#define FL_RETURN_BUTTON
#define FL_RETURN_CHANGED
#define FL_RETURN_END
#define FL_RETURN_END_CHANGED
#define FL_RIGHT_BCOL
#define FL_RIGHTMOUSE
#define FL_ROUNDED3D_DOWNBOX
#define FL_ROUNDED3D_UPBOX
#define fl_set_button_shortcut
#define fl_set_call_back
#define fl_set_chart_lcol
#define fl_set_clipping(x, y, w, h)
#define fl_set_form_call_back
#define fl_set_initial_placement
#define fl_set_object_align
#define fl_set_object_focus
#define fl_set_object_lcolor
#define FL_SHADOW_STYLE
#define fl_show_messages
#define FL_SLATEBLUE
#define FL_SLIDER_COL1
#define FL_SMALL_FONT
#define FL_SMALL_SIZE
#define FL_TIMES_STYLE
#define FL_TIMESBOLD_STYLE
#define FL_TIMESBOLDITALIC_STYLE
#define FL_TIMESITALIC_STYLE
#define FL_TINY_FONT
#define FL_TINY_SIZE
#define FL_TOMATO
#define FL_TOP_BCOL
#define FL_TOUCH_BUTTON
#define FL_TOUCH_MENU
#define fl_unset_clipping()
#define FL_VALID
#define FL_VERT_BROWSER_SLIDER
#define FL_WHEAT
#define FL_WHEN_NEEDED
#define forms_constructor(type, name)
#define forms_constructorb(type, name)
#define forms_constructort(type, name)
#define NULL
#define resizebox
#define TRUE

Typedefs

typedef int FL_COLOR
typedef int FL_Coord
typedef Fl_Window FL_FORM
typedef void(* FL_IO_CALLBACK )(int, void *)
typedef Fl_Widget FL_OBJECT
typedef void(* Forms_CB )(Fl_Widget *, long)
typedef void(* Forms_FormCB )(Fl_Widget *)

Enumerations

enum  {
  FL_PLACE_FREE, FL_PLACE_MOUSE, FL_PLACE_CENTER, FL_PLACE_POSITION,
  FL_PLACE_SIZE, FL_PLACE_GEOMETRY, FL_PLACE_ASPECT, FL_PLACE_FULLSCREEN,
  FL_PLACE_HOTSPOT, FL_PLACE_ICONIC, FL_FREE_SIZE, FL_FIX_SIZE
}
enum  { FL_NOBORDER, FL_FULLBORDER, FL_TRANSIENT }

Functions

int do_matching (char *a, const char *b)
void fl_activate_all_forms ()
void fl_activate_form (Fl_Window *w)
void fl_activate_object (Fl_Widget *o)
fl_add_roundbutton
fl_add_checkbutton Fl_Widget * 
fl_add_bitmapbutton (int t, int x, int y, int w, int h, const char *l)
Fl_Button * fl_add_button (uchar t, int x, int y, int w, int h, const char *l)
void fl_add_chart_value (Fl_Widget *o, double v, const char *s, uchar c)
void fl_add_io_callback (int fd, short w, FL_IO_CALLBACK cb, void *v)
Fl_Widget * fl_add_new (uchar t, Fl_Widget *p)
Fl_Widget * fl_add_new (Fl_Widget *p)
void fl_add_object (Fl_Window *f, Fl_Widget *x)
Fl_Widget * fl_add_pixmapbutton (int t, int x, int y, int w, int h, const char *l)
void fl_add_timeout (long msec, void(*cb)(void *), void *v)
void fl_addto_choice (Fl_Widget *o, const char *s)
void fl_addto_form (Fl_Window *f)
void fl_addto_group (Fl_Widget *o)
void fl_adjust_form_size (Fl_Window *)
Fl_Window * fl_bgn_form (Fl_Boxtype b, int w, int h)
Fl_Group * fl_bgn_group ()
void fl_call_object_callback (Fl_Widget *o)
Fl_Widget * fl_check_forms ()
Fl_Widget * fl_check_only_forms (void)
void fl_deactivate_all_forms ()
void fl_deactivate_form (Fl_Window *w)
void fl_deactivate_object (Fl_Widget *o)
void fl_delete_choice (Fl_Widget *o, int i)
void fl_delete_object (Fl_Widget *o)
void fl_deselect_browser (Fl_Widget *o)
void fl_deselect_browser_line (Fl_Widget *o, int n)
Fl_Widget * fl_do_forms (void)
Fl_Widget * fl_do_only_forms (void)
int fl_double_click ()
void fl_draw ()
void fl_drw_text (Fl_Align align, int x, int y, int w, int h, Fl_Color fgcolor, int size, Fl_Font style, const char *s)
void fl_drw_text_beside (Fl_Align align, int x, int y, int w, int h, Fl_Color fgcolor, int size, Fl_Font style, const char *s)
void fl_end_form ()
void fl_end_group ()
void fl_finish ()
void fl_flip_yorigin ()
int fl_form_is_visible (Fl_Window *f)
void fl_free_form (Fl_Window *x)
void fl_free_object (Fl_Widget *x)
void fl_freeze_all_forms ()
void fl_freeze_form (Fl_Window *)
void fl_freeze_object (Fl_Widget *)
int fl_get_border_width ()
int fl_get_browser (Fl_Widget *o)
int fl_get_browser_maxline (Fl_Widget *o)
int fl_get_browser_topline (Fl_Widget *o)
int fl_get_button (Fl_Widget *b)
int fl_get_button_numb (Fl_Widget *)
int fl_get_choice (Fl_Widget *o)
const char * fl_get_choice_text (Fl_Widget *o)
char * fl_get_directory ()
char * fl_get_filename ()
void fl_get_object_geometry (Fl_Widget *o, int *x, int *y, int *w, int *h)
void fl_get_object_position (Fl_Widget *o, int *x, int *y)
char * fl_get_pattern ()
double fl_get_timer (Fl_Widget *o)
void fl_gettime (long *sec, long *usec)
void fl_hide_form (Fl_Window *f)
void fl_hide_object (Fl_Widget *o)
void fl_init ()
void fl_initialize (int *, char *[], const char *, FL_CMD_OPT *, int)
void fl_insert_chart_value (Fl_Widget *o, int i, double v, const char *s, uchar c)
void fl_insert_object (Fl_Widget *o, Fl_Widget *b)
int fl_isdisplayed_browser_line (Fl_Widget *o, int n)
int fl_isselected_browser_line (Fl_Widget *o, int n)
void fl_mapcolor (Fl_Color c, uchar r, uchar g, uchar b)
int fl_mouse_button ()
Fl_Window * FL_ObjWin (Fl_Widget *o)
void fl_pop_form (Fl_Window *f)
void fl_raise_form (Fl_Window *f)
void fl_redraw_form (Fl_Window *f)
void fl_redraw_object (Fl_Widget *o)
void fl_remove_io_callback (int fd, short, FL_IO_CALLBACK)
void fl_remove_timeout (int)
void fl_replace_chart_value (Fl_Widget *o, int i, double v, const char *s, uchar c)
void fl_replace_choice (Fl_Widget *o, int i, const char *s)
void fl_reset_focus_object (Fl_Widget *o)
void fl_resume_timer (Fl_Widget *o)
void fl_scale_form (Fl_Window *f, double x, double y)
void fl_select_browser_line (Fl_Widget *o, int n)
void fl_set_bitmapbutton_data (Fl_Widget *o, int a, int b, uchar *c)
void fl_set_border_width (int)
void fl_set_browser_fontsize (Fl_Widget *o, int s)
void fl_set_browser_fontstyle (Fl_Widget *o, int s)
void fl_set_browser_specialkey (Fl_Widget *o, char c)
void fl_set_browser_topline (Fl_Widget *o, int n)
void fl_set_button (Fl_Widget *b, int v)
void fl_set_chart_autosize (Fl_Widget *o, int v)
void fl_set_chart_bounds (Fl_Widget *o, double a, double b)
void fl_set_chart_lcolor (Fl_Widget *o, unsigned v)
void fl_set_chart_lsize (Fl_Widget *o, int v)
void fl_set_chart_lstyle (Fl_Widget *o, Fl_Font v)
void fl_set_chart_maxnumb (Fl_Widget *o, int v)
void fl_set_choice (Fl_Widget *o, int i)
void fl_set_choice_fontsize (Fl_Widget *o, int x)
void fl_set_choice_fontstyle (Fl_Widget *o, Fl_Font x)
void fl_set_focus_object (Fl_Window *, Fl_Widget *o)
void fl_set_form_callback (Fl_Window *f, Forms_FormCB c)
void fl_set_form_dblbuffer (Fl_Window *, int)
void fl_set_form_geometry (Fl_Window *f, int x, int y, int w, int h)
void fl_set_form_hotobject (Fl_Window *w, Fl_Widget *o)
void fl_set_form_hotspot (Fl_Window *w, int x, int y)
void fl_set_form_position (Fl_Window *f, int x, int y)
void fl_set_form_size (Fl_Window *f, int w, int h)
void fl_set_form_title (Fl_Window *f, const char *s)
void fl_set_goodies_font (int a, unsigned b)
void fl_set_graphics_mode (int r, int)
void fl_set_idle_callback (void(*cb)())
void fl_set_object_boxtype (Fl_Widget *o, Fl_Boxtype a)
void fl_set_object_callback (Fl_Widget *o, Forms_CB c, long a)
void fl_set_object_color (Fl_Widget *o, unsigned a, unsigned b)
void fl_set_object_dblbuffer (Fl_Widget *, int)
void fl_set_object_geometry (Fl_Widget *o, int x, int y, int w, int h)
void fl_set_object_label (Fl_Widget *o, const char *a)
void fl_set_object_lalign (Fl_Widget *o, Fl_Align a)
void fl_set_object_lcol (Fl_Widget *o, unsigned a)
void fl_set_object_lsize (Fl_Widget *o, int s)
void fl_set_object_lstyle (Fl_Widget *o, int a)
void fl_set_object_position (Fl_Widget *o, int x, int y)
void fl_set_object_return (Fl_Widget *o, int v)
void fl_set_object_shortcut (Fl_Widget *b, const char *s, int=0)
void fl_set_object_size (Fl_Widget *o, int w, int h)
void fl_set_pixmapbutton_data (Fl_Widget *o, const char *const *c)
fl_add_timer void fl_set_timer (Fl_Widget *o, double v)
void fl_set_timer_countup (Fl_Widget *o, char d)
void fl_setdisplayed_browser_line (Fl_Widget *o, int n, int i)
void fl_show_alert (const char *, const char *, const char *, int=0)
int fl_show_choice (const char *m1, const char *m2, const char *m3, int numb, const char *b0, const char *b1, const char *b2)
int fl_show_choices (const char *c, int n, const char *b1, const char *b2, const char *b3, int)
char * fl_show_file_selector (const char *message, const char *dir, const char *pat, const char *fname)
void fl_show_form (Fl_Window *f, int p, int b, const char *n)
void fl_show_form_window (Fl_Window *)
const char * fl_show_input (const char *l, const char *d=0)
void fl_show_object (Fl_Widget *o)
int fl_show_question (const char *, const char *, const char *)
char * fl_show_simple_input (const char *label, const char *deflt=0)
void fl_suspend_timer (Fl_Widget *o)
void fl_title_form (Fl_Window *f, const char *s)
void fl_trigger_object (Fl_Widget *o)
void fl_unfreeze_all_forms ()
void fl_unfreeze_form (Fl_Window *)
void fl_unfreeze_object (Fl_Widget *)
 forms_constructor (Fl_Input, fl_add_input) inline void fl_set_input(Fl_Widget *o
 forms_constructor (Fl_Clock, fl_add_clock) inline void fl_get_clock(Fl_Widget *o
 forms_constructor (Fl_Choice, fl_add_choice) inline void fl_clear_choice(Fl_Widget *o)
 forms_constructor (Fl_Chart, fl_add_chart) inline void fl_clear_chart(Fl_Widget *o)
fl_add_roundbutton forms_constructor (Fl_Round_Button, fl_add_round3dbutton) forms_constructor(Fl_Check_Button
 forms_constructor (Fl_Light_Button, fl_add_lightbutton) forms_constructor(Fl_Round_Button
 forms_constructorb (Fl_FormsText, fl_add_text) forms_constructort(Fl_Timer
 forms_constructorb (Fl_FormsBitmap, fl_add_bitmap) inline void fl_set_bitmap_data(Fl_Widget *o

Variables

char fl_flip
char fl_modal_next
int int h
int int * m
int w

Detailed Description

This file provides Forms compatibility in FLTK 2.0. This documentation is old and may be inaccurate.

Forms was a popular GUI library on SGI machines before they switched to using X (they used to be GL only, actually a lot more powerful and useful than X or Win32 is today...). It was created by Mark Overmars at ???. X-Forms is a rewrite to work atop X, but unlike Forms it was not distributed as Open Source. Much of FLTK's terminology and widget design is based on and directly descended from Forms.

Importing Forms Layout Files

Fluid 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 compatibility header, <FL/forms.h>.

Using the Compatibility Header File

You should be able to compile existing Forms or XForms source code by changing the include directory 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.

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 files.

Although FLTK was designed to be compatible with the GL Forms 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 unused, or that was not X-specific.

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 even Digital Domain's inhouse code still uses forms.H a lot.

Forms-specific Widget classes

The following widget classes are provided to allow direct porting of Forms programs. They should not be used in normal FLTK programs.

Problems You Will Encounter

Many parts of XForms use X-specific structures like XEvent in their interface. I did not emulate these! Unfortunately these features (such as the "canvas" widget) are needed by most large programs. You will need to rewrite these to use FLTK subclasses.

Fl_Free widgets emulate the old Forms "free" widget. It may be useful for porting programs that change handle() function on widgets, but you will still need to rewrite things.

Fl_Timer widgets are provided to emulate the XForms timer. These work, but are quite inefficient and inaccurate compared to using fltk::add_timeout().

All instance variables are hidden. 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 "boxtype" with "box()".

const char * arguments to most FLTK methods are simply stored, while Forms would strdup() the passed string. This is most noticeable with the label of widgets. Your program must always pass static data such as a string constant or malloc'd buffer to label(). If you are using labels to display program output you may need to change the calls to Widget::copy_label().

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 does.

fdesign outputs a setting of a "fdui" instance variable to the main window. I did not emulate this because I wanted all instance variables to be hidden. You can store the same information in the Widget::user_data() field of a window. To do this, search through the fdesign output for all occurrences of "->fdui" and edit to use "->user_data()" instead. This will require casts and is not trivial.

The prototype for the functions passed to fl_add_timeout() and fl_set_idle_callback() callback are different.

All the following XForms calls are missing:

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 fltk::Widget. It is important to note that the Widget::handle() method is not exactly the same as the handle() function of Forms. Where a Forms handle() returned non-zero to trigger the widget callback, Widget::handle() must call Widget::do_callback(). And Widget::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:

FormsFLTK
MOUSE_Xfltk::event_x_root()
MOUSE_Yfltk::event_y_root()
LEFTSHIFTKEY,RIGHTSHIFTKEYfltk::event_state(fltk::SHIFT)
CAPSLOCKKEYfltk::event_state(fltk::CAPS_LOCK)
LEFTCTRLKEY,RIGHTCTRLKEYfltk::event_state(fltk::CTRL)
LEFTALTKEY,RIGHTALTKEYfltk::event_state(fltk::ALT)
MOUSE1,RIGHTMOUSEfltk::event_state(fltk::BUTTON1)
MOUSE2,MIDDLEMOUSEfltk::event_state(fltk::BUTTON2)
MOUSE3,LEFTMOUSEfltk::event_state(fltk::BUTTON3)

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. Add one to the index for these.

Wed Jun 17 08:58:24 2009. FLTK ©2007 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.