mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
CComponentsHeader: use isAdded() to avoid add multiple items
This commit is contained in:
@@ -168,10 +168,12 @@ void CComponentsHeader::initIcon()
|
|||||||
printf(" [CComponentsHeader]\n [%s - %d] init header icon: %s\n", __FUNCTION__, __LINE__, cch_icon_name);
|
printf(" [CComponentsHeader]\n [%s - %d] init header icon: %s\n", __FUNCTION__, __LINE__, cch_icon_name);
|
||||||
#endif
|
#endif
|
||||||
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);
|
||||||
//add item only one time
|
|
||||||
addCCItem(cch_icon_obj); //icon
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add item only one time
|
||||||
|
if (!cch_icon_obj->isAdded())
|
||||||
|
addCCItem(cch_icon_obj); //icon
|
||||||
|
|
||||||
//get dimensions of header icon
|
//get dimensions of header icon
|
||||||
int iw, ih;
|
int iw, ih;
|
||||||
frameBuffer->getIconSize(cch_icon_name, &iw, &ih);
|
frameBuffer->getIconSize(cch_icon_name, &iw, &ih);
|
||||||
@@ -242,6 +244,10 @@ void CComponentsHeader::initButtonFormSize()
|
|||||||
{
|
{
|
||||||
cch_buttons_w = 0;
|
cch_buttons_w = 0;
|
||||||
cch_buttons_h = 0;
|
cch_buttons_h = 0;
|
||||||
|
|
||||||
|
if (cch_btn_obj == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
for(size_t i=0; i<v_cch_btn.size(); i++){
|
for(size_t i=0; i<v_cch_btn.size(); i++){
|
||||||
int bw, bh;
|
int bw, bh;
|
||||||
frameBuffer->getIconSize(v_cch_btn[i].c_str(), &bw, &bh);
|
frameBuffer->getIconSize(v_cch_btn[i].c_str(), &bw, &bh);
|
||||||
@@ -254,9 +260,13 @@ void CComponentsHeader::initButtonFormSize()
|
|||||||
void CComponentsHeader::initButtons()
|
void CComponentsHeader::initButtons()
|
||||||
{
|
{
|
||||||
//exit if no button defined
|
//exit if no button defined
|
||||||
if (v_cch_btn.empty())
|
if (v_cch_btn.empty()){
|
||||||
|
if (cch_btn_obj)
|
||||||
|
delete cch_btn_obj;
|
||||||
|
cch_btn_obj = NULL;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
initButtonFormSize();
|
initButtonFormSize();
|
||||||
|
|
||||||
if (cch_btn_obj == NULL){
|
if (cch_btn_obj == NULL){
|
||||||
@@ -264,10 +274,12 @@ void CComponentsHeader::initButtons()
|
|||||||
#ifdef DEBUG_CC
|
#ifdef DEBUG_CC
|
||||||
printf(" [CComponentsHeader]\n [%s - %d] init header buttons...\n", __FUNCTION__, __LINE__);
|
printf(" [CComponentsHeader]\n [%s - %d] init header buttons...\n", __FUNCTION__, __LINE__);
|
||||||
#endif
|
#endif
|
||||||
//add button form
|
|
||||||
addCCItem(cch_btn_obj); //buttons
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add button form only one time
|
||||||
|
if (!cch_btn_obj->isAdded())
|
||||||
|
addCCItem(cch_btn_obj); //buttons
|
||||||
|
|
||||||
//set button form properties
|
//set button form properties
|
||||||
if (cch_btn_obj){
|
if (cch_btn_obj){
|
||||||
cch_btn_obj->setDimensionsAll(width-cch_offset-cch_buttons_w, cch_items_y, cch_buttons_w, cch_buttons_h);
|
cch_btn_obj->setDimensionsAll(width-cch_offset-cch_buttons_w, cch_items_y, cch_buttons_w, cch_buttons_h);
|
||||||
@@ -315,10 +327,12 @@ void CComponentsHeader::initCaption()
|
|||||||
printf(" [CComponentsHeader]\n [%s - %d] init header text: %s [ x %d w %d ]\n", __FUNCTION__, __LINE__, cch_text.c_str(), cch_text_x, cc_text_w);
|
printf(" [CComponentsHeader]\n [%s - %d] init header text: %s [ x %d w %d ]\n", __FUNCTION__, __LINE__, cch_text.c_str(), cch_text_x, cc_text_w);
|
||||||
#endif
|
#endif
|
||||||
cch_text_obj = new CComponentsText();
|
cch_text_obj = new CComponentsText();
|
||||||
//add text item
|
|
||||||
addCCItem(cch_text_obj); //text
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add text item
|
||||||
|
if (!cch_text_obj->isAdded())
|
||||||
|
addCCItem(cch_text_obj); //text
|
||||||
|
|
||||||
//set header text properties
|
//set header text properties
|
||||||
if (cch_text_obj){
|
if (cch_text_obj){
|
||||||
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height);
|
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height);
|
||||||
|
Reference in New Issue
Block a user