2 #include <algorithm> // for max()
3 #include "wmmeterbar.h"
10 // functions for WMMeterBar ----------------------------------------------
14 WMMeterBar::real_display()
16 if ((orientation() == Orientation::Horizontal
&& width() < 2 * border())
17 || (orientation() == Orientation::Vertical
&& height() < 2 * border()))
18 { cerr
<< "WMError: Meter Bar " << this << " too small" << endl
; return; }
20 //first draw desired background
24 if (orientation() == Orientation::Horizontal
)
25 WMApp::Xw
.draw_horizontal_gradient(window()->pixmap(),
26 b_left(), b_top(), b_right(), b_bottom(), 0x5C00, 0x5C0000);
28 WMApp::Xw
.draw_vertical_gradient(window()->pixmap(),
29 b_left(), b_top(), b_right(), b_bottom(), 0x5C0000, 0x5C00);
32 WMApp::Xw
.fill_rectangle(window()->pixmap(), b_position(),
36 WMApp::Xw
.fill_rectangle(window()->pixmap(), b_position(),
38 if (orientation() == Orientation::Horizontal
)
39 for (int x
= 0; x
< b_width(); x
+= 2)
40 WMApp::Xw
.draw_line(window()->pixmap(), x
+ b_left(), b_top(),
41 x
+ b_left(), b_bottom(), 0x004941);
43 for (int y
= 0; y
< b_height(); y
+= 2)
44 WMApp::Xw
.draw_line(window()->pixmap(), b_left(),
45 b_bottom() - y
, b_right(), b_bottom() - y
, 0x004941);
49 //then draw the progress bar
50 if (total() && value())
55 if (orientation() == Orientation::Horizontal
)
56 WMApp::Xw
.draw_horizontal_gradient(window()->pixmap(),
57 b_left(), b_top(), b_right(), b_bottom(),
58 0xFF00, 0xFF0000, fraction());
60 WMApp::Xw
.draw_vertical_gradient(window()->pixmap(),
61 b_left(), b_bottom(), b_right(), b_top(),
62 0xFF00, 0xFF0000, fraction());
65 if (orientation() == Orientation::Horizontal
)
67 x
< static_cast<int>(std::min(1.0, fraction()) * b_width());
69 WMApp::Xw
.draw_line(window()->pixmap(), x
+ b_left(), b_top(),
70 x
+ b_left(), b_bottom(), WMColor(Bright
));
73 y
< static_cast<int>(std::min(1.0, fraction()) * b_height());
75 WMApp::Xw
.draw_line(window()->pixmap(), b_left(), b_bottom() - y
,
76 b_right(), b_bottom() - y
, WMColor(Bright
));