123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #include <FL/Fl.H>
- #include <FL/fl_draw.H>
- #include <Fl/Fl_Progress.H>
- #include "Fl_Vert_Progress.h"
-
- Fl_Vert_Progress::Fl_Vert_Progress(int x, int y, int w, int h, const char* l)
- : Fl_Progress(x,y,w,h)
- {
- }
-
- // This member function is a slight variation on a verbatim
- // copy of Fl_Progress.cxx from the FLTK source library.
- void Fl_Vert_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)(h() * (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() + h() - (progress + by), w(), progress + by);
-
- 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<h())
- {
- fl_push_clip(x(), y(), w(), h()-progress);
-
- draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
-
- draw_label(tx, y() + by, tw, h() - bh);
-
- fl_pop_clip();
- }
- }
- else
- {
- draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
- draw_label(tx, y() + by, tw, h() - bh);
- }
- }
|