summaryrefslogtreecommitdiff
path: root/src/gui/speechbubble.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/speechbubble.cpp')
-rw-r--r--src/gui/speechbubble.cpp47
1 files changed, 16 insertions, 31 deletions
diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp
index 84eeb7d4..c76558e4 100644
--- a/src/gui/speechbubble.cpp
+++ b/src/gui/speechbubble.cpp
@@ -24,19 +24,15 @@
#include <guichan/widgets/label.hpp>
#include "gui.h"
+#include "scrollarea.h"
#include "speechbubble.h"
-
-#include "../resources/image.h"
-#include "../resources/resourcemanager.h"
+#include "textbox.h"
#include "../utils/gettext.h"
-// TODO: Fix windows so that they can each load their own skins without the
-// other windows overriding another window's skin.
SpeechBubble::SpeechBubble():
Window(_("Speech"), false, NULL, "graphics/gui/speechbubble.xml")
{
- // Height == Top Graphic (14px) + 1 Row of Text (15px) + Bottom Graphic (17px)
setContentSize(140, 46);
setShowTitle(false);
setTitleBarHeight(0);
@@ -61,11 +57,13 @@ SpeechBubble::SpeechBubble():
add(mSpeechArea);
setLocationRelativeTo(getParent());
+}
- // LEEOR / TODO: This causes an exception error.
- //moveToBottom(getParent());
-
- mSpeechBox->setTextWrapped( "" );
+SpeechBubble::~SpeechBubble()
+{
+ delete mCaption;
+ delete mSpeechBox;
+ delete mSpeechArea;
}
void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color)
@@ -77,31 +75,18 @@ void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color)
void SpeechBubble::setText(std::string mText)
{
- mSpeechBox->setMinWidth(140);
- mSpeechBox->setTextWrapped(mText);
+ int width = mCaption->getWidth() + 3;
+ mSpeechBox->setTextWrapped(mText, 130 > width ? 130 : width);
const int fontHeight = getFont()->getHeight();
const int numRows = mSpeechBox->getNumberOfRows() + 1;
- if (numRows > 2)
- {
- // 15 == height of each line of text (based on font heights)
- // 14 == speechbubble Top + Bottom graphic pixel heights
- setContentSize(mSpeechBox->getMinWidth() + fontHeight,
- (numRows * fontHeight) + 6);
- mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3,
- mSpeechBox->getMinWidth() + 5,
- (numRows * fontHeight)));
- }
- else
- {
- int width = mCaption->getWidth() + 3;
- if (width < getFont()->getWidth(mText))
- width = getFont()->getWidth(mText);
- setContentSize(width + fontHeight, (fontHeight * 2) + 6);
- mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3,
- width, fontHeight));
- }
+ if (width < mSpeechBox->getMinWidth())
+ width = mSpeechBox->getMinWidth();
+
+ setContentSize(width + fontHeight, (numRows * fontHeight) + 6);
+ mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, width + 5,
+ (numRows * fontHeight)));
}
unsigned int SpeechBubble::getNumRows()