diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index 56e0274b6..b071d5d40 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -340,13 +340,14 @@ bool FBSurface::isWhiteSpace(const char s) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::drawString(const GUI::Font& font, const string& s, +int FBSurface::drawString(const GUI::Font& font, const string& s, int x, int y, int w, int h, ColorId color, TextAlign align, int deltax, bool useEllipsis, ColorId shadowColor) { #ifdef GUI_SUPPORT string inStr = s; + int lines = 1; // draw multiline string while (font.getStringWidth(inStr) > w && h >= font.getFontHeight() * 2) @@ -371,8 +372,10 @@ void FBSurface::drawString(const GUI::Font& font, const string& s, h -= font.getFontHeight(); y += font.getFontHeight(); inStr = rightStr; + lines++; } drawString(font, inStr, x, y, w, color, align, deltax, useEllipsis, shadowColor); + return lines; #endif } diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index ce7e8eef7..8ee463068 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -218,7 +218,7 @@ class FBSurface @param useEllipsis Whether to use '...' when the string is too long */ - virtual void drawString( + virtual int drawString( const GUI::Font& font, const string& s, int x, int y, int w, int h, ColorId color, TextAlign align = TextAlign::Left, int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone); @@ -235,6 +235,7 @@ class FBSurface @param align The alignment of the text in the string width area @param deltax FIXME @param useEllipsis Whether to use '...' when the string is too long + @return Number of lines drawn */ virtual void drawString( const GUI::Font& font, const string& s, int x, int y, int w, diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index 83dbc0a68..90698f234 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -200,7 +200,8 @@ void RomInfoWidget::drawWidget(bool hilite) int xpos = _x + 8, ypos = _y + yoff + 10; for(const auto& info: myRomInfo) { - s.drawString(_font, info, xpos, ypos, _w - 16, onTop ? _textcolor : _shadowcolor); - ypos += _font.getLineHeight(); + int lines = s.drawString(_font, info, xpos, ypos, _w - 16, _font.getFontHeight() * 3, + onTop ? _textcolor : _shadowcolor); + ypos += _font.getLineHeight() + (lines - 1) * _font.getFontHeight(); } }