2001-08-11 18:49:51 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|
|
|
|
// Progress bar widget routines.
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// Copyright 2000-2005 by Michael Sweet.
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|
|
|
|
// Contents:
|
2008-09-15 04:27:28 +04:00
|
|
|
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|
|
|
|
// Fl_Progress::draw() - Draw the check button.
|
|
|
|
// Fl_Progress::Fl_Progress() - Construct a Fl_Progress widget.
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Include necessary header files...
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/Fl_Progress.H>
|
|
|
|
#include <FL/fl_draw.H>
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Fl_Progress is a progress bar widget based off Fl_Widget that shows a
|
|
|
|
// standard progress bar...
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// 'Fl_Progress::draw()' - Draw the check button.
|
|
|
|
//
|
|
|
|
|
2008-10-31 19:30:07 +03:00
|
|
|
/** Draws the progress bar. */
|
2001-08-11 18:49:51 +04:00
|
|
|
void Fl_Progress::draw()
|
|
|
|
{
|
|
|
|
int progress; // Size of progress bar...
|
|
|
|
int bx, by, bw, bh; // Box areas...
|
2001-12-06 21:12:35 +03:00
|
|
|
int tx, tw; // Temporary X + width
|
2001-08-11 18:49:51 +04:00
|
|
|
|
|
|
|
|
|
|
|
// Get the box borders...
|
|
|
|
bx = Fl::box_dx(box());
|
|
|
|
by = Fl::box_dy(box());
|
|
|
|
bw = Fl::box_dw(box());
|
|
|
|
bh = Fl::box_dh(box());
|
|
|
|
|
2001-12-06 21:12:35 +03:00
|
|
|
tx = x() + bx;
|
|
|
|
tw = w() - bw;
|
2001-08-11 18:49:51 +04:00
|
|
|
|
|
|
|
// Draw the progress bar...
|
|
|
|
if (maximum_ > minimum_)
|
2006-11-12 23:44:12 +03:00
|
|
|
progress = (int)(w() * (value_ - minimum_) / (maximum_ - minimum_) + 0.5f);
|
2001-08-11 18:49:51 +04:00
|
|
|
else
|
|
|
|
progress = 0;
|
|
|
|
|
2005-03-21 22:52:53 +03:00
|
|
|
// Draw the box and label...
|
|
|
|
if (progress > 0) {
|
|
|
|
Fl_Color c = labelcolor();
|
|
|
|
labelcolor(fl_contrast(labelcolor(), color2()));
|
|
|
|
|
2008-12-06 17:59:52 +03:00
|
|
|
fl_push_clip(x(), y(), progress + bx, h());
|
2001-12-06 21:12:35 +03:00
|
|
|
draw_box(box(), x(), y(), w(), h(), active_r() ? color2() : fl_inactive(color2()));
|
2005-03-21 22:52:53 +03:00
|
|
|
draw_label(tx, y() + by, tw, h() - bh);
|
2001-12-06 21:12:35 +03:00
|
|
|
fl_pop_clip();
|
2001-08-11 18:49:51 +04:00
|
|
|
|
2005-03-21 22:52:53 +03:00
|
|
|
labelcolor(c);
|
|
|
|
|
2006-11-12 23:44:12 +03:00
|
|
|
if (progress<w()) {
|
2008-12-06 17:59:52 +03:00
|
|
|
fl_push_clip(tx + progress, y(), w() - progress, h());
|
2006-11-12 23:44:12 +03:00
|
|
|
draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
|
|
|
|
draw_label(tx, y() + by, tw, h() - bh);
|
|
|
|
fl_pop_clip();
|
|
|
|
}
|
2005-03-21 22:52:53 +03:00
|
|
|
} else {
|
2006-11-12 23:44:12 +03:00
|
|
|
draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
|
2005-03-21 22:52:53 +03:00
|
|
|
draw_label(tx, y() + by, tw, h() - bh);
|
|
|
|
}
|
2001-08-11 18:49:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-15 04:27:28 +04:00
|
|
|
/**
|
|
|
|
The constructor creates the progress bar using the position,
|
|
|
|
size, and label.
|
|
|
|
<P> The inherited destructor removes the progress bar.
|
|
|
|
*/
|
2002-08-09 05:09:49 +04:00
|
|
|
Fl_Progress::Fl_Progress(int X, int Y, int W, int H, const char* l)
|
2008-09-15 04:27:28 +04:00
|
|
|
: Fl_Widget(X, Y, W, H, l) {
|
2001-08-11 18:49:51 +04:00
|
|
|
align(FL_ALIGN_INSIDE);
|
|
|
|
box(FL_DOWN_BOX);
|
2002-04-11 14:46:19 +04:00
|
|
|
color(FL_BACKGROUND2_COLOR, FL_YELLOW);
|
2001-08-11 18:49:51 +04:00
|
|
|
minimum(0.0f);
|
|
|
|
maximum(100.0f);
|
|
|
|
value(0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
2001-08-11 18:49:51 +04:00
|
|
|
//
|