remove widest_number definition and usage, add Font::getMaxDigitWidth() method instead

Signed-off-by: M. Liebmann <tuxcode.bbg@gmail.com>
This commit is contained in:
martii
2013-11-29 21:06:36 +01:00
committed by M. Liebmann
parent c88ad39c67
commit 15b2b2ec05
10 changed files with 47 additions and 25 deletions

View File

@@ -1213,15 +1213,29 @@ int CMenuOptionNumberChooser::getWidth(void)
const char * l_optionName = (optionString != NULL) ? optionString : g_Locale->getText(optionName);
int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_optionName, true);
char tmp[20], *t;
int _lower_bound = lower_bound;
int _upper_bound = upper_bound;
int m = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getMaxDigitWidth();
snprintf(tmp, sizeof(tmp), "%d", lower_bound);
for(t = tmp; *t; t++) if (isdigit((int)*t)) *t = *widest_number;
int w1 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true);
int w1 = 0;
if (_lower_bound < 0) {
w1 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-", true);
lower_bound *= -1;
}
while (_lower_bound > 0) {
w1 += m;
_lower_bound /= 10;
}
snprintf(tmp, sizeof(tmp), "%d", upper_bound);
for(t = tmp; *t; t++) if (isdigit((int)*t)) *t = *widest_number;
int w2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(tmp, true);
int w2 = 0;
if (_upper_bound < 0) {
w2 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-", true);
_upper_bound *= -1;
}
while (_upper_bound > 0) {
w1 += m;
_upper_bound /= 10;
}
width += (w1 > w2) ? w1 : w2;