/*
 * menu_event.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */

#include <vdr/status.h>
#include "menu_event.h"

// --- cMenuEventSearch ------------------------------------------------------------

cMenuEventSearch::cMenuEventSearch(const cEvent *Event, bool CanSwitch)
:cOsdMenu(tr("Event"))
{
  event = Event;
  if (event) {
     cChannel *channel = Channels.GetByChannelID(event->ChannelID(), true);
     if (channel) {
        SetTitle(channel->Name());
        SetHelp(tr("Record"), "<<", ">>", CanSwitch ? tr("Switch") : NULL);
        }
     }
}

void cMenuEventSearch::Display(void)
{
  cOsdMenu::Display();
  if (event)
  {
  	DisplayMenu()->SetEvent(event);
  	cStatus::MsgOsdTextItem(event->Description());
  }
}

eOSState cMenuEventSearch::ProcessKey(eKeys Key)
{
  switch (Key) {
    case kUp|k_Repeat:
    case kUp:
    case kDown|k_Repeat:
    case kDown:
    case kLeft|k_Repeat:
    case kLeft:
    case kRight|k_Repeat:
    case kRight:
                  DisplayMenu()->Scroll(NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft, NORMALKEY(Key) == kLeft || NORMALKEY(Key) == kRight);
                  cStatus::MsgOsdTextItem(NULL, NORMALKEY(Key) == kUp);
                  return osContinue;
    default: break;
    }

  eOSState state = cOsdMenu::ProcessKey(Key);

  if (state == osUnknown) {
     switch (Key) {
       case kOk:     return osBack;
       default: break;
       }
     }
  return state;
}

