Other Folder Routines (XForms (Forms Library) - Version 1.2 (Rev. 4) A Graphical User Interface Toolkit for X)

Next: Folder Remarks, Previous: Folder Interaction, Up: Folder Object [Contents][Index]

#### 20.1.4 Other Folder Routines

To populate a tabbed folder, use the following routine

    FL_OBJECT *fl_addto_tabfolder(FL_OBJECT *obj, const char *tab_name,
                                  FL_FORM *folder)

where `tab_name` is a string (with possible embedded newlines in it) indicating the text of the tab rider and `folder` is a regular form created between calls of `fl_bgn_form()` and `fl_end_form()`. Only the pointer to the form is required. This means that the application program should not destroy a form that has been added to a tabbed folder. The function returns the folder tab object, which is an object of class `FL_BUTTON`. The initial object color, label color, and other attributes (gravities, for example) of the tab button are inherited from the tabbed folder object `obj` and the location and size of the tab are determined automatically. You can change the attributes of the returned object just like any other objects, but not all possibilities result in a pleasing appearance. Note that although there is no specific requirement of what the backface of the folder/form should be, a boxtype other than `FL_FLAT_BOX` or `FL_NO_BOX` may not look nice. If the backface of the form is of `FL_FLAT_BOX` the associated tab will take on the color of the backface when activated.

One thing to note is that each tab must have its own form, i.e., you should not associate the same form with two different tabs. However, you can create copies of a form and use these copies.

To access the individual forms on the tabfolder, e.g., in order to modify something on it, use the following routines

    FL_FORM *fl_get_tabfolder_folder_bynumber(FL_OBJECT *obj, int num);
    FL_FORM *fl_get_tabfolder_folder_byname(FL_OBJECT *obj,
                                            const char *name);
    FL_FORM *fl_get_tabfolder_folder_byname_f(FL_OBJECT *obj,
                                              const char *fnt, ...);

The functions take either the sequence number (the first tab on the left has a sequence number 1, the second 2 etc) or the tab name, which can either be passed directly as a string or via a format string like for `printf()` etc. and the corresponding (unspecified) arguments. The functions return the form associated with the number or the name. If the requested number or name is invalid, `NULL` is returned.

If there are more tabs than that can be shown, the right-most tab will be shown as "broken". Clicking on the "broken" tab scrolls the tab to the right one per each click. To scroll to the left (if there are tabs scrolled-off screen from the left), clicking on the first tab scrolls right. How many tabs are "hidden" on the left can be determined and also set using the functions

    int fl_get_tabfolder_offset(FL_OBJECT *ojb);
    int gl_set_tabfolder_offset(FL_OBJECT *obj, int offset);

where `offset` is the number of tabs hidden on the left.

Although a regular form (top-level) and a form used as a folder behave almost identically, there are some differences. In a top-level form, objects that do not have callbacks bound to them will be returned, when their states change, to the application program via `fl_do_forms()` or `fl_check_forms()`. When a form is used as a folder, objects that do not have a callback are ignored even when their states changes. The reason for this behavior is that presumably the application does not care while the changes take place and they only become relevant when the the folder is switched off and at that time the application program can decide what to do with these objects’ states (apply or ignore for example). If immediate reaction is desired, just use callback functions for these objects.

To obtain the number of folders in the tabfolder, the following routine can be used

    int fl_get_tabfolder_numfolders(FL_OBJECT *obj);

To remove a folder, the following routine is available

    void fl_delete_folder(FL_OBJECT *obj, FL_FORM *folder);
    void fl_delete_folder_bynumber(FL_OBJECT *obj, int num);
    void fl_delete_folder_byname(FL_OBJECT *obj, const char *name);
    void fl_delete_folder_byname_f(FL_OBJECT *obj, const char *fmt, ...);

(the last two function differ in the way the tab names gets passed, the first is to be called with a simple string while the second expects a format string as used for `printf()` etc. and the appropriate number of arguments, from which the tab name gets constructed). wNote that after deletion, the number of folders in the tabfolder as well as the sequence numbers are updated. This means if you want to delete all folders after the second folder, you can do that by deleting the third folder repeatedly.

The application program can select which folder to show by using the following routines

    void fl_set_folder(FL_OBJECT *obj, FL_FORM *folder);
    void fl_set_folder_bynumber(FL_OBJECT *obj, int num);
    void fl_set_folder_byname(FL_OBJECT *obj, const char *name);
    void fl_set_folder_byname_f(FL_OBJECT *obj, const char *fmt, ...);

(The latter two functions only differ in the way the tab name gets passed top them, the first accepts a simple string while the second expects a format string as used for `printf()` etc. and the appropriate number of (unspecified arguments, from which the tab name is constructed.)

Since the area occupied by the tabbed folder contains the space for tabs, the following routine is available to obtain the actual folder size

    void fl_get_folder_area(FL_OBJECT *obj, FL_Coord *x, FL_Coord *y,
                            FL_OBJECT *w, FL_OBJECT *h)

where `x` and `y` are relative to the (top-level) form the tabbed folder belongs to. The size information may be useful for resizing the individual forms that has to go into the tabbed folder. Note that the folder area may not be constant depending on the current tabs (For example, adding a multi-line tab will reduce the area for the folders).

Since tab size can vary depending on monitor/font resolutions, it is in general not possible to design the forms (folders) so they fit exactly into the folder area. To dynamically adjust the sizes of the folders so they fit, the following routine is available

    int fl_set_tabfolder_autofit(FL_OBJECT *obj, int how);

where `how` can be one of the following constants:

`FL_NO`

  Do not scale the form.

`FL_FIT`

  Always scale the form.

`FL_ENLARGE_ONLY`

  Scale the form only if it is smaller than the folder area.

The function returns the old setting.

Next: Folder Remarks, Previous: Folder Interaction, Up: Folder Object [Contents][Index]