⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tidtv_usermenuapi.c

📁 ti的数字电视芯片 tvp9000的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
#include	<stdio.h>
#include	"ucos_ii.h"

#include	"TiDTV_DataType.h"
#include	"TiDTV_GLib.h"
#include	"TiDTV_GUI.h"
#include	"TiDTV_McuComm.h"
#include	"TiDTV_IrKey.h"
#include	"TiDTV_Icon.h"
#include	"TiDTV_Msg.h"
#include	"TiDTV_Menu.h"
//#include	"TiDTV_Utility.h"

#include	"TiDTV_SysCtrl.h"
#include	"TiDTV_Buffers.h"




extern void TiDTV_OsdDrawBitMap(TI_DTV_OSD_SCREEN *pOsdScreen, USHORT IconCode);
extern UINT32 TiDTV_OsdGetStringLength(TI_DTV_OSD_SCREEN *pOsdScreen, USHORT *pString);
extern UINT32 TiDTV_OsdGetStringHeight(TI_DTV_OSD_SCREEN *pOsdScreen, USHORT *pString);
//extern void TiDTV_OsdDrawStringWithAreaInfo(USHORT AreaWidth, USHORT AreaHeight, TI_DTV_OSD_SCREEN *pOsdScreen, USHORT *pString);
//extern void TiDTV_OsdDrawASCIIStringWithAreaInfo(USHORT AreaWidth, USHORT AreaHeight, TI_DTV_OSD_SCREEN *pOsdScreen, char *pString);
extern void TiDTV_BackupImage(TI_DTV_OSD_SCREEN *pOsdScreen, short x, short y, short w, short h, UCHAR *pImgBuf);
extern void TiDTV_RestoreImage(TI_DTV_OSD_SCREEN *pOsdScreen, short x, short y, short w, short h, UCHAR *pImgBuf);



static void TiDTV_DisplayMenuCheckBoxItemType(USHORT SelectedFlag, USHORT SelCursorIndex, USHORT UnSelCursorIndex, short *  UserPreferOffset, USHORT * LeafArray );
static void TiDTV_RestoreMenuCheckBoxItemType(USHORT SelectedFlag, USHORT SelCursorIndex, USHORT UnSelCursorIndex, short *  UserPreferOffset, USHORT * LeafArray );

unsigned char InRadioBox = 0;
unsigned short CurrentRadioBoxItem = 0;
unsigned char InCheckBox = 0;
unsigned short CurrentCheckBoxItem = 0;
unsigned short CurrentInfo_Index;
TI_DTV_MENU_NODE_NAVIGATION *CurrentNavigation;




/*******************************************************************************
*	@RoutineName:: TiDTV_UpdateInformationBar
*
*	@Description:: update information
*
*	@Input		:: TI_DTV_MENU_NODE * pMenuNode,USHORT Property
*					
*	@Output		:: none
*
*	@Return	int	:: none
*******************************************************************************/

void TiDTV_UpdateInformationBar(USHORT STRING_INDEX, UCHAR Color)
{
	USHORT i,xPos,yPos,Origin_x,Origin_y, Origin_w;
	USHORT  Bmp_index;
	short	CurrentStringLength;



	Origin_x = SUB_MENU_XPOSITION;
	Origin_y = SUB_MENU_YPOSITION;
	Origin_w = SUB_MENU_WIDTH;

	
	for(i = 0; i < Origin_w; i =  i + MENUPIECE_H_WIDTH)
	{
		if (i == 0)		// if is left up corner
		{
			Bmp_index = BMP_MAINLEFTUP;
		}
		else if (i == Origin_w - MENUPIECE_H_WIDTH) 
		{	// if it's right up corner
			Bmp_index = BMP_MAINRIGHTUP;
		}	
		
		else 
		{	// if it's Center Top edge
			Bmp_index = BMP_MAINCENTERUP;
		}
		xPos = Origin_x + i;
		yPos = Origin_y;
		TiDTV_OsdMove(&TiDTV_OsdScreenMain, xPos, yPos);
		TiDTV_OsdDrawBitMap(&TiDTV_OsdScreenMain, Bmp_index);
	}

	if(STRING_INDEX != NULL)
	{
		CurrentStringLength = (short)TiDTV_OsdGetStringLength(&TiDTV_OsdScreenMain, pCurDtvMsgBase[STRING_INDEX]);
		xPos = Origin_x + SUB_MENU_WIDTH/2 - CurrentStringLength/2;
		yPos = SUB_MENU_INFO_YPOSITION;
		TiDTV_OsdSetCharColor(&TiDTV_OsdScreenMain, Color, 0);
		TiDTV_OsdMove(&TiDTV_OsdScreenMain, xPos, yPos);
		TiDTV_OsdDrawString(&TiDTV_OsdScreenMain, pCurDtvMsgBase[STRING_INDEX]);
	}	
}



/***************************************************
*	@RoutineName:: TiDTV_UpdateNavigationBar
*
*	@Description:: update information
*
*	@Input		:: TI_DTV_MENU_NODE * pMenuNode,USHORT Property
*					
*	@Output		:: none
*
*	@Return	int	:: none
****************************************************
*/

void TiDTV_UpdateNavigationBar(TI_DTV_MENU_NODE_NAVIGATION *pNavigation, UINT32 Property)
{
	USHORT xPos;

	if(pNavigation != 0)
	{
		xPos = SUB_MENU_XPOSITION + 70;
		
		TiDTV_OsdMove(&TiDTV_OsdScreenMain, xPos, SUB_MENU_NAVIGATION_YPOSITION);
		TiDTV_OsdDrawBitMap(&TiDTV_OsdScreenMain, pNavigation->Confirm_SetValue);
		
		xPos = xPos + SUB_MENU_NAVIGATION_SPACE + 10;

		TiDTV_OsdMove(&TiDTV_OsdScreenMain, xPos, SUB_MENU_NAVIGATION_YPOSITION);
		TiDTV_OsdDrawBitMap(&TiDTV_OsdScreenMain, pNavigation->Cancel);

		xPos = xPos + SUB_MENU_NAVIGATION_SPACE;
		
		TiDTV_OsdMove(&TiDTV_OsdScreenMain, xPos, SUB_MENU_NAVIGATION_YPOSITION);
		TiDTV_OsdDrawBitMap(&TiDTV_OsdScreenMain, pNavigation->Move);

		xPos = xPos + SUB_MENU_NAVIGATION_SPACE - 10;
		TiDTV_OsdMove(&TiDTV_OsdScreenMain, xPos, SUB_MENU_NAVIGATION_YPOSITION);
		TiDTV_OsdDrawBitMap(&TiDTV_OsdScreenMain, pNavigation->Exit);
	}
	return;
}


/*******************************************************************************
*	@RoutineName:: TiDTV_UpdateAccessory
*
*	@Description:: update information
*
*	@Input		:: USHORT String_Index, TI_DTV_MENU_NODE_NAVIGATION *Navigation
*					
*	@Output		:: none
*
*	@Return	int	:: none
*******************************************************************************/

void TiDTV_UpdateAccessory(USHORT String_Index, TI_DTV_MENU_NODE_NAVIGATION *Navigation)
{
	if(String_Index != CurrentInfo_Index)
	{
		TiDTV_UpdateInformationBar(String_Index, SUB_MENU_CHARACTER_HIGHTLIGHTCOLOR);
		CurrentInfo_Index = String_Index;
	}
	if(Navigation != CurrentNavigation)
	{
		TiDTV_UpdateNavigationBar(Navigation, 0);
		CurrentNavigation = Navigation;
	}
}


/*******************************************************************************
*	@RoutineName:: TiDTV_DrawGuage
*
*	@Description:: create the main menu and display
*
*	@Input		:: USHORT xPos, USHORT yPos, USHORT Length, short Min, short Max, short Current_Value 
*					
*	@Output		:: none
*
*	@Return	int	:: none
*******************************************************************************/

void   TiDTV_DrawGuage(	UCHAR HighLight, 
						USHORT xPos, USHORT yPos, USHORT Length, 
						short Min, short Max, 
						short Current_Value, short Direction,
						UCHAR FontColor)
{
	USHORT xPos_Current, xPos_End;
	USHORT ForegroundLength, BackgroundLength;
	USHORT FrontBmp_index, BackBmp_index;
	USHORT Abs_Current_Value;
	float  Percentage;
	char pString[5] = {' ', ' ', ' ', ' ', '\0'};


	
	//caculate front/back percentage,and front length	 
	Percentage = (float)(Current_Value - Min)/(float)(Max - Min);
	// foregroundlength must be multiple of 4
	ForegroundLength = (((USHORT)((float)Length * Percentage)/4) * 4);
	// backgroundlength must be multiple of 4 
	BackgroundLength = (Length/4) * 4;
	
	
	// initialize bar 
	if(Direction == 0)
	{
	 
		xPos_End = BackgroundLength + xPos;
		for(xPos_Current = ForegroundLength + xPos; xPos_Current < xPos_End; xPos_Current = xPos_Current + SUB_MENU_GUAGE_STEP_WIDTH) 
		{// each step is 4 pixels
		
			// draw left corner
			if(xPos_Current == xPos)
			{
				BackBmp_index = BMP_GUAGEBACKLEFT;
			}
			// draw rigther corner
			else if(xPos_Current == xPos_End - SUB_MENU_GUAGE_STEP_WIDTH)
			{
				BackBmp_index = BMP_GUAGEBACKRIGHT;
			}
			// draw others 
			else
			{
				BackBmp_index = BMP_GUAGEBACKCENTER;
			}
			
			TiDTV_OsdMove(&TiDTV_OsdScreenMain, xPos_Current, yPos + 10);
			TiDTV_OsdDrawBitMap(&TiDTV_OsdScreenMain, BackBmp_index);
		}		
		xPos_End = ForegroundLength + xPos;
		// draw foreground 
		for(xPos_Current = xPos; xPos_Current < xPos_End; xPos_Current = xPos_Current + SUB_MENU_GUAGE_STEP_WIDTH) 
		{// each step is 4 pixels
			if(xPos_Current == xPos)
			{
				if(HighLight == 0)
				{
					FrontBmp_index = BMP_GUAGEFRONTLEFT;
				}	
				else
				{
					FrontBmp_index = BMP_SELGUAGEFRONTLEFT;
				}
			}
			else if(xPos_Current == xPos_End - SUB_MENU_GUAGE_STEP_WIDTH)
			{
				if(HighLight == 0)
				{
					if(ForegroundLength == BackgroundLength)
					{
						FrontBmp_index = BMP_GUAGEFRONTRIGHT;
					}
					else
					{
						FrontBmp_index = BMP_GUAGEFRONTRIGHTWITHBACK;
					}	
				}
				else
				{
					if(ForegroundLength == BackgroundLength)
					{
						FrontBmp_index = BMP_SELGUAGEFRONTRIGHT;
					}
					else
					{
						FrontBmp_index = BMP_SELGUAGEFRONTRIGHTWITHBACK;	
					}	
				}
			}
			else
			{
				if(HighLight == 0)
				{
					FrontBmp_index = BMP_GUAGEFRONTCENTER;
				}
				else
				{
					FrontBmp_index = BMP_SELGUAGEFRONTCENTER;
				}
			}
			TiDTV_OsdMove(&TiDTV_OsdScreenMain, xPos_Current, yPos + 10);
			TiDTV_OsdDrawBitMap(&TiDTV_OsdScreenMain, FrontBmp_index);
		}		
	}

	TiDTV_OsdSetCharColor(&TiDTV_OsdScreenMain, FontColor, SUB_MENU_CHARACTER_BACKCOLOR);
	

	TiDTV_OsdMove(&TiDTV_OsdScreenMain, BackgroundLength + xPos + 16, yPos);
	TiDTV_OsdDrawAsciiStr(&TiDTV_OsdScreenMain, pString);

	// write current chars
	if (Current_Value < 0)
	{
		// yPos - 5 is to make string is at the same y position with guage
		pString[0] = '-'; 
		TiDTV_OsdMove(&TiDTV_OsdScreenMain, BackgroundLength + xPos + 24, yPos);
	}
	else
	{
		pString[0] = '+'; 
		TiDTV_OsdMove(&TiDTV_OsdScreenMain, BackgroundLength + xPos + 16, yPos);
	}
	Abs_Current_Value = abs(Current_Value);
	pString[3] = '\0';	
	if(Abs_Current_Value >= 10)
	{
		TiDTV_MyInt2Str(Abs_Current_Value, &pString[1], 0, 0);
	}
	else
	{
		pString[1] = '0';
		TiDTV_MyInt2Str(Abs_Current_Value, &pString[2], 0, 0);
	
	}
	TiDTV_OsdDrawAsciiStr(&TiDTV_OsdScreenMain, pString);
//	TiDTV_OsdDrawAsciiStr(&TiDTV_OsdScreenMain, pString);

} 



/*******************************************************************************
*	@RoutineName:: TiDTV_CreateMainFrame
*
*	@Description:: create the main menu and display
*
*	@Input		:: USHORT xPos, USHORT yPos, USHORT Width, USHORT Height
*					
*	@Output		:: none
*
*	@Return	int	:: none
*******************************************************************************/

void TiDTV_CreateMainFrame(USHORT xPos, USHORT yPos, USHORT Width, USHORT Height )
{
	USHORT i,j,xPos_Current,yPos_Current,Origin_x,Origin_y, Origin_w,Origin_h;
	USHORT  Bmp_index;
	short	CurrentStringLength;
	
	if(xPos == 0 && yPos == 0 && Width == 0 && Height == 0)
	{	
		Origin_x = MENU_XPOSITION;
		Origin_y = MENU_YPOSITION;
		Origin_w = MENUPIECE_H_WIDTH * MAIN_MENU_H_STEP;
		Origin_h = MENUPIECE_V_HEIGHT * MAIN_MENU_V_STEP;
	}
	else
	{
		// for future use
	}
	// j is vertical counter, and i is horizontal counter
	for(j = 0; j < Origin_h; j = j + MENUPIECE_V_HEIGHT)
	{
		for(i = 0; i < Origin_w; i =  i + MENUPIECE_H_WIDTH)
		{
			if ((i == 0)&&(j == 0))		// if is left up corner
			{
				Bmp_index = BMP_MAINLEFTUP;
			}
			else if ((i == Origin_w - MENUPIECE_H_WIDTH) && (j == 0)) 
			{	// if it's right up corner
				Bmp_index = BMP_MAINRIGHTUP;
			}	
		
			else if((i == 0)&&(j == Origin_h - MENUPIECE_V_HEIGHT))
			{	// if it's left bottom corner
				Bmp_index = BMP_MAINLEFTBOTTOM;
			}
			else if((i == Origin_w - MENUPIECE_H_WIDTH)
					&&(j == Origin_h - MENUPIECE_V_HEIGHT))
			{	// if it's right bottom corner
				Bmp_index = BMP_MAINRIGHTBOTTOM;
			}
			else if(j == 0)
			{	// if it's Center Top edge
				Bmp_index = BMP_MAINCENTERUP;
			}
			else if(j == Origin_h - MENUPIECE_V_HEIGHT)
			{	// if it's center bottem edge 
				Bmp_index = BMP_MAINCENTERBOTTOM;
			}
			else
			{	// other place
				Bmp_index = BMP_MAINCENTER;
			}

			xPos_Current = Origin_x + i;
			yPos_Current = Origin_y + j;
			TiDTV_OsdMove(&TiDTV_OsdScreenMain, xPos_Current, yPos_Current);
			TiDTV_OsdDrawBitMap(&TiDTV_OsdScreenMain, Bmp_index);

		}	
	}
	
	CurrentStringLength = (short)TiDTV_OsdGetStringLength(&TiDTV_OsdScreenMain, pCurDtvMsgBase[MENU_INDEX]);
		// caculate root title's position
	TiDTV_OsdMove(&TiDTV_OsdScreenMain, (MAIN_MENU_CENTER_XPOSITION - CurrentStringLength/2), MAIN_MENU_TITLE_YPOSITION);

		// set root character attribute 
	TiDTV_OsdSetCharColor(&TiDTV_OsdScreenMain, MAIN_MENU_CHARACTER_HIGHTLIGHTCOLOR, 0);
		// draw root TitleIndex
	TiDTV_OsdDrawString(&TiDTV_OsdScreenMain, pCurDtvMsgBase[MENU_INDEX]);

} 

/*******************************************************************************
*	@RoutineName:: TiDTV_CreateSubFrame

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -