Re: XForms: Progress Bar using scrollbar?

Steve Lamont (spl@szechuan.ucsd.edu)
Fri, 22 Oct 99 14:37:35 PDT

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

> > fill_slider is almost designed with this kind of tasks.
>
> But it still doesn't solve the problem that you can't have a
> zero-length slider, hence it's not ideal for use as a progress
> bar monitor...

Harrumph. Did you try it?

The following is a little example I whacked together. It starts with
a zero length horizontal fill slider. Press the "Do it" button and
you should see a progress bar go from 0 to full length (100 percent)
in few seconds.

spl
- - -
#include <stdio.h>
#include <forms.h>
#include <stdlib.h>

void do_it_cb(FL_OBJECT *, long);

typedef struct {
FL_FORM *try;
void *vdata;
char *cdata;
long ldata;
FL_OBJECT *progress;
FL_OBJECT *do_it;
} FD_try;

FD_try *fd_try;

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, 435, 115);
obj = fl_add_box(FL_EMBOSSED_BOX,0,0,435,115,"");
fl_set_object_color(obj,FL_LEFT_BCOL,FL_COL1);
fdui->progress = obj = fl_add_slider(FL_HOR_FILL_SLIDER,65,35,300,30,"You call this progress?");
fl_set_object_color(obj,FL_GREEN,FL_RED);
fl_set_object_lsize(obj,FL_NORMAL_SIZE);
fl_set_object_lstyle(obj,FL_BOLD_STYLE);
fl_set_slider_size(obj, 0.15);
fdui->do_it = obj = fl_add_button(FL_NORMAL_BUTTON,10,80,85,30,"Do It");
fl_set_object_callback(obj,do_it_cb,0);
fl_end_form();

fl_adjust_form_size(fdui->try);
fdui->try->fdui = fdui;

return fdui;
}

void progress_cb( int id, void *data )

{

double *time = ( double *) data;

fl_set_slider_value( fd_try->progress, *time );
if ( *time < 1.0 )
fl_add_timeout( 100, progress_cb, data );

(*time) += .01;

}

void do_it_cb(FL_OBJECT *ob, long data)

{

static double time;

time = 0;
fl_add_timeout( 100, progress_cb, ( void *) &time );

}

int main(int argc, char *argv[])

{

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

fl_show_form(fd_try->try,FL_PLACE_CENTERFREE,FL_FULLBORDER,"try");
fl_set_slider_value( fd_try->progress, 0.0 );

fl_do_forms();

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