diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-09 23:41:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-09 23:41:59 +0300 |
commit | a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5 (patch) | |
tree | 20a5024ce03d3b0abedd76378c534f4150af0ee9 /src/gui/widgets/textbox.cpp | |
parent | d0ccffd7db79f5dbff6f2cb4f8b77a8bb3435e57 (diff) | |
download | plus-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.tar.gz plus-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.tar.bz2 plus-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.tar.xz plus-a9d1aaa774b9e986b8ee3c6cb1e7baa1d9ba3ea5.zip |
improve size() methods usage.
Diffstat (limited to 'src/gui/widgets/textbox.cpp')
-rw-r--r-- | src/gui/widgets/textbox.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 4eccbe76c..660655033 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -89,13 +89,14 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) xpos = 0; gcn::Font *const font = getFont(); const int spaceWidth = font->getWidth(" "); + size_t sz = line.size(); do { spacePos = line.find(" ", lastSpacePos); if (spacePos == std::string::npos) - spacePos = line.size(); + spacePos = sz; const std::string word = line.substr(lastSpacePos, spacePos - lastSpacePos); @@ -130,14 +131,13 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) mMinWidth = minWidth; wrappedStream.clear(); wrappedStream.str(""); -// spacePos = 0; lastNewlinePos = 0; newlinePos = text.find("\n", lastNewlinePos); if (newlinePos == std::string::npos) newlinePos = textSize; line = text.substr(lastNewlinePos, newlinePos - lastNewlinePos); -// width = 0; + sz = line.size(); break; } else @@ -148,14 +148,14 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) } lastSpacePos = spacePos + 1; } - while (spacePos != line.size()); + while (spacePos != sz); if (text.find("\n", lastNewlinePos) != std::string::npos) wrappedStream << "\n"; lastNewlinePos = newlinePos + 1; } - while (newlinePos != text.size()); + while (newlinePos != textSize); if (xpos > minWidth) minWidth = xpos; |