From 5daad15d3569bbd2c001383e7be039e2077d0580 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 15 Apr 2013 11:49:52 +0200 Subject: [PATCH] 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. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/336c3bc7a199254a45f2496484390ed4bc8a6a3f Author: Thilo Graf Date: 2013-04-15 (Mon, 15 Apr 2013) ------------------ This commit was generated by Migit --- src/gui/components/cc.h | 7 +++++++ src/gui/components/cc_frm.cpp | 3 ++- src/gui/components/cc_item.cpp | 9 +++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index ff7b3e934..f20b0c125 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -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;}; diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index fd3723639..34c1e4d25 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -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 diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index 16fe3d803..43a7ddb46 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -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 @@ -53,10 +53,11 @@ void CComponentsItem::initVarItem() { //CComponents initVarBasic(); - cc_item_index = CC_NO_INDEX; + cc_item_index = CC_NO_INDEX; cc_item_xr = cc_item_yr = -1; - cc_item_enabled = true; - cc_item_selected = false; + cc_item_enabled = true; + cc_item_selected = false; + cc_parent = NULL; } // Paint container background in cc-items with shadow, background and frame.