From fe02ca9dcaa593d361f0acebcfb514997dc4ca9e Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Wed, 16 Apr 2008 08:39:59 +0000 Subject: Restored the text wrapping in TextBox, since it was based on overriding a method that is no longer virtual in Guichan 0.8.0 (gcn::TextBox::setText()). --- ChangeLog | 7 +++++++ src/gui/npc_text.cpp | 8 ++++---- src/gui/npc_text.h | 7 ++++--- src/gui/scrollarea.h | 10 ++++------ src/gui/textbox.cpp | 9 +-------- src/gui/textbox.h | 7 +------ 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1da6749..62546bd4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-04-16 Bjørn Lindeijer + + * src/gui/npc_text.h, src/gui/textbox.cpp, src/gui/npc_text.cpp, + src/gui/scrollarea.h, src/gui/textbox.h: Restored the text wrapping in + TextBox, since it was based on overriding a method that is no longer + virtual in Guichan 0.8.0. + 2008-04-15 David Athay * src/gui/viewport.cpp, src/beingmanager.cpp, tmw.cbp: Fixed clicking diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 2dd223bd..7b4fc634 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -34,7 +34,7 @@ NpcTextDialog::NpcTextDialog(): Window("NPC") { - mTextBox = new TextBox(); + mTextBox = new TextBox; mTextBox->setEditable(false); gcn::ScrollArea *scrollArea = new ScrollArea(mTextBox); Button *okButton = new Button("OK", "ok", this); @@ -55,15 +55,15 @@ NpcTextDialog::NpcTextDialog(): } void -NpcTextDialog::setText(const char *text) +NpcTextDialog::setText(const std::string &text) { - mTextBox->setText(text); + mTextBox->setTextWrapped(text); } void NpcTextDialog::addText(const std::string &text) { - mTextBox->setText(mTextBox->getText() + text + "\n"); + mTextBox->setTextWrapped(mTextBox->getText() + text + "\n"); } void diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 869661c4..0ef1b938 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -28,7 +28,8 @@ #include #include "window.h" -#include "../guichanfwd.h" + +class TextBox; /** * The npc text dialog. @@ -57,7 +58,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener * @param string The new text. */ void - setText(const char *string); + setText(const std::string &string); /** * Adds the text to the text shows in the dialog. Also adds a newline @@ -69,7 +70,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener addText(const std::string &string); private: - gcn::TextBox *mTextBox; + TextBox *mTextBox; }; #endif diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index dd1f946d..be361f68 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -40,12 +40,12 @@ class ScrollArea : public gcn::ScrollArea /** * Constructor. */ - ScrollArea(bool gc=true); + ScrollArea(bool gc = true); /** * Constructor. */ - ScrollArea(gcn::Widget *content, bool gc=true); + ScrollArea(gcn::Widget *content, bool gc = true); /** * Destructor. @@ -71,14 +71,12 @@ class ScrollArea : public gcn::ScrollArea /** * Sets whether the widget should draw its background or not. */ - void - setOpaque(bool opaque); + void setOpaque(bool opaque); /** * Returns whether the widget draws its background or not. */ - bool - isOpaque() { return mOpaque; } + bool isOpaque() const { return mOpaque; } protected: enum BUTTON_DIR { diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index 84c8ad4b..8d16dc46 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -35,14 +35,7 @@ TextBox::TextBox(): setFrameSize(0); } -TextBox::TextBox(const std::string& text): - gcn::TextBox(text) -{ - setOpaque(false); - setFrameSize(0); -} - -void TextBox::setText(const std::string &text) +void TextBox::setTextWrapped(const std::string &text) { // Make sure parent scroll area sets width of this widget if (getParent()) diff --git a/src/gui/textbox.h b/src/gui/textbox.h index 54523281..f06f98ec 100644 --- a/src/gui/textbox.h +++ b/src/gui/textbox.h @@ -40,15 +40,10 @@ class TextBox : public gcn::TextBox { */ TextBox(); - /** - * Constructor. - */ - TextBox(const std::string& text); - /** * Sets the text after wrapping it to the current width of the widget. */ - void setText(const std::string &text); + void setTextWrapped(const std::string &text); }; #endif -- cgit v1.2.3-60-g2f50