diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index 5584c477e..c483c0df8 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -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); } + 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; @@ -154,10 +155,40 @@ void CHintBox::init(const std::string& Text, const int& Width, const std::string y_hint_obj = 0; h_hint_obj = obj_content->getHeight(); + //initialize timeout bar and its timer + timeout_pb = NULL; + timeout_pb_timer= NULL; + if (!Text.empty()) 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() { neutrino_msg_t msg; @@ -165,6 +196,9 @@ int CHintBox::exec() int res = messages_return::none; uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout ); + if (timeout > 0) + showTimeOutBar(); + while ( ! ( res & ( messages_return::cancel_info | messages_return::cancel_all ) ) ) { g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); @@ -394,7 +428,6 @@ void CHintBox::scroll_down(const uint& 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 res = messages_return::none; diff --git a/src/gui/widget/hintbox.h b/src/gui/widget/hintbox.h index b96db3834..b4a7fb357 100644 --- a/src/gui/widget/hintbox.h +++ b/src/gui/widget/hintbox.h @@ -64,6 +64,10 @@ class CHintBox : public CComponentsWindow ///content container object, contains the hint objects, it's a child of body object 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() void Scroll(bool down, const uint& hint_id = 0); @@ -115,11 +119,13 @@ class CHintBox : public CComponentsWindow const int& text_mode = 0, const int& indent = W_FRAME); - //~CHintBox(); //inherited + virtual ~CHintBox(); int exec(); ///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 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 diff --git a/src/gui/widget/msgbox.cpp b/src/gui/widget/msgbox.cpp index 67679e027..bee06c37d 100644 --- a/src/gui/widget/msgbox.cpp +++ b/src/gui/widget/msgbox.cpp @@ -218,12 +218,11 @@ int CMsgBox::exec() ccw_footer->getSelectedButtonObject()->setButtonAlias(mb_show_button); 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); + if (timeout > 0) + showTimeOutBar(); + bool loop = true; while (loop) {