CHintbox/CMsgBox: add vizualized timeout bar

Origin commit data
------------------
Commit: cb3699deb5
Author: Thilo Graf <dbt@novatux.de>
Date: 2016-10-11 (Tue, 11 Oct 2016)
This commit is contained in:
2016-10-11 23:50:25 +02:00
parent 3c1dc9d123
commit deca218ec8
3 changed files with 45 additions and 7 deletions

View File

@@ -125,6 +125,7 @@ CHintBox::CHintBox( const char * const Caption,
init(g_Locale->getText(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent); init(g_Locale->getText(Text), Width, string(Picon == NULL ? "" : Picon), header_buttons, text_mode, indent);
} }
void CHintBox::init(const std::string& Text, const int& Width, const std::string& Picon, const int& header_buttons, const int& text_mode, const int& indent) void CHintBox::init(const std::string& Text, const int& Width, const std::string& Picon, const int& header_buttons, const int& text_mode, const int& indent)
{ {
lines = 0; lines = 0;
@@ -154,10 +155,40 @@ void CHintBox::init(const std::string& Text, const int& Width, const std::string
y_hint_obj = 0; y_hint_obj = 0;
h_hint_obj = obj_content->getHeight(); h_hint_obj = obj_content->getHeight();
//initialize timeout bar and its timer
timeout_pb = NULL;
timeout_pb_timer= NULL;
if (!Text.empty()) if (!Text.empty())
addHintItem(Text, text_mode, Picon); addHintItem(Text, text_mode, Picon);
} }
CHintBox::~CHintBox()
{
if(timeout_pb){
delete timeout_pb; timeout_pb = NULL;
}
if(timeout_pb_timer){
delete timeout_pb_timer; timeout_pb_timer = NULL;
}
}
void CHintBox::showTimeOutBar()
{
if(timeout_pb){
timeout_pb->paint0();
timeout_pb->setValues(timeout_pb->getValue()+1, timeout);
}else{
timeout_pb = new CProgressBar();
timeout_pb->setDimensionsAll(ccw_body->getRealXPos(), ccw_body->getRealYPos(), ccw_body->getWidth(), 8);
timeout_pb->setValues(0, timeout);
if (!timeout_pb_timer)
timeout_pb_timer = new CComponentsTimer(1);
timeout_pb_timer->OnTimer.connect(sigc::mem_fun0(this, &CHintBox::showTimeOutBar));
timeout_pb_timer->startTimer();
}
}
int CHintBox::exec() int CHintBox::exec()
{ {
neutrino_msg_t msg; neutrino_msg_t msg;
@@ -165,6 +196,9 @@ int CHintBox::exec()
int res = messages_return::none; int res = messages_return::none;
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout ); uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout );
if (timeout > 0)
showTimeOutBar();
while ( ! ( res & ( messages_return::cancel_info | messages_return::cancel_all ) ) ) while ( ! ( res & ( messages_return::cancel_info | messages_return::cancel_all ) ) )
{ {
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
@@ -394,7 +428,6 @@ void CHintBox::scroll_down(const uint& hint_id)
Scroll(true, hint_id); Scroll(true, hint_id);
} }
int ShowHint(const char * const Caption, const char * const Text, const int Width, int timeout, const char * const Icon, const char * const Picon, const int& header_buttons) int ShowHint(const char * const Caption, const char * const Text, const int Width, int timeout, const char * const Icon, const char * const Picon, const int& header_buttons)
{ {
int res = messages_return::none; int res = messages_return::none;

View File

@@ -64,6 +64,10 @@ class CHintBox : public CComponentsWindow
///content container object, contains the hint objects, it's a child of body object ///content container object, contains the hint objects, it's a child of body object
CComponentsFrmChain *obj_content; CComponentsFrmChain *obj_content;
///timeout bar
CProgressBar *timeout_pb;
CComponentsTimer *timeout_pb_timer;
///scroll handler, default down and for the 1st hint item (=0), NOTE: exec() must be called! see also scroll_down()/scroll_up() ///scroll handler, default down and for the 1st hint item (=0), NOTE: exec() must be called! see also scroll_down()/scroll_up()
void Scroll(bool down, const uint& hint_id = 0); void Scroll(bool down, const uint& hint_id = 0);
@@ -115,11 +119,13 @@ class CHintBox : public CComponentsWindow
const int& text_mode = 0, const int& text_mode = 0,
const int& indent = W_FRAME); const int& indent = W_FRAME);
//~CHintBox(); //inherited virtual ~CHintBox();
int exec(); int exec();
///define timeout, timeout is enabled if parameter1 > -1 ///define timeout, timeout is enabled if parameter1 > -1
virtual void setTimeOut(const int& Timeout){timeout = Timeout;}; virtual void setTimeOut(const int& Timeout){timeout = Timeout;}
///shows timeout as progressbar
void showTimeOutBar();
///scroll handler for text objects: NOTE: exec() must be called ! see also Scroll() ///scroll handler for text objects: NOTE: exec() must be called ! see also Scroll()
///scroll up handler, default for the 1st hint item (=0), item id arises from the order of added items with addHintItem(), default we have minimal one item with id=0 ///scroll up handler, default for the 1st hint item (=0), item id arises from the order of added items with addHintItem(), default we have minimal one item with id=0

View File

@@ -218,12 +218,11 @@ int CMsgBox::exec()
ccw_footer->getSelectedButtonObject()->setButtonAlias(mb_show_button); ccw_footer->getSelectedButtonObject()->setButtonAlias(mb_show_button);
int selected = ccw_footer->getSelectedButton(); int selected = ccw_footer->getSelectedButton();
dprintf(DEBUG_NORMAL, "\033[32m[CMsgBox] [%s - %d] getSelectedButton()= %d\033[0m\n", __func__, __LINE__,ccw_footer->getSelectedButton());
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(timeout); uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
if (timeout > 0)
showTimeOutBar();
bool loop = true; bool loop = true;
while (loop) while (loop)
{ {