# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :
> The program below illustrates (some of) the peculiarities of
> fl_get_folder_area().
>
> 1) the behavior for all tabs is wrong although it differs for the
> first and later calls: For the first, h seems to be too large,
> and y seems ok, for later calls h seems ok and y seems too large.
Yes, methinks this is a bug. The first call returns the dimensions
and origin of the *entire* Folder area -- without tabs. Later calls
return the dimensions and origin after being offset by the tabs.
> 2) closer inspection reveals that the claim that x and y are
> relative to the top level form are not true, they appears
> approx. twice as large.
As far as I can tell by close inspection with a screen grabbed image,
they are correct. In your example, I get
x 13 y 40 w 354 h 87
where the Folder was created at x = 10, y = 10. Offsetting 3 pixels
for the box, that puts us at x = 13, y = 13. Offsetting 27 pixels for
the tab puts us at y = 40.
However, this information isn't terribly useful for positioning
objects within the Form managed by the Folder, anyhow, so I suggest
disregarding it.
The location of an Obect on a Form managed by a Folder is relative to
the child Form's origin (0,0). So, in your code
> /* top left */
> fl_add_box (FL_UP_BOX, x, y, butW, butH, txt);
> /* bottom_left, too low ?? */
> fl_add_box (FL_UP_BOX, x, y + h - butH, butW, butH, txt);
> /* top right, too far right ?? */
> fl_add_box (FL_UP_BOX, x + w - butW, y, butW, butH, txt);
> /* bottom_right, ?? */
> fl_add_text (FL_UP_BOX, x + w - butW, y + h - butH, butW, butH, txt);
you should be doing
fl_add_box (FL_UP_BOX, 0, 0, butW, butH, txt);
^^^^
fl_add_box (FL_UP_BOX, 0, h - butH, butW, butH, t0t);
^^^^^^^^^^^
fl_add_box (FL_UP_BOX, w - butW, 0, butW, butH, txt);
^^^^^^^^^^^
fl_add_text (FL_UP_BOX, w - butW, h - butH, butW, butH, txt);
^^^^^^^^^^^^^^^^^^
That will position the Objects where you want them, relative to the
origin of the containing Form.
A workaround for the bogus area returned by the first call is to
create the Form empty and then add your objects:
fl_get_folder_area (folder, &x, &y, &w, &h);
form = fl_bgn_form (FL_BORDER_BOX, w, h);
fl_end_form ();
fl_get_folder_area (folder, &x, &y, &w, &h);
fl_add_box (FL_UP_BOX, 0, 0, butW, butH, txt);
fl_add_box (FL_UP_BOX, 0, h - butH, butW, butH, t0t);
fl_add_box (FL_UP_BOX, w - butW, 0, butW, butH, txt);
fl_add_text (FL_UP_BOX, w - butW, h - butH, butW, butH, txt);
fl_end_form ();
You really only need to do this your first pass through the tab
creation routine -- later passes would work correctly with more
sensible
fl_get_folder_area (folder, &x, &y, &w, &h);
form = fl_bgn_form (FL_BORDER_BOX, w, h);
fl_add_box (FL_UP_BOX, 0, 0, butW, butH, txt);
fl_add_box (FL_UP_BOX, 0, h - butH, butW, butH, t0t);
fl_add_box (FL_UP_BOX, w - butW, 0, butW, butH, txt);
fl_add_text (FL_UP_BOX, w - butW, h - butH, butW, butH, txt);
fl_end_form ();
Perhaps you can create and add a bogus Form to the Folder and then
just delete it once you've created your real child Forms -- this would
make the creation logic somewhat less involved.
Beware the caveats regarding tab sizes and monitor resolutions
discussed in the manual.
I hope this makes some shred of sense.
spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/
This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 10:47:38 EDT