diff options
author | Ira Rice <irarice@gmail.com> | 2008-09-25 00:15:44 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-09-25 00:15:44 +0000 |
commit | 489a429bea6739dfa25503b9329bd9e33bffb856 (patch) | |
tree | 8112f6fd988fdc0610329b6bc14ee3f9d5801092 /src/gui/textbox.cpp | |
parent | 2dc8eadff1e67bb70b1772ecc19c9e1e2e40a5b4 (diff) | |
download | mana-client-489a429bea6739dfa25503b9329bd9e33bffb856.tar.gz mana-client-489a429bea6739dfa25503b9329bd9e33bffb856.tar.bz2 mana-client-489a429bea6739dfa25503b9329bd9e33bffb856.tar.xz mana-client-489a429bea6739dfa25503b9329bd9e33bffb856.zip |
Merged the Tametomo branch into trunk.
Diffstat (limited to 'src/gui/textbox.cpp')
-rw-r--r-- | src/gui/textbox.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index 743d88b6..4976549f 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -60,6 +60,8 @@ void TextBox::setTextWrapped(const std::string &text) text.substr(lastNewlinePos, newlinePos - lastNewlinePos); std::string::size_type spacePos, lastSpacePos = 0; int xpos = 0; + mMinWidth = getWidth(); + bool longWord = false; do { @@ -75,22 +77,28 @@ void TextBox::setTextWrapped(const std::string &text) int width = getFont()->getWidth(word); - if (xpos != 0 && xpos + width < getWidth()) + if (xpos != 0 && xpos + width + getFont()->getWidth(" ") < getWidth()) { xpos += width + getFont()->getWidth(" "); wrappedStream << " " << word; } else if (lastSpacePos == 0) { + if (xpos > mMinWidth) + { + longWord = true; + mMinWidth = xpos; + } xpos += width; wrappedStream << word; } else { + if ((xpos < mMinWidth) && !longWord && spacePos != line.size()) + mMinWidth = xpos; xpos = width; wrappedStream << "\n" << word; } - lastSpacePos = spacePos + 1; } while (spacePos != line.size()); |