Re: XForms: array of objects

Jimmie Mayfield (
Mon, 21 Jul 1997 08:27:02 -0400 (EDT)

To subscribers of the xforms list from Jimmie Mayfield <> :

According to Brigitte Meillon:
> So my solution was to write my own program with arrays of counters "by
> hand" without fdesign, but it's not very convenient and any modification
> in this panel must be done by program.

This is similar to how I use fdesign/xforms since I'm doing all my work
in C++ and all my user interface objects need to be treated as class
members. Each of my window clases has a member called "createObjects()"
into which I basically block copy fdesign's output for that particular
form, storing the (FL_OBJECT *)'s in arrays if needed. While I don't have any
form with an array of 160 objects, I do have several forms with arrays of
around 40 checkboxes and I have found the above method to work quite well
(it works especially well for arrays of similar objects).

To make it easier if you ever have to redesign the form's layout, I would
recommend using the following format to your "createObjects()" routine:

_form = fl_bgn_form();

// in here you only put the actual object creation calls
// fdesign will output something similar to
// obj = fl_add_checkbutton(...)
// so simply replace 'obj' with your array
_buttons[0] = fl_add_checkbutton(...);
_buttons[1] = fl_add_checkbutton(...);
_buttons[159] = fl_add_checkbutton(...);


// now, put the code to adjust label sizes and object attributes. these
// probably won't change as often as object positions so in the future,
// all you'll likely need to change is the stuff between fl_bgn_form()
// and fl_end_form()

for (int i=0; i<160; i++)
fl_set_object_lsize( _buttons[i], FL_NORMAL_SIZE );

BTW, it seems like 160 counters on the same form would be somewhat crowded?

Jimmie Mayfield                 "Hey brother can you spare a dime...              to get me off this slaughter line?"
#include <disclaimer.h> 
To unsubscribe, send the message "unsubscribe" to or see
Xforms Home Page:
List Archive: