summaryrefslogtreecommitdiff
path: root/src/gui/npc_text.cpp
diff options
context:
space:
mode:
authorFate <fate-tmw@googlemail.com>2008-12-06 20:02:33 -0700
committerFate <fate-tmw@googlemail.com>2008-12-06 20:02:33 -0700
commit28fa707f1ab22e7cac8abff703d534aec3228d5c (patch)
treebc0d906aa6d414b867eda5df02520b5f707216f1 /src/gui/npc_text.cpp
parent704f58c9033599c871c176df68ffe7ac3bc8c969 (diff)
parent7b11d719316e84d97e95a32de2a74803aa18e5da (diff)
downloadmana-client-28fa707f1ab22e7cac8abff703d534aec3228d5c.tar.gz
mana-client-28fa707f1ab22e7cac8abff703d534aec3228d5c.tar.bz2
mana-client-28fa707f1ab22e7cac8abff703d534aec3228d5c.tar.xz
mana-client-28fa707f1ab22e7cac8abff703d534aec3228d5c.zip
Merge branch 'master' into statuseffects
Diffstat (limited to 'src/gui/npc_text.cpp')
-rw-r--r--src/gui/npc_text.cpp42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 3c4beaf3..34c9cce1 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -32,10 +32,16 @@
NpcTextDialog::NpcTextDialog():
Window("NPC")
{
+ setResizable(true);
+
+ setMinWidth(200);
+ setMinHeight(150);
+
mTextBox = new TextBox;
mTextBox->setEditable(false);
- gcn::ScrollArea *scrollArea = new ScrollArea(mTextBox);
- Button *okButton = new Button("OK", "ok", this);
+
+ scrollArea = new ScrollArea(mTextBox);
+ okButton = new Button("OK", "ok", this);
setContentSize(260, 175);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -52,20 +58,36 @@ NpcTextDialog::NpcTextDialog():
setLocationRelativeTo(getParent());
}
-void
-NpcTextDialog::setText(const std::string &text)
+void NpcTextDialog::setText(const std::string &text)
+{
+ mText = text;
+ mTextBox->setTextWrapped(mText);
+}
+
+void NpcTextDialog::addText(const std::string &text)
{
- mTextBox->setTextWrapped(text);
+ setText(mText + text + "\n");
}
-void
-NpcTextDialog::addText(const std::string &text)
+void NpcTextDialog::widgetResized(const gcn::Event &event)
{
- mTextBox->setTextWrapped(mTextBox->getText() + text + "\n");
+ Window::widgetResized(event);
+
+ const gcn::Rectangle &area = getChildrenArea();
+ const int width = area.width;
+ const int height = area.height;
+
+ 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")
{