CProgressWindow: allow variable max value, allow define dimensions

This commit is contained in:
2017-02-10 01:32:51 +01:00
parent 4d68318447
commit 547238bfdd
2 changed files with 14 additions and 14 deletions

View File

@@ -33,8 +33,8 @@
#include <driver/fontrenderer.h> #include <driver/fontrenderer.h>
#include <driver/display.h> #include <driver/display.h>
CProgressWindow::CProgressWindow(CComponentsForm *parent) CProgressWindow::CProgressWindow(CComponentsForm *parent, const int &dx, const int &dy)
: CComponentsWindow(0, 0, 700, 200, string(), NEUTRINO_ICON_INFO, parent, CC_SHADOW_ON) : CComponentsWindow(0, 0, dx, dy, string(), NEUTRINO_ICON_INFO, parent, CC_SHADOW_ON)
{ {
Init(); Init();
} }
@@ -48,7 +48,7 @@ void CProgressWindow::Init()
int x_item = 10; int x_item = 10;
int y_item = 10; int y_item = 10;
setWidthP(75);
int w_item = width-2*x_item; int w_item = width-2*x_item;
int h_item = 14; int h_item = 14;
int h_pbar = 20; int h_pbar = 20;
@@ -86,7 +86,7 @@ void CProgressWindow::Init()
y_item += 2*h_pbar; y_item += 2*h_pbar;
h_height = ccw_head->getHeight(); h_height = ccw_head->getHeight();
height = y_item + h_height; height = max(height, y_item + h_height);
setCenterPos(); 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) if (global_progress == prog)
return; return;
@@ -132,17 +132,17 @@ void CProgressWindow::showStatus(const unsigned int prog)
global_bar->setHeight(g_height + g_height/2); 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) if (global_progress == prog)
return; return;
global_bar->allowPaint(true); global_bar->allowPaint(true);
global_progress = prog; global_progress = prog;
global_bar->setValues(prog, 100); global_bar->setValues(prog, (int)max);
global_bar->paint(false); global_bar->paint(false);
#ifdef VFD_UPDATE #ifdef VFD_UPDATE
@@ -150,14 +150,14 @@ void CProgressWindow::showGlobalStatus(const unsigned int prog)
#endif // VFD_UPDATE #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) if (local_progress == prog)
return; return;
local_bar->allowPaint(true); local_bar->allowPaint(true);
local_progress = prog; local_progress = prog;
local_bar->setValues(prog, 100); local_bar->setValues(prog, (int)max);
local_bar->paint(false); local_bar->paint(false);
#ifdef VFD_UPDATE #ifdef VFD_UPDATE

View File

@@ -43,16 +43,16 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget
public: public:
CProgressWindow(CComponentsForm *parent = NULL); CProgressWindow(CComponentsForm *parent = NULL, const int &dx = 700, const int &dy = 200);
void setTitle(const neutrino_locale_t title); void setTitle(const neutrino_locale_t title);
virtual void hide(); virtual void hide();
virtual int exec( CMenuTarget* parent, const std::string & actionKey ); virtual int exec( CMenuTarget* parent, const std::string & actionKey );
void showStatus(const unsigned int prog); void showStatus(const unsigned int prog, const unsigned int max = 100);
void showGlobalStatus(const unsigned int prog); void showGlobalStatus(const unsigned int prog, const unsigned int max = 100);
unsigned int getGlobalStatus(void); 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 showStatusMessageUTF(const std::string & text); // UTF-8
void paint(bool do_save_bg = true); void paint(bool do_save_bg = true);
void setTitle(const std::string & title); void setTitle(const std::string & title);