From 547238bfdd9457311f49fac7692ccc88f4be8ca5 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 10 Feb 2017 01:32:51 +0100 Subject: [PATCH] CProgressWindow: allow variable max value, allow define dimensions --- src/gui/widget/progresswindow.cpp | 20 ++++++++++---------- src/gui/widget/progresswindow.h | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gui/widget/progresswindow.cpp b/src/gui/widget/progresswindow.cpp index f7c84e024..b077cf2f0 100644 --- a/src/gui/widget/progresswindow.cpp +++ b/src/gui/widget/progresswindow.cpp @@ -33,8 +33,8 @@ #include #include -CProgressWindow::CProgressWindow(CComponentsForm *parent) -: CComponentsWindow(0, 0, 700, 200, string(), NEUTRINO_ICON_INFO, parent, CC_SHADOW_ON) +CProgressWindow::CProgressWindow(CComponentsForm *parent, const int &dx, const int &dy) +: CComponentsWindow(0, 0, dx, dy, string(), NEUTRINO_ICON_INFO, parent, CC_SHADOW_ON) { Init(); } @@ -48,7 +48,7 @@ void CProgressWindow::Init() int x_item = 10; int y_item = 10; - setWidthP(75); + int w_item = width-2*x_item; int h_item = 14; int h_pbar = 20; @@ -86,7 +86,7 @@ void CProgressWindow::Init() y_item += 2*h_pbar; h_height = ccw_head->getHeight(); - height = y_item + h_height; + height = max(height, y_item + h_height); setCenterPos(); } @@ -121,7 +121,7 @@ void CProgressWindow::fitItems() } } -void CProgressWindow::showStatus(const unsigned int prog) +void CProgressWindow::showStatus(const unsigned int prog, const unsigned int max) { if (global_progress == prog) return; @@ -132,17 +132,17 @@ void CProgressWindow::showStatus(const unsigned int prog) global_bar->setHeight(g_height + g_height/2); } - showGlobalStatus(prog); + showGlobalStatus(prog, max); } -void CProgressWindow::showGlobalStatus(const unsigned int prog) +void CProgressWindow::showGlobalStatus(const unsigned int prog, const unsigned int max) { if (global_progress == prog) return; global_bar->allowPaint(true); global_progress = prog; - global_bar->setValues(prog, 100); + global_bar->setValues(prog, (int)max); global_bar->paint(false); #ifdef VFD_UPDATE @@ -150,14 +150,14 @@ void CProgressWindow::showGlobalStatus(const unsigned int prog) #endif // VFD_UPDATE } -void CProgressWindow::showLocalStatus(const unsigned int prog) +void CProgressWindow::showLocalStatus(const unsigned int prog, const unsigned int max) { if (local_progress == prog) return; local_bar->allowPaint(true); local_progress = prog; - local_bar->setValues(prog, 100); + local_bar->setValues(prog, (int)max); local_bar->paint(false); #ifdef VFD_UPDATE diff --git a/src/gui/widget/progresswindow.h b/src/gui/widget/progresswindow.h index 6b8ff9e72..eaa8f8c63 100644 --- a/src/gui/widget/progresswindow.h +++ b/src/gui/widget/progresswindow.h @@ -43,16 +43,16 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget public: - CProgressWindow(CComponentsForm *parent = NULL); + CProgressWindow(CComponentsForm *parent = NULL, const int &dx = 700, const int &dy = 200); void setTitle(const neutrino_locale_t title); virtual void hide(); virtual int exec( CMenuTarget* parent, const std::string & actionKey ); - void showStatus(const unsigned int prog); - void showGlobalStatus(const unsigned int prog); + void showStatus(const unsigned int prog, const unsigned int max = 100); + void showGlobalStatus(const unsigned int prog, const unsigned int max = 100); unsigned int getGlobalStatus(void); - void showLocalStatus(const unsigned int prog); + void showLocalStatus(const unsigned int prog, const unsigned int max = 100); void showStatusMessageUTF(const std::string & text); // UTF-8 void paint(bool do_save_bg = true); void setTitle(const std::string & title);