CComponentsHeader: init code for icon and text outsource

slim down of paint()
This commit is contained in:
2012-11-09 23:53:35 +01:00
parent 6bdd8cd771
commit 8061b2938f
2 changed files with 30 additions and 16 deletions

View File

@@ -453,8 +453,14 @@ class CComponentsHeader : public CComponentsForm
neutrino_locale_t cch_locale_text; neutrino_locale_t cch_locale_text;
fb_pixel_t cch_col_text; fb_pixel_t cch_col_text;
Font* cch_font; Font* cch_font;
int cch_icon_x, cch_items_y;
void initCCHeaderIcon();
void initCCHeaderText();
protected: protected:
void initVarHeader(); void initVarHeader();
public: public:
CComponentsHeader(); CComponentsHeader();

View File

@@ -1694,6 +1694,8 @@ void CComponentsHeader::initVarHeader()
cch_text = "header"; cch_text = "header";
cch_locale_text = NONEXISTANT_LOCALE; cch_locale_text = NONEXISTANT_LOCALE;
cch_col_text = COL_MENUHEAD; cch_col_text = COL_MENUHEAD;
cch_items_y = 0;
cch_icon_x = 0;
//CComponentsForm //CComponentsForm
initVarForm(); initVarForm();
@@ -1721,18 +1723,8 @@ void CComponentsHeader::setHeaderIcon(const char* icon_name)
cch_icon_name = icon_name; cch_icon_name = icon_name;
} }
void CComponentsHeader::paint(bool do_save_bg) void CComponentsHeader::initCCHeaderIcon()
{ {
//paint body
paintInit(do_save_bg);
int cch_items_y = 0;
//clean up first possible old item objects, includes delete and clean up vector
clearCCItems();
//init icon
int cch_icon_x = 0;
if (cch_icon_name) if (cch_icon_name)
cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name); cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name);
cch_icon_obj->setWidth(height-2*fr_thickness); cch_icon_obj->setWidth(height-2*fr_thickness);
@@ -1748,9 +1740,10 @@ void CComponentsHeader::paint(bool do_save_bg)
else else
cc_icon_corner_type = CORNER_LEFT; cc_icon_corner_type = CORNER_LEFT;
cch_icon_obj->setCornerType(cc_icon_corner_type); cch_icon_obj->setCornerType(cc_icon_corner_type);
}
void CComponentsHeader::initCCHeaderText()
//init text {
int cch_text_x = cch_icon_x+cch_icon_obj->getWidth(); int cch_text_x = cch_icon_x+cch_icon_obj->getWidth();
cch_text_obj = new CComponentsText(cch_text_x, cch_items_y, width-cch_icon_obj->getWidth()-fr_thickness, height-2*fr_thickness, cch_text.c_str()); cch_text_obj = new CComponentsText(cch_text_x, cch_items_y, width-cch_icon_obj->getWidth()-fr_thickness, height-2*fr_thickness, cch_text.c_str());
cch_text_obj->setTextFont(cch_font); cch_text_obj->setTextFont(cch_font);
@@ -1760,6 +1753,21 @@ void CComponentsHeader::paint(bool do_save_bg)
//corner of text item //corner of text item
cch_text_obj->setCornerRadius(corner_rad-fr_thickness); cch_text_obj->setCornerRadius(corner_rad-fr_thickness);
cch_text_obj->setCornerType(corner_type); cch_text_obj->setCornerType(corner_type);
}
void CComponentsHeader::paint(bool do_save_bg)
{
//paint body
paintInit(do_save_bg);
//clean up first possible old item objects, includes delete and clean up vector
clearCCItems();
//init icon
initCCHeaderIcon();
//init text
initCCHeaderText();
//add elements //add elements
addCCItem(cch_icon_obj); addCCItem(cch_icon_obj);