summaryrefslogtreecommitdiff
path: root/src/gui/npc_text.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-01-20 10:09:59 +0000
committerIra Rice <irarice@gmail.com>2009-01-20 13:22:09 -0700
commit6498f9a6b140385b1614fe59abc4f5981d050050 (patch)
tree479398be96aeeb35c5a961724c0ccf04f6f4e435 /src/gui/npc_text.cpp
parent2805d11b7fa5cfc8a6e1dc739cf40f1aacef2232 (diff)
downloadmana-client-6498f9a6b140385b1614fe59abc4f5981d050050.tar.gz
mana-client-6498f9a6b140385b1614fe59abc4f5981d050050.tar.bz2
mana-client-6498f9a6b140385b1614fe59abc4f5981d050050.tar.xz
mana-client-6498f9a6b140385b1614fe59abc4f5981d050050.zip
Switch the NPC text dialog over to a BrowserBox
Diffstat (limited to 'src/gui/npc_text.cpp')
-rw-r--r--src/gui/npc_text.cpp46
1 files changed, 14 insertions, 32 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 0570d7a9..fde5dc9c 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -22,7 +22,9 @@
#include <string>
#include "npc_text.h"
-#include "textbox.h"
+#include "browserbox.h"
+#include "button.h"
+#include "scrollarea.h"
#include "../npc.h"
@@ -36,10 +38,10 @@ NpcTextDialog::NpcTextDialog():
setMinWidth(200);
setMinHeight(150);
- mTextBox = new TextBox;
- mTextBox->setEditable(false);
+ mBrowserBox = new BrowserBox(BrowserBox::AUTO_WRAP);
+ mBrowserBox->setOpaque(true);
- scrollArea = new ScrollArea(mTextBox);
+ scrollArea = new ScrollArea(mBrowserBox);
okButton = new Button(_("OK"), "ok", this);
setContentSize(260, 175);
@@ -57,47 +59,27 @@ NpcTextDialog::NpcTextDialog():
setLocationRelativeTo(getParent());
}
-void NpcTextDialog::setText(const std::string &text)
+void NpcTextDialog::clearText()
{
- const gcn::Rectangle &area = getChildrenArea();
- const int width = area.width;
-
- mText = text;
- mTextBox->setMinWidth(width - 30);
- mTextBox->setTextWrapped(mText);
+ mBrowserBox->clearRows();
}
-void NpcTextDialog::addText(const std::string &text)
+void NpcTextDialog::setText(const std::string &text)
{
- setText(mText + text + "\n");
+ mBrowserBox->clearRows();
+ mBrowserBox->addRow(text);
}
-void NpcTextDialog::widgetResized(const gcn::Event &event)
+void NpcTextDialog::addText(const std::string &text)
{
- Window::widgetResized(event);
-
- 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());
-
- // Set the text again so that it gets wrapped according to the new size
- mTextBox->setTextWrapped(mText);
+ mBrowserBox->addRow(text);
}
void NpcTextDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok")
{
- setText("");
+ clearText();
setVisible(false);
if (current_npc)
current_npc->nextDialog();