From c24b23093f6bd109f736c136c4bb2d47ec100061 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 6 May 2011 18:16:00 +0000 Subject: [PATCH] neutrino menue classes: member getName(), setString() optimized git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1436 e54a6e83-5905-42d5-8d5c-058d10e6a962 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/df0d94a03495c7378dcf5e80f166cd39669b81e1 Author: Thilo Graf Date: 2011-05-06 (Fri, 06 May 2011) Origin message was: ------------------ *neutrino menue classes: member getName(), setString() optimized git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1436 e54a6e83-5905-42d5-8d5c-058d10e6a962 ------------------ This commit was generated by Migit --- src/gui/widget/menue.cpp | 34 ++++++++++++++++++++++------------ src/gui/widget/menue.h | 4 ++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index db4a984d8..1b2912b08 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -288,7 +288,7 @@ CMenuWidget::CMenuWidget() CMenuWidget::CMenuWidget(const neutrino_locale_t Name, const std::string & Icon, const int mwidth, const int mheight) { name = Name; - nameString = g_Locale->getText(NONEXISTANT_LOCALE); + nameString = g_Locale->getText(Name); Init(Icon, mwidth, mheight); } @@ -382,6 +382,13 @@ bool CMenuWidget::hasItem() return !items.empty(); } +std::string CMenuWidget::getName() +{ + if (name != NONEXISTANT_LOCALE) + nameString = g_Locale->getText(name); + return nameString; +} + int CMenuWidget::exec(CMenuTarget* parent, const std::string &) { neutrino_msg_t msg; @@ -703,13 +710,10 @@ void CMenuWidget::hide() void CMenuWidget::paint() { - const char * l_name; - if(name == NONEXISTANT_LOCALE) - l_name = nameString.c_str(); - else - l_name = g_Locale->getText(name); - - CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8 /*, l_name*/); //FIXME menu name + if (name != NONEXISTANT_LOCALE) + nameString = g_Locale->getText(name); + + CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, nameString.c_str()); height = wanted_height; width = min_width; @@ -723,7 +727,7 @@ void CMenuWidget::paint() if(height > ((int)frameBuffer->getScreenHeight() - 10)) height = frameBuffer->getScreenHeight() - 10; - int neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(l_name, true); // UTF-8 + int neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(nameString.c_str(), true); // UTF-8 if (neededWidth > width-48) { width= neededWidth+ 49; } @@ -814,7 +818,7 @@ void CMenuWidget::paint() frameBuffer->getIconSize(iconfile.c_str(), &w, &h); HeadiconOffset = w+6; } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+(fw/3)+HeadiconOffset,y+hheight+1, width-((fw/3)+HeadiconOffset), l_name, COL_MENUHEAD, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+(fw/3)+HeadiconOffset,y+hheight+1, width-((fw/3)+HeadiconOffset), nameString.c_str(), COL_MENUHEAD, 0, true); // UTF-8 frameBuffer->paintIcon(iconfile, x + fw/4, y, hheight); item_start_y = y+hheight; @@ -1533,12 +1537,18 @@ CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text) int CMenuSeparator::getHeight(void) const { - return (text == NONEXISTANT_LOCALE) ? 10 : g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + if (separator_text.empty() && text == NONEXISTANT_LOCALE) + return 10; + else + return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); } const char * CMenuSeparator::getString(void) { - return g_Locale->getText(text); + if (!separator_text.empty()) + return separator_text.c_str(); + else + return g_Locale->getText(text); } void CMenuSeparator::setString(const std::string& s_text) diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 92feee916..236906de6 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -163,7 +163,7 @@ class CMenuSeparator : public CMenuItem int getWidth(void); virtual const char * getString(void); - virtual void setString(const std::string& text); + void setString(const std::string& text); }; class CMenuForwarder : public CMenuItem @@ -423,7 +423,7 @@ class CMenuWidget : public CMenuTarget virtual void paint(); virtual void hide(); virtual int exec(CMenuTarget* parent, const std::string & actionKey); - virtual std::string getName(){ return nameString;}; + virtual std::string getName(); virtual void setSelected(const int &Preselected){ preselected = Preselected; }; virtual int getSelected(){ return selected; }; void move(int xoff, int yoff);