From 6c806db4367e161d915196cd4638a44a941fca20 Mon Sep 17 00:00:00 2001
From: Guillaume Melquiond <guillaume.melquiond@gmail.com>
Date: Wed, 14 Nov 2007 10:07:55 +0000
Subject: Improved item amount dialog box.

(cherry picked from commit 69c147510bce9aa24be5ddcb3d050a5d52e3abe7)

Conflicts:

	src/gui/item_amount.cpp
---
 src/gui/inttextbox.cpp | 22 +++++++++++-----------
 src/gui/inttextbox.h   |  4 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

(limited to 'src/gui')

diff --git a/src/gui/inttextbox.cpp b/src/gui/inttextbox.cpp
index 858a3fcb..df8cf24e 100644
--- a/src/gui/inttextbox.cpp
+++ b/src/gui/inttextbox.cpp
@@ -19,9 +19,8 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <guichan/key.hpp>
-
 #include "inttextbox.h"
+#include "sdlinput.h"
 
 #include "../utils/tostring.h"
 
@@ -35,17 +34,20 @@ IntTextBox::keyPressed(gcn::KeyEvent &event)
 {
     const gcn::Key &key = event.getKey();
 
-    if (key.isNumber() || key.getValue() == gcn::Key::BACKSPACE
-        || key.getValue() == gcn::Key::DELETE)
+    if (key.getValue() == Key::BACKSPACE ||
+        key.getValue() == Key::DELETE)
     {
-        gcn::TextBox::keyPressed(event);
+        setText(std::string());
+        event.consume();
     }
 
-    std::stringstream s(gcn::TextBox::getText());
+    if (!key.isNumber()) return;
+    TextField::keyPressed(event);
+
+    std::istringstream s(getText());
     int i;
     s >> i;
-    if (gcn::TextBox::getText() != "")
-        setInt(i);
+    setInt(i);
 }
 
 void IntTextBox::setRange(int min, int max)
@@ -56,9 +58,7 @@ void IntTextBox::setRange(int min, int max)
 
 int IntTextBox::getInt()
 {
-    if (gcn::TextBox::getText() == "")
-        return 0;
-    return mValue;
+    return getText().empty() ? mMin : mValue;
 }
 
 void IntTextBox::setInt(int i)
diff --git a/src/gui/inttextbox.h b/src/gui/inttextbox.h
index 922ef4c5..9c6e8bf4 100644
--- a/src/gui/inttextbox.h
+++ b/src/gui/inttextbox.h
@@ -22,14 +22,14 @@
 #ifndef INTTEXTBOX_H
 #define INTTEXTBOX_H
 
-#include "textbox.h"
+#include "textfield.h"
 
 #include "../guichanfwd.h"
 
 /**
  * TextBox which only accepts numbers as input.
  */
-class IntTextBox : public TextBox
+class IntTextBox : public TextField
 {
     public:
         /**
-- 
cgit v1.2.3-70-g09d2