Re: XForms: Bug? -- browser xoffset setting

Steve Lamont (spl@szechuan.ucsd.edu)
Mon, 28 Sep 98 06:49:09 PDT

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

> Try to repeat following 2 lines:
>
> fl_set_browser_xoffset(someBrow, ZERO);
>
> fl_replace_browser_line(someBrow, line_num, "replace_text");

I did and still got the expected result -- that is, other than the
text changing, no discernable change.

The following is the test code which I used:

- - - try.c - - -
/* Form definition file generated with fdesign. */

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

FD_try *create_form_try(void)
{
FL_OBJECT *obj;
FD_try *fdui = (FD_try *) fl_calloc(1, sizeof(*fdui));

fdui->try = fl_bgn_form(FL_NO_BOX, 320, 250);
obj = fl_add_box(FL_UP_BOX,0,0,320,250,"");
obj = fl_add_button(FL_NORMAL_BUTTON,10,10,70,30,"Left");
fl_set_object_callback(obj,go_left_cb,0);
fdui->browser = obj = fl_add_browser(FL_NORMAL_BROWSER,20,60,280,160,"");
obj = fl_add_button(FL_NORMAL_BUTTON,240,10,70,30,"Right");
fl_set_object_callback(obj,go_right_cb,0);
fl_end_form();

fdui->try->fdui = fdui;

return fdui;
}
/*---------------------------------------*/

- - - try.h - - -
/** Header file generated with fdesign on Fri Sep 25 06:14:12 1998.**/

#ifndef FD_try_h_
#define FD_try_h_

/** Callbacks, globals and object handlers **/
extern void go_left_cb(FL_OBJECT *, long);
extern void go_right_cb(FL_OBJECT *, long);

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

extern FD_try * create_form_try(void);

#endif /* FD_try_h_ */
- - - try_main.c - - -
#include "forms.h"
#include "try.h"

/* callbacks and freeobj handles for form try */
void go_left_cb(FL_OBJECT *ob, long data)
{

FD_try *fd_try = ( FD_try *) ob->form->fdui;
static int n = 0;
char buffer[80];

fl_set_browser_xoffset( fd_try->browser, 0 );
sprintf( buffer, "try %d", n++ );
fl_replace_browser_line( fd_try->browser, 1, buffer );

}

void go_right_cb(FL_OBJECT *ob, long data)
{

FD_try *fd_try = ( FD_try *) ob->form->fdui;

fl_set_browser_xoffset( fd_try->browser, 100 );

}

int main(int argc, char *argv[])
{
FD_try *fd_try;
int i;
char buffer[129];

fl_initialize(&argc, argv, 0, 0, 0);
fd_try = create_form_try();

for ( i = 0; i < 128; i++ )
buffer[i] = ( i % 26 ) + 'a';
buffer[128] = '\0';
for ( i = 1; i < 50; i++ )
fl_add_browser_line( fd_try->browser, buffer );
fl_show_form(fd_try->try,FL_PLACE_CENTERFREE,FL_FULLBORDER,"try");
fl_do_forms();
return 0;
}
- - -

Compile and link in the standard manner.

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://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/