diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-03-18 14:47:14 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-03-18 14:47:14 +0000 |
commit | ab678324e3d73e2354cef331624ecef7cfc03203 (patch) | |
tree | 29394a5aca6e59f817f7cfa3b9281891a273d259 /src/gui/inttextbox.cpp | |
parent | 32badd4b6f843cb74fdc3238fe92119518c8c0ab (diff) | |
download | mana-ab678324e3d73e2354cef331624ecef7cfc03203.tar.gz mana-ab678324e3d73e2354cef331624ecef7cfc03203.tar.bz2 mana-ab678324e3d73e2354cef331624ecef7cfc03203.tar.xz mana-ab678324e3d73e2354cef331624ecef7cfc03203.zip |
Added a toString conversion function.
Diffstat (limited to 'src/gui/inttextbox.cpp')
-rw-r--r-- | src/gui/inttextbox.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/gui/inttextbox.cpp b/src/gui/inttextbox.cpp index 560a6cec..92f21e5f 100644 --- a/src/gui/inttextbox.cpp +++ b/src/gui/inttextbox.cpp @@ -23,10 +23,10 @@ #include "inttextbox.h" -#include <sstream> - #include <guichan/key.hpp> +#include "../utils/tostring.h" + IntTextBox::IntTextBox(int i): mValue(i) { @@ -40,9 +40,8 @@ void IntTextBox::keyPress(const gcn::Key &key) gcn::TextBox::keyPress(key); } - std::stringstream s; + std::stringstream s(gcn::TextBox::getText()); int i; - s << gcn::TextBox::getText(); s >> i; if (gcn::TextBox::getText() != "") setInt(i); @@ -63,11 +62,10 @@ int IntTextBox::getInt() void IntTextBox::setInt(int i) { - std::stringstream s; - if (i >= mMin && i <= mMax) mValue = i; - s << mValue; - setText(s.str()); - setCaretPosition(s.str().length() + 1); + + const std::string valStr = toString(mValue); + setText(valStr); + setCaretPosition(valStr.length() + 1); } |