CProgressWindow: implement CComponent classes

This implement window functionality from CComponentsWindow,
progress items from CProgressBar() and status text
items from CComponentsLabel()


Origin commit data
------------------
Commit: 2f0e4e1687
Author: Thilo Graf <dbt@novatux.de>
Date: 2014-06-09 (Mon, 09 Jun 2014)
This commit is contained in:
2014-06-09 14:56:12 +02:00
committed by vanhofen
parent 03914a6687
commit 7d1020cdf5
8 changed files with 99 additions and 175 deletions

View File

@@ -35,7 +35,7 @@
#define __update__ #define __update__
#include <gui/widget/menue.h> #include <gui/widget/menue.h>
#include <gui/widget/progressstatus.h>
#include <gui/widget/progresswindow.h> #include <gui/widget/progresswindow.h>
#include <driver/framebuffer.h> #include <driver/framebuffer.h>

View File

@@ -1,40 +0,0 @@
/*
Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
License: GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
*/
#ifndef __progressstatus__
#define __progressstatus__
#include <string>
class CProgress_StatusViewer
{
public:
virtual void showGlobalStatus(const unsigned int prog) = 0;
virtual unsigned int getGlobalStatus(void) = 0;
virtual void showLocalStatus(const unsigned int prog) = 0;
virtual void showStatusMessageUTF(const std::string & text) = 0;
virtual void paint() = 0;
};
#endif

View File

@@ -1,26 +1,24 @@
/* /*
$Id: progresswindow.cpp,v 1.16 2007/02/25 21:32:58 guenther Exp $ Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
Neutrino-GUI - DBoxII-Project Implementation of CComponent Window class.
Copyright (C) 2014 Thilo Graf 'dbt'
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
License: GPL License: GPL
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public
the Free Software Foundation; either version 2 of the License, or License as published by the Free Software Foundation; either
(at your option) any later version. version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program. If not, see <http://www.gnu.org/licenses/>.
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@@ -33,39 +31,66 @@
#include <neutrino.h> #include <neutrino.h>
#include <driver/fontrenderer.h> #include <driver/fontrenderer.h>
#include <driver/neutrinofonts.h>
#include <driver/rcinput.h> #include <driver/rcinput.h>
#include <driver/screen_max.h>
#include <gui/color.h>
CProgressWindow::CProgressWindow() CProgressWindow::CProgressWindow(CComponentsForm *parent)
: CComponentsWindow(0, 0, 700, 200, string(), NEUTRINO_ICON_INFO, NULL, parent)
{ {
frameBuffer = CFrameBuffer::getInstance(); Init();
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); }
mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
int fw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth();
width = w_max (50*fw, 0);
height = h_max(hheight+5*mheight, 20);
global_progress = local_progress = 101; void CProgressWindow::Init()
statusText = ""; {
globalstatusX = 0; global_progress = local_progress = 100;
globalstatusY = 0;
localstatusY = 0;
statusTextY = 0;
x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - width ) >> 1 ); showFooter(false);
y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - height) >>1 ); shadow = true;
caption = NONEXISTANT_LOCALE; int x_item = 10;
int y_item = 10;
int w_item = width-2*x_item;
int h_item = 20;
//create status text object
status_txt = new CComponentsLabel();
status_txt->setDimensionsAll(x_item, y_item, w_item, h_item);
status_txt->setColorBody(col_body);
addWindowItem(status_txt);
y_item += 2*h_item;
//create local_bar object
local_bar = new CProgressBar();
local_bar->setDimensionsAll(x_item, y_item, w_item, h_item);
local_bar->setColorBody(col_body);
local_bar->setActiveColor(COL_MENUCONTENT_PLUS_7);
local_bar->setFrameThickness(2);
local_bar->setColorFrame(COL_MENUCONTENT_PLUS_7);
addWindowItem(local_bar);
y_item += 2*h_item;
//create global_bar object
global_bar = new CProgressBar();
global_bar->setDimensionsAll(x_item, y_item, w_item, h_item);
global_bar->setColorBody(col_body);
global_bar->setActiveColor(COL_MENUCONTENT_PLUS_7);
global_bar->setFrameThickness(2);
global_bar->setColorFrame(COL_MENUCONTENT_PLUS_7);
addWindowItem(global_bar);
y_item += 2*h_item;
height = y_item + ccw_head->getHeight() + 10;
setCenterPos();
} }
void CProgressWindow::setTitle(const neutrino_locale_t title) void CProgressWindow::setTitle(const neutrino_locale_t title)
{ {
caption = title; setWindowCaption(title);
#ifdef VFD_UPDATE #ifdef VFD_UPDATE
CVFD::getInstance()->showProgressBar2(-1,NULL,-1,g_Locale->getText(caption)); // set global text in VFD CVFD::getInstance()->showProgressBar2(-1,NULL,-1,g_Locale->getText(ccw_caption)); // set global text in VFD
#endif // VFD_UPDATE #endif // VFD_UPDATE
} }
@@ -76,20 +101,8 @@ void CProgressWindow::showGlobalStatus(const unsigned int prog)
return; return;
global_progress = prog; global_progress = prog;
global_bar->setValues(prog, 100);
int pos = x + 10; global_bar->paint(false);
if(global_progress != 0)
{
if (global_progress > 100)
global_progress = 100;
pos += int( float(width-20)/100.0 * global_progress);
//vordergrund
frameBuffer->paintBox(x+10, globalstatusY,pos, globalstatusY+10, COL_MENUCONTENT_PLUS_7);
}
//hintergrund
frameBuffer->paintBox(pos, globalstatusY, x+width-10, globalstatusY+10, COL_MENUCONTENT_PLUS_2);
#ifdef VFD_UPDATE #ifdef VFD_UPDATE
CVFD::getInstance()->showProgressBar2(-1,NULL,global_progress); CVFD::getInstance()->showProgressBar2(-1,NULL,global_progress);
@@ -102,33 +115,24 @@ void CProgressWindow::showLocalStatus(const unsigned int prog)
return; return;
local_progress = prog; local_progress = prog;
local_bar->setValues(prog, 100);
int pos = x + 10; local_bar->paint(false);
if (local_progress != 0)
{
if (local_progress > 100)
local_progress = 100;
pos += int( float(width-20)/100.0 * local_progress);
//vordergrund
frameBuffer->paintBox(x+10, localstatusY,pos, localstatusY+10, COL_MENUCONTENT_PLUS_7);
}
//hintergrund
frameBuffer->paintBox(pos, localstatusY, x+width-10, localstatusY+10, COL_MENUCONTENT_PLUS_2);
#ifdef VFD_UPDATE #ifdef VFD_UPDATE
CVFD::getInstance()->showProgressBar2(local_progress); CVFD::getInstance()->showProgressBar2(local_progress);
#else #else
CVFD::getInstance()->showPercentOver(local_progress); CVFD::getInstance()->showPercentOver((uint8_t)local_progress);
#endif // VFD_UPDATE #endif // VFD_UPDATE
} }
void CProgressWindow::showStatusMessageUTF(const std::string & text) void CProgressWindow::showStatusMessageUTF(const std::string & text)
{ {
statusText = text; string txt = text;
frameBuffer->paintBox(x, statusTextY-mheight, x+width, statusTextY, COL_MENUCONTENT_PLUS_0); int w_txt = status_txt->getWidth();
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+10, statusTextY, width-20, text, COL_MENUCONTENT_TEXT); int h_txt = status_txt->getHeight();
status_txt->setText(txt, CTextBox::CENTER, *CNeutrinoFonts::getInstance()->getDynFont(w_txt, h_txt, txt), COL_MENUCONTENT_TEXT);
status_txt->paint(false);
#ifdef VFD_UPDATE #ifdef VFD_UPDATE
CVFD::getInstance()->showProgressBar2(-1,text.c_str()); // set local text in VFD CVFD::getInstance()->showProgressBar2(-1,text.c_str()); // set local text in VFD
@@ -141,35 +145,9 @@ unsigned int CProgressWindow::getGlobalStatus(void)
return global_progress; return global_progress;
} }
void CProgressWindow::hide(bool no_restore)
void CProgressWindow::hide()
{ {
frameBuffer->paintBackgroundBoxRel(x,y, width,height); CComponentsWindow::hide(no_restore);
}
void CProgressWindow::paint()
{
int ypos=y;
frameBuffer->paintBoxRel(x, ypos, width, hheight, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP);
if (caption != NONEXISTANT_LOCALE)
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10, ypos+ hheight, width - 10, g_Locale->getText(caption), COL_MENUHEAD_TEXT);
frameBuffer->paintBoxRel(x, ypos+ hheight, width, height- hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM);
ypos+= hheight + (mheight >>1);
statusTextY = ypos+mheight;
showStatusMessageUTF(statusText);
ypos+= mheight;
localstatusY = ypos+ mheight-20;
showLocalStatus(0);
ypos+= mheight+10;
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width- 10, g_Locale->getText(LOCALE_FLASHUPDATE_GLOBALPROGRESS), COL_MENUCONTENT_TEXT);
ypos+= mheight;
globalstatusY = ypos+ mheight-20;
//ypos+= mheight >>1;
showGlobalStatus(global_progress);
} }
int CProgressWindow::exec(CMenuTarget* parent, const std::string & /*actionKey*/) int CProgressWindow::exec(CMenuTarget* parent, const std::string & /*actionKey*/)

View File

@@ -1,24 +1,24 @@
/* /*
Neutrino-GUI - DBoxII-Project Based up Neutrino-GUI - Tuxbox-Project
Copyright (C) 2001 by Steffen Hehn 'McClean'
Copyright (C) 2001 Steffen Hehn 'McClean' Implementation of CComponent Window class.
Homepage: http://dbox.cyberphoria.org/ Copyright (C) 2014 Thilo Graf 'dbt'
License: GPL License: GPL
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public
the Free Software Foundation; either version 2 of the License, or License as published by the Free Software Foundation; either
(at your option) any later version. version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program. If not, see <http://www.gnu.org/licenses/>.
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
@@ -28,41 +28,27 @@
#include <driver/framebuffer.h> #include <driver/framebuffer.h>
#include <system/localize.h> #include <system/localize.h>
#include "progressstatus.h" #include <gui/components/cc.h>
#include "menue.h" #include "menue.h"
#include <string> #include <string>
class CProgressWindow : public CMenuTarget, public CProgress_StatusViewer class CProgressWindow : public CComponentsWindow, public CMenuTarget
{ {
protected: private:
CProgressBar *local_bar, *global_bar;
CComponentsLabel *status_txt;
CFrameBuffer *frameBuffer;
neutrino_locale_t caption;
int x;
int y;
int width;
int height;
int hheight; // head font height
int mheight; // menu font height
unsigned int global_progress; unsigned int global_progress;
unsigned int local_progress; unsigned int local_progress;
int globalstatusX;
int globalstatusY;
int localstatusY;
int statusTextY;
std::string statusText;
void Init();
//----------------------------
public: public:
CProgressWindow(); CProgressWindow(CComponentsForm *parent = NULL);
void setTitle(const neutrino_locale_t title); void setTitle(const neutrino_locale_t title);
virtual void hide(); virtual void hide(bool no_restore = false);
virtual void paint();
virtual int exec( CMenuTarget* parent, const std::string & actionKey ); virtual int exec( CMenuTarget* parent, const std::string & actionKey );

View File

@@ -65,7 +65,7 @@ void CFlashTool::setMTDDevice( const std::string & mtddevice )
printf("flashtool.cpp: set mtd device to %s\n", mtddevice.c_str()); printf("flashtool.cpp: set mtd device to %s\n", mtddevice.c_str());
} }
void CFlashTool::setStatusViewer( CProgress_StatusViewer* statusview ) void CFlashTool::setStatusViewer( CProgressWindow* statusview )
{ {
statusViewer = statusview; statusViewer = statusview;
} }

View File

@@ -33,7 +33,7 @@
#ifndef __flashtool__ #ifndef __flashtool__
#define __flashtool__ #define __flashtool__
#include <gui/widget/progressstatus.h> #include <gui/widget/progresswindow.h>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -43,7 +43,7 @@ class CFlashTool
{ {
private: private:
CProgress_StatusViewer* statusViewer; CProgressWindow* statusViewer;
std::string mtdDevice; std::string mtdDevice;
std::string ErrorMessage; std::string ErrorMessage;
@@ -61,7 +61,7 @@ class CFlashTool
const std::string & getErrorMessage(void) const; const std::string & getErrorMessage(void) const;
void setMTDDevice( const std::string & mtddevice ); void setMTDDevice( const std::string & mtddevice );
void setStatusViewer( CProgress_StatusViewer* statusview ); void setStatusViewer( CProgressWindow* statusview );
bool program( const std::string & filename, int globalProgressEndErase=-1, int globalProgressEndFlash=-1 ); bool program( const std::string & filename, int globalProgressEndErase=-1, int globalProgressEndFlash=-1 );
bool readFromMTD( const std::string & filename, int globalProgressEnd=-1 ); bool readFromMTD( const std::string & filename, int globalProgressEnd=-1 );

View File

@@ -37,7 +37,7 @@ CHTTPTool::CHTTPTool()
userAgent = "neutrino/httpdownloader"; userAgent = "neutrino/httpdownloader";
} }
void CHTTPTool::setStatusViewer( CProgress_StatusViewer* statusview ) void CHTTPTool::setStatusViewer( CProgressWindow* statusview )
{ {
statusViewer = statusview; statusViewer = statusview;
} }

View File

@@ -33,7 +33,7 @@
#ifndef __httptool__ #ifndef __httptool__
#define __httptool__ #define __httptool__
#include <gui/widget/progressstatus.h> #include <gui/widget/progresswindow.h>
#include <string> #include <string>
@@ -44,12 +44,12 @@ class CHTTPTool
int iGlobalProgressEnd; int iGlobalProgressEnd;
int iGlobalProgressBegin; int iGlobalProgressBegin;
CProgress_StatusViewer* statusViewer; CProgressWindow* statusViewer;
static int show_progress( void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); static int show_progress( void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
public: public:
CHTTPTool(); CHTTPTool();
void setStatusViewer( CProgress_StatusViewer* statusview ); void setStatusViewer( CProgressWindow* statusview );
bool downloadFile( const std::string & URL, const char * const downloadTarget, int globalProgressEnd=-1 ); bool downloadFile( const std::string & URL, const char * const downloadTarget, int globalProgressEnd=-1 );