1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #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)
- {
- }
-
- void Fl_Vert_Progress::draw()
- {
- int progress; // Size of progress bar...
- int bx, by, bw, bh; // Box areas...
- int tx, ty, tw, th; // Temporary X + width
-
- float min_ = minimum();
- float max_ = maximum();
- float val_ = value();
-
- // 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;
- ty = y() + by;
- tw = w() - bw;
- th = h() - bh;
-
-
- // Draw the progress bar...
- if (max_ > min_)
- progress = (int)( th * (val_ - min_) / (max_ - min_) );
- else
- progress = 0;
-
- // Draw the box and label...
- if (progress > 0)
- {
- Fl_Color c = labelcolor();
- labelcolor(fl_contrast(labelcolor(), selection_color()));
-
-
- // draw the progress area
- //fl_push_clip(x(), y() + h() - progress, w(), progress);
- fl_push_clip(tx,ty + th - progress, tw, progress );
- 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<w())
- {
- // draw the non-progress area
- //fl_push_clip(x(), y(), w(), h() - progress );
- fl_push_clip(tx,ty,tw,th-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);
- }
-
- //fl_draw_box(FL_FLAT_BOX,x(),y(),w(),h(), FL_RED);
- //fl_draw_box(FL_FLAT_BOX,tx,ty,tw,th, FL_GREEN);
- //fl_draw_box(FL_FLAT_BOX,tx,ty,tw,th-progress, FL_BLACK); // non-prog
- //fl_draw_box(FL_FLAT_BOX,tx,ty + th - progress,tw,progress,FL_BLUE); // prog
-
- }
|