summaryrefslogtreecommitdiff
path: root/src/gui/inttextfield.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-07 23:47:57 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-07 23:52:46 +0200
commitd69d85f06fa6dc22ac4c7789e4140e32d119a7f1 (patch)
tree1d2311bfdba616136d0ac26f8cbe9ab73c88f0e4 /src/gui/inttextfield.cpp
parent303c1f69761e90b83d4809e911f7785ec66b46aa (diff)
downloadmana-client-d69d85f06fa6dc22ac4c7789e4140e32d119a7f1.tar.gz
mana-client-d69d85f06fa6dc22ac4c7789e4140e32d119a7f1.tar.bz2
mana-client-d69d85f06fa6dc22ac4c7789e4140e32d119a7f1.tar.xz
mana-client-d69d85f06fa6dc22ac4c7789e4140e32d119a7f1.zip
Moved basic widgets into the gui/widgets directory
In an attempt to make the GUI code a little more structured, basic widgets are now put in gui/widgets. Many includes were also cleaned up.
Diffstat (limited to 'src/gui/inttextfield.cpp')
-rw-r--r--src/gui/inttextfield.cpp104
1 files changed, 0 insertions, 104 deletions
diff --git a/src/gui/inttextfield.cpp b/src/gui/inttextfield.cpp
deleted file mode 100644
index d3fe448b..00000000
--- a/src/gui/inttextfield.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "inttextfield.h"
-#include "sdlinput.h"
-
-#include "../utils/stringutils.h"
-
-IntTextField::IntTextField(int def):
- TextField(toString(def)),
- mDefault(def),
- mValue(def)
-{
-}
-
-void IntTextField::keyPressed(gcn::KeyEvent &event)
-{
- const gcn::Key &key = event.getKey();
-
- if (key.getValue() == Key::BACKSPACE ||
- key.getValue() == Key::DELETE)
- {
- setText(std::string());
- event.consume();
- }
-
- if (!key.isNumber())
- return;
-
- TextField::keyPressed(event);
-
- std::istringstream s(getText());
- int i;
- s >> i;
- setValue(i);
-}
-
-void IntTextField::setRange(int min, int max)
-{
- mMin = min;
- mMax = max;
-
- if (mValue < mMin)
- mValue = mMin;
- else if (mValue > mMax)
- mValue = mMax;
-
- if (mDefault < mMin)
- mDefault = mMin;
- else if (mDefault > mMax)
- mDefault = mMax;
-}
-
-int IntTextField::getValue()
-{
- return getText().empty() ? mMin : mValue;
-}
-
-void IntTextField::setValue(int i)
-{
- if (i < mMin)
- mValue = mMin;
- else if (i > mMax)
- mValue = mMax;
- else
- mValue = i;
-
- const std::string valStr = toString(mValue);
- setText(valStr);
- setCaretPosition(valStr.length() + 1);
-}
-
-void IntTextField::setDefaultValue(int value)
-{
- if (value < mMin)
- mDefault = mMin;
- else if (value > mMax)
- mDefault = mMax;
- else
- mDefault = value;
-}
-
-void IntTextField::reset()
-{
- setValue(mDefault);
-}