summaryrefslogtreecommitdiff
path: root/plugingui/progressbar.cc
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui/progressbar.cc')
-rw-r--r--plugingui/progressbar.cc136
1 files changed, 77 insertions, 59 deletions
diff --git a/plugingui/progressbar.cc b/plugingui/progressbar.cc
index 3b821bb..6882789 100644
--- a/plugingui/progressbar.cc
+++ b/plugingui/progressbar.cc
@@ -26,83 +26,101 @@
*/
#include "progressbar.h"
-#include "painter.h"
+namespace GUI {
-GUI::ProgressBar::ProgressBar(GUI::Widget *parent) : GUI::Widget(parent)
+ProgressBar::ProgressBar(Widget *parent)
+ : Widget(parent)
{
- bar_bg.left = new Image(":progress_back_l.png");
- bar_bg.right = new Image(":progress_back_r.png");
- bar_bg.center = new Image(":progress_back_c.png");
+ bar_bg.left = new Image(":progress_back_l.png");
+ bar_bg.right = new Image(":progress_back_r.png");
+ bar_bg.center = new Image(":progress_back_c.png");
- bar_blue.left = new Image(":progress_front_blue_l.png");
- bar_blue.right = new Image(":progress_front_blue_r.png");
- bar_blue.center = new Image(":progress_front_blue_c.png");
+ bar_blue.left = new Image(":progress_front_blue_l.png");
+ bar_blue.right = new Image(":progress_front_blue_r.png");
+ bar_blue.center = new Image(":progress_front_blue_c.png");
- bar_red.left = new Image(":progress_front_red_l.png");
- bar_red.right = new Image(":progress_front_red_r.png");
- bar_red.center = new Image(":progress_front_red_c.png");
+ bar_red.left = new Image(":progress_front_red_l.png");
+ bar_red.right = new Image(":progress_front_red_r.png");
+ bar_red.center = new Image(":progress_front_red_c.png");
- bar_green.left = new Image(":progress_front_green_l.png");
- bar_green.right = new Image(":progress_front_green_r.png");
- bar_green.center = new Image(":progress_front_green_c.png");
+ bar_green.left = new Image(":progress_front_green_l.png");
+ bar_green.right = new Image(":progress_front_green_r.png");
+ bar_green.center = new Image(":progress_front_green_c.png");
- state = blue;
- _progress = .5;
+ state = ProgressBarState::Blue;
+ _progress = .5;
}
-void GUI::ProgressBar::setState(GUI::ProgressBar::state_t state)
+ProgressBar::~ProgressBar()
{
- if(this->state != state) {
- this->state = state;
- repaintEvent(NULL);
- }
+ delete bar_bg.left;
+ delete bar_bg.right;
+ delete bar_bg.center;
+
+ delete bar_blue.left;
+ delete bar_blue.right;
+ delete bar_blue.center;
+
+ delete bar_red.left;
+ delete bar_red.right;
+ delete bar_red.center;
+
+ delete bar_green.left;
+ delete bar_green.right;
+ delete bar_green.center;
}
-float GUI::ProgressBar::progress()
+void ProgressBar::setState(ProgressBarState state)
{
- return _progress;
+ if(this->state != state)
+ {
+ this->state = state;
+ repaintEvent(nullptr);
+ }
}
-void GUI::ProgressBar::setProgress(float progress)
+float ProgressBar::progress()
{
- _progress = progress;
- repaintEvent(NULL);
+ return _progress;
}
-void GUI::ProgressBar::repaintEvent(GUI::RepaintEvent *e)
+void ProgressBar::setProgress(float progress)
{
- Painter p(this);
-
- int max = width() * _progress;
-
- p.clear();
-
- int brd = 4;
- p.drawBar(0, 0, &bar_bg, width(), height());
-
- GUI::Painter::Bar *b = NULL;
- switch(state) {
- case red: b = &bar_red; break;
- case green: b = &bar_green; break;
- case blue: b = &bar_blue; break;
- default: break;
- }
- if(b) p.drawBar(brd, 0, b, max - 2*brd, height());
+ _progress = progress;
+ repaintEvent(nullptr);
}
-#ifdef TEST_PROGRESSBAR
-//Additional dependency files
-//deps:
-//Required cflags (autoconf vars may be used)
-//cflags:
-//Required link options (autoconf vars may be used)
-//libs:
-#include "test.h"
-
-TEST_BEGIN;
-
-// TODO: Put some testcode here (see test.h for usable macros).
-
-TEST_END;
+void ProgressBar::repaintEvent(RepaintEvent* repaintEvent)
+{
+ Painter p(*this);
+
+ int max = width() * _progress;
+
+ p.clear();
+
+ int brd = 4;
+ p.drawBar(0, 0, bar_bg, width(), height());
+
+ Painter::Bar* bar = nullptr;
+ switch(state) {
+ case ProgressBarState::Red:
+ bar = &bar_red;
+ break;
+ case ProgressBarState::Green:
+ bar = &bar_green;
+ break;
+ case ProgressBarState::Blue:
+ bar = &bar_blue;
+ break;
+ case ProgressBarState::Off:
+ bar = nullptr;
+ break;
+ }
+
+ if(bar)
+ {
+ p.drawBar(brd, 0, *bar, max - 2 * brd, height());
+ }
+}
-#endif/*TEST_PROGRESSBAR*/
+} // GUI::