diff options
author | Ira Rice <irarice@gmail.com> | 2008-11-01 03:36:47 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-11-01 03:36:47 +0000 |
commit | 81299ca9acc39dec62e1e504781721ad0db0d471 (patch) | |
tree | 7732a30d6b3bf57582f3cababceb8d7b4045be0d /src/gui/npc_text.cpp | |
parent | d433f836a690199a89781a1c7f694620e7a1ad27 (diff) | |
download | mana-client-81299ca9acc39dec62e1e504781721ad0db0d471.tar.gz mana-client-81299ca9acc39dec62e1e504781721ad0db0d471.tar.bz2 mana-client-81299ca9acc39dec62e1e504781721ad0db0d471.tar.xz mana-client-81299ca9acc39dec62e1e504781721ad0db0d471.zip |
Made NPC dialogues resizeable.
Diffstat (limited to 'src/gui/npc_text.cpp')
-rw-r--r-- | src/gui/npc_text.cpp | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 8324a196..d74b3ddd 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -25,8 +25,6 @@ #include <string> -#include "scrollarea.h" -#include "button.h" #include "textbox.h" #include "../npc.h" @@ -34,11 +32,16 @@ NpcTextDialog::NpcTextDialog(): Window("NPC") { + setResizable(true); + + setMinWidth(200); + setMinHeight(150); + mTextBox = new TextBox; mTextBox->setEditable(false); - gcn::ScrollArea *scrollArea = new ScrollArea(mTextBox); - gcn::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); @@ -58,15 +61,37 @@ NpcTextDialog::NpcTextDialog(): void NpcTextDialog::setText(const std::string &text) { - mTextBox->setMinWidth(230); - mTextBox->setTextWrapped(text); + mText = text; + draw(); } void NpcTextDialog::addText(const std::string &text) { - mTextBox->setMinWidth(230); - mTextBox->setTextWrapped(mTextBox->getText() + text + "\n"); + mText = mTextBox->getText() + text + "\n"; + draw(); +} + +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->setMinWidth(width - 30); + 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()); } void |