summaryrefslogtreecommitdiff
path: root/src/gui/npc_text.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-07 00:23:59 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-07 00:28:10 +0100
commit43eb6ba950dd8bf978e539c7c7460ef5096438de (patch)
tree99ee4696eb974ec91b33399130831c4bfed806a3 /src/gui/npc_text.cpp
parent523eed88816298b1660ecb9e67db80776e4007bb (diff)
downloadmana-43eb6ba950dd8bf978e539c7c7460ef5096438de.tar.gz
mana-43eb6ba950dd8bf978e539c7c7460ef5096438de.tar.bz2
mana-43eb6ba950dd8bf978e539c7c7460ef5096438de.tar.xz
mana-43eb6ba950dd8bf978e539c7c7460ef5096438de.zip
Fixed wrapping in some cases, removed draw method
The 'draw' method was confusingly named, and was actually for updating the GUI after a resize. Its functionality has been merged into 'widgetResized'. The wrapping was broken in the case where text was added to the NPC dialog, cause it was added to an already wrapped string, causing the wrapping to become permanent. Sorry for all the reformatting. Signed-off-by: Bjørn Lindeijer <bjorn@lindeijer.nl>
Diffstat (limited to 'src/gui/npc_text.cpp')
-rw-r--r--src/gui/npc_text.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index ad2ccdce..34c9cce1 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -58,43 +58,36 @@ NpcTextDialog::NpcTextDialog():
setLocationRelativeTo(getParent());
}
-void
-NpcTextDialog::setText(const std::string &text)
+void NpcTextDialog::setText(const std::string &text)
{
mText = text;
- draw();
+ mTextBox->setTextWrapped(mText);
}
-void
-NpcTextDialog::addText(const std::string &text)
+void NpcTextDialog::addText(const std::string &text)
{
- mText = mTextBox->getText() + text + "\n";
- draw();
+ setText(mText + text + "\n");
}
void NpcTextDialog::widgetResized(const gcn::Event &event)
{
Window::widgetResized(event);
- draw();
-}
-void NpcTextDialog::draw()
-{
const gcn::Rectangle &area = getChildrenArea();
const int width = area.width;
const int height = area.height;
- mTextBox->setTextWrapped(mText);
-
scrollArea->setDimension(gcn::Rectangle(
5, 5, width - 10, height - 15 - okButton->getHeight()));
okButton->setPosition(
width - 5 - okButton->getWidth(),
height - 5 - okButton->getHeight());
+
+ // Set the text again so that it gets wrapped according to the new size
+ mTextBox->setTextWrapped(mText);
}
-void
-NpcTextDialog::action(const gcn::ActionEvent &event)
+void NpcTextDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok")
{