/*
 * See the files COPYING and README for copyright information and how to reach
 * the author.
 *
 *  $Id: menuburn.h,v 1.14 2006/05/16 17:00:19 lordjaxom Exp $
 */

#ifndef VDR_BURN_MENUBURN_H
#define VDR_BURN_MENUBURN_H

#include "menubase.h"
#include "jobs.h"
#include <vector>
#include <utility>
#include <string>
#include <vdr/menuitems.h>

namespace vdr_burn
{

	class job;
	class recording;

	namespace menu
	{
		// --- track_editor ---------------------------------------------------

		class track_editor: public cMenuSetupPage
		{
			typedef std::pair<track_info_list::iterator, int> data_pair;
			typedef std::vector<data_pair> data_list;
			typedef data_list::iterator data_iterator;

		public:
			track_editor(recording& recording_);

		protected:
			void refresh(void);
			void add_track(data_pair& track);
			bool can_move_down(void);
			void set_help_keys(void);
			eOSState dispatch_key(eKeys key);
			void move_down(void);

			virtual void Store(void);
			virtual eOSState ProcessKey(eKeys key);

		private:
			recording& m_recording;
			data_list  m_data;
		};

		// --- title_chooser --------------------------------------------------
		
		class title_chooser: public cOsdMenu
		{
			typedef std::vector<std::string> title_list;

		public:
			title_chooser(const std::string& fileName);

		protected:
			void refresh(void);
			void add_title(const std::string& title);

			virtual eOSState ProcessKey(eKeys key);

		private:
			title_list m_data;
		};

		// --- recordings -----------------------------------------------------
		
		class recordings: public pagebase
		{
		public:
			recordings(void);

		protected:
			void display(void);

			virtual void set_help_keys(void);
			virtual bool menu_closing(void);
			virtual eOSState ok_pressed(void);
			virtual eOSState red_pressed(void);

		private:
			std::string m_basePath;
			int         m_pathLevel;
			bool        m_pathChanged;
		};

		// --- job ------------------------------------------------------------
		
		class job_editor: public pagebase
		{
		public:
			job_editor(void);

		protected:
			void display(void);
			
			virtual void set_help_keys(void);
			virtual eOSState menu_update(void);
			virtual eOSState ok_pressed(void);
			virtual eOSState red_pressed(void);
			virtual eOSState green_pressed(void);
			virtual eOSState yellow_pressed(void);

		private:
			uint m_offset;

			enum item_group
			{
				label,
				recording,
				setup
			};
			// job options that affect the menu page
			struct job_options
			{
				int diskType;
				int storeMode;
				int diskSizeMB;
				int cutOnDemux;
				double jobSizeMB;
				
				job_options(const job& job_):
					diskType( job_.get_disk_type() ),
					storeMode( job_.get_store_mode() ),
					diskSizeMB( job_.get_disk_size_mb() ),
					cutOnDemux( job_.get_cut_on_demux() ),
					jobSizeMB( job_.get_size_mb() ) {}

				bool operator!=(const job_options& rhs)
				{
					return diskType != rhs.diskType || 
							storeMode != rhs.storeMode ||
							diskSizeMB != rhs.diskSizeMB ||
							cutOnDemux != rhs.cutOnDemux ||
							jobSizeMB != rhs.jobSizeMB;
				}
			};

			job_options m_lastOptions;
		};

		// --- status ---------------------------------------------------------
		
		class status: public pagebase
		{
		public:
			status(void);

		protected:
			void display(void);

			virtual void set_help_keys(void);
			virtual eOSState menu_update(void);
			virtual eOSState green_pressed(void);
			virtual eOSState yellow_pressed(void);
		};
	}

}

#endif // VDR_BURN_MENUBURN_H
