XForms: What's up with this?

Gerald Gryschuk (ggryschuk@scf.sk.ca)
Tue, 14 Jul 1998 11:27:15 -0600

# To subscribers of the xforms list from Gerald Gryschuk <ggryschuk@scf.sk.ca> :

Hi.

I was attempting to create my own object when I discovered the following
behaviour, which may not be unexpected but I was wondering how to get
around it. If you add text directly to a form using fl_drw_text then
resize the form using the mouse or freeze the form and then resize an
object on the form and unfreeze the form the text disappears. Just to be
clear on this I've included some sample code showing this behaviour:

#include "forms.h"
#include <stdlib.h>

/**** Forms and Objects ****/
typedef struct {
FL_FORM *resizeform;
void *vdata;
char *cdata;
long ldata;
FL_OBJECT* browser;
} FD_resizeform;

// extern FD_resizeform * create_form_resizeform(void);

FD_resizeform *create_form_resizeform(void)
{
FL_OBJECT *obj;
FD_resizeform *fdui = (FD_resizeform *) fl_calloc(1, sizeof(*fdui));

fdui->resizeform = fl_bgn_form(FL_NO_BOX, 510, 340);
obj = fl_add_box(FL_UP_BOX,0,0,510,340,"");
fdui->browser = obj =
fl_add_browser(FL_NORMAL_BROWSER,130,80,160,210,"A Browser");
fl_end_form();

fdui->resizeform->fdui = fdui;

return fdui;
}

#define THETEXT "This is some really long text so that I can test the
scrolling of the browser"

int main(int argc,char** argv)
{
FD_resizeform* t = NULL;
FL_OBJECT* obj = NULL;
FL_COORD width,height;
char buf[255];
int i = 0;
fl_initialize(&argc,argv,0,0,0);

t = create_form_resizeform();

fl_show_form(t->resizeform,FL_PLACE_FREE,FL_FULLBORDER,"resize
test");

/* this line should cause a small yellow filled right facing
triangle
* to appear in the upper left corner of the form.
*/

fl_drw_text(FL_ALIGN_LEFT,0,0,20,20,FL_YELLOW,FL_NORMAL_STYLE,12,"@>");

fl_freeze_form(t->resizeform);
fl_add_browser_line(t->browser,"This is a line of text");
fl_add_browser_line(t->browser,THETEXT);

/* but freezing the form and then resizing the browser makes the
* yellow triangle above disappear, why? Comment out the
fl_freeze
* and fl_unfreeze to see the yellow triangle.
*/
fl_set_object_size(t->browser,t->browser->w - 20,t->browser->h -
20);
fl_unfreeze_form(t->resizeform);

fl_do_forms();
}

The basic problem is that I want to resize my composite object similar
to the way the browser does when you add a line longer than its window
or more lines than the window can fit. That is if you take out the
set_object_size line the browser had to have resized itself but the
yellow triangle is still visible. So if the browser doesn't use a call
to fl_set_object_size internally what does it do?

Any help is muchly appreciated.

-- 
Gerald Gryschuk(ggryschuk@scf.sk.ca)
Programmer Analyst
Saskatoon Cancer Centre
((306)655-2746)
_________________________________________________
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://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/