diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2001-08-11 14:49:51 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2001-08-11 14:49:51 +0000 |
| commit | 64859c22f78f736eb9c44e5bd45dbbfafdab24d1 (patch) | |
| tree | dfc31353ae060200dd0e3dd1f8345edb86929c9d /src/Fl_Progress.cxx | |
| parent | 90781ce4280770f05bdeab21bf2c8e268f1b55fc (diff) | |
Add more widgets from the bazaar...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1571 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Progress.cxx')
| -rw-r--r-- | src/Fl_Progress.cxx | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/src/Fl_Progress.cxx b/src/Fl_Progress.cxx new file mode 100644 index 000000000..d8406aff7 --- /dev/null +++ b/src/Fl_Progress.cxx @@ -0,0 +1,108 @@ +// +// "$Id: Fl_Progress.cxx,v 1.1.2.1 2001/08/11 14:49:51 easysw Exp $" +// +// Progress bar widget routines. +// +// Copyright 2000-2001 by Michael Sweet. +// +// 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. +// +// Please report all bugs and problems to "fltk-bugs@fltk.org". +// +// Contents: +// +// 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. +// + +void Fl_Progress::draw() +{ + int progress; // Size of progress bar... + int bx, by, bw, bh; // Box areas... + + + // Get the box borders... + bx = Fl::box_dx(box()); + by = Fl::box_dy(box()); + bw = Fl::box_dw(box()); + bh = Fl::box_dh(box()); + + // Draw the box... + draw_box(box(), x(), y(), w(), h(), color()); + + // Draw the progress bar... + if (maximum_ > minimum_) + progress = (int)((w() - bw) * (value_ - minimum_) / + (maximum_ - minimum_) + 0.5f); + else + progress = 0; + + if (progress > 0) + { + fl_clip(x() + bx, y() + by, w() - bw, h() - bh); + + fl_color(active_r() ? color2() : inactive(color2())); + fl_polygon(x() + bx, y() + by, + x() + bx, y() + h() - by, + x() + 3 + progress - h() / 4, y() + h() - by, + x() + 1 + progress + h() / 4, y() + by); + + fl_pop_clip(); + } + + // Finally, the label... + draw_label(x() + bx, y() + by, w() - bw, h() - bh); +} + + +// +// 'Fl_Progress::Fl_Progress()' - Construct a Fl_Progress widget. +// + +Fl_Progress::Fl_Progress(int x, int y, int w, int h, const char* l) +: Fl_Widget(x, y, w, h, l) +{ + align(FL_ALIGN_INSIDE); + box(FL_DOWN_BOX); + color(FL_WHITE, FL_YELLOW); + minimum(0.0f); + maximum(100.0f); + value(0.0f); +} + + +// +// End of "$Id: Fl_Progress.cxx,v 1.1.2.1 2001/08/11 14:49:51 easysw Exp $". +// |
