gui/scan_setup: show unit for motor speed

This commit is contained in:
martii
2013-12-21 22:34:32 +01:00
committed by Jacek Jendrzej
parent 9ead2b459b
commit a0f2960501
5 changed files with 23 additions and 6 deletions

View File

@@ -1159,6 +1159,7 @@ CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name,
optionString = non_localized_name;
numberFormat = "%d";
numberFormatFunction = NULL;
observ = Observ;
slider_on = sliderOn;
}
@@ -1187,11 +1188,15 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*)
int CMenuOptionNumberChooser::paint(bool selected)
{
const char * l_option;
char option_value[11];
char option_value[40];
if ((localized_value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized_value))
{
sprintf(option_value, numberFormat.c_str(), ((*optionValue) + display_offset));
if (numberFormatFunction) {
std::string s = numberFormatFunction(*optionValue + display_offset);
strncpy(option_value, s.c_str(), s.length());
} else
sprintf(option_value, numberFormat.c_str(), *optionValue + display_offset);
l_option = option_value;
}
else
@@ -1243,7 +1248,10 @@ int CMenuOptionNumberChooser::getWidth(void)
width += (w1 > w2) ? w1 : w2;
if (numberFormat != "%d") {
if (numberFormatFunction) {
std::string s = numberFormatFunction(0);
width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(s.c_str(), true) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0", true); // arbitrary
} else 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);