diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 367638618..7ff1c504e 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -103,7 +103,7 @@ class CComponentsIconForm : public CComponentsForm class CComponentsHeader : public CComponentsForm { - private: + protected: CComponentsPicture * cch_icon_obj; CComponentsText * cch_text_obj; CComponentsIconForm * cch_btn_obj; @@ -114,13 +114,12 @@ class CComponentsHeader : public CComponentsForm int cch_icon_x, cch_items_y, cch_text_x, ccif_width, cch_icon_w, cch_buttons, cch_btn_offset; std::vector v_cch_btn; - void initCCHeaderIcon(); - void initCCHeaderText(); - void initCCHeaderButtons(); - void initCCHDefaultButtons(); - void initCCButtonFormSize(); + void initIcon(); + void initCaption(); + void initButtons(); + void initDefaultButtons(); + void initButtonFormSize(); - protected: void initVarHeader(); public: @@ -146,16 +145,18 @@ class CComponentsHeader : public CComponentsForm fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); ~CComponentsHeader(); + + virtual void setCaption(const std::string& caption); + virtual void setCaption(neutrino_locale_t caption_locale); + virtual void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;}; + virtual void setButtonOffset(const int offset){cch_btn_offset = offset;}; + virtual void setIcon(const char* icon_name); + virtual void addButtonIcon(const std::string& button_name); + virtual void removeButtonIcons(); + virtual void setDefaultButtons(const int buttons); + virtual void initCCItems(); + void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); - void setHeaderText(const std::string& caption); - void setHeaderText(neutrino_locale_t caption_locale); - void setColorHeaderBody(fb_pixel_t text_color){cch_col_text = text_color;}; - void setHeaderButtonOffset(const int offset){cch_btn_offset = offset;}; - void setHeaderIcon(const char* icon_name); - void addHeaderButton(const std::string& button_name); - void removeHeaderButtons(); - void setHeaderDefaultButtons(const int buttons); - void initCCHeaderItems(); }; class CComponentsWindow : public CComponentsForm diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp index fdd2937b3..2bc3f99ab 100644 --- a/src/gui/components/cc_frm_header.cpp +++ b/src/gui/components/cc_frm_header.cpp @@ -60,8 +60,9 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in cch_text = caption; cch_icon_name = icon_name; cch_buttons = buttons; - initCCHDefaultButtons(); - initCCHeaderItems(); + + initDefaultButtons(); + initCCItems(); } CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t caption_locale, const char* icon_name, const int buttons, bool has_shadow, @@ -83,8 +84,8 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in cch_icon_name = icon_name; cch_buttons = buttons; - initCCHDefaultButtons(); - initCCHeaderItems(); + initDefaultButtons(); + initCCItems(); } void CComponentsHeader::initVarHeader() @@ -128,22 +129,22 @@ CComponentsHeader::~CComponentsHeader() cleanCCForm(); } -void CComponentsHeader::setHeaderText(const std::string& caption) +void CComponentsHeader::setCaption(const std::string& caption) { cch_text = caption; } -void CComponentsHeader::setHeaderText(neutrino_locale_t caption_locale) +void CComponentsHeader::setCaption(neutrino_locale_t caption_locale) { cch_text = g_Locale->getText(caption_locale); } -void CComponentsHeader::setHeaderIcon(const char* icon_name) +void CComponentsHeader::setIcon(const char* icon_name) { cch_icon_name = icon_name; } -void CComponentsHeader::initCCHeaderIcon() +void CComponentsHeader::initIcon() { //reset cch_icon_w cch_icon_w = cch_btn_offset; @@ -191,21 +192,21 @@ void CComponentsHeader::initCCHeaderIcon() } } -void CComponentsHeader::addHeaderButton(const std::string& button_name) +void CComponentsHeader::addButtonIcon(const std::string& button_name) { v_cch_btn.push_back(button_name); - initCCHeaderButtons(); + initButtons(); } -void CComponentsHeader::removeHeaderButtons() +void CComponentsHeader::removeButtonIcons() { v_cch_btn.clear(); cch_btn_obj->removeAllIcons(); - initCCHeaderButtons(); + initButtons(); } -void CComponentsHeader::initCCHDefaultButtons() +void CComponentsHeader::initDefaultButtons() { if (cch_buttons & CC_BTN_EXIT) v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_HOME); @@ -220,15 +221,15 @@ void CComponentsHeader::initCCHDefaultButtons() #endif } -void CComponentsHeader::setHeaderDefaultButtons(const int buttons) +void CComponentsHeader::setDefaultButtons(const int buttons) { cch_buttons = buttons; v_cch_btn.clear(); - initCCHDefaultButtons(); + initDefaultButtons(); } // calculate minimal width of icon form -void CComponentsHeader::initCCButtonFormSize() +void CComponentsHeader::initButtonFormSize() { ccif_width = 0; for(size_t i=0; isetXPos(0); ccw_head->setYPos(0); ccw_head->setWidth(width); - ccw_head->setHeaderIcon(ccw_icon_name); - ccw_head->setHeaderText(ccw_caption); - ccw_head->initCCHeaderItems(); + ccw_head->setIcon(ccw_icon_name); + ccw_head->setCaption(ccw_caption); + ccw_head->initCCItems(); ccw_start_y = ccw_head->getHeight(); - ccw_head->setHeaderDefaultButtons(ccw_buttons); + ccw_head->setDefaultButtons(ccw_buttons); } } diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index 4e06919a9..f860f5d83 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -437,7 +437,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) if (header == NULL){ header = new CComponentsHeader (100, 50, 500, hh, "Test-Header"/*, NEUTRINO_ICON_INFO, CComponentsHeader::CC_BTN_HELP | CComponentsHeader::CC_BTN_EXIT | CComponentsHeader::CC_BTN_MENU*/); // header->addHeaderButton(NEUTRINO_ICON_BUTTON_RED); - header->setHeaderDefaultButtons(CComponentsHeader::CC_BTN_HELP | CComponentsHeader::CC_BTN_EXIT | CComponentsHeader::CC_BTN_MENU); + header->setDefaultButtons(CComponentsHeader::CC_BTN_HELP | CComponentsHeader::CC_BTN_EXIT | CComponentsHeader::CC_BTN_MENU); } // else //For existing instances it's recommended // //to remove old button icons before add new buttons, otherwise icons will be appended. @@ -449,7 +449,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) // header->setCornerType(CORNER_TOP); // change text of header - header->setHeaderText("Test"); + header->setCaption("Test"); // add any other button icon // header->addHeaderButton(NEUTRINO_ICON_BUTTON_BLUE);