CComponentsItem/CComponentsForm: add property focus

Specifies that some certain operations especially eg. exec events for
that item are possible.
This commit is contained in:
2014-09-02 08:35:12 +02:00
committed by [CST] Focus
parent 5ae495716e
commit 0c0e0e85ff
3 changed files with 19 additions and 0 deletions

View File

@@ -241,6 +241,8 @@ class CComponentsItem : public CComponents
///property: page number, this defines current item page location, means: this item is embedded in a parent container on page number n, see also setPageNumber() ///property: page number, this defines current item page location, means: this item is embedded in a parent container on page number n, see also setPageNumber()
///default value is 0 for page one, any value > 0 causes handling for mutilple pages at parent container ///default value is 0 for page one, any value > 0 causes handling for mutilple pages at parent container
uint8_t cc_page_number; uint8_t cc_page_number;
///specifies that some certain operations especially eg. exec events for that item are possible, see also setFocus(), hasFocus()
bool cc_has_focus;
///Pointer to the form object in which this item is embedded. ///Pointer to the form object in which this item is embedded.
///Is typically the type CComponentsForm or derived classes, default intialized with NULL ///Is typically the type CComponentsForm or derived classes, default intialized with NULL
@@ -269,6 +271,10 @@ class CComponentsItem : public CComponents
virtual CComponentsForm* getParent(){return cc_parent;}; virtual CComponentsForm* getParent(){return cc_parent;};
///property: returns true if item is added to a form ///property: returns true if item is added to a form
virtual bool isAdded(); virtual bool isAdded();
///indicates wether item has focus
virtual bool hasFocus(){return cc_has_focus;}
///set or unset focus of item, stand alone items without parent have always set focus to true, inside of a parent form object, always the last added item has focus
virtual void setFocus(bool focus);
///abstract: paint item, arg: do_save_bg see paintInit() above ///abstract: paint item, arg: do_save_bg see paintInit() above
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0; virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;

View File

@@ -111,6 +111,7 @@ void CComponentsForm::addCCItem(CComponentsItem* cc_Item)
//assign item index //assign item index
int new_index = genIndex(); int new_index = genIndex();
cc_Item->setIndex(new_index); cc_Item->setIndex(new_index);
cc_Item->setFocus(true);
dprintf(DEBUG_DEBUG, "\t%s-%d parent index = %d, assigned index ======> %d\n", __func__, __LINE__, cc_item_index, new_index); dprintf(DEBUG_DEBUG, "\t%s-%d parent index = %d, assigned index ======> %d\n", __func__, __LINE__, cc_item_index, new_index);

View File

@@ -50,6 +50,7 @@ CComponentsItem::CComponentsItem(CComponentsForm* parent)
cc_item_enabled = true; cc_item_enabled = true;
cc_item_selected = false; cc_item_selected = false;
cc_page_number = 0; cc_page_number = 0;
cc_has_focus = true;
initParent(parent); initParent(parent);
} }
@@ -214,3 +215,14 @@ void CComponentsItem::setWidthP(const uint8_t& w_percent)
{ {
width = cc_parent ? w_percent*cc_parent->getWidth()/100 : w_percent*frameBuffer->getScreenWidth(true)/100; width = cc_parent ? w_percent*cc_parent->getWidth()/100 : w_percent*frameBuffer->getScreenWidth(true)/100;
} }
void CComponentsItem::setFocus(bool focus)
{
if(cc_parent){
for(size_t i=0; i<cc_parent->size(); i++){
if (focus)
cc_parent->getCCItem(i)->setFocus(false);
}
}
cc_has_focus = focus;
}