diff options
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | menuitems.c | 42 | ||||
-rw-r--r-- | menuitems.h | 8 |
3 files changed, 36 insertions, 17 deletions
@@ -4487,3 +4487,6 @@ Video Disk Recorder Revision History - Fixed handling the color button texts when switching from the 'Schedule' menu of a channel without EPG info to the 'What's on now' menu (reported by Rolf Ahrenberg). +- cMenuEditIntItem and cMenuEditChanItem can now be given strings to label the + minimum and maximum values, and the case that no channel has been selected, + respectively. diff --git a/menuitems.c b/menuitems.c index a20a64a1..0c368284 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.35 2006/03/31 15:17:21 kls Exp $ + * $Id: menuitems.c 1.36 2006/04/09 12:05:05 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); diff --git a/menuitems.h b/menuitems.h index 38c98b6f..f993e6cf 100644 --- a/menuitems.h +++ b/menuitems.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menuitems.h 1.18 2006/03/31 15:12:42 kls Exp $ + * $Id: menuitems.h 1.19 2006/04/09 12:05:05 kls Exp $ */ #ifndef __MENUITEMS_H @@ -28,9 +28,10 @@ class cMenuEditIntItem : public cMenuEditItem { protected: int *value; int min, max; + const char *minString, *maxString; virtual void Set(void); public: - cMenuEditIntItem(const char *Name, int *Value, int Min = 0, int Max = INT_MAX); + cMenuEditIntItem(const char *Name, int *Value, int Min = 0, int Max = INT_MAX, const char *MinString = NULL, const char *MaxString = NULL); virtual eOSState ProcessKey(eKeys Key); }; @@ -110,9 +111,10 @@ public: class cMenuEditChanItem : public cMenuEditIntItem { protected: + const char *noneString; virtual void Set(void); public: - cMenuEditChanItem(const char *Name, int *Value); + cMenuEditChanItem(const char *Name, int *Value, const char *NoneString = NULL); virtual eOSState ProcessKey(eKeys Key); }; |