CComponentsItem: add members to set pointer for parent object

Pointer is typically of type CComponentsForm or derived classes,
default intialized with NULL and serves to access for
properties of parent object by embedded items.
This commit is contained in:
2013-04-15 11:49:52 +02:00
parent 4317b0b4fb
commit 336c3bc7a1
3 changed files with 14 additions and 5 deletions

View File

@@ -101,6 +101,10 @@ class CComponentsItem : public CComponents
int cc_item_index;
bool cc_item_enabled, cc_item_selected;
///Pointer to the form object in which this item is embedded.
///Is typically the type CComponentsForm or derived classes, default intialized with NULL
CComponents *cc_parent;
///contains real position and dimensions on screen,
int cc_item_xr, cc_item_yr;
@@ -111,6 +115,9 @@ class CComponentsItem : public CComponents
public:
CComponentsItem();
///sets pointer to the form object in which this item is embedded.
virtual void setParent(CComponents *parent){cc_parent = parent;};
///sets real position on screen. Use this, if item contains own render methods and item is added to a form
virtual void setRealPos(const int& xr, const int& yr){cc_item_xr = xr; cc_item_yr = yr;};
virtual int getRealXPos(){return cc_item_xr;};

View File

@@ -16,7 +16,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
@@ -129,6 +129,7 @@ void CComponentsForm::addCCItem(CComponentsItem* 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());
#endif
cc_Item->setParent(this);
v_cc_items.push_back(cc_Item);
}
#ifdef DEBUG_CC

View File

@@ -16,7 +16,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
@@ -57,6 +57,7 @@ void CComponentsItem::initVarItem()
cc_item_xr = cc_item_yr = -1;
cc_item_enabled = true;
cc_item_selected = false;
cc_parent = NULL;
}
// Paint container background in cc-items with shadow, background and frame.