#ifndef _MENUDIRECTOR_H
#define _MENUDIRECTOR_H 1

#include <vdr/channels.h>
#include <vdr/osdbase.h>

#include "arghdirector.h"

class cMenuDirector;

class cMenuDirectorItem : public cOsdItem
{
   private:

      const cChannel* mChannel;
      const cEvent* mEvent;
      cMenuDirector* mMenu;
      int mDetails;
      int mNext;
      int lastTimerMatch;

   public:

      cMenuDirectorItem(cMenuDirector* menu, const cChannel* channel, 
                        const cEvent* event = 0, 
                        int details = false, int next = false);
      virtual ~cMenuDirectorItem() { }

      const cChannel* Channel()    { return mChannel; }
      const cEvent* Event()        { return mEvent; }
      int Update(int force);
};

class cMenuDirector : public cOsdMenu
{
   private:

      static cMenuDirectorData* mData;
      static const cChannel* mReferenceChannel;
      const  cChannel* mCurrentChannel;

      void DetermineReferenceChannel();
      void AddEpgItem(const cEvent* event);
      void SelectCurrentChannel();
      cChannel* GetChannel(int Index);
      void SwitchToChannel(const cChannel* channel);
      eOSState Record(cMenuDirectorItem* item);
      void SetHelpKeys(cMenuDirectorItem* item);

      static void ChannelSwitchNonOsd(const cChannel* channel);
      static const cLinkChannels* GetLinkChannelsOutOfChannel(const cChannel* channel);
      static const cChannel* GetRefChannelOutOfChannel(const cChannel* channel);

   public:

      cMenuDirector(const char* title, cMenuDirectorData* data);
      virtual ~cMenuDirector();

      const char* hotKey(const char *s) { return hk(s); }
      virtual eOSState ProcessKey(eKeys Key);
      void Update();

      static cOsdMenu* Create(const char* title, cOsdProxyData* data);
      static void Release();
      static void ChannelSwitchNonOsd(int direction);
      static eOSState KeyHandlerFunction(eKeys Key);

      const char* MenuKind() { return "MenuArghDirector"; }
};

#endif
