summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2008-11-01 03:36:47 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-07 01:59:09 +0100
commit48edf44d7fafe90321e92e05cb22b300d9cad6d9 (patch)
tree319c44509c1d55b1db6e4bc1923430c0dc1eb528 /src
parentb6d2aeca1439c1a929e4f4e164735ad123ca0da2 (diff)
downloadmana-48edf44d7fafe90321e92e05cb22b300d9cad6d9.tar.gz
mana-48edf44d7fafe90321e92e05cb22b300d9cad6d9.tar.bz2
mana-48edf44d7fafe90321e92e05cb22b300d9cad6d9.tar.xz
mana-48edf44d7fafe90321e92e05cb22b300d9cad6d9.zip
Made NPC dialogues resizeable.
Conflicts: src/gui/inventorywindow.cpp src/gui/npc_text.cpp (cherry picked from eAthena commit 523eed88816298b1660ecb9e67db80776e4007bb)
Diffstat (limited to 'src')
-rw-r--r--src/gui/npc_text.cpp37
-rw-r--r--src/gui/npc_text.h16
-rw-r--r--src/gui/npclistdialog.cpp33
-rw-r--r--src/gui/npclistdialog.h15
4 files changed, 94 insertions, 7 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index c593feb1..60505794 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -34,10 +34,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);
@@ -57,13 +63,36 @@ NpcTextDialog::NpcTextDialog():
void
NpcTextDialog::setText(const std::string &text)
{
- mTextBox->setTextWrapped(text);
+ mText = text;
+ draw();
}
void
NpcTextDialog::addText(const std::string &text)
{
- 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->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
diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h
index 2c9771d3..939fb8fa 100644
--- a/src/gui/npc_text.h
+++ b/src/gui/npc_text.h
@@ -45,6 +45,18 @@ class NpcTextDialog : public Window, public gcn::ActionListener
NpcTextDialog();
/**
+ * Called when resizing the window
+ *
+ * @param event The calling event
+ */
+ void widgetResized(const gcn::Event &event);
+
+ /**
+ * Redraws the window
+ */
+ void draw();
+
+ /**
* Called when receiving actions from the widgets.
*/
void
@@ -68,7 +80,11 @@ class NpcTextDialog : public Window, public gcn::ActionListener
addText(const std::string &string);
private:
+ gcn::Button *okButton;
+ gcn::ScrollArea *scrollArea;
TextBox *mTextBox;
+
+ std::string mText;
};
#endif
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index 918031b4..e896778c 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -34,10 +34,15 @@
NpcListDialog::NpcListDialog():
Window(_("NPC"))
{
+ setResizable(true);
+
+ setMinWidth(200);
+ setMinHeight(150);
+
mItemList = new ListBox(this);
- ScrollArea *scrollArea = new ScrollArea(mItemList);
- Button *okButton = new Button(_("Ok"), "ok", this);
- Button *cancelButton = new Button(_("Cancel"), "cancel", this);
+ scrollArea = new ScrollArea(mItemList);
+ okButton = new Button(_("OK"), "ok", this);
+ cancelButton = new Button(_("Cancel"), "cancel", this);
setContentSize(260, 175);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -84,6 +89,28 @@ NpcListDialog::reset()
mItems.clear();
}
+void NpcListDialog::widgetResized(const gcn::Event &event)
+{
+ Window::widgetResized(event);
+ draw();
+}
+
+void NpcListDialog::draw()
+{
+ 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()));
+ cancelButton->setPosition(
+ width - 5 - cancelButton->getWidth(),
+ height - 5 - cancelButton->getHeight());
+ okButton->setPosition(
+ cancelButton->getX() - 5 - okButton->getWidth(),
+ cancelButton->getY());
+}
+
void
NpcListDialog::action(const gcn::ActionEvent &event)
{
diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h
index e21f9e8c..e5e973e7 100644
--- a/src/gui/npclistdialog.h
+++ b/src/gui/npclistdialog.h
@@ -49,6 +49,18 @@ class NpcListDialog : public Window, public gcn::ActionListener,
NpcListDialog();
/**
+ * Called when resizing the window
+ *
+ * @param event The calling event
+ */
+ void widgetResized(const gcn::Event &event);
+
+ /**
+ * Redraws the window
+ */
+ void draw();
+
+ /**
* Called when receiving actions from the widgets.
*/
void
@@ -79,6 +91,9 @@ class NpcListDialog : public Window, public gcn::ActionListener,
private:
gcn::ListBox *mItemList;
+ gcn::ScrollArea *scrollArea;
+ gcn::Button *okButton;
+ gcn::Button *cancelButton;
std::vector<std::string> mItems;
};