
package com.tcl.factory.view;


import android.view.KeyEvent;

import com.tcl.factory.bsp.TV;
import com.tcl.factory.bsp.TVDefine;
import com.tcl.factory.def.DEFS;
import com.tcl.factory.utils.Debug;

public class ParamSettingOverscan extends SubMenu{
	private int sourcetype=0;
	private int Overscantype=0; // 
	
	
public static  String MenuInfos_ParamSettingOverscan[][]={
	{"Source",""},
	{"H Position",""},
	{"H.size",""},
	{"V Position",""},
	{"V.size",""},
};

 	public ParamSettingOverscan()
	{
		super.menuInfos=MenuInfos_ParamSettingOverscan;
		super.menuLabel = "Main\\Param Setting\\Overscan";
		super.setTAG();
		updateMenuInfos();
	}

 	
	public void KeyEvent(int keyCode,int pos){
		super.enterSubMenu(pos);
		switch(keyCode)
		{
		case KeyEvent.KEYCODE_DPAD_LEFT:
		case KeyEvent.KEYCODE_DPAD_RIGHT:
		{		
			switch(pos)
			{
				case 0: changeNextInputSource(keyCode);break;
				case 1: super.ValueHandler(TVDefine.Overscan, keyCode, 0);break;
				case 2: super.ValueHandler(TVDefine.Overscan, keyCode, 1);break;
				case 3: super.ValueHandler(TVDefine.Overscan, keyCode, 2);break;
				case 4: super.ValueHandler(TVDefine.Overscan, keyCode, 3);break;
			}
		}
		break;
		default:
			break;
		}
	}

	/* (non-Javadoc)
	 * Factory
	 */
	@Override
	public void updateMenuInfos() {
		updateCurrentInputSource();
		super.updateValueInfo(TVDefine.Overscan,0, 1);
		super.updateValueInfo(TVDefine.Overscan,1, 2);
		super.updateValueInfo(TVDefine.Overscan,2, 3);
		super.updateValueInfo(TVDefine.Overscan,3, 4);
	}
	
	public void  updateCurrentInputSource(){
		
		menuInfos[0][1]=TV.getSourceType();
		String str=menuInfos[0][1];
		Debug.v("updateCurrentInputSource--------", str);
		if(str.equals("ATV")){
			sourcetype=0;
		}
		else if(str.equals("AV")){
			sourcetype=1;
		}
		else if(str.equals("YPBPR")){
			sourcetype=2;
		}
		else if(str.equals("VGA")){
			sourcetype=3;
		}
		else if(str.equals("HDMI")){
			sourcetype=4;
		}
		else if(str.equals("DTV")){
			sourcetype=5;
		}
		else if(str.equals("USB-STORAGE")){
			sourcetype=6;
		}
		Debug.v("updateCurrentInputSource--------", str);
	}


	void changeNextInputSource(int keyCode){		

		if(keyCode==KeyEvent.KEYCODE_DPAD_RIGHT){
			sourcetype++;
			if(sourcetype>6)
				sourcetype=0;
		}
		else{
			sourcetype--;
			if(sourcetype<0)
				sourcetype=6;
		}
		switch(sourcetype){
		
		case 0:TV.setSource(DEFS.SOURCE_ATV, 1);break;
		case 1:TV.setSource(DEFS.SOURCE_AV, 1);break;
		case 2:TV.setSource(DEFS.SOURCE_YPBPR, 1);break;
		case 3:TV.setSource(DEFS.SOURCE_VGA, 1);break;
		case 4:TV.setSource(DEFS.SOURCE_HDMI, 1);break;
		case 5:TV.setSource(DEFS.SOURCE_DTV, 1);break;
		case 6:TV.setSource(DEFS.SOURCE_STORAGE, 1);break;
		}
	}

}
