summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2004-03-28 09:20:02 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2004-03-28 09:20:02 +0200
commit3c4010bb7525dc6497d38584692b8085d0f4fcad (patch)
tree20599d003a79d26684f66229a69b3aa9df50bfdd /menu.c
parentb5e7c111781cb48a4a6e46d18b7df5116e3257bb (diff)
downloadvdr-3c4010bb7525dc6497d38584692b8085d0f4fcad.tar.gz
vdr-3c4010bb7525dc6497d38584692b8085d0f4fcad.tar.bz2
Moved several menu item classes from menu.c to menuitems.[hc] to make them available for plugins
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c326
1 files changed, 1 insertions, 325 deletions
diff --git a/menu.c b/menu.c
index 4fdb994b..3e29fd67 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c 1.297 2004/03/14 13:24:02 kls Exp $
+ * $Id: menu.c 1.298 2004/03/28 09:17:15 kls Exp $
*/
#include "menu.h"
@@ -37,330 +37,6 @@
#define CHNUMWIDTH (numdigits(Channels.MaxNumber()) + 1)
-// --- cMenuEditChanItem -----------------------------------------------------
-
-class cMenuEditChanItem : public cMenuEditIntItem {
-protected:
- virtual void Set(void);
-public:
- cMenuEditChanItem(const char *Name, int *Value);
- virtual eOSState ProcessKey(eKeys Key);
- };
-
-cMenuEditChanItem::cMenuEditChanItem(const char *Name, int *Value)
-:cMenuEditIntItem(Name, Value, 1, Channels.MaxNumber())
-{
- 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);
-}
-
-eOSState cMenuEditChanItem::ProcessKey(eKeys Key)
-{
- int delta = 1;
-
- switch (Key) {
- case kLeft|k_Repeat:
- case kLeft: delta = -1;
- case kRight|k_Repeat:
- case kRight:
- {
- cChannel *channel = Channels.GetByNumber(*value + delta, delta);
- if (channel) {
- *value = channel->Number();
- Set();
- }
- }
- break;
- default : return cMenuEditIntItem::ProcessKey(Key);
- }
- return osContinue;
-}
-
-// --- cMenuEditTranItem -----------------------------------------------------
-
-class cMenuEditTranItem : public cMenuEditChanItem {
-private:
- int number;
- int transponder;
-public:
- cMenuEditTranItem(const char *Name, int *Value);
- virtual eOSState ProcessKey(eKeys Key);
- };
-
-cMenuEditTranItem::cMenuEditTranItem(const char *Name, int *Value)
-:cMenuEditChanItem(Name, Value)
-{
- number = 0;
- transponder = *Value;
- cChannel *channel = Channels.First();
- while (channel) {
- if (!channel->GroupSep() && ISTRANSPONDER(channel->Frequency(), *Value)) {
- number = channel->Number();
- break;
- }
- 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);
- if (channel)
- transponder = channel->Frequency();
- *value = transponder;
- return state;
-}
-
-// --- cMenuEditDayItem ------------------------------------------------------
-
-class cMenuEditDayItem : public cMenuEditIntItem {
-protected:
- static int days[];
- int d;
- virtual void Set(void);
-public:
- cMenuEditDayItem(const char *Name, int *Value);
- virtual eOSState ProcessKey(eKeys Key);
- };
-
-int cMenuEditDayItem::days[] ={ cTimer::ParseDay("M------"),
- cTimer::ParseDay("-T-----"),
- cTimer::ParseDay("--W----"),
- cTimer::ParseDay("---T---"),
- cTimer::ParseDay("----F--"),
- cTimer::ParseDay("-----S-"),
- cTimer::ParseDay("------S"),
- cTimer::ParseDay("MTWTF--"),
- cTimer::ParseDay("MTWTFS-"),
- cTimer::ParseDay("MTWTFSS"),
- cTimer::ParseDay("-----SS"),
- 0 };
-
-cMenuEditDayItem::cMenuEditDayItem(const char *Name, int *Value)
-:cMenuEditIntItem(Name, Value, -INT_MAX, 31)
-{
- d = -1;
- if (*value < 0) {
- int n = 0;
- while (days[n]) {
- if (days[n] == *value) {
- d = n;
- break;
- }
- n++;
- }
- }
- Set();
-}
-
-void cMenuEditDayItem::Set(void)
-{
- SetValue(cTimer::PrintDay(*value));
-}
-
-eOSState cMenuEditDayItem::ProcessKey(eKeys Key)
-{
- switch (Key) {
- case kLeft|k_Repeat:
- case kLeft: if (d > 0)
- *value = days[--d];
- else if (d == 0) {
- *value = 31;
- d = -1;
- }
- else if (*value == 1) {
- d = sizeof(days) / sizeof(int) - 2;
- *value = days[d];
- }
- else
- return cMenuEditIntItem::ProcessKey(Key);
- Set();
- break;
- case kRight|k_Repeat:
- case kRight: if (d >= 0) {
- *value = days[++d];
- if (*value == 0) {
- *value = 1;
- d = -1;
- }
- }
- else if (*value == 31) {
- d = 0;
- *value = days[d];
- }
- else
- return cMenuEditIntItem::ProcessKey(Key);
- Set();
- break;
- default : return cMenuEditIntItem::ProcessKey(Key);
- }
- return osContinue;
-}
-
-// --- cMenuEditDateItem -----------------------------------------------------
-
-class cMenuEditDateItem : public cMenuEditItem {
-protected:
- time_t *value;
- virtual void Set(void);
-public:
- cMenuEditDateItem(const char *Name, time_t *Value);
- virtual eOSState ProcessKey(eKeys Key);
- };
-
-cMenuEditDateItem::cMenuEditDateItem(const char *Name, time_t *Value)
-:cMenuEditItem(Name)
-{
- value = Value;
- Set();
-}
-
-void cMenuEditDateItem::Set(void)
-{
-#define DATEBUFFERSIZE 32
- char buf[DATEBUFFERSIZE];
- if (*value) {
- struct tm tm_r;
- localtime_r(value, &tm_r);
- strftime(buf, DATEBUFFERSIZE, "%Y-%m-%d ", &tm_r);
- strcat(buf, WeekDayName(tm_r.tm_wday));
- }
- else
- *buf = 0;
- SetValue(buf);
-}
-
-eOSState cMenuEditDateItem::ProcessKey(eKeys Key)
-{
- eOSState state = cMenuEditItem::ProcessKey(Key);
-
- if (state == osUnknown) {
- if (NORMALKEY(Key) == kLeft) { // TODO might want to increase the delta if repeated quickly?
- *value -= SECSINDAY;
- if (*value < time(NULL))
- *value = 0;
- }
- else if (NORMALKEY(Key) == kRight) {
- if (!*value)
- *value = cTimer::SetTime(time(NULL), 0);
- *value += SECSINDAY;
- }
- else
- return state;
- Set();
- state = osContinue;
- }
- return state;
-}
-
-// --- cMenuEditTimeItem -----------------------------------------------------
-
-class cMenuEditTimeItem : public cMenuEditItem {
-protected:
- int *value;
- int hh, mm;
- int pos;
- virtual void Set(void);
-public:
- cMenuEditTimeItem(const char *Name, int *Value);
- virtual eOSState ProcessKey(eKeys Key);
- };
-
-cMenuEditTimeItem::cMenuEditTimeItem(const char *Name, int *Value)
-:cMenuEditItem(Name)
-{
- value = Value;
- hh = *value / 100;
- mm = *value % 100;
- pos = 0;
- Set();
-}
-
-void cMenuEditTimeItem::Set(void)
-{
- char buf[10];
- switch (pos) {
- case 1: snprintf(buf, sizeof(buf), "%01d-:--", hh / 10); break;
- case 2: snprintf(buf, sizeof(buf), "%02d:--", hh); break;
- case 3: snprintf(buf, sizeof(buf), "%02d:%01d-", hh, mm / 10); break;
- default: snprintf(buf, sizeof(buf), "%02d:%02d", hh, mm);
- }
- SetValue(buf);
-}
-
-eOSState cMenuEditTimeItem::ProcessKey(eKeys Key)
-{
- eOSState state = cMenuEditItem::ProcessKey(Key);
-
- if (state == osUnknown) {
- if (k0 <= Key && Key <= k9) {
- if (fresh || pos > 3) {
- pos = 0;
- fresh = false;
- }
- int n = Key - k0;
- switch (pos) {
- case 0: if (n <= 2) {
- hh = n * 10;
- mm = 0;
- pos++;
- }
- break;
- case 1: if (hh + n <= 23) {
- hh += n;
- pos++;
- }
- break;
- case 2: if (n <= 5) {
- mm += n * 10;
- pos++;
- }
- break;
- case 3: if (mm + n <= 59) {
- mm += n;
- pos++;
- }
- break;
- }
- }
- else if (NORMALKEY(Key) == kLeft) { // TODO might want to increase the delta if repeated quickly?
- if (--mm < 0) {
- mm = 59;
- if (--hh < 0)
- hh = 23;
- }
- fresh = true;
- }
- else if (NORMALKEY(Key) == kRight) {
- if (++mm > 59) {
- mm = 0;
- if (++hh > 23)
- hh = 0;
- }
- fresh = true;
- }
- else
- return state;
- *value = hh * 100 + mm;
- Set();
- state = osContinue;
- }
- return state;
-}
-
// --- cMenuEditCaItem -------------------------------------------------------
class cMenuEditCaItem : public cMenuEditIntItem {