aboutsummaryrefslogtreecommitdiff
path: root/gui/newgui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/newgui.cpp')
-rw-r--r--gui/newgui.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index 7adfa1aaea..dbdf9d170d 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -401,11 +401,12 @@ void NewGui::drawChar(const char chr, int xx, int yy, int16 color)
}
}
-int NewGui::getStringWidth(const char *str)
+int NewGui::getStringWidth(const String &str)
{
int space = 0;
- while (*str)
- space += getCharWidth(*str++);
+
+ for (int i = 0; i < str.size(); ++i)
+ space += getCharWidth(str[i]);
return space;
}
@@ -414,17 +415,17 @@ int NewGui::getCharWidth(char c)
return guifont[c+6];
}
-void NewGui::drawString(const char *str, int x, int y, int w, int16 color, int align)
+void NewGui::drawString(const String &str, int x, int y, int w, int16 color, int align)
{
int width = getStringWidth(str);
if (align == kTextAlignCenter)
x = x + (w - width - 1)/2;
else if (align == kTextAlignRight)
x = x + w - width;
- while (*str) {
- drawChar(*str, x, y, color);
- x += getCharWidth(*str);
- str++;
+
+ for (int i = 0; i < str.size(); ++i) {
+ drawChar(str[i], x, y, color);
+ x += getCharWidth(str[i]);
}
}