summaryrefslogtreecommitdiff
path: root/menuitems.c
diff options
context:
space:
mode:
Diffstat (limited to 'menuitems.c')
-rw-r--r--menuitems.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/menuitems.c b/menuitems.c
index 34e0dd7..8d7e50e 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.34 2006/03/26 09:10:17 kls Exp $
+ * $Id: menuitems.c 1.36 2006/04/09 13:10:02 kls Exp $
*/
#include "menuitems.h"
@@ -45,12 +45,14 @@ void cMenuEditItem::SetValue(const char *Value)
// --- cMenuEditIntItem ------------------------------------------------------
-cMenuEditIntItem::cMenuEditIntItem(const char *Name, int *Value, int Min, int Max)
+cMenuEditIntItem::cMenuEditIntItem(const char *Name, int *Value, int Min, int Max, const char *MinString, const char *MaxString)
:cMenuEditItem(Name)
{
value = Value;
min = Min;
max = Max;
+ minString = MinString;
+ maxString = MaxString;
if (*value < min)
*value = min;
else if (*value > max)
@@ -60,9 +62,15 @@ cMenuEditIntItem::cMenuEditIntItem(const char *Name, int *Value, int Min, int Ma
void cMenuEditIntItem::Set(void)
{
- char buf[16];
- snprintf(buf, sizeof(buf), "%d", *value);
- SetValue(buf);
+ if (minString && *value == min)
+ SetValue(minString);
+ else if (maxString && *value == max)
+ SetValue(maxString);
+ else {
+ char buf[16];
+ snprintf(buf, sizeof(buf), "%d", *value);
+ SetValue(buf);
+ }
}
eOSState cMenuEditIntItem::ProcessKey(eKeys Key)
@@ -549,18 +557,23 @@ void cMenuEditStraItem::Set(void)
// --- cMenuEditChanItem -----------------------------------------------------
-cMenuEditChanItem::cMenuEditChanItem(const char *Name, int *Value)
-:cMenuEditIntItem(Name, Value, 1, Channels.MaxNumber())
+cMenuEditChanItem::cMenuEditChanItem(const char *Name, int *Value, const char *NoneString)
+:cMenuEditIntItem(Name, Value, NoneString ? 0 : 1, Channels.MaxNumber())
{
+ noneString = NoneString;
Set();
}
void cMenuEditChanItem::Set(void)
{
- char buf[255];
- cChannel *channel = Channels.GetByNumber(*value);
- snprintf(buf, sizeof(buf), "%d %s", *value, channel ? channel->Name() : "");
- SetValue(buf);
+ if (*value > 0) {
+ char buf[255];
+ cChannel *channel = Channels.GetByNumber(*value);
+ snprintf(buf, sizeof(buf), "%d %s", *value, channel ? channel->Name() : "");
+ SetValue(buf);
+ }
+ else
+ SetValue(noneString);
}
eOSState cMenuEditChanItem::ProcessKey(eKeys Key)
@@ -574,10 +587,11 @@ eOSState cMenuEditChanItem::ProcessKey(eKeys Key)
case kRight:
{
cChannel *channel = Channels.GetByNumber(*value + delta, delta);
- if (channel) {
+ if (channel)
*value = channel->Number();
- Set();
- }
+ else if (delta < 0 && noneString)
+ *value = 0;
+ Set();
}
break;
default: return cMenuEditIntItem::ProcessKey(Key);
@@ -588,11 +602,11 @@ eOSState cMenuEditChanItem::ProcessKey(eKeys Key)
// --- cMenuEditTranItem -----------------------------------------------------
cMenuEditTranItem::cMenuEditTranItem(const char *Name, int *Value, int *Source)
-:cMenuEditChanItem(Name, Value)
+:cMenuEditChanItem(Name, &number)
{
number = 0;
source = Source;
- transponder = *Value;
+ transponder = Value;
cChannel *channel = Channels.First();
while (channel) {
if (!channel->GroupSep() && *source == channel->Source() && ISTRANSPONDER(channel->Transponder(), *Value)) {
@@ -601,22 +615,17 @@ cMenuEditTranItem::cMenuEditTranItem(const char *Name, int *Value, int *Source)
}
channel = (cChannel *)channel->Next();
}
- *Value = number;
Set();
- *Value = transponder;
}
eOSState cMenuEditTranItem::ProcessKey(eKeys Key)
{
- *value = number;
eOSState state = cMenuEditChanItem::ProcessKey(Key);
- number = *value;
- cChannel *channel = Channels.GetByNumber(*value);
+ cChannel *channel = Channels.GetByNumber(number);
if (channel) {
*source = channel->Source();
- transponder = channel->Transponder();
+ *transponder = channel->Transponder();
}
- *value = transponder;
return state;
}