From e59c6ac433e50f76986331a3ff2e610e60ddf4b5 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 12 Apr 2008 13:39:12 +0200 Subject: Re-implemented handling of DVB-S2 --- menuitems.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'menuitems.c') diff --git a/menuitems.c b/menuitems.c index 4aba66c6..200834ec 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.58 2008/02/10 16:03:30 kls Exp $ + * $Id: menuitems.c 2.1 2008/04/12 12:05:25 kls Exp $ */ #include "menuitems.h" @@ -936,6 +936,64 @@ eOSState cMenuEditTimeItem::ProcessKey(eKeys Key) return state; } +// --- cMenuEditMapItem ------------------------------------------------------ + +cMenuEditMapItem::cMenuEditMapItem(const char *Name, int *Value, const tChannelParameterMap *Map, const char *ZeroString) +:cMenuEditItem(Name) +{ + value = Value; + map = Map; + zeroString = ZeroString; + Set(); +} + +void cMenuEditMapItem::Set(void) +{ + const char *s = NULL; + int n = MapToUser(*value, map, &s); + if (n == 999) + SetValue(tr("auto")); + else if (n == 0 && zeroString) + SetValue(zeroString); + else if (n >= 0) { + if (s) + SetValue(s); + else { + char buf[16]; + snprintf(buf, sizeof(buf), "%d", n); + SetValue(buf); + } + } + else + SetValue("???"); +} + +eOSState cMenuEditMapItem::ProcessKey(eKeys Key) +{ + eOSState state = cMenuEditItem::ProcessKey(Key); + + if (state == osUnknown) { + int newValue = *value; + int n = DriverIndex(*value, map); + if (NORMALKEY(Key) == kLeft) { // TODO might want to increase the delta if repeated quickly? + if (n-- > 0) + newValue = map[n].driverValue; + } + else if (NORMALKEY(Key) == kRight) { + if (map[++n].userValue >= 0) + newValue = map[n].driverValue; + } + else + return state; + if (newValue != *value) { + *value = newValue; + Set(); + } + state = osContinue; + } + return state; +} + // --- cMenuSetupPage -------------------------------------------------------- cMenuSetupPage::cMenuSetupPage(void) -- cgit v1.2.3