summaryrefslogtreecommitdiff
path: root/menuitems.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2003-04-12 09:24:48 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2003-04-12 09:24:48 +0200
commite58802d2a0a04e860dcd9bb2db8f03b0f9c3402e (patch)
tree4782bd329513c296ed904d1b5dac7eb1cf41c930 /menuitems.c
parentc30aeec7165ed63bc2f30ee0d85b15f4a83df005 (diff)
downloadvdr-e58802d2a0a04e860dcd9bb2db8f03b0f9c3402e.tar.gz
vdr-e58802d2a0a04e860dcd9bb2db8f03b0f9c3402e.tar.bz2
Fixed handling min/max borders when entering integer values
Diffstat (limited to 'menuitems.c')
-rw-r--r--menuitems.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/menuitems.c b/menuitems.c
index 56b91995..d680ff9c 100644
--- a/menuitems.c
+++ b/menuitems.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menuitems.c 1.12 2003/01/18 13:34:40 kls Exp $
+ * $Id: menuitems.c 1.13 2003/04/12 09:21:33 kls Exp $
*/
#include "menuitems.h"
@@ -62,27 +62,30 @@ eOSState cMenuEditIntItem::ProcessKey(eKeys Key)
eOSState state = cMenuEditItem::ProcessKey(Key);
if (state == osUnknown) {
- int newValue;
- if (k0 <= Key && Key <= k9) {
- if (fresh) {
- *value = 0;
- fresh = false;
- }
- newValue = *value * 10 + (Key - k0);
- }
- else if (NORMALKEY(Key) == kLeft) { // TODO might want to increase the delta if repeated quickly?
- newValue = *value - 1;
- fresh = true;
- }
- else if (NORMALKEY(Key) == kRight) {
- newValue = *value + 1;
- fresh = true;
- }
- else {
- if (*value < min) { *value = min; Set(); }
- if (*value > max) { *value = max; Set(); }
- return state;
- }
+ int newValue = *value;
+ Key = NORMALKEY(Key);
+ switch (Key) {
+ case kNone: break;
+ case k0 ... k9:
+ if (fresh) {
+ *value = 0;
+ fresh = false;
+ }
+ newValue = *value * 10 + (Key - k0);
+ break;
+ case kLeft: // TODO might want to increase the delta if repeated quickly?
+ newValue = *value - 1;
+ fresh = true;
+ break;
+ case kRight:
+ newValue = *value + 1;
+ fresh = true;
+ break;
+ default:
+ if (*value < min) { *value = min; Set(); }
+ if (*value > max) { *value = max; Set(); }
+ return state;
+ }
if ((!fresh || min <= newValue) && newValue <= max) {
*value = newValue;
Set();