From ab42250af3c2ec3d7795d45ce34b2f02d0b202b5 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Thu, 8 Dec 2011 16:45:41 +0000 Subject: [PATCH] paintButtons: add max txt length option git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1960 e54a6e83-5905-42d5-8d5c-058d10e6a962 Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/2b72b7c57eb30099b7613e655e9526ce0ebac8fc Author: Jacek Jendrzej Date: 2011-12-08 (Thu, 08 Dec 2011) --- src/gui/bedit/bouqueteditor_bouquets.cpp | 5 ++++- src/gui/widget/buttons.cpp | 16 ++++++++++++++-- src/gui/widget/buttons.h | 5 ++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 14b32519f..f14466807 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -160,6 +160,9 @@ void CBEBouquetWidget::paintFoot() Button[2] = CBEBouquetWidgetButtons[2]; Button[3].button = NEUTRINO_ICON_BUTTON_BLUE; + const neutrino_locale_t button_ids[] = {LOCALE_BOUQUETEDITOR_RENAME,LOCALE_BOUQUETEDITOR_HIDE,LOCALE_BOUQUETEDITOR_LOCK}; + const std::vector buttonID_rest (button_ids, button_ids + sizeof(button_ids) / sizeof(neutrino_locale_t) ); + fh = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight(); frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icol_w, &icol_h); @@ -182,7 +185,7 @@ void CBEBouquetWidget::paintFoot() Button[3].locale = LOCALE_BOUQUETEDITOR_LOCK; break; } - ::paintButtons(x, y+height, width, 4, Button, ButtonHeight); + ::paintButtons(x, y+height, width, 4, Button, ButtonHeight,0,false,COL_INFOBAR_SHADOW,NULL,0,true, buttonID_rest); frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_MENU, x + width - 10 - icol_w, y + height, ButtonHeight); } diff --git a/src/gui/widget/buttons.cpp b/src/gui/widget/buttons.cpp index 7aac19fed..b04e3cef6 100644 --- a/src/gui/widget/buttons.cpp +++ b/src/gui/widget/buttons.cpp @@ -70,7 +70,8 @@ int paintButtons( const int &x, const unsigned char fcolor, const char * alt_buttontext, const uint &buttontext_id, - bool show) + bool show, + const std::vector& all_buttontext_id) { CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); Font * font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]; @@ -114,7 +115,18 @@ int paintButtons( const int &x, int fwidth = font->getRenderWidth(buttontext, true); w_max_text = std::max(w_max_text, fwidth); } - + if(!all_buttontext_id.empty()) + { + for(vector::const_iterator it = all_buttontext_id.begin(); it != all_buttontext_id.end(); ++it) + { + //text + const char * buttontext = *it ? g_Locale->getText( *it ) : ""; + + //text width + int fwidth = font->getRenderWidth(buttontext, true); + w_max_text = std::max(w_max_text, fwidth); + } + } //calculate button width w_button = buttonwidth == 0 ? (w_max_icon + w_space + w_max_text) : buttonwidth; diff --git a/src/gui/widget/buttons.h b/src/gui/widget/buttons.h index 0a2d9dfd7..90adfb51b 100644 --- a/src/gui/widget/buttons.h +++ b/src/gui/widget/buttons.h @@ -27,6 +27,8 @@ #include #include +#include + typedef struct button_label { const char * button; @@ -44,6 +46,7 @@ int paintButtons( const int &x, const unsigned char fcolor = COL_INFOBAR_SHADOW, const char * alt_buttontext = NULL, const uint &buttontext_id = 0, - bool show = true); + bool show = true, + const std::vector& all_buttontext_id = std::vector()); #endif /* __gui_widget_buttons_h__ */