diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index e7bfa8728..f3fd74796 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1158,6 +1158,7 @@ CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name, localized_value_name = special_value_name; optionString = non_localized_name; + numberFormat = "%d"; observ = Observ; slider_on = sliderOn; } @@ -1190,7 +1191,7 @@ int CMenuOptionNumberChooser::paint(bool selected) if ((localized_value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized_value)) { - sprintf(option_value, "%d", ((*optionValue) + display_offset)); + sprintf(option_value, numberFormat.c_str(), ((*optionValue) + display_offset)); l_option = option_value; } else @@ -1242,6 +1243,12 @@ int CMenuOptionNumberChooser::getWidth(void) width += (w1 > w2) ? w1 : w2; + if (numberFormat != "%d") { + char format[numberFormat.length()]; + snprintf(format, numberFormat.length(), numberFormat.c_str(), 0); + width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(format, true) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0", true); + } + return width + 10; /* min 10 pixels between option name and value. enough? */ } diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 6ee0da92f..21e5e7297 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -298,6 +298,7 @@ private: neutrino_locale_t localized_value_name; bool slider_on; CChangeObserver * observ; + std::string numberFormat; public: CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, const char * non_localized_name = NULL, bool sliderOn = false ); @@ -307,6 +308,7 @@ private: int exec(CMenuTarget* parent); int isMenueOptionChooser(void) const{return 1;} int getWidth(void); + void setNumberFormat(std::string format) { numberFormat = format; } }; class CMenuOptionChooser : public CAbstractMenuOptionChooser