> I'm making a program that uses a lot of CPU time, and I want to have
> a percentage bar (you know, a grey bar that goes form 0% to 100%),
> and my rutine is something like this:
> rutine
> {
> for(x=0;x<100;x++)
> {
> work_a_lot (); //some seconds with 100% CPU
> status_bar.percent=x;
> refresh (status_bar); //refresh status bar
> }
> }
> but there is a little problem, the refresh rutine doesn't work, a
> think that refresh gives the order to paint o refresh the status bar
> to the X11 window manager, but it doesn't enought time or CPU to
> redraw the status bar.
Unless you return control to XForms, the status bar won't get
updated.
The following is a little routine I use to show a progress bar:
void working( InfoP info_ptr, 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 ) {
if ( percent >= 100.0 ) {
destroy_fdui_form( progress );
progress = NULL;
fl_activate_all_forms();
} else
fl_set_slider_value( progress->percent_done, percent );
}
fl_check_forms();
}
Note that I call fl_check_forms() after I update my slider in the
form.
destroy_fdui_form() hides and frees the form, then frees the fdui
structure.
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/