diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-04-16 08:39:59 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-04-16 08:39:59 +0000 |
commit | fe02ca9dcaa593d361f0acebcfb514997dc4ca9e (patch) | |
tree | 3dccd5a76a231f2f7a6261732f144c70e850afb7 /src/gui | |
parent | 2aae7dcba5b240674a76e0d85dbf64cede1d478b (diff) | |
download | mana-fe02ca9dcaa593d361f0acebcfb514997dc4ca9e.tar.gz mana-fe02ca9dcaa593d361f0acebcfb514997dc4ca9e.tar.bz2 mana-fe02ca9dcaa593d361f0acebcfb514997dc4ca9e.tar.xz mana-fe02ca9dcaa593d361f0acebcfb514997dc4ca9e.zip |
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()).
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/npc_text.cpp | 8 | ||||
-rw-r--r-- | src/gui/npc_text.h | 7 | ||||
-rw-r--r-- | src/gui/scrollarea.h | 10 | ||||
-rw-r--r-- | src/gui/textbox.cpp | 9 | ||||
-rw-r--r-- | src/gui/textbox.h | 7 |
5 files changed, 14 insertions, 27 deletions
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 <guichan/actionlistener.hpp> #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 @@ -41,14 +41,9 @@ 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 |