diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index b7bba8f93..b7e964356 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -124,8 +124,7 @@ void CComponentsButton::initVarButton( const int& x_pos, const int& y_pos, const cc_btn_font = NULL; cc_btn_icon = icon_name; cc_btn_text = caption; - cc_directKey = CRCInput::RC_nokey; - cc_directKeyAlt = cc_directKey; + cc_directKeys.push_back(CRCInput::RC_nokey); cc_btn_result = -1; cc_btn_alias = -1; diff --git a/src/gui/components/cc_frm_button.h b/src/gui/components/cc_frm_button.h index a0540636b..92bf474f8 100644 --- a/src/gui/components/cc_frm_button.h +++ b/src/gui/components/cc_frm_button.h @@ -70,9 +70,9 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen ///property: icon name, only icons supported, to find in gui/widget/icons.h std::string cc_btn_icon; - ///property: assigned event message value, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonDirectKey(), getButtonDirectKey() - neutrino_msg_t cc_directKey; - ///property: assigned an alternate event message value, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonDirectKeyAlt(), getButtonDirectKeyAlt() + ///property: container for all assigned event message values, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonDirectKey(), hasButtonDirectKey() + std::vectorcc_directKeys; + ///property: assigned an alternate event message value, see driver/rcinput.h for possible values, default value = CRCInput::RC_nokey, see also setButtonDirectKeyAlt(), hasButtonDirectKeyAlt() neutrino_msg_t cc_directKeyAlt; ///property: assigned return value, see also setButtonResult(), getButtonResult(), default value = -1 (not defined) int cc_btn_result; @@ -135,7 +135,7 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen fb_pixel_t color_frame = COL_SHADOW_PLUS_0, fb_pixel_t color_body = COL_BUTTON_BODY, fb_pixel_t color_shadow = COL_SHADOW_PLUS_0); ///set text color - inline virtual void setButtonTextColor(fb_pixel_t caption_color){cc_btn_text_col = caption_color;}; + void setButtonTextColor(fb_pixel_t caption_color){cc_btn_text_col = caption_color;}; /**Member to modify background behavior of embeded caption object. * @param[in] mode @@ -159,42 +159,80 @@ class CComponentsButton : public CComponentsFrmChain, public CCTextScreen }; ///set caption: parameter as string - virtual void setCaption(const std::string& text); + void setCaption(const std::string& text); ///set caption: parameter as locale - virtual void setCaption(const neutrino_locale_t locale_text); + void setCaption(const neutrino_locale_t locale_text); ///get caption, type as std::string - inline virtual std::string getCaptionString(){return cc_btn_text;}; + std::string getCaptionString(){return cc_btn_text;}; ///get loacalized caption id, type = neutrino_locale_t - inline virtual neutrino_locale_t getCaptionLocale(){return cc_btn_text_locale;}; + neutrino_locale_t getCaptionLocale(){return cc_btn_text_locale;}; ///property: set font for label caption, parameter as font object, value NULL causes usaage of dynamic font - virtual void setButtonFont(Font* font){cc_btn_font = font; initCCBtnItems();}; + void setButtonFont(Font* font){cc_btn_font = font; initCCBtnItems();}; ///reinitialize items - virtual void Refresh(){initCCBtnItems();}; + void Refresh(){initCCBtnItems();}; ///paint button object void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); - ///assigns an event msg value to button object, parameter1 as neutrino_msg_t, see driver/rcinput.h for possible values - inline virtual void setButtonDirectKey(const neutrino_msg_t& msg){cc_directKey = msg;}; - ///assigns an alternate event msg value to button object, parameter1 as neutrino_msg_t, see driver/rcinput.h for possible values - inline virtual void setButtonDirectKeyA(const neutrino_msg_t& msg){cc_directKeyAlt = msg;}; - ///returns an event msg value to button object, see driver/rcinput.h for possible values - inline virtual neutrino_msg_t getButtonDirectKey(){return cc_directKey;}; - ///returns an alternate event msg value to button object, but returns the primary direct key if no key was defined, see driver/rcinput.h for possible values - inline virtual neutrino_msg_t getButtonDirectKeyA(){return cc_directKeyAlt != CRCInput::RC_nokey ? cc_directKeyAlt : cc_directKey ;}; + /** + * Assigns a single event msg value to button object + * @param[in] neutrino_msg_t + * @li excepts type msg_result_t + * @note This method adds only one message key value into the cc_directKeys container, \n + * Already existant keys will be removed. When more than one key value is required, \n + * use setButtonDirectKeys(). + * @see setButtonDirectKeys(), driver/rcinput.h for possible values + */ + + void setButtonDirectKey(const neutrino_msg_t& msg){cc_directKeys.clear(); cc_directKeys.push_back(msg);} + /** + * Assigns a container with any event msg values to button object + * @param[in] v_directKeys + * @li excepts type std::vector + * @note This method adds any message key values into the cc_directKeys container, \n + * Already existant keys will be removed. When only one key value is required, \n + * use setButtonDirectKey(). + * @see driver/rcinput.h for possible values + */ + void setButtonDirectKeys(const std::vector &v_directKeys){cc_directKeys = v_directKeys;} + + /** + * Returns current primary event msg value of button object. + * @return neutrino_msg_t + * @note This method returns only the first existant message value from cc_directKeys container \n + * Other existant keys ar ignored. If a certain value is required, \n + * use hasButtonDirectKey(). + * @see bool hasButtonDirectKey(), driver/rcinput.h for possible values + */ + neutrino_msg_t getButtonDirectKey(){return cc_directKeys[0];} + + /** + * Returns true if filtered event msg value of button object is found in cc_directKeys container. + * @return bool + * @param[in] msg + * @li exepts type neutrino_msg_t as filter for searched message + * @see neutrino_msg_t getButtonDirectKey(), driver/rcinput.h for possible values + */ + bool hasButtonDirectKey(const neutrino_msg_t& msg) + { + for (size_t i= 0; i< cc_directKeys.size(); i++) + if (cc_directKeys[i] == msg) + return true; + return false; + } ///assigns an return value to button object, parameter1 as int - inline virtual void setButtonResult(const int& result_value){cc_btn_result = result_value;}; + void setButtonResult(const int& result_value){cc_btn_result = result_value;} ///returns current result value of button object - inline virtual int getButtonResult(){return cc_btn_result;}; + int getButtonResult(){return cc_btn_result;} ///assigns an alias value to button object, parameter1 as int, e.g. previous known as mbYes, mbNo... from message boxes - inline virtual void setButtonAlias(const int& alias_value){cc_btn_alias = alias_value;}; + void setButtonAlias(const int& alias_value){cc_btn_alias = alias_value;} ///returns an alias value from button object, see also cc_btn_alias - inline virtual int getButtonAlias(){return cc_btn_alias;}; + int getButtonAlias(){return cc_btn_alias;} }; //! Sub class of CComponentsButton. diff --git a/src/gui/components/cc_frm_footer.cpp b/src/gui/components/cc_frm_footer.cpp index 37372ba2f..63c9f4cf9 100644 --- a/src/gui/components/cc_frm_footer.cpp +++ b/src/gui/components/cc_frm_footer.cpp @@ -192,8 +192,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label_cc * const con CComponentsButton *btn = new CComponentsButton(0, y_btn, w_btn, h_btn, txt, icon_name, NULL, false, true, ccf_enable_button_shadow); btn->doPaintBg(ccf_enable_button_bg); - btn->setButtonDirectKey(content[i].directKey); - btn->setButtonDirectKeyA(content[i].directKeyAlt); + btn->setButtonDirectKeys(content[i].directKeys); btn->setButtonResult(content[i].btn_result); btn->setButtonAlias(content[i].btn_alias); btn->setButtonFont(ccf_btn_font); @@ -253,7 +252,7 @@ void CComponentsFooter::setButtonLabels(const struct button_label * const conten buttons[i].locale = content[i].locale; //NOTE: here are used default values, because old button label struct don't know about this, //if it possible, don't use this methode! - buttons[i].directKey = buttons[i].directKeyAlt = CRCInput::RC_nokey; + buttons[i].directKeys.push_back(CRCInput::RC_nokey); buttons[i].btn_result = -1; buttons[i].btn_alias = -1; } @@ -269,8 +268,7 @@ void CComponentsFooter::setButtonLabels(const vector &v_content buttons[i].button = v_content[i].button; buttons[i].text = v_content[i].text; buttons[i].locale = v_content[i].locale; - buttons[i].directKey = v_content[i].directKey; - buttons[i].directKeyAlt = v_content[i].directKeyAlt; + buttons[i].directKeys = v_content[i].directKeys; buttons[i].btn_result = v_content[i].btn_result; buttons[i].btn_alias = v_content[i].btn_alias; } @@ -284,15 +282,13 @@ void CComponentsFooter::setButtonLabel( const char *button_icon, const int& label_width, const neutrino_msg_t& msg, const int& result_value, - const int& alias_value, - const neutrino_msg_t& directKeyAlt) + const int& alias_value) { button_label_cc button[1]; button[0].button = button_icon; button[0].text = text; - button[0].directKey = msg; - button[0].directKeyAlt = directKeyAlt; + button[0].directKeys.push_back(msg); button[0].btn_result = result_value; button[0].btn_alias = alias_value; @@ -305,12 +301,11 @@ void CComponentsFooter::setButtonLabel( const char *button_icon, const int& label_width, const neutrino_msg_t& msg, const int& result_value, - const int& alias_value, - const neutrino_msg_t& directKeyAlt) + const int& alias_value) { string txt = locale != NONEXISTANT_LOCALE ? g_Locale->getText(locale) : ""; - setButtonLabel(button_icon, txt, chain_width, label_width, msg, result_value, alias_value, directKeyAlt); + setButtonLabel(button_icon, txt, chain_width, label_width, msg, result_value, alias_value); } void CComponentsFooter::enableButtonBg(bool enable) diff --git a/src/gui/components/cc_frm_footer.h b/src/gui/components/cc_frm_footer.h index 3cc572605..852faaae1 100644 --- a/src/gui/components/cc_frm_footer.h +++ b/src/gui/components/cc_frm_footer.h @@ -99,8 +99,7 @@ class CComponentsFooter : public CComponentsHeader const int& label_width = 0, const neutrino_msg_t& msg = CRCInput::RC_nokey, const int& result_value = -1, - const int& alias_value = -1, - const neutrino_msg_t& directKeyAlt = CRCInput::RC_nokey); + const int& alias_value = -1); ///add single button label with locale label type as content, chain_width as int, label width as int void setButtonLabel( const char *button_icon, const neutrino_locale_t& locale, @@ -108,8 +107,7 @@ class CComponentsFooter : public CComponentsHeader const int& label_width = 0, const neutrino_msg_t& msg = CRCInput::RC_nokey, const int& result_value = -1, - const int& alias_value = -1, - const neutrino_msg_t& directKeyAlt = CRCInput::RC_nokey); + const int& alias_value = -1); ///enables background of buttons, parameter bool show, default= true void enableButtonBg(bool enable = true); diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index 5f56ee181..83b22f8d3 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -179,16 +179,19 @@ typedef struct cc_string_ext_txt_t //for 'button_label' type with string typedef struct button_label_cc { - const char * button; - std::string text; - neutrino_locale_t locale; - neutrino_msg_t directKey; - neutrino_msg_t directKeyAlt; - int btn_result; - int btn_alias; - std::string bg_image; - std::string hint; - button_label_cc(): button(NULL), text(std::string()), locale(NONEXISTANT_LOCALE){} + const char * button; + std::string text; + neutrino_locale_t locale; + std::vector directKeys; + int btn_result; + int btn_alias; + std::string bg_image; + std::string hint; + //defaults + button_label_cc(): button(NULL), + text(std::string()), + locale(NONEXISTANT_LOCALE), + directKeys(1, CRCInput::RC_nokey){} } button_label_cc_struct; #define CC_WIDTH_MIN 16 diff --git a/src/gui/widget/msgbox.cpp b/src/gui/widget/msgbox.cpp index bcdd23e8a..eb40539cb 100644 --- a/src/gui/widget/msgbox.cpp +++ b/src/gui/widget/msgbox.cpp @@ -134,8 +134,8 @@ void CMsgBox::initButtons() if (mb_show_button & mbOk){ btn.button = NEUTRINO_ICON_BUTTON_OKAY; btn.text = BTN_TEXT(mbOk); - btn.directKey = CRCInput::RC_ok; - btn.directKeyAlt = btn.directKey; + btn.directKeys.clear(); + btn.directKeys.push_back(CRCInput::RC_ok); btn.btn_result = mbrOk; btn.btn_alias = mbOk; v_buttons.push_back(btn); @@ -143,8 +143,9 @@ void CMsgBox::initButtons() if (mb_show_button & mbNo){ btn.button = NEUTRINO_ICON_BUTTON_RED; btn.text = BTN_TEXT(mbNo); - btn.directKey = CRCInput::RC_red; - btn.directKeyAlt = CRCInput::RC_home; + btn.directKeys.clear(); + btn.directKeys.push_back(CRCInput::RC_red); + btn.directKeys.push_back(CRCInput::RC_home); btn.btn_result = mbrNo; btn.btn_alias = mbNo; v_buttons.push_back(btn); @@ -152,8 +153,9 @@ void CMsgBox::initButtons() if (mb_show_button & mbYes){ btn.button = NEUTRINO_ICON_BUTTON_GREEN; btn.text = BTN_TEXT(mbYes); - btn.directKey = CRCInput::RC_green; - btn.directKeyAlt = CRCInput::RC_ok; + btn.directKeys.clear(); + btn.directKeys.push_back(CRCInput::RC_green); + btn.directKeys.push_back(CRCInput::RC_ok); btn.btn_result = mbrYes; btn.btn_alias = mbYes; v_buttons.push_back(btn); @@ -161,8 +163,9 @@ void CMsgBox::initButtons() if (mb_show_button & mbCancel){ btn.button = NEUTRINO_ICON_BUTTON_HOME; btn.text = BTN_TEXT(mbCancel); - btn.directKey = CRCInput::RC_home; - btn.directKeyAlt = CRCInput::RC_setup; + btn.directKeys.clear(); + btn.directKeys.push_back(CRCInput::RC_home); + btn.directKeys.push_back(CRCInput::RC_setup); btn.btn_result = mbrCancel; btn.btn_alias = mbCancel; v_buttons.push_back(btn); @@ -170,8 +173,8 @@ void CMsgBox::initButtons() if (mb_show_button & mbBack){ btn.button = NEUTRINO_ICON_BUTTON_HOME; btn.text = BTN_TEXT(mbBack); - btn.directKey = CRCInput::RC_home; - btn.directKeyAlt = btn.directKey; + btn.directKeys.clear(); + btn.directKeys.push_back(CRCInput::RC_home); btn.btn_result = mbrBack; btn.btn_alias = mbBack; v_buttons.push_back(btn); @@ -179,15 +182,18 @@ void CMsgBox::initButtons() if (mb_show_button & mbNoYes){ btn.button = NEUTRINO_ICON_BUTTON_RED; btn.text = BTN_TEXT(mbYes); - btn.directKey = CRCInput::RC_red; - btn.directKeyAlt = CRCInput::RC_ok; + btn.directKeys.clear(); + btn.directKeys.push_back(CRCInput::RC_red); + btn.directKeys.push_back(CRCInput::RC_ok); btn.btn_result = mbrYes; btn.btn_alias = mbYes; v_buttons.push_back(btn); + btn.button = NEUTRINO_ICON_BUTTON_GREEN; btn.text = BTN_TEXT(mbNo); - btn.directKey = CRCInput::RC_green; - btn.directKeyAlt = CRCInput::RC_home; + btn.directKeys.clear(); + btn.directKeys.push_back(CRCInput::RC_green); + btn.directKeys.push_back(CRCInput::RC_home); btn.btn_result = mbrNo; btn.btn_alias = mbNo; v_buttons.push_back(btn); @@ -299,7 +305,7 @@ int CMsgBox::exec() //***action buttons without preselection*** for (size_t i = 0; i< ccw_footer->getButtonChainObject()->size(); i++){ CComponentsButton* btn_action = static_cast(ccw_footer->getButtonChainObject()->getCCItem(i)); - if (msg == btn_action->getButtonDirectKey() || msg == btn_action->getButtonDirectKeyA()){ + if (btn_action->hasButtonDirectKey(msg)){ result = (msg_result_t)btn_action->getButtonResult(); dprintf(DEBUG_INFO, "\033[32m[CMsgBox] [%s - %d] result = %d, mb_show_button = %d\033[0m\n", __func__, __LINE__, result, mb_show_button); loop = false;