CComponentsItem: move function isAdded() to CComponentsItem class

This commit is contained in:
2013-10-19 01:13:26 +02:00
parent a1e5a60184
commit 3438b23f68
7 changed files with 19 additions and 18 deletions

View File

@@ -244,6 +244,8 @@ class CComponentsItem : public CComponents
virtual void setParent(CComponentsItem *parent){cc_parent = parent;};
///returns pointer to the form object in which this item is embedded.
virtual CComponentsItem * getParent(){return cc_parent;};
///property: returns true if item is added to a form
virtual bool isAdded(CComponentsItem *parent_frm = NULL);
///abstract: paint item, arg: do_save_bg see paintInit() above
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;

View File

@@ -165,14 +165,6 @@ int CComponentsForm::getCCItemId(CComponentsItem* cc_Item)
return -1;
}
bool CComponentsForm::isAdded(CComponentsItem* cc_item)
{
bool ret = false;
if (getCCItemId(cc_item) != -1)
ret = true;
return ret;
}
int CComponentsForm::genIndex()
{
int count = v_cc_items.size();

View File

@@ -69,8 +69,6 @@ class CComponentsForm : public CComponentsItem
virtual void clearCCItems();
virtual void cleanCCForm();
virtual void setAppendOffset(const int &h_offset, const int& v_offset){append_h_offset = h_offset; append_v_offset = v_offset;};
///property: returns true, if item already added to form
virtual bool isAdded(CComponentsItem *cc_item);
};
class CComponentsIconForm : public CComponentsForm

View File

@@ -133,7 +133,7 @@ void CSignalBar::initSBarScale()
sb_scale->setColorBody(col_body);
//add scale object to container
if(!isAdded(sb_scale))
if(!sb_scale->isAdded())
addCCItem(sb_scale);
}
@@ -158,7 +158,7 @@ void CSignalBar::initSBarValue()
sb_vlbl->setColorBody(col_body);
//add value label object to container
if (!isAdded(sb_vlbl))
if (!sb_vlbl->isAdded())
addCCItem(sb_vlbl);
}
@@ -184,7 +184,7 @@ void CSignalBar::initSBarName()
sb_lbl->setColorBody(col_body);
//add name label object to container
if (!isAdded(sb_lbl))
if (!sb_lbl->isAdded())
addCCItem(sb_lbl);
}

View File

@@ -206,12 +206,12 @@ void CSampleClass::showSNR()
signalbox = new CSignalBox(10, 100, 500, 38, frontend);
// signalbox->setCornerRadius(0); //optional
// signalbox->setColorBody(COL_BLACK); //optional
signalbox->setColorBody(COL_MENUHEAD_PLUS_0);
signalbox->setColorBody(COL_MENUHEAD_PLUS_0);q
signalbox->doPaintBg(false);
//if you want to add the object to a CC-Container (e.g. CComponentsWindow()), remove this line:
signalbox->paint(false);
//and add this lines:
// if (!isAdded(signalbox))
// if (!ignalbox->isAdded())
// addCCItem(signalbox);
//Note: signal box objects deallocate together with the CC-Container!
}

View File

@@ -232,12 +232,12 @@ void CComponentsWindow::initCCWItems()
initBody();
//add header, body and footer items only one time
if (!isAdded(ccw_head))
if (!ccw_head->isAdded())
addCCItem(ccw_head);
if (!isAdded(ccw_body))
if (!ccw_body->isAdded())
addCCItem(ccw_body);
if (ccw_footer)
if (!isAdded(ccw_footer))
if (!ccw_footer->isAdded())
addCCItem(ccw_footer);
}

View File

@@ -151,3 +151,12 @@ int CComponentsItem::getItemType()
#endif
return -1;
}
//returns true if current item is added to a form
bool CComponentsItem::isAdded(CComponentsItem *parent_frm)
{
if (cc_parent)
return true;
return false;
}