From 949867e4acba32ecf94b69a9fa81cc75ada5c6d3 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 19 Nov 2012 15:53:17 +0100 Subject: [PATCH] CComponentsForm: add virtual members to manipulate ccitems --- src/gui/components/cc.h | 4 ++++ src/gui/components/components.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index ae4f89db5..cbe1cf194 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -442,6 +442,10 @@ class CComponentsForm : public CComponentsItem void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void hide(bool no_restore = false); virtual void addCCItem(CComponentsItem* cc_Item); + virtual void insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item); + virtual void removeCCItem(const uint& cc_item_id); + virtual int getCCItemId(CComponentsItem* cc_Item); + virtual CComponentsItem* getCCItem(const uint& cc_item_id); virtual void paintCCItems(); }; diff --git a/src/gui/components/components.cpp b/src/gui/components/components.cpp index 7fc197d88..c3c0e3b5f 100644 --- a/src/gui/components/components.cpp +++ b/src/gui/components/components.cpp @@ -1570,6 +1570,36 @@ void CComponentsForm::addCCItem(CComponentsItem* cc_Item) v_cc_items.push_back(cc_Item); } +void CComponentsForm::insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item) +{ + v_cc_items.insert(v_cc_items.begin()+cc_item_id, cc_Item); +} + +int CComponentsForm::getCCItemId(CComponentsItem* cc_Item) +{ + for (size_t i= 0; i< v_cc_items.size(); i++) + if (v_cc_items[i] == cc_Item) + return i; + return -1; +} + +CComponentsItem* CComponentsForm::getCCItem(const uint& cc_item_id) +{ + if (v_cc_items[cc_item_id]) + return v_cc_items[cc_item_id]; + return NULL; +} + +void CComponentsForm::removeCCItem(const uint& cc_item_id) +{ + if (v_cc_items[cc_item_id]) { + delete v_cc_items[cc_item_id]; + v_cc_items[cc_item_id] = NULL; + v_cc_items.erase(v_cc_items.begin()+cc_item_id); + } + +} + void CComponentsForm::paint(bool do_save_bg) { //paint body