summaryrefslogtreecommitdiff
path: root/src/gui/speechbubble.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-25 22:50:59 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-25 22:50:59 +0100
commitcc79f0fe21e1a2ef73cbe987d54e848b9a47142d (patch)
treeedd316eb6094f0c02d6d014385865dcd88a2bc56 /src/gui/speechbubble.cpp
parentb0df784f1be44a657ca8092069488602270629b7 (diff)
parent99e8a3fd77b63a029fe02dcf771b6af1aad252ed (diff)
downloadmana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.gz
mana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.bz2
mana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.xz
mana-client-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.zip
Merge branch 'eathena/master'
Conflicts: A lot of files.
Diffstat (limited to 'src/gui/speechbubble.cpp')
-rw-r--r--src/gui/speechbubble.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp
index 165d216f..73ada2e1 100644
--- a/src/gui/speechbubble.cpp
+++ b/src/gui/speechbubble.cpp
@@ -29,14 +29,17 @@
#include "speechbubble.h"
#include "textbox.h"
+#include "../graphics.h"
+
#include "../utils/gettext.h"
SpeechBubble::SpeechBubble():
- Window(_("Speech"), false, NULL, "graphics/gui/speechbubble.xml")
+ Popup("Speech", NULL, "graphics/gui/speechbubble.xml"),
+ mText("")
{
setContentSize(140, 46);
- setShowTitle(false);
- setTitleBarHeight(0);
+ setMinWidth(29);
+ setMinHeight(29);
mCaption = new gcn::Label("");
mCaption->setFont(boldFont);
@@ -45,6 +48,7 @@ SpeechBubble::SpeechBubble():
mSpeechBox = new TextBox;
mSpeechBox->setEditable(false);
mSpeechBox->setOpaque(false);
+ mSpeechBox->setTextColor(&guiPalette->getColor(Palette::CHAT));
mSpeechArea = new ScrollArea(mSpeechBox);
@@ -56,26 +60,29 @@ SpeechBubble::SpeechBubble():
add(mCaption);
add(mSpeechArea);
-
- setLocationRelativeTo(getParent());
}
-void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color)
+void SpeechBubble::setCaption(const std::string &name, const gcn::Color *color)
{
mCaption->setCaption(name);
mCaption->adjustSize();
- mCaption->setForegroundColor(color);
+ mCaption->setForegroundColor(*color);
}
-void SpeechBubble::setText(std::string mText, bool showName)
+void SpeechBubble::setText(std::string text, bool showName)
{
+ if ((text == mText) && (mCaption->getWidth() <= mSpeechBox->getMinWidth()))
+ return;
+
+ graphics->setColor(guiPalette->getColor(Palette::TEXT));
+
int width = mCaption->getWidth();
- mSpeechBox->setTextWrapped(mText, 130 > width ? 130 : width);
+ mSpeechBox->setTextWrapped(text, 130 > width ? 130 : width);
const int fontHeight = getFont()->getHeight();
const int numRows = showName ? mSpeechBox->getNumberOfRows() + 1 :
mSpeechBox->getNumberOfRows();
- int yPos = showName ? fontHeight + 3 : 3;
+ int yPos = showName ? fontHeight + getPadding() : getPadding();
int height = (numRows * fontHeight);
if (width < mSpeechBox->getMinWidth())
@@ -83,11 +90,11 @@ void SpeechBubble::setText(std::string mText, bool showName)
if (numRows == 1)
{
- yPos = (fontHeight / 4) + 3;
+ yPos = (fontHeight / 4) + getPadding();
height = ((3 * fontHeight) / 2) + 1;
}
- setContentSize(width + fontHeight, height + 6);
+ setContentSize(width + fontHeight, height + getPadding());
mSpeechArea->setDimension(gcn::Rectangle(4, yPos, width + 5, height));
}