change getRenderWidth() default to UTF8

Origin commit data
------------------
Commit: 8b91cda918
Author: vanhofen <vanhofen@gmx.de>
Date: 2014-06-11 (Wed, 11 Jun 2014)

Origin message was:
------------------
- change getRenderWidth() default to UTF8
This commit is contained in:
vanhofen
2014-06-11 11:48:59 +02:00
parent 81d1ff3ebc
commit 3bba3094e2
35 changed files with 127 additions and 128 deletions

View File

@@ -140,9 +140,9 @@ int paintButtons( const int &x,
buttontext[i] = g_Locale->getText(content[i].locale);
//text width
if (alt_buttontext != NULL && i == buttontext_id)
fwidth[i] = font->getRenderWidth(alt_buttontext, true); //...with an alternate buttontext
fwidth[i] = font->getRenderWidth(alt_buttontext); //...with an alternate buttontext
else
fwidth[i] = font->getRenderWidth(buttontext[i], true);
fwidth[i] = font->getRenderWidth(buttontext[i]);
w_text += fwidth[i];
count_labels++;
} else {

View File

@@ -79,7 +79,7 @@ CColorChooser::CColorChooser(const neutrino_locale_t Name, unsigned char *R, uns
//calculate max width of LOCALS
offset = 0;
for (int i = 0; i < 4; i++) {
int tmpoffset = g_Font[font_info]->getRenderWidth(g_Locale->getText (colorchooser_names[i]));
int tmpoffset = g_Font[font_info]->getRenderWidth(g_Locale->getText(colorchooser_names[i]));
if (tmpoffset > offset) {
offset = tmpoffset;
}

View File

@@ -80,7 +80,7 @@ DText::DText(const char *text)
void DText::init()
{
m_width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(m_text, true); // UTF-8
m_width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(m_text);
m_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
}

View File

@@ -106,15 +106,14 @@ void CHintBox::init(const char * const Caption, const char * const Text, const i
else
iconfile = "";
//nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(caption), true); // UTF-8
nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(caption, true); // UTF-8
nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(caption);
if (nw > width)
width = nw;
for (std::vector<char *>::const_iterator it = line.begin(); it != line.end(); ++it)
{
int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(*it, true); // UTF-8
int w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(*it);
maxLineWidth = std::max(maxLineWidth, w);
nw = additional_width + w;
if (nw > width)

View File

@@ -224,7 +224,7 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const std::string &Capti
m_iconfile = "";
const char *l_caption = (m_caption == NONEXISTANT_LOCALE) ? m_captionString.c_str() : g_Locale->getText(m_caption);
nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(l_caption, true); // UTF-8
nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(l_caption);
if (nw > m_width)
m_width = nw;

View File

@@ -157,11 +157,11 @@ void CKeyChooserItem::paint()
CFrameBuffer * frameBuffer = CFrameBuffer::getInstance();
int tmp;
width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name), true);
tmp = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(LOCALE_KEYCHOOSER_TEXT1), true);
width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name));
tmp = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(LOCALE_KEYCHOOSER_TEXT1));
if (tmp > width)
width = tmp;
tmp = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(LOCALE_KEYCHOOSER_TEXT2), true);
tmp = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(LOCALE_KEYCHOOSER_TEXT2));
if (tmp > width)
width = tmp;
width += 20;

View File

@@ -166,8 +166,8 @@ void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height,
//right text
if (right_text && (*right_text || right_bgcol))
{
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text, true);
int stringstartposOption = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text, true) + icon_frame_w, x + dx - stringwidth - icon_frame_w); //+ offx
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text);
int stringstartposOption = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text) + icon_frame_w, x + dx - stringwidth - icon_frame_w); //+ offx
if (right_bgcol) {
if (!*right_text)
stringstartposOption -= 60;
@@ -210,9 +210,9 @@ void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height,
return;
int stringwidth = 0;
if (right_text != NULL) {
stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("U999", true) ;
stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("U999") ;
}
int stringwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text, true);
int stringwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text);
int maxspace = dx - stringwidth - icon_frame_w - stringwidth2 - 10;
if(maxspace < slider_lenght){
@@ -863,7 +863,7 @@ void CMenuWidget::calcSize()
if(height > ((int)frameBuffer->getScreenHeight() - 10))
height = frameBuffer->getScreenHeight() - 10;
int neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(nameString.c_str(), true); // UTF-8
int neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(nameString);
if (neededWidth > width-48) {
width= neededWidth+ 49;
}
@@ -1345,14 +1345,14 @@ int CMenuOptionNumberChooser::paint(bool selected)
int CMenuOptionNumberChooser::getWidth(void)
{
int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName(), true);
int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName());
int _lower_bound = lower_bound;
int _upper_bound = upper_bound;
int m = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getMaxDigitWidth();
int w1 = 0;
if (_lower_bound < 0)
w1 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-", true);
w1 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-");
while (_lower_bound) {
w1 += m;
_lower_bound /= 10;
@@ -1360,7 +1360,7 @@ int CMenuOptionNumberChooser::getWidth(void)
int w2 = 0;
if (_upper_bound < 0)
w2 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-", true);
w2 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-");
while (_upper_bound) {
w1 += m;
_upper_bound /= 10;
@@ -1370,11 +1370,11 @@ int CMenuOptionNumberChooser::getWidth(void)
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
width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(s) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0"); // 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);
width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(format) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0");
}
return width + 10; /* min 10 pixels between option name and value. enough? */
@@ -1710,17 +1710,17 @@ int CMenuOptionChooser::paint( bool selected)
int CMenuOptionChooser::getWidth(void)
{
int ow = 0;
int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName(), true);
int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName());
int width = tw;
for(unsigned int count = 0; count < options.size(); count++) {
ow = 0;
if (options[count].valname)
ow = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]
->getRenderWidth(options[count].valname, true);
->getRenderWidth(options[count].valname);
else
ow = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]
->getRenderWidth(g_Locale->getText(options[count].value), true);
->getRenderWidth(g_Locale->getText(options[count].value));
if (tw + ow > width)
width = tw + ow;
@@ -1979,7 +1979,7 @@ int CMenuForwarder::getHeight(void) const
int CMenuForwarder::getWidth(void)
{
const char *_name = (name == NONEXISTANT_LOCALE) ? nameString.c_str() : g_Locale->getText(name);
int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(_name, true);
int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(_name);
fb_pixel_t bgcol = 0;
std::string option_name = getOption();
@@ -1987,7 +1987,7 @@ int CMenuForwarder::getWidth(void)
bgcol = jumpTarget->getColor();
if (!option_name.empty())
tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_name.c_str(), true);
tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_name);
else if (bgcol)
tw += 10 + 60;
@@ -2087,7 +2087,7 @@ int CMenuSeparator::getWidth(void)
w = 30; /* 15 pixel left and right */
const char *l_name = getName();
if ((type & STRING) && *l_name)
w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name, true);
w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name);
return w;
}
@@ -2119,7 +2119,7 @@ int CMenuSeparator::paint(bool selected)
if (*l_name)
{
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name, true); // UTF-8
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name);
/* if no alignment is specified, align centered */
if (type & ALIGN_LEFT)

View File

@@ -131,7 +131,7 @@ int CMessageBox::getButtonWidth()
neutrino_locale_t localeMsg[localeMsgCount] = {LOCALE_MESSAGEBOX_YES, LOCALE_MESSAGEBOX_NO, LOCALE_MESSAGEBOX_CANCEL, LOCALE_MESSAGEBOX_OK, LOCALE_MESSAGEBOX_BACK};
int MaxButtonTextWidth = 0;
for (int i = 0; i < localeMsgCount; i++)
MaxButtonTextWidth = std::max(g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(g_Locale->getText(localeMsg[i]), true), MaxButtonTextWidth);
MaxButtonTextWidth = std::max(g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getRenderWidth(g_Locale->getText(localeMsg[i])), MaxButtonTextWidth);
return MaxButtonTextWidth + i_maxw + 36 + (RADIUS_LARGE / 2);
}

View File

@@ -341,7 +341,7 @@ void CMsgBox::refreshFoot(void)
//const char* text;
int MaxButtonTextWidth = m_pcFontFoot->getRenderWidth(g_Locale->getText(LOCALE_MESSAGEBOX_CANCEL), true); // UTF-8
int MaxButtonTextWidth = m_pcFontFoot->getRenderWidth(g_Locale->getText(LOCALE_MESSAGEBOX_CANCEL));
int ButtonWidth = 20 + 33 + MaxButtonTextWidth;
int ButtonSpacing = (m_cBoxFrameFootRel.iWidth - 20- (ButtonWidth*3) ) / 2;
int xpos = m_cBoxFrameFootRel.iX;

View File

@@ -179,7 +179,7 @@ CShellWindow::~CShellWindow()
int iw, ih;
frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_OKAY, &iw, &ih);
Font *font = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL];
int b_width = font->getRenderWidth(g_Locale->getText(LOCALE_MESSAGEBOX_OK), true) + 36 + ih + (RADIUS_LARGE / 2);
int b_width = font->getRenderWidth(g_Locale->getText(LOCALE_MESSAGEBOX_OK)) + 36 + ih + (RADIUS_LARGE / 2);
int fh = font->getHeight();
int b_height = std::max(fh, ih) + 8 + (RADIUS_LARGE / 2);
int xpos = frameBuffer->getScreenWidth() - b_width;

View File

@@ -114,7 +114,7 @@ void CStringInput::init()
width = std::max(size*input_w + 2*offset, (int) frameBuffer->getScreenWidth() / 100 * 45);
int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head.c_str(), true); // UTF-8
int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head);
if (!(iconfile.empty()))
{
@@ -130,13 +130,13 @@ void CStringInput::init()
{
if (hint_1 != NONEXISTANT_LOCALE)
{
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_1), true);
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_1));
width = std::max(width, tmp_w + 2*offset);
bheight += iheight;
}
if (hint_2 != NONEXISTANT_LOCALE)
{
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_2), true);
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_2));
width = std::max(width, tmp_w + 2*offset);
bheight += iheight;
}

View File

@@ -66,7 +66,7 @@ void CExtendedInput::Init(void)
width = frameBuffer->getScreenWidth() / 100 * 45;
int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name), true); // UTF-8
int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name));
width = std::max(width, tmp_w + offset);
bheight = input_h + 2*offset;
@@ -74,13 +74,13 @@ void CExtendedInput::Init(void)
{
if (hint_1 != NONEXISTANT_LOCALE)
{
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_1), true);
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_1));
width = std::max(width, tmp_w + 2*offset);
bheight += iheight;
}
if (hint_2 != NONEXISTANT_LOCALE)
{
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_2), true);
tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_INFO]->getRenderWidth(g_Locale->getText(hint_2));
width = std::max(width, tmp_w + 2*offset);
bheight += iheight;
}

View File

@@ -395,7 +395,7 @@ void CTextBox::refreshTextLineArray(void)
aktWord = m_cText.substr(pos_prev, pos - pos_prev + 1);
//calculate length of current found word
aktWordWidth = m_pcFontText->getRenderWidth(aktWord, true);
aktWordWidth = m_pcFontText->getRenderWidth(aktWord);
//set next start pos
pos_prev = pos + 1;
@@ -628,10 +628,10 @@ void CTextBox::refreshText(void)
{
//calculate centered xpos
if( m_nMode & CENTER ){
x_center = ((m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i], true))>>1) - text_Hborder_width;
x_center = ((m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i]))>>1) - text_Hborder_width;
}
else if ( m_nMode & RIGHT ){
x_center = ((m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i], true)) - text_Hborder_width*2);
x_center = ((m_cFrameTextRel.iWidth - m_pcFontText->getRenderWidth(m_cLineArray[i])) - text_Hborder_width*2);
if ( m_nMode & SCROLL )
x_center -= SCROLL_FRAME_WIDTH;
}