// // "$Id: Fl_Progress.cxx 8864 2011-07-19 04:49:30Z greg.ercolano $" // // Progress bar widget routines. // // Copyright 2000-2010 by Michael Sweet. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this // file is missing or damaged, see the license at: // // http://www.fltk.org/COPYING.php // // Please report all bugs and problems on the following page: // // http://www.fltk.org/str.php // // Contents: // // Fl_Progress::draw() - Draw the check button. // Fl_Progress::Fl_Progress() - Construct a Fl_Progress widget. // // // Include necessary header files... // #include #include #include // // Fl_Progress is a progress bar widget based off Fl_Widget that shows a // standard progress bar... // // // 'Fl_Progress::draw()' - Draw the progress bar. // /** Draws the progress bar. */ void Fl_Progress::draw() { int progress; // Size of progress bar... int bx, by, bw, bh; // Box areas... int tx, tw; // Temporary X + width // Get the box borders... bx = Fl::box_dx(box()); by = Fl::box_dy(box()); bw = Fl::box_dw(box()); bh = Fl::box_dh(box()); tx = x() + bx; tw = w() - bw; // Draw the progress bar... if (maximum_ > minimum_) progress = (int)(w() * (value_ - minimum_) / (maximum_ - minimum_) + 0.5f); else progress = 0; // Draw the box and label... if (progress > 0) { Fl_Color c = labelcolor(); labelcolor(fl_contrast(labelcolor(), selection_color())); fl_push_clip(x(), y(), progress + bx, h()); draw_box(box(), x(), y(), w(), h(), active_r() ? selection_color() : fl_inactive(selection_color())); draw_label(tx, y() + by, tw, h() - bh); fl_pop_clip(); labelcolor(c); if (progress