void butt_cb(Fl_Widget *butt, void *data) { // Deactivate the button butt->deactivate(); // prevent button from being pressed again Fl::check(); // give fltk some cpu to gray out button // Make the progress bar Fl_Window *w = (Fl_Window*)data; // access parent window w->begin(); // add progress bar to it.. Fl_Progress *progress = new Fl_Progress(10,50,200,30); progress->minimum(0); // set progress range to be 0.0 ~ 1.0 progress->maximum(1); progress->color(0x88888800); // background color progress->selection_color(0x4444ff00); // progress bar color progress->labelcolor(FL_WHITE); // percent text color w->end(); // end adding to window // Computation loop.. for ( int t=1; t<=500; t++ ) { progress->value(t/500.0); // update progress bar with 0.0 ~ 1.0 value char percent[10]; sprintf(percent, "%d%%", int((t/500.0)*100.0)); progress->label(percent); // update progress bar's label Fl::check(); // give fltk some cpu to update the screen Sleep(1000); // 'your stuff' that's compute intensive } // Cleanup w->remove(progress); // remove progress bar from window delete(progress); // deallocate it butt->activate(); // reactivate button w->redraw(); // tell window to redraw now that progress removed }
void Mixer::redraw_windows ( void ) { window()->redraw(); if ( Fl::first_window() ) for ( Fl_Window *w = Fl::first_window(); ( w = Fl::next_window( w ) ); ) w->redraw(); }