mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
CProgressWindow: encapsulate show methodes, add dimension defines
This commit is contained in:
@@ -82,54 +82,52 @@ void CProgressWindow::Init( signal<void, size_t, size_t, string> *statusSignal,
|
|||||||
global_progress = local_progress = 100;
|
global_progress = local_progress = 100;
|
||||||
|
|
||||||
showFooter(false);
|
showFooter(false);
|
||||||
shadow = true;
|
|
||||||
|
|
||||||
int x_item = 10;
|
|
||||||
int y_item = 10;
|
|
||||||
|
|
||||||
int w_item = width-2*x_item;
|
|
||||||
int h_item = 14;
|
|
||||||
int h_pbar = 20;
|
|
||||||
w_bar_frame = 0;
|
|
||||||
|
|
||||||
//create status text object
|
//create status text object
|
||||||
status_txt = new CComponentsLabel();
|
status_txt = new CComponentsLabel();
|
||||||
int h_txt = max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(), h_item);
|
status_txt->setDimensionsAll(OFFSET_INNER_MID, OFFSET_INNER_MID, width-2*OFFSET_INNER_MID, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight());
|
||||||
status_txt->setDimensionsAll(x_item, y_item, w_item, h_txt);
|
|
||||||
status_txt->setColorBody(col_body);
|
status_txt->setColorBody(col_body);
|
||||||
status_txt->doPaintTextBoxBg(true);
|
status_txt->doPaintTextBoxBg(true);
|
||||||
status_txt->doPaintBg(false);
|
status_txt->doPaintBg(false);
|
||||||
addWindowItem(status_txt);
|
addWindowItem(status_txt);
|
||||||
y_item += h_txt + 10;
|
|
||||||
|
|
||||||
//create local_bar object
|
//create local_bar object
|
||||||
local_bar = new CProgressBar();
|
local_bar = InitProgressItem();
|
||||||
local_bar->allowPaint(false);
|
|
||||||
local_bar->setDimensionsAll(x_item, y_item, w_item, h_pbar);
|
|
||||||
local_bar->setColorBody(col_body);
|
|
||||||
local_bar->setActiveColor(COL_PROGRESSBAR_ACTIVE_PLUS_0);
|
|
||||||
local_bar->setFrameThickness(w_bar_frame);
|
|
||||||
local_bar->setColorFrame(COL_PROGRESSBAR_ACTIVE_PLUS_0);
|
|
||||||
addWindowItem(local_bar);
|
|
||||||
y_item += 2*h_pbar;
|
|
||||||
|
|
||||||
//create global_bar object
|
//create global_bar object
|
||||||
global_bar = new CProgressBar();
|
global_bar = InitProgressItem();
|
||||||
global_bar->allowPaint(false);
|
|
||||||
global_bar->setDimensionsAll(x_item, y_item, w_item, h_pbar);
|
|
||||||
global_bar->setColorBody(col_body);
|
|
||||||
global_bar->setActiveColor(COL_PROGRESSBAR_ACTIVE_PLUS_0);
|
|
||||||
global_bar->setFrameThickness(w_bar_frame);
|
|
||||||
global_bar->setColorFrame(COL_PROGRESSBAR_ACTIVE_PLUS_0);
|
|
||||||
addWindowItem(global_bar);
|
|
||||||
y_item += 2*h_pbar;
|
|
||||||
|
|
||||||
|
//set window height
|
||||||
h_height = ccw_head->getHeight();
|
h_height = ccw_head->getHeight();
|
||||||
height = max(height, y_item + h_height);
|
ccw_body->setHeight((OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight())*ccw_body->size());
|
||||||
|
|
||||||
|
height = max(height, ccw_body->getHeight() + h_height);
|
||||||
|
|
||||||
|
//set position on screen
|
||||||
setCenterPos();
|
setCenterPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CProgressBar* CProgressWindow::InitProgressItem()
|
||||||
|
{
|
||||||
|
CProgressBar *pBar = new CProgressBar();
|
||||||
|
pBar->allowPaint(false);
|
||||||
|
int y_tmp = 0;
|
||||||
|
for(size_t i = 0; i< ccw_body->size(); i++){
|
||||||
|
y_tmp += ccw_body->getCCItem(i)->getHeight();
|
||||||
|
y_tmp += OFFSET_INNER_MID;
|
||||||
|
}
|
||||||
|
pBar->setDimensionsAll(OFFSET_INNER_MID, y_tmp, width-2*OFFSET_INNER_MID, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight());
|
||||||
|
pBar->setColorBody(col_body);
|
||||||
|
pBar->setActiveColor(COL_PROGRESSBAR_ACTIVE_PLUS_0);
|
||||||
|
pBar->setFrameThickness(1);
|
||||||
|
pBar->setColorFrame(COL_PROGRESSBAR_ACTIVE_PLUS_0);
|
||||||
|
addWindowItem(pBar);
|
||||||
|
|
||||||
|
ccw_body->setHeight(y_tmp+OFFSET_INNER_MID);
|
||||||
|
|
||||||
|
return pBar;
|
||||||
|
}
|
||||||
|
|
||||||
void CProgressWindow::setTitle(const neutrino_locale_t title)
|
void CProgressWindow::setTitle(const neutrino_locale_t title)
|
||||||
{
|
{
|
||||||
setWindowCaption(title);
|
setWindowCaption(title);
|
||||||
@@ -155,36 +153,31 @@ void CProgressWindow::fitItems()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for(size_t i=0; i<ccw_body->size() ;i++){
|
for(size_t i=0; i<ccw_body->size() ;i++){
|
||||||
int y_item = ccw_body->getCCItem(i)->getYPos() + h_height - 10;
|
int y_item = ccw_body->getCCItem(i)->getYPos() + h_height - OFFSET_INNER_MID;
|
||||||
ccw_body->getCCItem(i)->setYPos(y_item);
|
ccw_body->getCCItem(i)->setYPos(y_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CProgressWindow::initStatus(const unsigned int prog, const unsigned int max, const string &statusText, CProgressBar *pBar)
|
||||||
|
{
|
||||||
|
pBar->allowPaint(true);
|
||||||
|
pBar->setValues(prog, (int)max);
|
||||||
|
if (!statusText.empty())
|
||||||
|
showStatusMessageUTF(statusText);
|
||||||
|
pBar->paint(false);
|
||||||
|
}
|
||||||
|
|
||||||
void CProgressWindow::showStatus(const unsigned int prog, const unsigned int max, const string &statusText)
|
void CProgressWindow::showStatus(const unsigned int prog, const unsigned int max, const string &statusText)
|
||||||
{
|
{
|
||||||
if (global_progress == prog)
|
showLocalStatus(prog, max, statusText);
|
||||||
return;
|
|
||||||
|
|
||||||
if (!global_bar->isPainted()){
|
|
||||||
int g_height = global_bar->getHeight();
|
|
||||||
global_bar->setYPos(local_bar->getYPos() + g_height/2);
|
|
||||||
global_bar->setHeight(g_height + g_height/2);
|
|
||||||
}
|
|
||||||
|
|
||||||
showGlobalStatus(prog, max, statusText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CProgressWindow::showGlobalStatus(const unsigned int prog, const unsigned int max, const string &statusText)
|
void CProgressWindow::showGlobalStatus(const unsigned int prog, const unsigned int max, const string &statusText)
|
||||||
{
|
{
|
||||||
if (global_progress == prog)
|
if (global_progress == prog)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
global_bar->allowPaint(true);
|
|
||||||
global_progress = prog;
|
global_progress = prog;
|
||||||
global_bar->setValues(prog, (int)max);
|
initStatus(prog, max, statusText, global_bar);
|
||||||
if (!statusText.empty())
|
|
||||||
showStatusMessageUTF(statusText);
|
|
||||||
global_bar->paint(false);
|
|
||||||
|
|
||||||
#ifdef VFD_UPDATE
|
#ifdef VFD_UPDATE
|
||||||
CVFD::getInstance()->showProgressBar2(-1,NULL,global_progress);
|
CVFD::getInstance()->showProgressBar2(-1,NULL,global_progress);
|
||||||
@@ -195,13 +188,8 @@ void CProgressWindow::showLocalStatus(const unsigned int prog, const unsigned in
|
|||||||
{
|
{
|
||||||
if (local_progress == prog)
|
if (local_progress == prog)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
local_bar->allowPaint(true);
|
|
||||||
local_progress = prog;
|
local_progress = prog;
|
||||||
local_bar->setValues(prog, (int)max);
|
initStatus(prog, max, statusText, local_bar);
|
||||||
if (!statusText.empty())
|
|
||||||
showStatusMessageUTF(statusText);
|
|
||||||
local_bar->paint(false);
|
|
||||||
|
|
||||||
#ifdef VFD_UPDATE
|
#ifdef VFD_UPDATE
|
||||||
CVFD::getInstance()->showProgressBar2(local_progress);
|
CVFD::getInstance()->showProgressBar2(local_progress);
|
||||||
|
@@ -28,6 +28,9 @@
|
|||||||
#include <gui/components/cc.h>
|
#include <gui/components/cc.h>
|
||||||
#include "menue.h"
|
#include "menue.h"
|
||||||
|
|
||||||
|
#define PW_MIN_WIDTH 700
|
||||||
|
#define PW_MIN_HEIGHT 100
|
||||||
|
|
||||||
class CProgressWindow : public CComponentsWindow, public CMenuTarget
|
class CProgressWindow : public CComponentsWindow, public CMenuTarget
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -36,11 +39,13 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget
|
|||||||
|
|
||||||
unsigned int global_progress;
|
unsigned int global_progress;
|
||||||
unsigned int local_progress;
|
unsigned int local_progress;
|
||||||
int w_bar_frame;
|
|
||||||
int h_height;
|
int h_height;
|
||||||
void Init( sigc::signal<void, size_t, size_t, std::string> *statusSignal,
|
void Init( sigc::signal<void, size_t, size_t, std::string> *statusSignal,
|
||||||
sigc::signal<void,size_t, size_t, std::string> *localSignal,
|
sigc::signal<void,size_t, size_t, std::string> *localSignal,
|
||||||
sigc::signal<void, size_t, size_t, std::string> *globalSignal);
|
sigc::signal<void, size_t, size_t, std::string> *globalSignal);
|
||||||
|
|
||||||
|
CProgressBar* InitProgressItem();
|
||||||
|
void initStatus(const unsigned int prog, const unsigned int max, const std::string &statusText, CProgressBar *pBar);
|
||||||
void fitItems();
|
void fitItems();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -131,8 +136,8 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget
|
|||||||
* Don't use status_Signal at same time with localSignal and globalSignal. In This case please set status_Signal = NULL
|
* Don't use status_Signal at same time with localSignal and globalSignal. In This case please set status_Signal = NULL
|
||||||
*/
|
*/
|
||||||
CProgressWindow(CComponentsForm *parent = NULL,
|
CProgressWindow(CComponentsForm *parent = NULL,
|
||||||
const int &dx = 700,
|
const int &dx = PW_MIN_WIDTH,
|
||||||
const int &dy = 200,
|
const int &dy = PW_MIN_HEIGHT,
|
||||||
sigc::signal<void, size_t, size_t, std::string> *status_Signal = NULL,
|
sigc::signal<void, size_t, size_t, std::string> *status_Signal = NULL,
|
||||||
sigc::signal<void,size_t, size_t, std::string> *localSignal = NULL,
|
sigc::signal<void,size_t, size_t, std::string> *localSignal = NULL,
|
||||||
sigc::signal<void, size_t, size_t, std::string> *globalSignal = NULL);
|
sigc::signal<void, size_t, size_t, std::string> *globalSignal = NULL);
|
||||||
@@ -144,8 +149,8 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget
|
|||||||
* @see For other arguments and examples, see related constructor(s)
|
* @see For other arguments and examples, see related constructor(s)
|
||||||
*/
|
*/
|
||||||
CProgressWindow(const neutrino_locale_t title,
|
CProgressWindow(const neutrino_locale_t title,
|
||||||
const int &dx = 700,
|
const int &dx = PW_MIN_WIDTH,
|
||||||
const int &dy = 200,
|
const int &dy = PW_MIN_HEIGHT,
|
||||||
sigc::signal<void, size_t, size_t, std::string> *status_Signal = NULL,
|
sigc::signal<void, size_t, size_t, std::string> *status_Signal = NULL,
|
||||||
sigc::signal<void,size_t, size_t, std::string> *localSignal = NULL,
|
sigc::signal<void,size_t, size_t, std::string> *localSignal = NULL,
|
||||||
sigc::signal<void, size_t, size_t, std::string> *globalSignal = NULL);
|
sigc::signal<void, size_t, size_t, std::string> *globalSignal = NULL);
|
||||||
@@ -157,8 +162,8 @@ class CProgressWindow : public CComponentsWindow, public CMenuTarget
|
|||||||
* @see For other arguments and examples, see related constructor(s)
|
* @see For other arguments and examples, see related constructor(s)
|
||||||
*/
|
*/
|
||||||
CProgressWindow(const std::string &title,
|
CProgressWindow(const std::string &title,
|
||||||
const int &dx = 700,
|
const int &dx = PW_MIN_WIDTH,
|
||||||
const int &dy = 200,
|
const int &dy = PW_MIN_HEIGHT,
|
||||||
sigc::signal<void, size_t, size_t, std::string> *status_Signal = NULL,
|
sigc::signal<void, size_t, size_t, std::string> *status_Signal = NULL,
|
||||||
sigc::signal<void,size_t, size_t, std::string> *localSignal = NULL,
|
sigc::signal<void,size_t, size_t, std::string> *localSignal = NULL,
|
||||||
sigc::signal<void, size_t, size_t, std::string> *globalSignal = NULL);
|
sigc::signal<void, size_t, size_t, std::string> *globalSignal = NULL);
|
||||||
|
Reference in New Issue
Block a user