/*$cb
 *    This file is a part of OpenMHP VDR plugin.
 *
 *    Copyright (C) 2005 Mikko Novaro <miknov@gmail.com>
 *
 *    See README file for licensing and contact information.
 $ce*/

#include "setup.h"
#include "openmhp.h"

const char *cMenuSetupOpenmhp::bitdepthChoices[] = {"4", "8"}; // Only up to 256 colors are supported: "16", "24", "32"};
const int cMenuSetupOpenmhp::bitdepthChoiceCount = 2;
const char *cMenuSetupOpenmhp::virtualXServerChoices[] =
  {"none", "xvfb", "xvnc"};;
const int cMenuSetupOpenmhp::virtualXServerChoiceCount = 3;
const char *cMenuSetupOpenmhp::openmhpOutputChoices[] = {"discard", "log",
							 "display"};
const int cMenuSetupOpenmhp::openmhpOutputChoiceCount = 3;

cMenuSetupOpenmhp::cMenuSetupOpenmhp(cPluginOpenmhp * OPENMHP)
{
  openmhp = OPENMHP;

  newDitheringEnabled = openmhp->setup->DitheringEnabled;
  newOsdBitdepth = openmhp->setup->OsdBitdepth;
  newOsdScale = openmhp->setup->OsdScale;
  newVirtualXServer = openmhp->setup->VirtualXServer;
  newVirtualXDisplay = openmhp->setup->VirtualXDisplay;
  newOpenmhpOutput = openmhp->setup->OpenmhpOutput;

  newMhpCacheDir = new char[MAXPATHLENGTH+1];
  strcpy(newMhpCacheDir, openmhp->setup->MhpCacheDir);
  
  Add(new cMenuEditStraItem(tr("OSD color depth (bit)"), &newOsdBitdepth,
			    bitdepthChoiceCount, bitdepthChoices));
  Add(new cMenuEditIntItem(tr("OSD size (\%)"), &newOsdScale, 10,100));
  Add(new cMenuEditBoolItem(tr("Enable dithering"), &newDitheringEnabled));
  Add(new cMenuEditStrItem(tr("Mhp cache location"), newMhpCacheDir,
			   MAXPATHLENGTH,
               // file system characters (incomplete, TODO)
               "abcdefghijklmnopqrstuvwxyz/~_-."));
  Add(new cMenuEditStraItem(tr("Virtual X server"), &newVirtualXServer,
			    virtualXServerChoiceCount, virtualXServerChoices));
  Add(new cMenuEditIntItem(tr("Virtual X display number"), &newVirtualXDisplay,
			   0, 100));
  Add(new cMenuEditStraItem(tr("OpenMHP output"), &newOpenmhpOutput,
			    openmhpOutputChoiceCount, openmhpOutputChoices));
}

cMenuSetupOpenmhp::~cMenuSetupOpenmhp() {
    delete(newMhpCacheDir);
}

void cMenuSetupOpenmhp::Store(void)
{
  SetupStore("DitheringEnabled", openmhp->setup->DitheringEnabled =
	     newDitheringEnabled);
  SetupStore("OsdBitdepth", openmhp->setup->OsdBitdepth = newOsdBitdepth);
  SetupStore("VirtualXServer",
	     openmhp->setup->VirtualXServer = newVirtualXServer);
  SetupStore("VirtualXDisplay",
	     openmhp->setup->VirtualXDisplay = newVirtualXDisplay);
  SetupStore("OsdScale", openmhp->setup->OsdScale = newOsdScale);
  SetupStore("OpenmhpOutput",
	     openmhp->setup->OpenmhpOutput = newOpenmhpOutput);
  SetupStore("MhpCacheDir", strcpy(openmhp->setup->MhpCacheDir,
				   newMhpCacheDir));
}
