Re: XForms: status bars

Steve Lamont (spl@szechuan.ucsd.edu)
Tue, 21 Jul 98 12:55:56 PDT

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

> Part of my program involves some lengthy calculations so
> I thought it would be nice to add a status bar while the
> calculations were in progress. ...

I do this with a horizontal fill slider.

Just create and show a form with the slider and periodically update
the slider in your compute loop and call fl_check_forms(). Here's a
little routine which does this:

void working( double percent )

{

static FD_progress *progress;

if ( percent == 0 ) {

Window window;

progress = create_form_progress();
window = fl_show_form( progress->progress,
FL_PLACE_CENTER,
FL_NOBORDER,
"progress" );
fl_deactivate_all_forms();

}
if ( progress ) {

fl_set_slider_value( progress->percent_done, percent );
if ( percent >= 100.0 ) {

destroy_object_form( progress->percent_done );
progress = NULL;
fl_activate_all_forms();

}

}
fl_check_forms();

}

The fdesign text looks like:

=============== FORM ===============
Name: progress
Width: 185
Height: 55
Number of Objects: 3

--------------------
class: FL_BOX
type: EMBOSSED_BOX
box: 0 0 185 55
boxtype: FL_EMBOSSED_BOX
colors: FL_YELLOW FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name:
callback:
argument:

--------------------
class: FL_VALSLIDER
type: HOR_FILL_SLIDER
box: 5 30 175 20
boxtype: FL_FLAT_BOX
colors: FL_YELLOW FL_GREEN
alignment: FL_ALIGN_BOTTOM
style: FL_BOLD_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: percent_done
callback:
argument:
bounds: 0 100
precision: 0
value: 0
slsize: 0.15

--------------------
class: FL_TEXT
type: NORMAL_TEXT
box: 5 5 175 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER|FL_ALIGN_INSIDE
style: FL_BOLD_STYLE+FL_EMBOSSED_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Percent Done...
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name:
callback:
argument:

I simply call the routine working() every so many iterations of my
compute (or whatever) loop.

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/