summaryrefslogtreecommitdiff
path: root/src/gui/textbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/textbox.cpp')
-rw-r--r--src/gui/textbox.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp
index 2a86d549..a4024de3 100644
--- a/src/gui/textbox.cpp
+++ b/src/gui/textbox.cpp
@@ -37,52 +37,46 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension)
{
// Make sure parent scroll area sets width of this widget
if (getParent())
- {
getParent()->logic();
- }
// Take the supplied minimum dimension as a starting point and try to beat it
mMinWidth = minDimension;
std::stringstream wrappedStream;
- std::string::size_type newlinePos, lastNewlinePos = 0;
+ std::string::size_type spacePos, newlinePos, lastNewlinePos = 0;
int minWidth = 0;
int xpos;
+ spacePos = text.rfind(" ", text.size());
+
+ if (spacePos != std::string::npos)
+ {
+ const std::string word = text.substr(spacePos + 1);
+ const int length = getFont()->getWidth(word);
+
+ if (length > mMinWidth)
+ mMinWidth = length;
+ }
+
do
{
// Determine next piece of string to wrap
newlinePos = text.find("\n", lastNewlinePos);
if (newlinePos == std::string::npos)
- {
newlinePos = text.size();
- }
std::string line =
text.substr(lastNewlinePos, newlinePos - lastNewlinePos);
- std::string::size_type spacePos, lastSpacePos = 0;
+ std::string::size_type lastSpacePos = 0;
xpos = 0;
- spacePos = text.rfind(" ", text.size());
-
- if (spacePos != std::string::npos)
- {
- const std::string word = text.substr(spacePos + 1);
- const int length = getFont()->getWidth(word);
-
- if (length > mMinWidth)
- mMinWidth = length;
- }
-
do
{
spacePos = line.find(" ", lastSpacePos);
if (spacePos == std::string::npos)
- {
spacePos = line.size();
- }
std::string word =
line.substr(lastSpacePos, spacePos - lastSpacePos);