From 2ca8b1bce03866da449c417daa39bdb9770a36dc Mon Sep 17 00:00:00 2001 From: thilo Date: Fri, 6 May 2011 18:16:06 +0000 Subject: [PATCH] *neutrino menu classes: new members added insertItem(), removeItem(), getItemsCount(), getItem() git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1437 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/gui/widget/menue.cpp | 32 ++++++++++++++++++++++++++++++++ src/gui/widget/menue.h | 5 +++++ 2 files changed, 37 insertions(+) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 1b2912b08..121e07918 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -377,11 +377,43 @@ void CMenuWidget::resetWidget() selected=-1; } +void CMenuWidget::insertItem(const uint& item_id, CMenuItem* menuItem) +{ + items.insert(items.begin()+item_id, menuItem); +} + +void CMenuWidget::removeItem(const uint& item_id) +{ + items.erase(items.begin()+item_id); +} + bool CMenuWidget::hasItem() { return !items.empty(); } +int CMenuWidget::getItemId(CMenuItem* menuItem) +{ + for (uint i= 0; i< items.size(); i++) + { + if (items[i] == menuItem) + return i; + } + + return -1; +} + +CMenuItem* CMenuWidget::getItem(const uint& item_id) +{ + for (uint i= 0; i< items.size(); i++) + { + if (i == item_id) + return items[i]; + } + + return NULL; +} + std::string CMenuWidget::getName() { if (name != NONEXISTANT_LOCALE) diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 236906de6..fd0fb2bc1 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -420,6 +420,11 @@ class CMenuWidget : public CMenuTarget virtual void addIntroItems(neutrino_locale_t subhead_text = NONEXISTANT_LOCALE, neutrino_locale_t section_text = NONEXISTANT_LOCALE, int buttontype = BTN_TYPE_BACK ); bool hasItem(); void resetWidget(); + void insertItem(const uint& item_id, CMenuItem* menuItem); + void removeItem(const uint& item_id); + int getItemId(CMenuItem* menuItem); + int getItemsCount(){return items.size();}; + CMenuItem* getItem(const uint& item_id); virtual void paint(); virtual void hide(); virtual int exec(CMenuTarget* parent, const std::string & actionKey);