summaryrefslogtreecommitdiff
path: root/src/gui/inttextfield.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/inttextfield.cpp')
-rw-r--r--src/gui/inttextfield.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/gui/inttextfield.cpp b/src/gui/inttextfield.cpp
index adade3b9..9f633965 100644
--- a/src/gui/inttextfield.cpp
+++ b/src/gui/inttextfield.cpp
@@ -1,8 +1,8 @@
/*
- * Aethyra
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
+ * The Mana World
+ * Copyright (C) 2004 The Mana World Development Team
*
- * This file is part of Aethyra.
+ * 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
@@ -57,6 +57,16 @@ 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()
@@ -66,18 +76,28 @@ int IntTextField::getValue()
void IntTextField::setValue(int i)
{
- if (i >= mMin && i <= mMax)
- mValue = i;
- else if (i < mMin)
+ 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);