1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Additional label strings for cMenuEditIntItem and cMenuEditChanItem

This commit is contained in:
Klaus Schmidinger 2006-04-09 12:05:05 +02:00
parent 060c3f3ddc
commit e36da7ab8d
3 changed files with 36 additions and 17 deletions

View File

@ -4487,3 +4487,6 @@ Video Disk Recorder Revision History
- Fixed handling the color button texts when switching from the 'Schedule' menu of - 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 a channel without EPG info to the 'What's on now' menu (reported by Rolf
Ahrenberg). 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.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "menuitems.h"
@ -45,12 +45,14 @@ void cMenuEditItem::SetValue(const char *Value)
// --- cMenuEditIntItem ------------------------------------------------------ // --- 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) :cMenuEditItem(Name)
{ {
value = Value; value = Value;
min = Min; min = Min;
max = Max; max = Max;
minString = MinString;
maxString = MaxString;
if (*value < min) if (*value < min)
*value = min; *value = min;
else if (*value > max) else if (*value > max)
@ -60,9 +62,15 @@ cMenuEditIntItem::cMenuEditIntItem(const char *Name, int *Value, int Min, int Ma
void cMenuEditIntItem::Set(void) void cMenuEditIntItem::Set(void)
{ {
char buf[16]; if (minString && *value == min)
snprintf(buf, sizeof(buf), "%d", *value); SetValue(minString);
SetValue(buf); else if (maxString && *value == max)
SetValue(maxString);
else {
char buf[16];
snprintf(buf, sizeof(buf), "%d", *value);
SetValue(buf);
}
} }
eOSState cMenuEditIntItem::ProcessKey(eKeys Key) eOSState cMenuEditIntItem::ProcessKey(eKeys Key)
@ -549,18 +557,23 @@ void cMenuEditStraItem::Set(void)
// --- cMenuEditChanItem ----------------------------------------------------- // --- cMenuEditChanItem -----------------------------------------------------
cMenuEditChanItem::cMenuEditChanItem(const char *Name, int *Value) cMenuEditChanItem::cMenuEditChanItem(const char *Name, int *Value, const char *NoneString)
:cMenuEditIntItem(Name, Value, 1, Channels.MaxNumber()) :cMenuEditIntItem(Name, Value, NoneString ? 0 : 1, Channels.MaxNumber())
{ {
noneString = NoneString;
Set(); Set();
} }
void cMenuEditChanItem::Set(void) void cMenuEditChanItem::Set(void)
{ {
char buf[255]; if (*value > 0) {
cChannel *channel = Channels.GetByNumber(*value); char buf[255];
snprintf(buf, sizeof(buf), "%d %s", *value, channel ? channel->Name() : ""); cChannel *channel = Channels.GetByNumber(*value);
SetValue(buf); snprintf(buf, sizeof(buf), "%d %s", *value, channel ? channel->Name() : "");
SetValue(buf);
}
else
SetValue(noneString);
} }
eOSState cMenuEditChanItem::ProcessKey(eKeys Key) eOSState cMenuEditChanItem::ProcessKey(eKeys Key)
@ -574,10 +587,11 @@ eOSState cMenuEditChanItem::ProcessKey(eKeys Key)
case kRight: case kRight:
{ {
cChannel *channel = Channels.GetByNumber(*value + delta, delta); cChannel *channel = Channels.GetByNumber(*value + delta, delta);
if (channel) { if (channel)
*value = channel->Number(); *value = channel->Number();
Set(); else if (delta < 0 && noneString)
} *value = 0;
Set();
} }
break; break;
default: return cMenuEditIntItem::ProcessKey(Key); default: return cMenuEditIntItem::ProcessKey(Key);

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef __MENUITEMS_H
@ -28,9 +28,10 @@ class cMenuEditIntItem : public cMenuEditItem {
protected: protected:
int *value; int *value;
int min, max; int min, max;
const char *minString, *maxString;
virtual void Set(void); virtual void Set(void);
public: 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); virtual eOSState ProcessKey(eKeys Key);
}; };
@ -110,9 +111,10 @@ public:
class cMenuEditChanItem : public cMenuEditIntItem { class cMenuEditChanItem : public cMenuEditIntItem {
protected: protected:
const char *noneString;
virtual void Set(void); virtual void Set(void);
public: public:
cMenuEditChanItem(const char *Name, int *Value); cMenuEditChanItem(const char *Name, int *Value, const char *NoneString = NULL);
virtual eOSState ProcessKey(eKeys Key); virtual eOSState ProcessKey(eKeys Key);
}; };