/*
 * See the files COPYING and README for copyright information and how to reach
 * the author.
 *
 *  $Id: render.h,v 1.4 2006/04/17 19:03:45 lordjaxom Exp $
 */

#ifndef VDR_BURN_RENDER_H
#define VDR_BURN_RENDER_H

#include "jobs.h"
#include "proctools/process.h"
#include "proctools/format.h"

extern "C" {
#define X_DISPLAY_MISSING // we don't want to be x-dependent
#include <Imlib2.h>
};

namespace vdr_burn
{

	class cBurnRender: public proctools::process
	{
	private:
		const job&                     mJob;
		recording_list::const_iterator m_current;
		std::string                    mFontPath;
		std::string                    mFontFace;
		int                            mFontSize;

	protected:
		bool InitializeFont(void);
		void InitializeImage(int Width, int Height, bool Alpha,
							 uint32_t Color = 0x00000000);
		bool InitializeImage(int Width, int Height, bool Alpha,
							 const std::string& FileName);
		bool SaveImage(const std::string& FileName);
		void DestroyFont(void);

		bool DrawImage(const std::string& Filename, int X, int Y);
		int  DrawText(const std::string& Text, int X, int Y, int Width, 
					  int Height, int Align = 0, int First = 0);
		void DrawRectangle(int X, int Y, int Width, int Height, uint32_t Color);

		char *WrapText(const std::string& Text, int Width, int &LineHeight);

		bool CreateMainMenuPage(int Page, int Count);
		bool CreateMainMenuButtons(int Page, int Count);
		bool CreateMainMenu(void);

		bool CreateTitleMenuPage(int &Lines, int Page);
		bool CreateTitleMenuButtons(int Lines, int Page);
		bool CreateTitleMenu(void);

		std::string GetFontName(void) const;

	protected:
		virtual std::string info(pid_t pid);
		virtual int run(void);

	public:
		cBurnRender(const job& job_);

		bool Render(void);
	};

	inline 
	std::string cBurnRender::GetFontName(void) const
	{
		return proctools::format("{0}/{1}") % mFontFace % mFontSize;
	}

}

#endif // VDR_BURN_RENDER_H
