summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/speechbubble.cpp7
-rw-r--r--src/gui/speechbubble.h2
-rw-r--r--src/gui/textbox.cpp31
3 files changed, 32 insertions, 8 deletions
diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp
index c5c653e7..0ccbebc0 100644
--- a/src/gui/speechbubble.cpp
+++ b/src/gui/speechbubble.cpp
@@ -59,8 +59,13 @@ SpeechBubble::SpeechBubble()//:
mSpeechBox->setTextWrapped( "" );
}
-void SpeechBubble::setText(const std::string mText)
+void SpeechBubble::setText(std::string mText)
{
+ while (mText[0] == ' ')
+ {
+ mText = mText.substr(1, mText.size());
+ }
+
mSpeechBox->setMinWidth(140);
mSpeechBox->setTextWrapped( mText );
diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h
index c4ca9109..7a2a73b8 100644
--- a/src/gui/speechbubble.h
+++ b/src/gui/speechbubble.h
@@ -35,7 +35,7 @@ class SpeechBubble : public Window
SpeechBubble();
- void setText(const std::string mText);
+ void setText(std::string mText);
void setLocation(int x, int y);
unsigned int getNumRows();
diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp
index 1a689ad5..f2d9b6ee 100644
--- a/src/gui/textbox.cpp
+++ b/src/gui/textbox.cpp
@@ -92,13 +92,31 @@ void TextBox::setTextWrapped(const std::string &text)
if (xpos > minWidth)
{
minWidth = xpos;
- if (minWidth > mMinWidth)
- {
- mMinWidth = minWidth;
- }
+ }
+ // The window wasn't big enough. Resize it and try again.
+ if (minWidth > mMinWidth)
+ {
+ mMinWidth = minWidth;
+ // This is a reaaaly ugly hack for getting the string stream
+ // to clear itself. Don't mess with the spacer in the stream
+ // reset, as well as removing the break. These are all there
+ // because there are several compilers that I have tried
+ // that do not properly reset the string stream.
+ // You have been warned!
+ wrappedStream.str(" ");
+ spacePos = 0;
+ lastNewlinePos = 0;
+ newlinePos = text.find("\n", lastNewlinePos);
+ line = text.substr(lastNewlinePos, newlinePos -
+ lastNewlinePos);
+ width = 0;
+ break;
+ }
+ else
+ {
+ wrappedStream << "\n" << word;
}
xpos = width;
- wrappedStream << "\n" << word;
}
lastSpacePos = spacePos + 1;
}
@@ -116,9 +134,10 @@ void TextBox::setTextWrapped(const std::string &text)
{
minWidth = xpos;
}
+ mMinWidth = minWidth;
if (minWidth > mMinWidth)
{
- mMinWidth = minWidth;
+ setTextWrapped(text);
}
gcn::TextBox::setText(wrappedStream.str());