next up previous contents index
Next: Designing your own object Up: XForms Online Manual Previous: The Form Designer

An overview of all object classes

 

Introduction

This part describes all different object classes that are available in the Forms Library.

All available object classes are summarized in Table 14.1.

 

Name Description
Static Objects
Box Rectangular areas to visually group objects.
Frame A box with an empty inside region.
Labelframe A frame with label on the frame.
Text Simple one line labels.
Bitmap Displays an X11 bitmap.
Pixmap Displays a pixmap using the XPM library.
Clock A clock.
Chart Bar-charts, pie-charts, strip-charts, etc.
Button Like Objects
Button Many different kinds and types of buttons that the user can push to indicate certain settings or actions.
Valuator Objects
Slider Both vertical and horizontal sliders to let the user indicate some float value.
Scrollbar Sliders plus two directional buttons.
Dial A dial to let the user indicate a float value.
Positioner Lets the user indicate an (x,y) position with the mouse.
Counter A different way to let a user step through values.
Input Objects
Input Lets the user type in an input string.
Choice Objects
Menu Both pop-up and drop-down menus can be created.
Choice Can be used to let the user make a choice from a set of items.
Browser A text browser with a slider. Can be used for making selections from sets of choices.
Container Objects
Tabbed Folders A tabbed folder is a compound object capable of holding multiple groups of objects.
Menu bar A menubar is a collection of individual menus.
Other Objects
Timer A timer that runs from a set time towards 0. Can e.g. be used to do default actions after some time has elapsed.
XYPlot XYPlot shows simple 2D xy-plot from a tabulated function or a datafile. Data points can be interactively manipulated and retrieved.
Pop-ups Pop-ups are used by menu and choice. it can also be used stand-alone to allow the user to make selections among many choices.
Canvas Canvases are managed plain X windows. It differs from a raw application window only in the way its geometry is managed, not in the way various interaction is set up.
Table 14.1: List of object classes

 

For each class there is a section in this document that describes it. The section starts with a short description of the object, followed by the routine(s) to add it to a form. For (almost) all classes this routine has the same form

   FL_OBJECT *fl_add_NAME(int type, FL_Coord x, FL_Coord y,
                            FL_Coord w, FL_Coord h, const char *label)

Here type is the type of the object in its class. Most classes have many different types. They are described in the section. x, y, w and h give the left bottom corner and the width and height of the bounding box of the object. label is the label that is placed inside or next to the object. For each object class the default placement of the label is described. When the label starts with the character @ the label is not printed but replaced by a symbol instead.

For each object class there is also a routine

   FL_OBJECT *fl_create_NAME(int type, FL_Coord x, FL_Coord y,
                             FL_Coord w, FL_Coord h, const char *label)

that only creates the object but does not put it in the form. This routine is useful for building hierarchical object classes. The routine is not described in the following sections.

An important aspect of objects is how interaction is performed with them. First of all there is the way in which the user interacts with the object and secondly it is indicated when the object changes status and is returned to the application program for some action. Both are described in the section.

Object attributes can be divided into generic and object specific ones. For generic attributes (e.g., the object label size), the routines that change them always start with fl_set_object_xxx() where xxx is the name of the attribute. When a specific object is created and added to a form, it inherits many aspects of the generic object or initializes the object attributes to its needed defaults. Thus, in the following sections, only the object specific routines are documented. Routines that set generic object attributes are documented in Part v.

When appropriate, the effect of certain (generic) attributes of the objects on the specific object is discussed. In particular it is indicated what the effect of the routine fl_set_object_color() is on the appearance of the object. Also some remarks on possible boxtypes are made.

Static objects

Box

 

Short description

Boxes are simply used to give the dialogue forms a nicer appearance. They can be used to visually group other objects together. The bottom of each form is a box.

Adding an object

To add a box to a form you use the routine

 

   FL_OBJECT *fl_add_box(int type, FL_Coord x, FL_Coord y,
                         FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is default placed centered in the box.

Types

The following types are available:

 
  FL_UP_BOX   		 A box that comes out of the screen.

FL_DOWN_BOX A box that goes down into the screen.

FL_FLAT_BOX A flat box without a border.

FL_BORDER_BOX A flat box with a border.

FL_FRAME_BOX A flat box with an engraved frame.

FL_SHADOW_BOX A flat box with a shadow.

FL_ROUNDED_BOX A rounded box.

FL_RFLAT_BOX A rounded box without a border.

FL_RSHADOW_BOX A rounded box with a shadow.

FL_OVAL_BOX An elliptic box.

FL_NO_BOX No box at all, only a centered label.

Interaction

No interaction takes place with boxes.

Other routines

No other routines are available for boxes.

Attributes

Color1 controls the color of the box.

Remarks

Do not use FL_NO_BOX type if the label is to change during the execution of the program.

Boxes are used in most demo's. Also see Fig. 3.1. 

Frame

   

Short description

Frames are simply used to give the dialogue forms a nicer appearance. They can be used to visually group other objects together. Frames are almost the same as a box, except that the interior of the bounding box is not filled. Use of frames can speed up drawing in certain situations. For example, to place a group of radio buttons within an FL_ENGRAVED_FRAME. If we were to use an FL_FRAME_BOX to group the buttons, visually they would look the same. However, the latter is faster as we don't have to fill the interior of the bounding box and can also reduce flicker. Frames are useful in decorating free objects and canvases.

Adding an object

To add a frame to a form you use the routine

 

   FL_OBJECT *fl_add_frame(int type, FL_Coord x, FL_Coord y,
                         FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual except that the frame is drawn outside of the bounding box (so a flat box of the same size just fills the inside of the frame without any gaps). The label is by default placed centered inside the frame.

Types

The following types are available:

 
  FL_NO_FRAME		 Nothing is drawn

FL_UP_FRAME A frame appears coming out of the screen

FL_DOWN_FRAME A frame that goes down into the screen.

FL_BORDER_FRAME A frame with a simple outline

FL_ENGRAVED_FRAME A frame appears to be engraved.

FL_EMBOSSED_FRAME A frame appears embossed .

FL_ROUNDED_FRAME A rounded frame.

FL_OVAL_FRAME An elliptic box.

Interaction

No interaction takes place with frames.

Other routines

None.

Attributes

Color1 controls the color of the frame if applicable. Boxtype attribute does not apply to the frame class.

Remarks

It may be faster to use frames instead of boxes for text that is truly static. See freedraw.c for an example use of frame objects. 

LabelFrame

   

Short description

A label frame is almost the same as a frame except that the label is placed on the frame (See Fig. 15.1) instead of inside or outside of the bounding box as in a regular frame.

   figure1716
Figure 15.1: Labelframe Classes

Adding an object

To add a labelframe to a form you use the routine

 

   FL_OBJECT *fl_add_labelframe(int type, FL_Coord x, FL_Coord y,
                         FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual except that the frame is drawn outside of the bounding box (so a flat box of the same size just fills the inside of the frame without any gaps). The label is by default placed centered inside the frame.

Types

The following types are available:

 
  FL_NO_FRAME		 Nothing is drawn

FL_UP_FRAME A frame appears coming out of the screen

FL_DOWN_FRAME A frame that goes down into the screen.

FL_BORDER_FRAME A frame with a simple outline

FL_ENGRAVED_FRAME A frame appears to be engraved.

FL_EMBOSSED_FRAME A frame appears embossed .

FL_ROUNDED_FRAME A rounded frame.

FL_OVAL_FRAME An elliptic box.

Interaction

No interaction takes place with frames.

Other routines

None.

Attributes

Color1 controls the color of the frame if applicable. Color2 controls the background color of the label. Boxtype attribute does not apply to the labelframe class.

Remarks

You can not draw a label inside or outside of the frame box. If you try, say, by requesting FL_ALIGN_CENTER, the label is drawn using FL_ALIGN_TOP_LEFT.  

Text

   

Short description

Text objects simply consist of a label possibly placed in a box.

Adding an object

To add a text to a form you use the routine

 

   FL_OBJECT *fl_add_text(int type, FL_Coord x, FL_Coord y,
                       FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is by default placed flushed left in the bounding box.

Types

Only one type of text exists: FL_NORMAL_TEXT.

Interaction

No interaction takes place with text objects.

To set or change the text shown, use fl_set_object_label()  

Other routines

No other routines are available for texts.

Attributes

Any boxtype can be used for text. Color1 controls the color of the box. The color of the text is controlled by lcol as usual. However, if the text is to change dynamically, NO_BOX should not be used.

Remarks

Don't use boxtype FL_NO_BOX if the label is to change dynamically.

Note that there is almost no difference between a box with a label and a text. The only difference lies in the position where the text is placed and the fact that text is clipped to the bounding box. Text is normally placed inside the box at the left side. This helps you putting different lines of text below each other. Labels inside boxes are default centered in the box. You can change the position of the text inside the box using the routine fl_set_object_lalign(). In contrast to boxes, different alignments for text always place the text inside the box rather than outside the box.

 

Bitmap

     

Short description

A bitmap is a simple bitmap shown on a form.

Adding an object

 

To add a bitmap to a form you use the routine  

   FL_OBJECT *fl_add_bitmap(int type, FL_Coord x, FL_Coord y,
                            FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is by default placed below the bitmap. The bitmap will be empty.

Types

Only the type FL_NORMAL_BITMAP is available.

Interaction

No interaction takes place with a bitmap. For bitmap that interacts, see Section 16.1 on bitmapbutton. (You can also place a hidden button over it if you want something to happen when pressing the mouse on a static bitmap.) 

Other routines

To set the actual bitmap being displayed use      

   void fl_set_bitmap_data(FL_OBJECT *ob, int w, int h, unsigned char *bits)

   void fl_set_bitmap_file(FL_OBJECT *ob, const char *file);

bits contains the bitmap data as a character string. file is the name of the file that contains bitmap data. A number of bitmaps can be found in /usr/include/X11/bitmaps or similar places. The X program bitmap can be used to create bitmaps.

Two additional routines are provided to make a Pixmap from a bitmap file or data

       

   Pixmap fl_read_bitmapfile(Window win, const char *filename,
                             unsigned *width, unsigned *height,
                             int *hotx, int *hoty)

   Pixmap fl_create_from_bitmapdata(Window win, const char *data,
                                   int width, int height)

where win is any window ID in your application and other parameters have the obvious meanings. If there is no window created yet, fl_default_win()  may be used.

Note pixmaps created by the above routines have a depth of 1 and should be displayed using XCopyPlane.

Attributes

Label color controls the foreground color of the bitmap. Color1 controls the background color of the bitmap (and the color of the box). Color2 is not used.

Remarks

See demo33.c for a demo of a bitmap. 

Pixmap

     

Short description

A pixmap is a simple pixmap (color icons) shown on a form .

Adding an object

To add a bitmap to a form you use the routine

 

   FL_OBJECT *fl_add_pixmap(int type, FL_Coord x, FL_Coord y,
                            FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is by default placed below the pixmap. The pixmap will be empty.

Types

Only the type FL_NORMAL_PIXMAP is available.

Interaction

No interaction takes place with a pixmap. For pixmap that interacts, see Section 16.1 on pixmapbutton. (You can also place a hidden button over it if you want something to happen when pressing the mouse on a static pixmap.)

Other routines

A pixmap file (usually with suffix xpm) is an ASCII file that contains the definition of the pixmap as a char pointer array that can be included directly into a C (or C++) source file.

To set the actual pixmap being displayed, use one of the following routines:

   

   void fl_set_pixmap_file(FL_OBJECT *ob, const char *file);

   void fl_set_pixmap_data(FL_OBJECT *ob, char **data)

In the first routine, you specify the pixmap by the filename that contains it. In the second routine, you #include the pixmap at compile time and use the pixmap data (an array of char pointers) directly. Note that both of these functions do not free the old pixmaps associated with the object. If you're writing a pixmap browser type applications, be sure to free the old pixmaps using fl_free_pixmap_pixmap prior to calling these two routines.

To obtain the pixmap ID currently being displayed, the following routine can be used

 

   Pixmap fl_get_pixmap_pixmap(FL_OBJECT *ob, Pixmap *id, Pixmap *mask);

In some situations, you might already have a Pixmap resource ID, e.g., from fl_read_pixmapfile(), you can use the following routine to change the the pixmap

 

   void fl_set_pixmap_pixmap(FL_OBJECT *ob, Pixmap id, Pixmap mask)

where mask is used for transparency (See fl_read_pixmapfile().) Use 0 for mask if no special clipping attributes are desired.

This routine does not free the pixmap ID nor the mask already associated with the object. Thus if you no longer need the old pixmaps, they should be freed prior to changing the pixmaps using the following routine

 

   void fl_free_pixmap_pixmap(FL_OBJECT *ob);

This routine in addition to freeing the pixmap and the mask, it also frees the colors the pixmap allocated.

Pixmaps are by default displayed centered inside the bounding box. However, this can be changed using the following routine

 

   void fl_set_pixmap_align(FL_OBJECT *ob, int align, int dx, int dy)

where align is the same as that used for labels. See Section 3.11.3 for a list. dx and dy are extra margins to leave in addition to the object border width. By default, dx and dy are set to 3. Note that although you can place a pixmap outside of the bounding box, it probably is not a good idea.

Attributes

By default, if a pixmap has more colors than that available in the colormap, the library will use substitute colors that are judged ``close enough". This closeness is defined as the difference between the requested color and color found being smaller than some pre-set threshold values between 0 and 65535 (0 means exact match). The default thresholds are 40000 for red, 30000 for green and 50000 for blue. The change these defaults, use the following routine

   

   void fl_set_pixmap_colorcloseness(int red, int green, int blue);

Remarks

The following routines may come in handy to read a pixmap file into a Pixmap

     

   Pixmap fl_read_pixmapfile(Window win, const char *filename,
                      unsigned *width, unsigned *height,
                      Pixmap *shape_mask, int *hotx, int *hoty,
                      FL_COLOR tran)

where win is the window in which the pixmap is to be displayed. If the window is yet to be created, you can use the default window fl_default_window().     Parameter shape_mask is set to a Pixmap, if not null, that can be used as a clip mask to achieve transparency. hotx and hoty are the center of the pixmap (useful if the pixmap is to be used as a cursor). Parameter tran is currently un-used.

If you have already had the pixmap data in memory, the following routine may be used

     

   Pixmap fl_create_from_pixmapdata(Window win, char **data,
                                    unsigned *width, unsigned *height,
                                    Pixmap *shape_mask,
                                    int *hotx, int *hoty, FL_COLOR tran)

All parameters have the same meaning as in fl_read_pixmapfile.

Note the Forms Library handles transparency,  if specified in the pixmap file or data, for pixmap and pixmapbutton objects. However, when using fl_read_pixmapfile or fl_create_from_pixmapdata, the application programmer is responsible to set the clip mask in appropriate GCs.

Finally there is a routine that can be used to free a Pixmap

     

   void fl_free_pixmap(Pixmap Id)

You will need the XPM library (version 3.4c or later) developed by Arnaud Le Hors and GROUPE BULL (lehors@sophia.inria.fr) to use pixmap. XPM library can be obtained from many X distribution/mirror sites via anonymous ftp or web     (ftp://ftp.x.org/contrib and ftp://avahi.inria.fr/pub/xpm are the official site for anonymous ftp and http://www.inria.fr/koala/lehors/xpm.html is the home page).  

Clock

 

Short description

A clock object simply displays a clock on the form.

Adding an object

To add a clock to a form you use the routine

 

   FL_OBJECT *fl_add_clock(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, char label[])

The meaning of the parameters is as usual. The label is by default placed below the clock.

Types

The following types are available:

 
  FL_ANALOG_CLOCK		 An analog clock complete with the second hand.

FL_DIGITAL_CLOCK A digital clock.

Interaction

No interaction takes place with clocks.

Other routines

To get the displayed time (local time as modified by the adjustment described below) use the following routine

 

   void fl_get_clock(FL_OBJECT *obj, int *h, int *m, int *s)

Upon function return, the parameters are set as follows: h is between 0-23 indicating the hour, m is between 0-59 indicating the minutes and s is between 0-59 indicating the seconds.

To display time other than the local time, use the following routine

 

   long fl_set_clock_adjustment(FL_OBJECT *ob, long adj)

where adj is in seconds. For example, to display a time that is one hour behind the local time, an adjustment of -3600 can be used. The function returns the old adjustment value.

By default, the digital clock uses 24hr system. You can switch the display to 12hr system (am-pm) by using the following routine

 

   void fl_set_clock_ampm(FL_OBJECT *ob, int yes_no)

Attributes

Never use FL_NO_BOX as boxtype for a digital clock.

Color1 controls the color of the background, color2 the color of the hands.

Remarks

See flclock.c for an example of the use of clocks.

See also Page gif for other time related routines.  

Chart

 

Short description

The chart object gives you an easy way to display a number of different types of charts like bar-charts, pie-charts, line-charts, etc. They can either be used to display some fixed chart or a changing chart (e.g. a strip-chart). Values in the chart can be changed and new values can be added which makes the chart move to the left, i.e., new entries appear at the right and old entries disappear at the left. This can be used to e.g. monitor some process.

Adding an object

To add a chart object to a form use the routine

 

   FL_OBJECT *fl_add_chart(int type, FL_Coord x, FL_Coord y,
                           FL_Coord w, FL_Coord h, const char *label)

It shows an empty box on the screen with the label below it.

Types

The following types are available:

 
  FL_BAR_CHART   		 A bar-chart

FL_HORBAR_CHART A horizontal bar-chart

FL_LINE_CHART A line-chart

FL_FILLED_CHART A line-chart but area below curve is filled

FL_SPIKE_CHART A chart with a vertical spike for each value

FL_PIE_CHART A pie-chart

FL_SPECIALPIE_CHART A pie-chart with displaced first item

All charts except pie-charts can display positive and negative data. Pie-charts will ignore values that are tex2html_wrap_inline9699 0. The maximal number of values displayed in the chart can be set using the routine fl_set_chart_maxnumb(). The number must be bounded by FL_CHART_MAX which is 512. Switching between different types can be done without any complications.

Interaction

No interaction takes place with charts.

Other routines

There are a number of routines to change the values in the chart and to change its behavior. To clear a chart use the routine

 

   void fl_clear_chart(FL_OBJECT *obj)

To add an item to a chart use

 

   void fl_add_chart_value(FL_OBJECT *obj, double val, 
                           const char *text, int col)

Here val is the value of the item, text is the label to be associated with the item (can be empty) and col is an index in the colormap (FL_RED etc) that is the color of this item. The chart will be redrawn each time you add an item. This might not be appropriate if you are filling a chart with values. In this case put the calls between fl_freeze_form() and fl_unfreeze_form().

By default, the label is drawn with tiny font in black. You can change the font style, size or color using the following routine

     

   void fl_set_chart_lstyle(FL_OBJECT *ob, int fontstyle)

   void fl_set_chart_lsize(FL_OBJECT *ob, int fontsize)

   void fl_set_chart_lcolor(FL_OBJECT *ob, int color)

Note that fl_set_chart_lcolor() only affects the label color of subsequent items, not the items already created.

You can also insert a new value at a particular place using

 

   void fl_insert_chart_value(FL_OBJECT *obj, int index,
                           double val, const char *text, int col)

index is the index before which the new item should be inserted. The first item is number 1. So, for example, to make a strip-chart where the new value appears at the left, each time insert the new value before index 1.

To replace the value of a particular item use the routine

 

   void fl_replace_chart_value(FL_OBJECT *obj, int index,
                               double val, const char *text, int col)

Here index is the index of the value to be replaced. The first value has an index of 1, etc.

Normally, bar-charts and line-charts are automatically scaled in the vertical direction such that all values can be displayed. This is often not wanted when new values are added from time to time. To set the minimal and maximal value displayed use the routine

 

   void fl_set_chart_bounds(FL_OBJECT *obj, double min, double max)

To return to automatic scaling choose min = max = 0.0.

Also the width of the bars and distance between the points in a line-chart are normally scaled. To change this use

 

   void fl_set_chart_autosize(FL_OBJECT *obj, int autosize)

with autosize = 0. In this case the width of the bars will be such that the maximal number of items fits in the box. This maximal number (default FL_CHART_MAX) can be changed using

 

   void fl_set_chart_maxnumb(FL_OBJECT *obj, int maxnumb)

where maxnumb is the maximal number of items to be displayed.

Attributes

Don't use FL_NO_BOX for a chart object if it changes value. Color1 controls the color of the box.

Remarks

  See chartall.c and chartstrip.c for examples of the use of chart objects.

Button like objects

Button

   

Short description

A very important class of objects are the buttons. Buttons are placed on the form such that the user can push them with the mouse. Different types of buttons exist: buttons that return to their normal position when the user releases the mouse, buttons that stay pushed until the user pushes them again and radio buttons that make other buttons be released.

   figure1886
Figure 16.1: Button Classes

Also different shapes of buttons exist. Normal buttons are rectangles that come out of the background. When the user pushes them they go into the background (and possibly change color). Lightbuttons have a small light inside them. Pushing the button switches the light on. Round buttons are simple circles. When pushed, a colored circle appears inside them. Bitmap and pixmap   buttons are buttons whose labels are graphics rather than text.

Adding an object

To add buttons use one of the following routines:                

   FL_OBJECT *fl_add_button(int type, FL_Coord x, FL_Coord y,
                            FL_Coord w, FL_Coord h, const char *label)

   FL_OBJECT *fl_add_lightbutton(int type, FL_Coord x, FL_Coord y,
                                FL_Coord w,FL_Coord h, const char *label)

   FL_OBJECT *fl_add_roundbutton(int type, FL_Coord x, FL_Coord y,
                                FL_Coord w,FL_Coord h, const char *label)

   FL_OBJECT *fl_add_round3dbutton(int type, FL_Coord x, FL_Coord y,
                                FL_Coord w,FL_Coord h, const char *label)

   FL_OBJECT *fl_add_checkbutton(int type, FL_Coord x, FL_Coord y,
                                FL_Coord w,FL_Coord h, const char *label)

   FL_OBJECT *fl_add_bitmapbutton(int type, FL_Coord x, FL_Coord y,
                                FL_Coord w,FL_Coord h, const char *label)

   FL_OBJECT *fl_add_pixmapbutton(int type, FL_Coord x, FL_Coord y,
                                FL_Coord w,FL_Coord h, const char *label)

   FL_OBJECT *fl_add_scrollbutton(int type, FL_Coord x, FL_Coord y,
                                FL_Coord w,FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is by default placed inside the button for button and lightbutton. For roundbutton, round3dbutton, bitmapbutton   and pixmapbutton, it is placed to the right of the circle and to the bottom of the bitmap/pixmap respectively. For

scrollbutton, the label must be of some pre-determined string that indicates the direction of the scroll arrow.

Types

The following types of buttons are available:                                      

 
  FL_NORMAL_BUTTON		 Returns value when released.

FL_PUSH_BUTTON Stays pushed until user pushes it again.

FL_MENU_BUTTON Returns value when pushed.

FL_TOUCH_BUTTON Returns value as long as the user pushes it.

FL_RADIO_BUTTON Push button that switches off other radio buttons.

FL_HIDDEN_BUTTON Invisible normal button.

FL_INOUT_BUTTON Returns value both when pushed and when released.

FL_RETURN_BUTTON Like a normal button but reacts on the <Return> key.

FL_HIDDEN_RET_BUTTON Invisible return button.

Except for the FL_HIDDEN_BUTTON and FL_HIDDEN_RET_BUTTON, which are invisible, they all look similar on the screen but their function is quite different. Each of these buttons gets pushed down when the user presses the mouse on top of it. What actually happens when the user does so depends on the type of the button. An FL_NORMAL_BUTTON, FL_TOUCH_BUTTON and FL_INOUT_BUTTON gets released when the user releases the mouse button. Their difference lies in the moment at which the interaction routines return them (see below). A FL_PUSH_BUTTON remains pushed and is only released when the user pushes it again. A FL_RADIO_BUTTON is a push button with the following extra property. Whenever the user pushes a radio button, all other pushed radio buttons in the form (or in a group) are released. In this way the user can make its choice among some possibilities. A FL_RETURN_BUTTON behaves like a normal button, but it also reacts when the <Return> key on the keyboard is pressed. When a form contains such a button (of course there can only be one) the <Return> key can no longer be used to move between input fields. For this the <Tab> key must be used.

A FL_HIDDEN_BUTTON behaves like a normal button but is invisible. A FL_HIDDEN_RET_BUTTON is like a hidden button but also reacts to <Return> key presses.

Interaction

FL_NORMAL_BUTTONs, FL_PUSH_BUTTONs, FL_RADIO_BUTTONs, FL_RETURN_BUTTONs and FL_HIDDEN_BUTTONs are returned at the moment the user releases the mouse after having pressed it on the button. An FL_INOUT_BUTTON is returned both when the user presses it and when the user releases it. A FL_TOUCH_BUTTON is returned all the time as long as the user keeps it pressed. A FL_RETURN_BUTTON and a FL_HIDDEN_RET_BUTTON are also returned when the user presses the <Return> key.

See demo butttypes.c for a feel of the different button types.

Other routines

The application program can also set a button to be pushed or not itself without a user action. To this end use the routine

 

   void fl_set_button(FL_OBJECT *obj, int pushed)

pushed indicates whether the button should be pushed (1) or released (0). When setting a FL_RADIO_BUTTON to be pushed this automatically releases the currently pushed button if different. Also note that this routine only simulates the visual appearance and perhaps some internal states, it does not affect the program flow in anyway, i.e., setting a button being pushed does not invoke its callback or results in the button returned to the program. For that, fl_trigger_object() is needed     or more conveniently follow fl_set_button() with fl_call_object_callback().

To figure out whether a button is pushedgif or not use

 

   int fl_get_button(FL_OBJECT *obj)

Sometimes you want to give the button a different meaning depending on which mouse button pressed it. To find out which mouse button was used at the last push (or release) use the routine

 

   int fl_get_button_numb(FL_OBJECT *obj)

It returns one of the constants FL_LEFT_MOUSE, FL_MIDDLE_MOUSE and FL_RIGHT_MOUSE indicating the physical location of the mouse button on the mouse. If the last push is triggered by a shortcut (see below), the function returns the keysym (ascii value if ASCII) of the key plus FL_SHORTCUT. For example, if a button has a shortcut <CNTRL> C, the button number returned upon activation of the shortcut would be FL_SHORTCUT 3+.

If more information is desired about the last event, use

 

   const XEvent *fl_last_event(void);

In a number of situations it is useful to define a keyboard equivalent to a button. E.g., you might want to define that ^Q (<CNTRL> Q) has the same meaning as pressing the Quit button. This can be achieved using the following call:  

   void fl_set_button_shortcut(FL_OBJECT *obj, const char *str, 
                               int showUL)

Note that str is a string, not a character. This string should contain all the characters that correspond to this button. So, e.g., if you use string "^QQq" the button will react on the keys q, Q and <CNTRL> Q. (As you see you should use the symbol ^ to indicate the control key. Similarly you can use the symbol # to indicate the <ALT> key.) Be careful with your choices. When the form also contains input fields you probably don't want to use the normal printable characters because they can no longer be used for input in the input fields. Shortcuts  always go before input fields. Other special keys, such as <F1> etc., can also be used as shortcuts. See Section 24.1 for details. Finally realize that a return button is in fact a normal button with the <Return> key as a shortcut. So don't change the shortcuts for such a button.

If the second parameter showUL is true, and one of the letters in the object label matches the shortcut, the matching letter will be underlined.  This applies to non-printable characters (such as #A) as well in the sense that if the label contains letter a or A, it will be underlined (i.e., special characters such as # and ^ are ignored when matching). A false showUL turns off the underline without affecting the shortcut. Note that although the entire object label is searched for matching character to underline, the shortcut string itself is not searched, thus shortcut ``Yy" for label ``Yes" will result in the underlining of Y while ``yY" will not.

To set the bitmap to use for the bitmap button, the following routines can be used,  

   

   void fl_set_bitmapbutton_data(FL_OBJECT *ob, int w, int h,
                                unsigned char *bits)

   void fl_set_bitmapbutton_file(FL_OBJECT *ob, const char *filename)

Similarly, to set the pixmap to use for the pixmap button, the following routines can be used  

     

   void fl_set_pixmapbutton_data(FL_OBJECT *ob, unsigned char **bits)

   void fl_set_pixmapbutton_file(FL_OBJECT *ob, const char *filename)

   void fl_set_pixmapbutton_pixmap(FL_OBJECT *ob, Pixmap id, Pixmap mask)

In the first routine, you #include the pixmap file into you source code and use the pixmap definition data (an array of char pointers) directly. In the second routine, the filename that contains the pixmap defination is used to specify the pixmap. The last routine assumes that you've already have X Pixmap resource IDs for the pixmap you want to use. Note that these routines do not free the pixmaps already associated with the button. To free the pixmaps, use the following routine

 

   void fl_free_pixmapbutton_pixmap(FL_OBJECT *ob);

This function frees the pixmap and mask together with all the colors they allocated.

To get the pixmap that is currently being displayed, use the following routine

 

   Pixmap fl_get_pixmapbutton_pixmap(FL_OBJECT *ob, 
                                     Pixmap &pixmap, Pixmap &mask)

Pixmaps are by default displayed centered inside the bounding box. However, this can be changed using the following routine

 

   void fl_set_pixmapbutton_align(FL_OBJECT *ob, int align, 
                            int xmargin, int ymargin)

where align is the same as that used for labels. See Section 3.11.3 for a list. xmargin and ymargin are extra margins to leave in addition to the object border width. Note that although you can place a pixmap outside of the bounding box, it probably is not a good idea.

Finally there is routine that can be used to disable the focus outline with a false flag

 

   void fl_set_pixmapbutton_focus_outline(FL_OBJECT *ob, int flag)

See also Section 15.6 for pixmap color and transparency   handling.

Attributes

For normal buttons color1 controls the normal color and color2 the color when pushed. For lightbuttons color1 is the color of the light when off and color2 the color when on. For round buttons, color1 is the color of the circle and color2 the color of the circle that is placed inside it when pushed. For round3dbutton, color1 is the color of the inside of the circle and color2 the color of the embedded circle. For bitmapbuttons, color1 is the normal box color (or bitmap background if nobox) and color2 is used to indicate the focus color. The foreground color of the bitmap is controlled by label color.   For scrollbutton, col1 is the overall boundbox color (if not NO_BOX), col2 is the arrow color. The label of the scrollbutton must be of a string of a number between 1 - 9 (except 5), indicating the arrow direciton like the numerical key pad. The label can have an optional prefix # to indicate uniform scaling. For example, a label "#9" indicates the arrow should be pointing up-right and the arrow has the identical width and height regardless the overall bounding box size.

Remarks

See all demo programs, in particular pushbutton.c and buttonall.c, for the use of buttons.  

Valuator objects

Slider

   

Short description

Sliders are useful for letting the user indicate a value between some fixed bounds. Both horizontal and vertical sliders exist. They have a minimum, maximum and current value (all floats). The user can change this value by shifting the slider with the mouse. Whenever the value changes, this is reported to the application program.

Adding an object

To add a slider to a form use

 

   FL_OBJECT *fl_add_slider(int type, FL_Coord x, FL_Coord y,
                            FL_Coord w, FL_Coord h, const char *label)

or

 

   FL_OBJECT *fl_add_valslider(int type, FL_Coord x, FL_Coord y,
                               FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is by default placed below the slider. The second type of slider displays its value above or to the left of the slider.

Types

The following types of sliders are available:

 
  FL_VERT_SLIDER   		 A vertical slider.

FL_HOR_SLIDER A horizontal slider.

FL_VERT_FILL_SLIDER A vertical slider, filled from the bottom.

FL_HOR_FILL_SLIDER A horizontal slider, filled from the left.

FL_VERT_NICE_SLIDER A nice looking vertical slider.

FL_HOR_NICE_SLIDER A nice looking horizontal slider.

FL_VERT_BROWSER_SLIDER A different looking vertical slider.

FL_HOR_BROWSER_SLIDER A different looking horizontal slider.

  figure1995
Figure 17.1: All sliders

Interaction

Whenever the user changes the value of the slider using the mouse, the slider is returned (or the callback called) by the interaction routines. The slider position is changed by moving the mouse inside the slider area. For fine control, hold down the left or right <SHIFT> key while moving the slider. Depending on the object size (pixels) and the slider value range, dragging the sliding bar might not always get the value you want, even with the <SHIFT> fine control, if the range is larger than the number of pixels (for example, if you use 100 pixels to represent 150 values, no matter how you control the motion, you will not get all the values). In these situations, you should use the right or middle mouse button with appropriate increments (see fl_set_slider_increment() below). The interaction with increment is that it updates the value first (as opposed to reading off the pixel position) then maps the value back into pixel position, thus all values of multiple increments are obtainable.

In some applications you might not want the slider to be returned all the time. To change the default, call the following routine:

 

   void fl_set_slider_return(FL_OBJECT *obj, int when)

where parameter when can be one of the four values

               

FL_RETURN_END_CHANGED
return at end (mouse release) if value is changed (since last return).

FL_RETURN_CHANGED
return whenever the slider value is changed.

FL_RETURN_END
return at end (mouse release) regardless if the value is changed or not.

FL_RETURN_ALWAYS
return all the time. Not very useful.

See demo objreturn.c for an example use of this.

Other routines

To change the value and bounds of a slider use the following routines

   

   void fl_set_slider_value(FL_OBJECT *obj, double val)

   void fl_set_slider_bounds(FL_OBJECT *obj, double min, double max)

By default, the minimum value is 0.0, the maximum is 1.0 and the value is 0.5. For vertical sliders, min and max indicate, respectively, the values at the top and the bottom of the sliders,   thus max > min needs not be observed.

To obtain the current value or bounds of a slider use

   

   double fl_get_slider_value(FL_OBJECT *obj)

   void fl_get_slider_bounds(FL_OBJECT *obj, double *min, double *max)

In a number of situations you would like slider values to be rounded to some values, e.g. to integer values. To this end use the routine

 

   void fl_set_slider_step(FL_OBJECT *obj, double step)

After this call slider values will be rounded to multiples of step. Use the value 0.0 to stop rounding.

By default, if mouse is pressed below or above the the sliding bar, the sliding bar jumps to the location where the mouse is pressed. You can, however, use the following routine to change this default so the jumps are made is discrete increments:

 

   void fl_set_slider_increment(FL_OBJECT *obj, double lj, double rj)

where lj indicates how much to jump if the left mouse button is pressed and rj indicates how much to increment if rigth/middle mouse buttons pressed. This routine can be used if finer control of the slider value is needed or assigning different meaning to different mouse buttons. For example, for the slider in the browser class, the left mouse jump is made to be one page and right jump is made to be one line.

To obtain the current increment, use the following routine

 

   void fl_get_slider_increment(FL_OBJECT *obj, float *lj, float *rj)

Attributes

Never use FL_NO_BOX as boxtype for a slider. For FL_VERT_NICE_SLIDERs and FL_HOR_NICE_SLIDERs one best uses a FL_FLAT_BOX in the color of the background to get the nicest effect. Color1 controls the color of the background of the slider, color2 the color of the slider itself.

You can control the size of the slider inside the box using the routine

 

   void fl_set_slider_size(FL_OBJECT *obj, double size)

size should be a float between 0.0 and 1.0. The default is FL_SLIDER_WIDTH = 0.10 for regular sliders and 0.15 for browser sliders. With size=1.0, the slider covers the box completely and can no longer be moved. This function does not apply to NICE_SLIDER and FILL_SLIDER.

The routine

 

   void fl_set_slider_precision(FL_OBJECT *obj, int prec)

sets the precision with which the value of the slider is shown. This only applies to sliders showing their value.

By default, the value shown by valslider is the slider value in floating point format. You can override the default by registering a filter function using the following routine

     

   void fl_set_slider_filter(FL_OBJECT *obj,
                              const char *(*filter)(FL_OBJECT *,
                                                    double value, 
                                                    int prec));

where value and prec are the slider value and precision respectively. The filter function filter should return a string that is to be shown. The default filter is equivalent to the following

   const char *filter(FL_OBJECT *ob, double value, int prec)
   {
       static char buf[32];
       sprintf(buf, "%.*f", prec, value);
       return buf;
   }

Remarks

See the demo program demo05.c for an example of the use of sliders. See demos sldsize.c and sliderall.c for the effect of setting slider sizes and the different types of sliders.

Although all function prototypes would seem to indicate that sliders have a resolution of a double, it is not true. All internal calculations are done with float precision. 

Scrollbars

   

Short description

Scrollbars are similar to sliders (as a matter of fact, scrollbars are made with sliders and scrollbuttons), and useful in letting the user indicate a value between some fixed bounds. Both horizontal and vertical scrollbars exist. They have a minimum, maximum and current value (all floats). The user can change this value by dragging the sliding bar with the mouse or press the scroll buttons. Whenever the value changes, it is reported to the application program via the callback function.

Adding an object

To add a scrollbar to a form use

 

   FL_OBJECT *fl_add_scrollbar(int type, FL_Coord x, FL_Coord y,
                            FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is by default placed below the scrollbar.

   figure2047
Figure 17.2: All Scrollbars

Types

The following types of scrollbar are available:

FL_VERT_SCROLLBARA vertical scrollbar.
FL_HOR_SCROLLBARA horizontal scrollbar.
FL_VERT_THIN_SCROLLBARA different looking vertical scrollbar.
FL_HOR_THIN_SCROLLBARA different looking horizontal scrollbar.
FL_VERT_NICE_SCROLLBARA vertical scrollbar using NICE_SLIDER.
FL_HOR_NICE_SCROLLBARA horizontal scrollbar using NICE_SLIDER.
FL_VERT_PLAIN_SCROLLBARSimilar to THIN_SCROLLBAR.
FL_HOR_PLAIN_SCROLLBARSimilar to THIN_SCROLLBAR.

Interaction

Whenever the user changes the value of the scrollbar using the mouse, the scrollbar's callback is called by the main loop. The scrollbar position is changed by moving the mouse inside the scrollbar area. For fine control, hold down the left or right <SHIFT> key while moving the slider.

In some applications you might not want the scrollbar to be returned all the time. To change the default, call the following routine:

 

   void fl_set_scrollbar_return(FL_OBJECT *obj, int when)

where parameter when can be one of the following four values

               

FL_RETURN_END_CHANGED
return at end (mouse release) if value is changed (since last return).

FL_RETURN_CHANGED
return whenever the scrollbar value is changed.

FL_RETURN_END
return at end (mouse release) regardless if the value is changed or not.

FL_RETURN_ALWAYS
return all the time. Not very useful.

See demo objreturn.c for an example use of this.

Other routines

To change the value and bounds of a scrollbar use the following routines

   

   void fl_set_scrollbar_value(FL_OBJECT *obj, double val)

   void fl_set_scrollbar_bounds(FL_OBJECT *obj, double min, double max)

By default, the minimum value is 0.0, the maximum is 1.0 and the value is 0.5. For vertical scrollbars, min and max indicate, respectively, the value at the top and the bottom of the scrollbars,   thus max > min needs not be observed.

To obtain the current value and bounds of a scrollbar use

   

   double fl_get_scrollbar_value(FL_OBJECT *obj)

   void fl_get_scrollbar_bounds(FL_OBJECT *obj, double *min, double *max)

In a number of situations you would like scrollbar values to be rounded to some values, e.g. to integer values. To this end use the routine

 

   void fl_set_scrollbar_step(FL_OBJECT *obj, double step)

After this call scrollbar values will be rounded to multiples of step. Use the value 0.0 to stop rounding. This should not be confused with the increment/decrement value when the scroll buttons are pressed. Use fl_set_scrollbar_increment() to change the increment value.

By default, if mouse is pressed below or above the the sliding bar, the sliding bar jumps to the location where the mouse is pressed. You can, however, use the following routine to change this default so the jumps are made is discrete increments:

 

   void fl_set_scrollbar_increment(FL_OBJECT *obj, double lj, double rj)

where lj indicates how much to increment if the left mouse button is pressed and rj indicates how much to jump if right/middle mouse button pressed. For example, for the scrollbar in the browser class, the left mouse jump is made to be one page and right/middle mouse jump is made to be one line. The increment (decrement) value when the scrollbuttons are pressed is set to the value of the right jump.

To obtain the current increment settings, use the following routine

 

   void fl_get_scrollbar_increment(FL_OBJECT *ob, float *lj, float *sj)

Attributes

Never use FL_NO_BOX as boxtype for a scrollbar. For FL_VERT_NICE_SCROLLBARs and FL_HOR_NICE_SCROLLBARs one best uses a FL_FLAT_BOX in the color of the background to get the nicest effect. Color1 controls the color of the background of the scrollbar, color2 the color of the sliding bar itself.

You can control the size of the sliding bar inside the box using the routine

 

   void fl_set_scrollbar_size(FL_OBJECT *obj, double size)

size should be a float between 0.0 and 1.0. The default is FL_SLIDER_WIDTH = 0.15 for all scrollbars With size=1.0, the scrollbar covers the box completely and can no longer be moved. This function does not apply to NICE_SCROLLBAR.

Remarks

See the demo program scrollbar.c for an example of the use of scrollbars.

Although all function prototypes would indicate that scrollbars have a resolution of a double, it is not true. All internal calculations are done with float precision.

Also note that the get routines take pointers to floats as parameters while the set routines take doubles as parameters. It is perfectly legal to pass floats as doubles. The reason for this inconsistency is to work around some (buggy) C++ compilers that always widen function parameters, causing mismatches between the compiled library and the application program.

 

Dial

 

Short description

Dial objects are dials that the user can put in a particular position using the mouse. They have a minimum, maximum and current value (all floats). The user can change this value by turning the dial with the mouse. Whenever the value changes, this is reported to the application program.

Adding an object

To add a dial to a form use

 

   FL_OBJECT *fl_add_dial(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is by default placed below the dial.

Types

The following types of dials are available:

 
  FL_NORMAL_DIAL   		 A dial with a knob indicating the position.

FL_LINE_DIAL A dial with a line indicating the position.

FL_FILL_DIAL The area between initial and current is filled.

  figure2099
Figure 17.3: Types of dials

Interaction

By default, the dial value is returned to the application when the user releases the mouse. It is possible to change this behavior using the following routine

 

   void fl_set_dial_return(FL_OBJECT *obj, int how_return)

where how_return can be one of the following

FL_RETURN_END_CHANGED Return at end (mouse release) and only if the dial value is changed. The Default.
FL_RETURN_CHANGED Return whenever the dial value is changed.
FL_RETURN_END Return at the end regardless if the dial value is changed or not.

Other routines

To change the value of the dial use

   

   void fl_set_dial_value(FL_OBJECT *obj, double val)

   void fl_set_dial_bounds(FL_OBJECT *obj, double min, double max)

By default, the minimum value is 0.0, the maximum is 1.0 and the value is 0.5. To obtain the current values of the dial use

   

   double fl_get_dial_value(FL_OBJECT *obj)

   void fl_get_dial_bounds(FL_OBJECT *obj, double *min, double *max)

Sometimes, it might be desirable to limit the angular range a dial can take or choose an angle other than 0 to represent the minimum value. For this purpose, use the following routine

 

   void fl_set_dial_angles(FL_OBJECT *ob, double thetai, double thetaf)

where thetai maps to the minimum value of the dial and thetaf maps to the maximum value of the dial. The angles are relative to the origin of the dial, which is by default at 6 o'clock (270 tex2html_wrap_inline9880 from 3 o'clock) and rotates clock-wise. By default, the minimum angle is 0 and the maximum angle is 360.

By default, crossing from 359.9 to 0 or from 0 to 359.9 is not allowed. To allowing crossing, use the following routine

 

   void fl_set_dial_cross(FL_OBJECT *ob, int flag)

In a number of situations you might want dial values to be rounded to some values, e.g. to integer values. To this end use the routine

 

   void fl_set_dial_step(FL_OBJECT *obj, double step)

After this call dial values will be rounded to multiples of step. Use the value 0.0 to stop rounding.

By default, clock-wise rotation increases the dial value. To change, use the following routine

\index{Dial Class!fl_set_dial_direction@{\verb+fl_set_dial_direction+}}
%\index{fl_get_dial_direction@{\verb+fl_get_dial_direction+}}
\begin{verbatim}
   void fl_set_dial_direction(FL_OBJECT *obj, int dir)

where dir can be either FL_DIAL_CCW or FL_DIAL_CW.

Attributes

You can use any boxtype you like, but the final dial face always appears to be circular although certain correlation between the requested boxtype and actual boxtype exists (for example, FL_FRAME_BOX is translated into a circular frame box.)

Color1 controls the color of the background of the dial, color2 the color of the knob or the line or the fill color.

Remarks

The resolution of a dial is about 0.2 degrees, i.e., there are only about 2000 steps per 360 degrees and depending on the size of the dial, it is typically less.

The dial is always drawn with a circular box. If you specify a FL_UP_BOX, a FL_OVAL3D_UPBOX will be used.

See the demo program ldial.c, ndial.c and fdial.c for examples of the use of dials. 

Positioner

 

Short description

A positioner is an object in which the user can indicate a position with an x- and a y-coordinate. It displays a box with a cross-hair cursor in it. Clicking the mouse inside the box changes the position of the cross-hair cursor and, hence, the x- and y-values.

Adding an object

A positioner can be added to a form using the call

 

   FL_OBJECT *fl_add_positioner(int type, FL_Coord x, FL_Coord y,
                                FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is placed below the box by default.

Types

The following types of positioner exist:

 
   FL_NORMAL_POSITIONER    		Cross-hair inside a box.

FL_OVERLAY_POSITIONER Cross-hair inside a box, but moves in XOR mode.

Interaction

The user changes the setting of the positioner using the mouse inside the box. Whenever the values change, the object is returned by the interaction routines.

In some applications you only want the positioner to be returned to the application program when the user releases the mouse, i.e., not all the time. To achieve this call the routine

 

   void fl_set_positioner_return(FL_OBJECT *obj, int always)

Set always to 0 to achieve this goal.

Other routines

To set the value of the positioner and the boundary values use the routines:

       

   void fl_set_positioner_xvalue(FL_OBJECT *obj, double val)

   void fl_set_positioner_xbounds(FL_OBJECT *obj, double min, double max)

   void fl_set_positioner_yvalue(FL_OBJECT *obj, double val)

   void fl_set_positioner_ybounds(FL_OBJECT *obj, double min, double max)

By default the minimum values are 0.0, the maximum values are 1.0 and the values are 0.5. For ybounds, min and max should be taken to mean the value at the bottom and value at the top of the positioner.

To obtain the current values of the positioner use

       

   double fl_get_positioner_xvalue(FL_OBJECT *obj)

   void fl_get_positioner_xbounds(FL_OBJECT *obj, double *min, double *max)

   double fl_get_positioner_yvalue(FL_OBJECT *obj)

   void fl_get_positioner_ybounds(FL_OBJECT *obj, double *min, double *max)

In a number of situations you would like positioner values to be rounded to some values, e.g. to integer values. To this end use the routines

   

   void fl_set_positioner_xstep(FL_OBJECT *obj, double step)

   void fl_set_positioner_ystep(FL_OBJECT *obj, double step)

After these calls positioner values will be rounded to multiples of step. Use the value 0.0 to stop rounding.

Sometimes, it makes more sense for a positioner to have an icon/pixmap as the background that represents a minified version of the area where positioner's values apply. Type OVERLAY_POSITIONER is specifically designed for this by drawing the moving cross-hair in XOR mode as not to erase the background. A typical creation procedure might look something like the following

    obj = fl_add_pixmap(FL_NORMAL_PIXMAP, x, y, w, h, label);
       fl_set_pixmap_file(obj, iconfile);
    pos = fl_add_positioner(FL_OVERLAY_POSITIONER, x, y, w, h, label);

Of course, you can overlay this type of positioner on objects other than a pixmap. See demo program positionerXOR.c for an example.

Attributes

Never use FL_NO_BOX for a positioner. Color1 controls the color of the box, color2 the color of the cross-hair.

Remarks

A demo can be found in positioner.c. 

Counter

 

Short description

A counter provides a different mechanism for the user to indicate a value. In consists of a box displaying the value and four buttons two at the left and two at the right side. The user can press these buttons to change the value. The extreme buttons make the value change fast, the other buttons make it change slowly. As long as the user keeps his mouse pressed, the value changes.

Adding an object

To add a counter to a form use

 

   FL_OBJECT *fl_add_counter(int type, FL_Coord x, FL_Coord y,
                             FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is by default placed below the counter.

Types

The following types of counters are available:

 
  FL_NORMAL_COUNTER   		 A counter with two buttons on each side.

FL_SIMPLE_COUNTER A counter with one button on each side.

  figure2165
Figure 17.4: Counter types

Interaction

The user changes the value of the counter by keeping his mouse pressed on one of the buttons. Whenever he releases the mouse the counter is returned to the application program.

In some applications you might want the counter to be returned to the application program whenever the value changes. To this end, the following routine is available

 

   void fl_set_counter_return(FL_OBJECT *obj, int how)

where how can be either FL_RETURN_END_CHANGED

(the default) or FL_RETURN_CHANGED.

Other routines

To change the value of the counter use the routines

     

   void fl_set_counter_value(FL_OBJECT *obj, double val)

   void fl_set_counter_bounds(FL_OBJECT *obj, double min, double max)

   void fl_set_counter_step(FL_OBJECT *obj, double small, double large)

The first routine sets the value (default is 0), the second routine sets the minimum and maximum values that the counter will take (default -1000000 and 1000000) and the third routine sets the sizes of the small and large steps (default 0.1 and 1). (For simple counters only the small step is used.)

For conflicting settings, bounds take precedence over value, i.e., if setting a value that is outside of the current bounds, it is clamped.

To obtain the current value of the counter use

 

   double fl_get_counter_value(FL_OBJECT *obj)

To obtain the current bounds and steps, use the following functions

   

   void fl_get_counter_bounds(FL_OBJECT *obj, double *min, double *max)

   void fl_get_counter_step(FL_OBJECT *obj, float *small, float *large)

To set the precision (number of digits after the dot) with which the counter value is displayed use the routine

 

   void fl_set_counter_precision(FL_OBJECT *obj, int prec)

By default, the value shown is the counter value in floating point format. You can override the default by registering a filter function using the following routine

     

   void fl_set_counter_filter(FL_OBJECT *obj,
                              const char *(*filter)(FL_OBJECT *,
                                                    double value, 
                                                    int prec));

where value and prec are the counter value and precision respectively. The filter function filter should return a string that is to be shown. Note that the default filter is equivalent to the following

   const char *filter(FL_OBJECT *ob, double value, int prec)
   {
       static char buf[32];
       sprintf(buf, "%.*f",prec,value);
       return buf;
   }

Attributes

Never use FL_NO_BOX as boxtype for a counter. Color1 controls the color of the background of the counter, color2 the color of the arrows in the counter.

Remarks

Although function prototypes give the impression that a counter has a resolution of a double, this is not true. Internal calculation is done entirely in float precision. The reason for using doubles as function parameters is to workaround bugs in some C++ compilers that always promote floats to doubles for C functions.

  See counter.c for an example of the use of counters.

Input objects

Input

   

Short description

It is often required to obtain textual input from the user, e.g. a file name, some fields in a database, etc. To this end input fields exist in the Forms Library. An input field is a field that can be edited by the user using the keyboard.

Adding an object

To add an input field to a form you use the routine

 

   FL_OBJECT *fl_add_input(int type, FL_Coord x, FL_Coord y,
                           FL_Coord w, FL_Coord h, const char *label)

The meaning of the parameters is as usual. The label is by default placed in front of the input field.

Types

The following types of input fields exist:

 
  FL_NORMAL_INPUT	Any type of text can be typed into this field.

FL_FLOAT_INPUT Only a float value can be typed in (e.g. -23.2e12).

FL_INT_INPUT Only an integer value can be typed in (e.g. -86).

FL_DATE_INPUT Only a date (MM/DD/YY) can be typed in.

FL_MULTILINE_INPUT An input field allowing for multiple lines.

FL_SECRET_INPUT A normal input field that does not show the text.

FL_HIDDEN_INPUT A normal input field but invisible.

A normal input field can contain one line of text, to be typed in by the user. A float input field can only contain a float number. If the user tries to type in something other than a float, it is not shown and the bell is sounded. Similarly, an int input field can only contain an integer number and a date input field can only contain a valid date (see below). A multi-line input field can contain multiple lines of text. A secret input field works like a normal input field but the text is not shown. Only the cursor is shown which does move while text is being entered. This can be  used for getting passwords, for example. Finally, a hidden input field is not shown at all but does collect text for the application program to use.

Interaction

Whenever the user presses the mouse inside an input field a cursor will appear in it (and the field will change color to indicate input focus). Further input will be directed to this field. The user can use the following keys (as in emacs(1)) to edit or move around inside the input field:

delete previous char <DELETE>
delete next char <CNTRL> D
delete previous word <META><DELETE>,<CNTRL> W
delete next word <META> d
delete to end of line <CNTRL> k
backspace <CNTRL> H
to beginning of line <CNTRL> A,<SHIFT><LEFT>
to end of line <CNTRL> E, <SHIFT><RIGHT>
char backward <CNTRL> B, <LEFT>
char forward <CNTRL> F, <RIGHT>
next line <CNTRL> N, <DOWN>
previous line <CNTRL> P, <UP>
next page <PAGEDOWN>
previous page <PAGEUP>
word backward <META> b
word forward <META> f
beginning of field <META> <, <HOME>, <SHIFT><UP>
end of field <META> >, <END>, <SHIFT><DOWN>
clear input field <CNTRL> U
paste <CNTRL> y

It is possible to remap the the bindings, see later for details.

There are three ways to select part of the input field. Dragging, double-click and triple-click. Double-click selects the word the mouse is on and triple-click selects the entire line the mouse is on. The selected part of the input field is removed when the user types the <BACKSPACE> key or replaced by what the user types in. Also the cursor can be placed at different positions in the input field using the mouse.

One additional property of selecting part of the text field is that if the selection is done with the leftmouse the selected part becomes the primary (XA_PRIMARY) selection of the X Selection mechanism,  thus other applications, e.g., xterm, can request this selection. Conversely, the cutbuffers from other applications can be pasted into the input field. Use the middle mouse for pasting.  Note <CNTRL> y only pastes the cutbuffer generated by <CNTRL> k and is not related to the X Selection mechanism, thus it only works within the same application.

When the user presses the <TAB> key the input field is returned to the application program and the input focus is directed to the next input field. This also happens when the user presses the <RETURN> key but only if the  form does not contain a return button. The order which input field gets the focus when the <TAB>     is pressed is the same as the order the input field is added to the form. From within Form Designer, using the raising function arrange (re-arrange) the focus order. See Part ii Section 10.6 for details.

This (<TAB> and <RETURN>) does not work for multi-line input fields where <RETURN> key is used to separate lines and <TAB> is a legitimate input character (not currently handled though). Also when the user picks a new input field with the mouse, the current input object is returned.

The above mechanism is the default behavior of an input field. Depending on the application, other options might be useful. To change the precise condition for the object to be returned (or equivalently the callback invoked), the following function can be used:

 

   void fl_set_input_return(FL_OBJECT *obj, int when)

Where when can take one of the following values:

     

FL_RETURN_END_CHANGED
The default. Callback is called at the end if the field is modified.

FL_RETURN_CHANGED
Invoke the callback function whenever the field is changed.

FL_RETURN_END
Invoke the callback function at the end regardless if the field is modified or not.

FL_RETURN_ALWAYS
Invoke the callback function upon each keystroke.

See demo objreturn.c for an example use of this.

There is a routine that can be used to limit the number of characters per line for NORMAL_INPUT

 

   void fl_set_input_maxchars(FL_OBJECT *ob, int maxchars);

To reset the limit to infinite, set maxchars to 0.

Although an input with FL_RETURN_ALWAYS attributes can be used in combination with the callback function to check the validity of characters that are entered into the input field, use of the following is typically more appropriate

     

   typedef int (*FL_INPUTVALIDATOR)(FL_OBJECT *ob,
               const char *old, const char *cur, int c);
   FL_INPUTVALIDATOR fl_set_input_filter(FL_OBJECT *ob, 
                     FL_INPUTVALIDATOR filter);

The filter function is called whenever a new (regular) character is entered. old is the string in the input field before the newly typed character c is merged into cur. If the new character is not an acceptable character for the input field, the filter function should return FL_INVALID otherwise FL_VALID. If FL_INVALID is returned, the new character is discarded and the input field remains unmodified. The function returns the old filter. Unlike the built-in filters, keyboard bell is not sound when FL_INVALID is received. To sound the bell, return FL_INVALID|FL_RINGBELL.

This still leaves the possibility that the input is valid for every character entered, but the string is invalid for the field because it is incomplete. For example, 12.0e is valid for a float input field for every character typed, but the final string is not a valid floating point. To guard again this, the filter function is called just prior to returning the object with c set to zero. If the validator returns FL_INVALID, the object is not returned to the application program, but input focus can change to the next input field. If the return value is FL_INVALID|FL_RINGBELL, keyboard bell is sound and the object is not returned to the application program. Further, the input focus is not changed.

To facilitate specialized input fields using validators, the following validator dependent routines are available

   

   void fl_set_input_format(FL_OBJECT *ob, int attrib1, int attrib2)

   void fl_get_input_format(FL_OBJECT *ob, int *attrib1, int *attrib2)

These two routines more or less provide a means for the validator to store and retrieve some information about user preference or other state dependent information. attrib1 and attrib2 can be any validator defined variables. For the built-in class, only DATE_INPUT utilizes these to store the date format: for attrib1, it can take FL_INPUT_MMDD or FL_INPUT_DDMM     and attrib2 is the separator between month and day. For example, to set the date format to dd/mm, use the following

   void fl_set_input_format(ob, FL_INPUT_DDMM,'/')

For the built-in DATE_INPUT the default is FL_INPUT_MMDD and the separator is '/'. There is no limit on the year other than it must be an integer and appear after month and day.

Other routines

Note that the label is not the default text in the input field.

To set the contents of the input field use the routine

 

   void fl_set_input(FL_OBJECT *obj, const char *str)

There is very limited check for the validity of str for the input field. Use an empty string the clear an input field. 

Setting the content of an input field does not trigger object event, i.e., the object callback is not called. In some situations you might want to have the callback invoked. For this, use the following the routine

   

   void fl_call_object_callback(FL_OBJECT *obj)

To obtain the string in the field (when the user has changed it) use:

 

   const char *fl_get_input(FL_OBJECT *obj)

This function returns a char pointer for all input types. Thus for numerical input types, atoi(3), atof(3) or sscanf(3) should be used to convert the string to the proper data type you need. For multiline input, the returned pointer points to the entire content with possibly embedded newlines. The application should not modify the content pointed to by the returned pointer, which points to the internal buffer.

To select or deselect the current input or part of it, the following two routines can be used

   

   void fl_set_input_selected(FL_OBJECT *ob, int flag)

   void fl_set_input_selected_range(FL_OBJECT *ob, int start, int end)

where start and end are measured in characters. When start is 0 and end equals the number of characters in the string, fl_set_input_selected() makes the entire input field selected. However, there is a subtle difference between this routine and fl_set_input_selected() with flag==1. fl_set_input_selected() always places the cursor at the end of the string while fl_set_input_selected_range() places the cursor at the beginning of the selection.

To obtain the currently selected range, either selected by the application or by the user, use the following routine

 

   const char *fl_get_input_selected_range(FL_OBJECT *ob, 
                                          int *start, int *end)

Where start and end, if not null, are set to the begining and end position of the selected range, measured in characters. For example, if start is 5, and end is 7, it means the selection starts at character 6 (str[5]) and ends before character 8 (str[7]), so a total of two characters are selected (i.e., character 6 and 7). The function returns the selected string. If there is currently no selection, the function returns null and both start and end are set to -1. Note that the char pointer returned by the function points to (kind of) a static buffer, and will be overwritten by the next call.

It is possible to obtain the cursor position using the following routine

 

   int fl_get_input_cursorpos(FL_OBJECT *ob, int *xpos, int *ypos)

The function returns the cursor position measured in number of characters (including newline characters) in front of the cursor. If the input field does not have input focus (thus does not have a cursor), the function returns -1. Upon function return, ypos is set to the line number (starting from 1) the cursor is on and xpos set to the number of characters in front of the cursor measured from the beginning of the current line, i.e., ypos. If the input field does not have input focus, the xpos is set to -1.

It is possible to move the cursor within the input field programmatically using the following routine

 

   void fl_set_input_cursorpos(FL_OBJECT *ob, int xpos, int ypos)

where xpos and ypos are measured in characters (lines). E.g., given the input field, "an arbitrary string", the call fl_set_input_cursorpos(ob, 4, 1) places the the cursor after the first character <A> in arbitrary.

Shortcut keys can be associated with an input field to switch input focus.   To this end, use the following routine

 

   void fl_set_input_shortcut(FL_OBJECT *obj, const char *sc, int showit)

By default, if a MULTILINE_INPUT field contains more text than that can be shown, scrollbars will appear with which the user can scroll the text around horizontally or vertically. To change this default, use the following routines

   

   void fl_set_input_hscrollbar(FL_OBJECT *ob, int how)

   void fl_set_input_vscrollbar(FL_OBJECT *ob, int how)

where how can be one of the following values

FL_AUTO
The default. Shows the scrollbar only if needed.
FL_ON
Always shows the scrollbar.
FL_OFF
No scrollbar is shown.

Note however, turning off scrollbars for an input field does not turn off scrolling, the user can still scroll the field using cursor and other keys.

To completely turn off scrolling for an input field (for both multiline and single line input field), use the following routine with a false flag

 

   void fl_set_input_scroll(FL_OBJECT *obj, int flag)

There are also routines that can scroll the input field programmatically. To scroll vertically (for MULTILINE_INPUT only), use the following routine

 

   void fl_set_input_topline(FL_OBJECT *obj, int line)

where line is the new top line (starting from 1) in the input field.

To scroll horizontally, use the following routine

 

   void fl_set_input_xoffset(FL_OBJECT *ob, int pixels)

where pixels, a positive number, indicates how many pixels to scroll to the left relative to the nominal position of the text lines.

To obtain the current xoffset, use the following function

 

   int fl_get_input_xoffset(FL_OBJECT *ob)

To obtain the number of lines in the input field, use the following routine

 

   int fl_get_input_numberoflines(FL_OBJECT *ob)

To obtain the current topline in the input field, use

 

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,
                          FL_Coord w, FL_Coord h, const char *label)

It shows a box on the screen with the label centered in it.

Types

The following types are available:        

 
  FL_PUSH_MENU 		 The menu appears when the user presses a mouse button on it.

FL_PULLDOWN_MENU The menu appears when the user presses a mouse button on it.

FL_TOUCH_MENU The menu appears when the user move the mouse inside it.

PUSH_MENU and PULLDOWN_MENU behaves in exactly the same way. The only difference is in the way they are drawn when the menu is active: PUSH_MENU's menu appears to be an up_box casting a shadow while PULLDOWN_MENU's is just an extension of the menu box (see Fig. 19.1).

   figure2372
Figure 19.1: Menu types

Interaction

When the menu appears the user can make a selection using the left mouse button or make no selection by clicking outside the menu. When he makes a selection the menu object is returned0;

   int fl_get_input_topline(FL_OBJECT *ob)

To obtain the number of lines that fit inside the input box, use the following routine

 

   int fl_get_input_screenlines(FL_OBJECT *ob)

Attributes

Never use FL_NO_BOX as boxtype.

Color1 controls the color of the input field when it is not selected and color2 is the color when selected.

To change the color of the input text or the cursor use

 

   void fl_set_input_color(FL_OBJECT *obj, int tcol, int ccol)

Here tcol indicates the color of the text and ccol is the color of the cursor.

By default, the scrollbar size is dependent on the initial size of the input box. To change the size of the scrollbars, use the following routine

   void fl_set_input_scrollbarsize(FL_OBJECT *ob, int hh, int vw)

where hh is the horizontal scrollbar height and vw is the vertical scrollbar width in pixels.

The default scrollbar type is THIN_SCROLLBAR. There are two ways you can change the default. One way

      is to use fl_set_defaults() or fl_set_scrollbar_type()

to set the application wide default (preferred); another way is to use fl_get_object_component() to   get the object handle to the scrollbars and change the   the object type forcibly. Although the second method of changing the scrollbar type is not recommended, the object handle obtained can be useful in changing the scrollbar colors etc.

As mentioned earlier, it is possible for the application program to change the default edit keymaps. The editing key assignment is held in a FL_EditKeymap structure defined as follows:

 

   typedef struct
   {
      long del_prev_char;         /* delete previous char    */
      long del_next_char;         /* delete next char        */
      long del_prev_word;         /* delete previous word    */
      long del_next_word;         /* delete next word        */

      long moveto_prev_line;     /* one line  up             */
      long moveto_next_line;     /* one line down            */
      long moveto_prev_char;     /* one char left            */
      long moveto_next_char;     /* one char right           */
      long moveto_prev_word;     /* one word left            */
      long moveto_next_word;     /* one word right           */
      long moveto_prev_page;     /* one page up              */
      long moveto_next_page;     /* one page down            */
      long moveto_bol;           /* move to begining of line */
      long moveto_eol;           /* move to end of line      */
      long moveto_bof;           /* move to begin of file    */
      long moveto_eof;           /* move to end of file      */

      long transpose;            /* switch two char positions*/
      long paste;                /* paste the edit buffer    */
      long backspace;            /* alias for del_prev_char  */
      long del_to_eol;           /* cut to end of line       */
      long del_to_bol;           /* cut to end of line       */
      long clear_field;          /* delete all               */
      long del_to_eos;           /* not implemented yet      */
   } FL_EditKeymap;

To change the default edit keymaps, the following routine is available:

 

   void fl_set_input_editkeymap(FL_EditKeymap *km)

with a filled or partially filled FL_EditKeymap structure. The unfilled members must be set to zero so the default mapping is retained. Change of edit keymap is global and affects all input field within the application.

Setting km to null restores the default.

All cursor keys (<LEFT>, <HOME> etc.) are reserved and their meanings hard-coded, thus can't be used in the mapping. For example, if you try to set del_prev_char to <HOME>, pressing the <HOME> key will not delete the previous character.

In filling the keymap structure, regular control characters (value < 32) and ASCII characters ( < 128) should be given their ASCII codes (<CNTRL> C is 3 etc) and special characters their Keysyms (XK_F1 etc). Control and special character combination is obtained by adding FL_CONTROL_MASK to the keysym. To specify meta add FL_ALT_MASK to the key value.

   FL_EditKeymap ekm;

   memset(ekm, 0 , sizeof(ekm));           /* zero struct    */
   ekm.del_prev_char = 8;                  /* control-H      */ 
   ekm.del_next_char = 127;                /* delete         */
   ekm.del_prev_word = 'h'|FL_ALT_MASK;    /* meta-H         */
   ekm.del_next_word = 127|FL_ALT_MASK;    /* meta-delete    */
   ekm.moveto_bof = XK_F1;                 /* F1 to bof      */
   ekm.moveto_eof = XK_F1|FL_CONTROL_MASK; /* cntl-F1 to eof */

   fl_set_input_editkeymap(&ekm);

Remarks

Always make sure that the input field is high enough to contain a single line of text. If the field is not high enough,   the text may get clipped, i.e., invisible.

See the program demo06.c for an example of the use of input fields. See minput.c for multi-line input fields. See secretinput.c for secret input fields and inputall.c for all input fields.  

Choice objects

Menu

 

Short description

Also menus can be added to forms. These menus can be used to let the user choose from many different possibilities. Each menu object has a box with a label in it in the form. Whenever the user presses the mouse inside the box (or moves the mouse on top of the box) a pop-up menu appears. The user can then make a selection from the menu.

Adding an object

To add a menu to a form use the routine

 

   FL_OBJECT *fl_add_menu(int type, FL_Coord x, FL_Coord y,