From b03435fd4ad3c19b96dd7ae960e0950fdd35392c Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 7 Dec 2008 00:23:59 +0100 Subject: Fixed wrapping in some cases, removed draw method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/gui/npc_text.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/gui/npc_text.cpp') diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 052b5f33..a8edc1db 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -55,28 +55,21 @@ 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; @@ -89,10 +82,12 @@ void NpcTextDialog::draw() 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") { -- cgit v1.2.3-70-g09d2