Previous: , Up: Part V Resources for Forms Library   [Contents][Index]


34.2 Going Further

It is possible to implement your own form/object specific resources management system using the services mentioned above. For example, to implement a user-configurable form size, code similar to the following can be used, assuming the form is named "myform":

struct fsize {
    int width,
        height;
} myformsize;

FL_RESOURCE res[] = {
  {"myform.width", "XForm.width",  FL_INT, &myform.width,  "150"},
  {"myform.height","XForm.height", FL_INT, &myform.height, "150"}
};

fl_initialize(&argc, argv, app_class, 0, 0);
fl_get_app_resources(res, 2);

/* create the forms */

myform = fl_bgn_form(myformsize.width, myformsize.height,.....);

Or (more realistically) you create the form first using fdesign and then scale it before it is shown:

fl_initialize(&argc, argv, app_class, 0, 0);
fl_get_app_resources(res, 2);

/*create_all_forms here */

fl_set_form_size(myform, mysformsize.width, myformsize.height);
fl_show_form(myform, ...);

Since eventually form geometry and other things might be done via XForms internal routines it is recommended that you name your form to be the form title with all spaces removed and the first letter lower-cased, i.e., if a form is shown with a label Foo Bar, the name of the form should be fooBar.