diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-07 02:00:41 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-07 02:00:41 +0100 |
commit | ceb3ff6bba5a4133000142920a21899114e91cd1 (patch) | |
tree | 0a2ecbae0fbae1584c766efe10b224851a110ec4 /src/gui | |
parent | 48edf44d7fafe90321e92e05cb22b300d9cad6d9 (diff) | |
download | mana-client-ceb3ff6bba5a4133000142920a21899114e91cd1.tar.gz mana-client-ceb3ff6bba5a4133000142920a21899114e91cd1.tar.bz2 mana-client-ceb3ff6bba5a4133000142920a21899114e91cd1.tar.xz mana-client-ceb3ff6bba5a4133000142920a21899114e91cd1.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>
(cherry picked from eAthena commit 43eb6ba950dd8bf978e539c7c7460ef5096438de)
Conflicts:
src/gui/npclistdialog.cpp
src/gui/npclistdialog.h
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/npc_text.cpp | 23 | ||||
-rw-r--r-- | src/gui/npc_text.h | 16 | ||||
-rw-r--r-- | src/gui/npclistdialog.cpp | 16 | ||||
-rw-r--r-- | src/gui/npclistdialog.h | 19 |
4 files changed, 21 insertions, 53 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 60505794..c9ace303 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -60,43 +60,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") { diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 939fb8fa..76161f88 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -52,23 +52,16 @@ class NpcTextDialog : public Window, public gcn::ActionListener void widgetResized(const gcn::Event &event); /** - * Redraws the window - */ - void draw(); - - /** * Called when receiving actions from the widgets. */ - void - action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event); /** * Sets the text shows in the dialog. * * @param string The new text. */ - void - setText(const std::string &string); + void setText(const std::string &string); /** * Adds the text to the text shows in the dialog. Also adds a newline @@ -76,8 +69,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener * * @param string The text to add. */ - void - addText(const std::string &string); + void addText(const std::string &string); private: gcn::Button *okButton; @@ -87,4 +79,4 @@ class NpcTextDialog : public Window, public gcn::ActionListener std::string mText; }; -#endif +#endif // _TMW_NPC_TEXT_H diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index e896778c..57783d96 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -66,14 +66,12 @@ NpcListDialog::NpcListDialog(): setLocationRelativeTo(getParent()); } -int -NpcListDialog::getNumberOfElements() +int NpcListDialog::getNumberOfElements() { return mItems.size(); } -std::string -NpcListDialog::getElementAt(int i) +std::string NpcListDialog::getElementAt(int i) { return mItems[i]; } @@ -83,8 +81,7 @@ void NpcListDialog::addItem(std::string const &item) mItems.push_back(item); } -void -NpcListDialog::reset() +void NpcListDialog::reset() { mItems.clear(); } @@ -92,11 +89,7 @@ NpcListDialog::reset() 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; @@ -111,8 +104,7 @@ void NpcListDialog::draw() cancelButton->getY()); } -void -NpcListDialog::action(const gcn::ActionEvent &event) +void NpcListDialog::action(const gcn::ActionEvent &event) { int choice = 0; diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index e5e973e7..9d970ac2 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -56,27 +56,19 @@ class NpcListDialog : public Window, public gcn::ActionListener, void widgetResized(const gcn::Event &event); /** - * Redraws the window - */ - void draw(); - - /** * Called when receiving actions from the widgets. */ - void - action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event); /** * Returns the number of items in the choices list. */ - int - getNumberOfElements(); + int getNumberOfElements(); /** * Returns the name of item number i of the choices list. */ - std::string - getElementAt(int i); + std::string getElementAt(int i); /** * Adds an item to the option list. @@ -86,8 +78,7 @@ class NpcListDialog : public Window, public gcn::ActionListener, /** * Resets the list by removing all items. */ - void - reset(); + void reset(); private: gcn::ListBox *mItemList; @@ -98,4 +89,4 @@ class NpcListDialog : public Window, public gcn::ActionListener, std::vector<std::string> mItems; }; -#endif +#endif // _TMW_GUI_NPCLISTDIALOG_H |