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:
parent
060c3f3ddc
commit
e36da7ab8d
3
HISTORY
3
HISTORY
@ -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.
|
||||
|
26
menuitems.c
26
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,10 +62,16 @@ cMenuEditIntItem::cMenuEditIntItem(const char *Name, int *Value, int Min, int Ma
|
||||
|
||||
void cMenuEditIntItem::Set(void)
|
||||
{
|
||||
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,19 +557,24 @@ 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)
|
||||
{
|
||||
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,11 +587,12 @@ eOSState cMenuEditChanItem::ProcessKey(eKeys Key)
|
||||
case kRight:
|
||||
{
|
||||
cChannel *channel = Channels.GetByNumber(*value + delta, delta);
|
||||
if (channel) {
|
||||
if (channel)
|
||||
*value = channel->Number();
|
||||
else if (delta < 0 && noneString)
|
||||
*value = 0;
|
||||
Set();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: return cMenuEditIntItem::ProcessKey(Key);
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user