aboutsummaryrefslogtreecommitdiff
path: root/gui/newgui.cpp
diff options
context:
space:
mode:
authorMax Horn2002-11-05 13:33:34 +0000
committerMax Horn2002-11-05 13:33:34 +0000
commitd0d709627c3ce57b6137be2026d95a01125f97b9 (patch)
tree7f7f5ef7dacfdbc065b0ee90911b18cf7bcf3f41 /gui/newgui.cpp
parentb165ec698e10696bc7dd13253b4a3a1b1a3aebd0 (diff)
downloadscummvm-rg350-d0d709627c3ce57b6137be2026d95a01125f97b9.tar.gz
scummvm-rg350-d0d709627c3ce57b6137be2026d95a01125f97b9.tar.bz2
scummvm-rg350-d0d709627c3ce57b6137be2026d95a01125f97b9.zip
clip text drawing
svn-id: r5416
Diffstat (limited to 'gui/newgui.cpp')
-rw-r--r--gui/newgui.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index ed9d20fb16..d4edecc5a7 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -432,6 +432,7 @@ int NewGui::getCharWidth(char c)
void NewGui::drawString(const String &str, int x, int y, int w, int16 color, int align)
{
+ const int leftX = x, rightX = x + w;
int width = getStringWidth(str);
if (align == kTextAlignCenter)
x = x + (w - width - 1)/2;
@@ -439,8 +440,12 @@ void NewGui::drawString(const String &str, int x, int y, int w, int16 color, int
x = x + w - width;
for (int i = 0; i < str.size(); ++i) {
- drawChar(str[i], x, y, color);
- x += getCharWidth(str[i]);
+ w = getCharWidth(str[i]);
+ if (x+w > rightX)
+ break;
+ if (x >= leftX)
+ drawChar(str[i], x, y, color);
+ x += w;
}
}