CComponentsForm: add index to items

Helpers to identfie added items.
This commit is contained in:
2013-05-29 12:08:58 +02:00
parent e665ab18ab
commit ddaa7a876e
2 changed files with 25 additions and 7 deletions

View File

@@ -32,7 +32,7 @@
#include <string>
#include <driver/pictureviewer/pictureviewer.h>
//#define DEBUG_CC
#define DEBUG_CC
/// Basic component class.
/*!
@@ -193,7 +193,9 @@ class CComponentsItem : public CComponents
protected:
///property: define of item type, see cc_types.h for possible types
int cc_item_type;
///property: define of item index, all bound items get an index, default: CC_NO_INDEX
///property: define of item index, all bound items get an index,
///default: CC_NO_INDEX as identifer for not embedded item and default index=0 for form as main parent
///see also getIndex(), setIndex()
int cc_item_index;
///property: default enabled
bool cc_item_enabled;
@@ -254,6 +256,11 @@ class CComponentsItem : public CComponents
virtual bool isSelected(){return cc_item_selected;};
///get enable mode, see also setEnable() above
virtual bool isEnabled(){return cc_item_enabled;};
///get current index of item, see also attribut cc_item_index
virtual int getIndex(){return cc_item_index;};
///set index to item, see also attribut cc_item_index
virtual void setIndex(const int& index){cc_item_index = index;};
};
#endif

View File

@@ -31,7 +31,7 @@
#include <global.h>
#include <neutrino.h>
#include "cc_frm.h"
#include <stdlib.h>
using namespace std;
//-------------------------------------------------------------------------------------------------------
@@ -70,7 +70,7 @@ void CComponentsForm::cleanCCForm()
#ifdef DEBUG_CC
printf("[CComponentsForm] [%s - %d] clean up...\n", __FUNCTION__, __LINE__);
#endif
// hide();
clearCCItems();
clearSavedScreen();
clear();
@@ -117,20 +117,31 @@ void CComponentsForm::initVarForm()
col_shadow = COL_MENUCONTENTDARK_PLUS_0;
corner_rad = RADIUS_LARGE;
corner_type = CORNER_ALL;
cc_item_index = 0;
//CComponentsForm
v_cc_items.clear();
}
void CComponentsForm::addCCItem(CComponentsItem* cc_Item)
{
if (cc_Item){
#ifdef DEBUG_CC
printf(" [CComponentsForm] %s-%d add cc_Item [type %d] [current count %d] \n", __FUNCTION__, __LINE__, cc_Item->getItemType(), v_cc_items.size());
printf(" [CComponentsForm] %s-%d add cc_Item [type %d] to form [current index=%d] \n", __FUNCTION__, __LINE__, cc_Item->getItemType(), cc_item_index);
#endif
cc_Item->setParent(this);
v_cc_items.push_back(cc_Item);
//assign item index
int count = v_cc_items.size();
char buf[16];
snprintf(buf, sizeof(buf), "%d%d", cc_item_index, count);
buf[15] = '\0';
int new_index = atoi(buf);
cc_Item->setIndex(new_index);
#ifdef DEBUG_CC
printf(" %s-%d parent index = %d, assigned index ======> %d\n", __FUNCTION__, __LINE__, cc_item_index, new_index);
#endif
}
#ifdef DEBUG_CC
else