diff options
-rw-r--r-- | menuitems.c | 53 | ||||
-rw-r--r-- | menuitems.h | 12 |
2 files changed, 63 insertions, 2 deletions
diff --git a/menuitems.c b/menuitems.c index e724febd..e60956c0 100644 --- a/menuitems.c +++ b/menuitems.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: menuitems.c,v 1.5 2007-03-14 11:52:01 phintuka Exp $ + * $Id: menuitems.c,v 1.6 2007-05-17 16:13:23 phintuka Exp $ * */ @@ -46,6 +46,57 @@ void cMenuEditTypedIntItem::Set(void) SetValue(buf); } } +// --- cMenuEditOddIntItem ------------------------------------------------------ +cMenuEditOddIntItem::cMenuEditOddIntItem(const char *Name, int *Value, int Min, int Max, const char *MinString, const char *MaxString) +:cMenuEditIntItem(Name,Value,Min,Max,MinString,MaxString) +{ + value = Value; + min = Min; + max = Max; + minString = MinString; + maxString = MaxString; + if (*value < min) + *value = min; + else if (*value > max) + *value = max; + Set(); +} + +eOSState cMenuEditOddIntItem::ProcessKey(eKeys Key) +{ + eOSState state = cMenuEditItem::ProcessKey(Key); + + if (state == osUnknown) { + int newValue = *value; + bool IsRepeat = Key & k_Repeat; + Key = NORMALKEY(Key); + switch (Key) { + case kNone: break; + case kLeft: + newValue = *value - 2; + fresh = true; + if (!IsRepeat && newValue < min && max != INT_MAX) + newValue = max; + break; + case kRight: + newValue = *value + 2; + fresh = true; + if (!IsRepeat && newValue > max && min != INT_MIN) + newValue = min; + break; + default: + if (*value < min) { *value = min; Set(); } + if (*value > max) { *value = max; Set(); } + return state; + } + if (newValue != *value && (!fresh || min <= newValue) && newValue <= max) { + *value = newValue; + Set(); + } + state = osContinue; + } + return state; +} // --- cMenuEditStraI18nItem ------------------------------------------------- diff --git a/menuitems.h b/menuitems.h index b47b455c..d6d0dbcd 100644 --- a/menuitems.h +++ b/menuitems.h @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: menuitems.h,v 1.3 2006-09-19 08:24:09 phintuka Exp $ + * $Id: menuitems.h,v 1.4 2007-05-17 16:13:23 phintuka Exp $ * */ @@ -30,6 +30,16 @@ class cMenuEditTypedIntItem : public cMenuEditIntItem ~cMenuEditTypedIntItem(); }; +// --- cMenuEditOddIntItem ------------------------------------------------- + +class cMenuEditOddIntItem : public cMenuEditIntItem +{ + public: + cMenuEditOddIntItem(const char *Name, int *Value, int Min = 1, int Max = INT_MAX, const char *MinString = NULL, const char *MaxString = NULL); + eOSState ProcessKey(eKeys Key); +}; + + // --- cMenuEditStraI18nItem ------------------------------------------------- class cMenuEditStraI18nItem : public cMenuEditIntItem |