Re: XForms: resizing a form

Steve Lamont (spl@szechuan.ucsd.edu)
Mon, 2 Feb 98 18:07:30 PST

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> In order to get this to work, I have to set every object's resize to
> RESIZE_NONE, and both gravities to FL_North. After doing that, it works ok.
> This isn't the problem.
>
> The problem is that after doing the above, the form is un-resizable. The only
> way to make it resizable again is to change all the gravity and resize
> properties one by one back to their original values. This is the part I want
> to avoid, for obvious reasons.

Okay, I guess I don't understand what you want to do. I thought the
objective was to basically hide part of the form's objects. But you
also want to be able to have the form resized by the user. Right?

Here's a hack that does this:

void set_resize( FL_OBJECT *ob, FL_RESIZE_T resize_type, int nw, int se )

{

FL_FORM *form = ob->form;
FL_OBJECT *obj = form->first->next; /* The first object is junk */
/* We'll also skip the */
/* background box */
do {

obj = obj->next;
fl_set_object_resize( obj, resize_type );
fl_set_object_gravity( obj, nw, se );

} while ( obj != form->last );

}

void restore_resize( int timeout, void *data )

{

FL_OBJECT *ob = ( FL_OBJECT *) data;

set_resize( ob, FL_RESIZE_ALL, FL_NoGravity, FL_NoGravity );

}

void resize_me_cb(FL_OBJECT *ob, long data)

{

static int change_size = 0;

set_resize( ob, FL_RESIZE_NONE, FL_NorthWest, FL_NoGravity );

if ( change_size )
fl_set_form_size( ob->form, ob->form->w * 2, ob->form->h );
else
fl_set_form_size( ob->form, ob->form->w / 2, ob->form->h );

fl_add_timeout( 250, restore_resize, ob );
change_size = !change_size;

}

Note that the resize restore is done by a timeout callback rather than
by the resize_me_cb callback. This is because the ConfigureNotify
event apparently doesn't get processed by XForms's event loop until
after resize_me_cb returns. This would cause XForms to process the
event with the wrong set of resize/gravity attributes for the form.

Obviously, you'd want to change the arguments to fl_set_form_size() to
appropriate values and perhaps change the bookkeeping for change_size,
as well.

This is rather inelegant but it does allow the kind of resize you want
and doesn't require you to rename all the objects. As far as I know
there's no more direct way to do this.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bloch.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/