CComponentsHeader: rename some members for plausible usage in subclasses

Some members are usable in subclasses, but current names could be not
suitable or not plausible with respect to the name of subclass.


Origin commit data
------------------
Branch: ni/coolstream
Commit: 8e46f63900
Author: Thilo Graf <dbt@novatux.de>
Date: 2013-05-27 (Mon, 27 May 2013)

Origin message was:
------------------
CComponentsHeader: rename some members for plausible usage in subclasses

Some members are usable in subclasses, but current names could be not
suitable or not plausible with respect to the name of subclass.


------------------
This commit was generated by Migit
This commit is contained in:
2013-05-27 11:57:17 +02:00
parent 0789b2735b
commit e7da096348
4 changed files with 48 additions and 46 deletions

View File

@@ -103,7 +103,7 @@ class CComponentsIconForm : public CComponentsForm
class CComponentsHeader : public CComponentsForm class CComponentsHeader : public CComponentsForm
{ {
private: protected:
CComponentsPicture * cch_icon_obj; CComponentsPicture * cch_icon_obj;
CComponentsText * cch_text_obj; CComponentsText * cch_text_obj;
CComponentsIconForm * cch_btn_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; int cch_icon_x, cch_items_y, cch_text_x, ccif_width, cch_icon_w, cch_buttons, cch_btn_offset;
std::vector<std::string> v_cch_btn; std::vector<std::string> v_cch_btn;
void initCCHeaderIcon(); void initIcon();
void initCCHeaderText(); void initCaption();
void initCCHeaderButtons(); void initButtons();
void initCCHDefaultButtons(); void initDefaultButtons();
void initCCButtonFormSize(); void initButtonFormSize();
protected:
void initVarHeader(); void initVarHeader();
public: 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); 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(); ~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 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 class CComponentsWindow : public CComponentsForm

View File

@@ -60,8 +60,9 @@ CComponentsHeader::CComponentsHeader( const int x_pos, const int y_pos, const in
cch_text = caption; cch_text = caption;
cch_icon_name = icon_name; cch_icon_name = icon_name;
cch_buttons = buttons; 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, 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_icon_name = icon_name;
cch_buttons = buttons; cch_buttons = buttons;
initCCHDefaultButtons(); initDefaultButtons();
initCCHeaderItems(); initCCItems();
} }
void CComponentsHeader::initVarHeader() void CComponentsHeader::initVarHeader()
@@ -128,22 +129,22 @@ CComponentsHeader::~CComponentsHeader()
cleanCCForm(); cleanCCForm();
} }
void CComponentsHeader::setHeaderText(const std::string& caption) void CComponentsHeader::setCaption(const std::string& caption)
{ {
cch_text = 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); 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; cch_icon_name = icon_name;
} }
void CComponentsHeader::initCCHeaderIcon() void CComponentsHeader::initIcon()
{ {
//reset cch_icon_w //reset cch_icon_w
cch_icon_w = cch_btn_offset; 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); v_cch_btn.push_back(button_name);
initCCHeaderButtons(); initButtons();
} }
void CComponentsHeader::removeHeaderButtons() void CComponentsHeader::removeButtonIcons()
{ {
v_cch_btn.clear(); v_cch_btn.clear();
cch_btn_obj->removeAllIcons(); cch_btn_obj->removeAllIcons();
initCCHeaderButtons(); initButtons();
} }
void CComponentsHeader::initCCHDefaultButtons() void CComponentsHeader::initDefaultButtons()
{ {
if (cch_buttons & CC_BTN_EXIT) if (cch_buttons & CC_BTN_EXIT)
v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_HOME); v_cch_btn.push_back(NEUTRINO_ICON_BUTTON_HOME);
@@ -220,15 +221,15 @@ void CComponentsHeader::initCCHDefaultButtons()
#endif #endif
} }
void CComponentsHeader::setHeaderDefaultButtons(const int buttons) void CComponentsHeader::setDefaultButtons(const int buttons)
{ {
cch_buttons = buttons; cch_buttons = buttons;
v_cch_btn.clear(); v_cch_btn.clear();
initCCHDefaultButtons(); initDefaultButtons();
} }
// calculate minimal width of icon form // calculate minimal width of icon form
void CComponentsHeader::initCCButtonFormSize() void CComponentsHeader::initButtonFormSize()
{ {
ccif_width = 0; ccif_width = 0;
for(size_t i=0; i<v_cch_btn.size(); i++){ for(size_t i=0; i<v_cch_btn.size(); i++){
@@ -238,13 +239,13 @@ void CComponentsHeader::initCCButtonFormSize()
} }
} }
void CComponentsHeader::initCCHeaderButtons() void CComponentsHeader::initButtons()
{ {
//exit if no button defined //exit if no button defined
if (v_cch_btn.empty()) if (v_cch_btn.empty())
return; return;
initCCButtonFormSize(); initButtonFormSize();
if (cch_btn_obj == NULL){ if (cch_btn_obj == NULL){
cch_btn_obj = new CComponentsIconForm(); cch_btn_obj = new CComponentsIconForm();
@@ -267,7 +268,7 @@ void CComponentsHeader::initCCHeaderButtons()
} }
} }
void CComponentsHeader::initCCHeaderText() void CComponentsHeader::initCaption()
{ {
//reset header text position first //reset header text position first
cch_text_x = cch_icon_x+cch_icon_w; cch_text_x = cch_icon_x+cch_icon_w;
@@ -300,22 +301,22 @@ void CComponentsHeader::initCCHeaderText()
} }
} }
void CComponentsHeader::initCCHeaderItems() void CComponentsHeader::initCCItems()
{ {
//init icon //init icon
initCCHeaderIcon(); initIcon();
//init text //init text
initCCHeaderText(); initCaption();
//init buttons //init buttons
initCCHeaderButtons(); initButtons();
} }
void CComponentsHeader::paint(bool do_save_bg) void CComponentsHeader::paint(bool do_save_bg)
{ {
//prepare items //prepare items
initCCHeaderItems(); initCCItems();
//paint form contents //paint form contents
paintForm(do_save_bg); paintForm(do_save_bg);

View File

@@ -106,11 +106,11 @@ void CComponentsWindow::initHeader()
ccw_head->setXPos(0); ccw_head->setXPos(0);
ccw_head->setYPos(0); ccw_head->setYPos(0);
ccw_head->setWidth(width); ccw_head->setWidth(width);
ccw_head->setHeaderIcon(ccw_icon_name); ccw_head->setIcon(ccw_icon_name);
ccw_head->setHeaderText(ccw_caption); ccw_head->setCaption(ccw_caption);
ccw_head->initCCHeaderItems(); ccw_head->initCCItems();
ccw_start_y = ccw_head->getHeight(); ccw_start_y = ccw_head->getHeight();
ccw_head->setHeaderDefaultButtons(ccw_buttons); ccw_head->setDefaultButtons(ccw_buttons);
} }
} }

View File

@@ -437,7 +437,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
if (header == NULL){ 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 = 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->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 // else //For existing instances it's recommended
// //to remove old button icons before add new buttons, otherwise icons will be appended. // //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); // header->setCornerType(CORNER_TOP);
// change text of header // change text of header
header->setHeaderText("Test"); header->setCaption("Test");
// add any other button icon // add any other button icon
// header->addHeaderButton(NEUTRINO_ICON_BUTTON_BLUE); // header->addHeaderButton(NEUTRINO_ICON_BUTTON_BLUE);