/**
 *  GraphTFT plugin for the Video Disk Recorder 
 * 
 *  osd.c - A plugin for the Video Disk Recorder
 *
 *  (c) 2004 Lars Tegeler, Sascha Volkenandt  
 *
 * This code is distributed under the terms and conditions of the
 * GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
 *
 * $Id: osd.c,v 1.3 2004/05/16 14:46:31 lordjaxom Exp $
 *
 **/

#include "common.h"
#include "display.h"
#include "osd.h"
#include "setup.h"

cGraphTFTOsdObject::cGraphTFTOsdObject(cGraphTFTDisplay *display)
{
	_display = display;
}

cGraphTFTOsdObject::~cGraphTFTOsdObject(void)
{

	delete osd;
}

void cGraphTFTOsdObject::Show(void)
{
	d(4,"osd.c: Show()\n");
#if VDRVERSNUM >= 10307
	osd = cOsdProvider::NewOsd(GraphTFTSetup.OSDOffsetX, GraphTFTSetup.OSDOffsetY);
	if (osd) 
	{
		tArea control = { 0, 0, 600, 80, 4 };
		const cFont *font = cFont::GetFont(fontOsd);
		osd->SetAreas(&control, 1);
		cBitmap* _region = new cBitmap(control.Width(), control.Height(), control.bpp, control.x1, control.y1);
		_region->DrawText(5, 10, "graphTFT - Picture beside Picture", clrWhite, clrGray50, font);
		
		osd->DrawRectangle(0,50,150,80, clrRed);
		osd->DrawText(10, 50, "Restart", clrWhite, clrRed,font);
		
		osd->DrawRectangle(150,50,300,80, clrGreen);
		osd->DrawText(160, 50, "Switch", clrBlack, clrGreen,font);
		
		osd->DrawRectangle(300,50,450,80, clrYellow);
		osd->DrawText(310, 50, "Back to...", clrBlack, clrYellow,font);
		
		osd->DrawRectangle(450,50,600,80, clrBlue);
		osd->DrawText(460, 50, "End PbP", clrWhite, clrBlue,font);
		
		osd->DrawBitmap(_region->X0(), _region->Y0(), *_region);
		osd->Flush();
	}
#else
	osd = cOsd::OpenRaw(0, 0);
 	if (osd)
	{
		tWindowHandle control=osd->Create(GraphTFTSetup.OSDOffsetX, GraphTFTSetup.OSDOffsetY, 600, 80, 4, true, false);

		osd->AddColor(clrBackground,control);
		osd->AddColor(clrRed,control);
		osd->AddColor(clrBlue,control);
		osd->AddColor(clrYellow,control);
		osd->AddColor(clrGreen,control);
		osd->AddColor(clrWhite,control);
		osd->Clear();

		osd->Text(5, 10, "graphTFT - Picture beside Picture", clrWhite, clrBackground ,control);
		
		osd->Fill(0,50,150,80, clrRed,control);
		osd->Text(10, 50, "Restart", clrWhite, clrRed,control);
		
		osd->Fill(150,50,300,80, clrGreen,control);
		osd->Text(160, 50, "Switch", clrBlack, clrGreen,control);
		
		osd->Fill(300,50,450,80, clrYellow,control);
		osd->Text(310, 50, "Back to...", clrBlack, clrYellow,control);
		
		osd->Fill(450,50,600,80, clrBlue,control);
		osd->Text(460, 50, "End PbP", clrWhite, clrBlue,control);

		osd->Flush();

	}
#endif
}


eOSState cGraphTFTOsdObject::ProcessKey(eKeys Key)
{
  eOSState state = cOsdObject::ProcessKey(Key);
  if (state == osUnknown) {
     switch (Key & ~k_Repeat) {
       case kUp:	
						break;
       case kDown:	
						break;
       case kRed:
						break;
       case kGreen:		
						break;
       case kYellow:		
						return osEnd;
       case kBlue:		
						return osEnd;
	   case kBack:   return osEnd;
       case kOk:     return osEnd;
       default: return state;
       }

     state = osContinue;
     }
  return state;
}
