#/*
 * menu.h: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 */

//***************************************************************************
// Includes
//***************************************************************************

#include <vdr/interface.h>
#include <vdr/osdbase.h>
#include <vdr/plugin.h>

#include "locks.h"

//***************************************************************************
// Pin Menu Item
//***************************************************************************

class cPinMenuItem : public cOsdItem
{
      
   public:
   
      cPinMenuItem(const char* title, int aAction);

      int getAction() { return action; }

  protected:

      int action;

};

//***************************************************************************
// Pin Menu
//***************************************************************************

class cPinMenu : public cOsdMenu
{
   public:

      enum Item
      {
         miLock,
         miAddCurrentChannel,
         miDelChannel,
         miEditChannelList,
         miEditBroadcastList,
         miAddCurrentBroadcast,
         miEditPluginList
      };
   
      cPinMenu(const char* title, cLockItems* theChannels, 
               cLockedBroadcasts* theBroadcasts, cLockItems* thePlugins);
      ~cPinMenu();
      
      virtual eOSState ProcessKey(eKeys key);

      int currentAction() { return ((cPinMenuItem*)Get(Current()))->getAction(); }
      int addCurrentChannel();
      int addCurrentBroadcast();

  protected:

      cLockItems* lockedChannels;
      cLockedBroadcasts* lockedBroadcasts;
      cLockItems* lockedPlugins;
};

//***************************************************************************
// Channel Menu Item
//***************************************************************************

class cChannelMenuItem : public cOsdItem
{
      
   public:
   
      cChannelMenuItem(cLockItem* aChannel);
      ~cChannelMenuItem();
      const char* GetTitle()         { return channel->GetName(); }
      cLockItem* GetChannel()        { return channel; }

   protected:

      cLockItem* channel;
};

//***************************************************************************
// Channel Menu
//***************************************************************************

class cChannelMenu : public cOsdMenu
{
   public:
 
      cChannelMenu(const char* title, cLockItems* theChannels);
      ~cChannelMenu();
      
      eOSState ProcessKey(eKeys key);

   protected:

      cLockItems* lockedChannels;
};

//***************************************************************************
// Channel Edit Menu
//***************************************************************************

class cChannelEditMenu : public cMenuSetupPage
{
   public:

      enum Misc
      {
         sizeChannelNameMax = 50
      };

      cChannelEditMenu(cLockItem* aChannel);
      ~cChannelEditMenu();
      
      void Store(void);

   protected:

      cLockItem* channel;
      char name[sizeChannelNameMax+TB];
      int active;
      int start;
      int end;
};


//***************************************************************************
// Broadcast Menu Item
//***************************************************************************

class cBroadcastMenuItem : public cOsdItem
{
      
   public:
   
      cBroadcastMenuItem(cLockedBroadcast* aBroadcast);
      ~cBroadcastMenuItem();
      const char* GetTitle()             { return broadcast->GetName(); }
      cLockedBroadcast* GetBroadcast()   { return broadcast; }

   protected:

      cLockedBroadcast* broadcast;
};

//***************************************************************************
// Broadcast Menu
//***************************************************************************

class cBroadcastMenu : public cOsdMenu
{
   public:
 
      cBroadcastMenu(const char* title, cLockedBroadcasts* theBroadcasts);
      ~cBroadcastMenu();
      
      eOSState ProcessKey(eKeys key);

   protected:

      cLockedBroadcasts* lockedBroadcasts;
};

//***************************************************************************
// Broadcast Edit Menu
//***************************************************************************

class cBroadcastEditMenu : public cMenuSetupPage
{
   public:

      enum Misc
      {
         sizePatternMax = 50,
         sizeTitleMax = 50
      };

      cBroadcastEditMenu(cLockedBroadcast* aBroadcast);
      ~cBroadcastEditMenu();
      
      void Store(void);

   protected:

      cLockedBroadcast* broadcast;
      char pattern[sizePatternMax+TB];
      char title[sizeTitleMax+TB];
      int active;
      int searchMode;
};

//***************************************************************************
// Plugin Menu Item
//***************************************************************************

class cPluginMenuItem : public cOsdItem
{
      
   public:
   
      cPluginMenuItem(cLockItem* aPlugin);
      ~cPluginMenuItem();
      const char* GetTitle()         { return item->GetName(); }
      cLockItem* GetPlugin()         { return item; }

   protected:

      cLockItem* item;
};

//***************************************************************************
// Plugin Menu
//***************************************************************************

class cPluginMenu : public cOsdMenu
{
   public:
 
      cPluginMenu(const char* title, cLockItems* thePlugins);
      ~cPluginMenu();
      
      eOSState ProcessKey(eKeys key);

   protected:

      cLockItems* lockedPlugins;
};

//***************************************************************************
// Plugin Edit Menu
//***************************************************************************

class cPluginEditMenu : public cMenuSetupPage
{
   public:

      enum Misc
      {
         sizePluginNameMax = 50
      };

      cPluginEditMenu(cLockItem* aPlugin);
      ~cPluginEditMenu();
      
      void Store(void);

   protected:

      cLockItem* item;
      char name[sizePluginNameMax+TB];
      int active;
      int start;
      int end;
};
