/*
 * See the files COPYING and README for copyright information and how to reach 
 * the author.
 *
 *  $Id: menuitems.c,v 1.7 2006/04/24 19:43:37 lordjaxom Exp $
 */

#include "menuitems.h"
#include "jobs.h"
#include "i18n.h"
#include "common.h"
#include "proctools/format.h"
#include "proctools/logger.h"//XXX
#include <vdr/remote.h>
#include <vdr/status.h>
#include <ctype.h>

#define SHIFTTIMEOUT 2

namespace vdr_burn
{

	using namespace std;
	using proctools::format;
	using proctools::logger;

	namespace menu
	{

		// --- text_item ------------------------------------------------------

		text_item::text_item(const std::string& text, bool selectable):
				std::string(text),
				cOsdItem(c_str())
		{
			SetSelectable(selectable);
		}

		// --- job_item -------------------------------------------------------

		job_item::job_item(job* job_, int number, bool done):
				cOsdItem(),
				m_job(job_)
		{
			SetText(cString::sprintf("%d. %s", number, m_job->get_title()));
		}

		// --- recording_item -------------------------------------------------

		recording_item::recording_item(const cRecording* recording_, int level):
				cOsdItem(get_recording_title(recording_, level).c_str()),
				m_recording(recording_),
				m_total(0),
				m_new(0)
		{
			if (level < recording_->HierarchyLevels())
				m_name = Text() + 2;
		}

		void recording_item::add_entry(bool isNew)
		{
			++m_total;
			if (isNew)
				++m_new;
			SetText(cString::sprintf("%d\t%d\t%s", m_total, m_new, 
									 m_name.c_str()));
		}

		// --- recording_edit_item --------------------------------------------

		recording_edit_item::recording_edit_item(recording_list::iterator rec):
				cMenuEditStrItem(rec->get_datetime().c_str(), rec->m_name, 
								 JOBNAMELEN, TitleChars),
				m_recording(rec)
		{
		}

		// --- speed_edit_item ------------------------------------------------

		speed_edit_item::speed_edit_item(const string& name, int& value):
				cMenuEditIntItem(name.c_str(), &value, 0, 32)
		{
			Set();
		}

		void speed_edit_item::Set(void)
		{
			if (*value == 0)
				SetValue(tr("unlimited"));
			else
				cMenuEditIntItem::Set();
		}

	}
}
