📄 emc_channelmanage.c
字号:
/*******************************************************************************
File name : emc_channelmanage.c
Description : channel management
Revision : 1.0
COPYRIGHT (C) EMC-HUST-JRC 2005.
Date Label Auther Comment
---- ---- ------ ---------------------
12-30-2005 Allen Wu Created
*********************************************************************************/
/* Includes --------------------------------------------------------------- */
#include "stdio.h"
#include "string.h"
//#include "Hl_stosd.h"
//#include "OsdRegionInit.h"
#include "gui.h"
#include "osdwrap.h"
#include "loadchannels.h"
#include "UIPositionDef.h"
//#include "cmdcontrol.h"
#include "emc_font.h"
#include "emc_menustate.h"
#include "emc_channeldisplay.h"
#include "emc_channelmanage.h"
#include "pics/data_bitmap_ch_favor.h"
#include "pics/data_struct_ch_favor.h"
#include "pics/data_bitmap_ch_lock.h"
#include "pics/data_struct_ch_lock.h"
#include "pics/data_bitmap_confirm_delete.h"
#include "pics/data_struct_confirm_delete.h"
#define MAX_ITEMS_IN_CHANNELMANAGEMENT 7
static int iChOffInChManagement = 0;/*Current Channel offset in Channel Management*/
static int iTransOffInChManagement = 0;/*Current Transponder offset in Channel Management */
static BOOL bChannelManage = TRUE;
extern TRANSPONDER_LIST *pstTransponderList;
extern TRANSPONDER_INFO_STRUCT *pastTransponderInfoTable;
extern PROG_INFO_STRUCT *astProgInfoTable;
extern short int sProgIndex2bRetrieved;
extern int iProgNumberBeingRetrieved;
extern int iCurrentProgramNo;
extern int iPAL_Mode;
extern int LangSelect;
extern EMCFont_Type EMCFontTypeArray[];
extern dvb_state_e currMenuState;
extern void sttbx_Print(const char *const Format_p, ...);
//extern void msm_ChannelDisplay(MenuAct_LinkId_t eNumber);
extern void transponderDeleteFunc(int iItemOffPassed, int iNoOfValidItems , int iMaxNumOnScreen);
static int InitProgramsDBase()
{
#define MAX_INIT_PROG 5
#define MAX_INIT_TRAN 5
static BOOL bInitialed = FALSE; // always called by Channel Management, but only initial once,
char *aProgramsList[MAX_INIT_PROG][2] = {
/*program name*/ /*program provider name*/ /*THE string size must < 10*/
{"Prog1 ", "Provide1"},
{"Prog2 ", "Provide2"},
{"Prog3 ", "Provide3"},
{"Prog4 ", "Provide4"},
{"Prog5 ", "Provide5"},
};
char *aTransList[MAX_INIT_TRAN] = {
/*transponder name*/
{"trans1"},
{"trans2"},
{"trans3"},
{"trans4"},
{"trans5"},
};
signed char scTransIdx;
signed char ascTransIdx[MAX_INIT_TRAN]; // transponder index in whole array
TRANSPONDER_INFO_STRUCT * pTransInfo = (TRANSPONDER_INFO_STRUCT*)NULL;
short sProgIdx = INVALID_LINK;
int i = 0;
if (bInitialed == TRUE)
return 0;
/*0. delete all programs of all transponder*/
#if 1
while(pstTransponderList->cNoOfValidTransponders)
{
scTransIdx = pstTransponderList->cHeadTransponderIndex;
SRDBE_DeleteProgramsByTransponder(scTransIdx);
DeleteTransponderSlot(scTransIdx);
}
#endif
/*1. Add a transponder */
for(i = 0 ; i<MAX_INIT_TRAN; i++)
{
ascTransIdx[i] = -1;
pTransInfo = SRDBE_AppendTransponderSlot(&ascTransIdx[i]);
if(pTransInfo == (TRANSPONDER_INFO_STRUCT*)NULL)
{
return 0;
}
pTransInfo->Xpdr.Terrestrial.iTransponderFreq = (i+1) * 100;
memcpy(pTransInfo->Xpdr.Terrestrial.acNetworkName, aTransList[i],strlen(aTransList[i]));
}
/*1.2 cheat, set the 1st program's transponder = scTransIdx[3]*/
astProgInfoTable[0].stProgNo.unShort.sHi16 = ascTransIdx[3];
/*2. add programs to the last transponder*/
sttbx_Print("programlist array size [aProgramsList] %d", sizeof(aProgramsList));
sttbx_Print("programlist array size [aProgramsList[0]]%d", sizeof(aProgramsList[0]));
for( i = 0 ; i< MAX_INIT_PROG; i++)
{
sProgIdx = GetFreeProgramSlot();
if (sProgIdx == INVALID_LINK)
{
sttbx_Print("error to get free progslot!\n");
}
++ProgramList->NoOfValidPgms;
astProgInfoTable[sProgIdx].status = ELEMENT_OCCUPIED;
astProgInfoTable[sProgIdx].stProgNo.unShort.sHi16 = ascTransIdx[i];
astProgInfoTable[sProgIdx].bFavoriteStatus = FALSE; /* Clear the favorite status */
astProgInfoTable[sProgIdx].bLockedStatus = FALSE;
memcpy(astProgInfoTable[sProgIdx].cServiceName, aProgramsList[i][0], strlen(aProgramsList[i][0]));
memcpy(astProgInfoTable[sProgIdx].cServiceProviderName, aProgramsList[i][1], strlen(aProgramsList[i][1]));
/* update the linked list*
* by default when it is appended it is TAIL element in the list*/
astProgInfoTable[sProgIdx].sNextProgIndex = INVALID_LINK;
if (ProgramList->HeadProgIndex == INVALID_LINK)
{
/* top in the list*/
ProgramList->HeadProgIndex = ProgramList->TailProgIndex = sProgIdx;
astProgInfoTable[sProgIdx].sPrevProgIndex = INVALID_LINK;
}
else
{
astProgInfoTable[ProgramList->TailProgIndex].sNextProgIndex = sProgIdx;
astProgInfoTable[sProgIdx].sPrevProgIndex = ProgramList->TailProgIndex;
ProgramList->TailProgIndex = sProgIdx;
}
}
/* end of initialization */
bInitialed= TRUE;
return 1;
}
static ST_ErrorCode_t local_drawRoundWindowFrame(STOSD_RegionHandle_t Handle, U32 x, U32 y, U32 w, U32 h, int bordersize, STOSD_Color_t colorlt,STOSD_Color_t colorrb,STOSD_Color_t fillcolor)
{
int i=0;
for(i=0; i<=bordersize;i++)
{
STOSD_DrawLine( Handle, x+bordersize-i, y+i, x+w-1-bordersize/2+i, y+i, colorlt);
STOSD_DrawLine( Handle, x+bordersize-i, y+h-1-i, x+w-1-bordersize/2+i, y+h-1-i, colorrb);
}
for(i=0; i<bordersize;i++)
{
STOSD_DrawLine( Handle, x+i, y+bordersize-i, x+i, y+h-1-bordersize+i, colorlt);
STOSD_DrawLine( Handle, x+w-1-i,y+bordersize-i, x+w-1-i,y+h-1-bordersize+i, colorrb);
}
STOSD_FillRectangle(Handle, x+bordersize , y+bordersize, w-2*bordersize, h-2*bordersize,fillcolor);
}
/*
##############colorLTOuter#######.-
# ****************colorLTInner*********.-
# * .-
# * .-
# * .-
# * .-
................................colorRBInner...............-
------------------colorRBOuter----------
corner_color is the color used to erase the corner backgroud
*/
static ST_ErrorCode_t local_drawRoundWindowFrame1(STOSD_RegionHandle_t Handle, U32 x, U32 y, U32 w, U32 h, STOSD_Color_t colorLTOuter,STOSD_Color_t colorLTInner,STOSD_Color_t colorRBInner,STOSD_Color_t colorRBOuter, STOSD_Color_t corner_color)
{
char dx= 0,dy=0;
STOSD_DrawLine( Handle, x+1, y, x+w-1-1, y, colorLTOuter);
STOSD_DrawLine( Handle, x, y+1, x, y+h-1-1, colorLTOuter);
STOSD_DrawLine( Handle, x+1, y+1, x+w-1-1, y+1, colorLTInner);
STOSD_DrawLine( Handle, x+1, y+1, x+1, y+h-1-1, colorLTInner);
STOSD_DrawLine( Handle, x+1, y+h-1-1, x+w-1-1, y+h-1-1, colorRBInner);
STOSD_DrawLine( Handle, x+w-1-1, y+1, x+w-1-1, y+h-1-1, colorRBInner);
STOSD_DrawLine( Handle, x+1, y+h-1, x+w-1-1, y+h-1, colorRBOuter);
STOSD_DrawLine( Handle, x+w-1,y+1, x+w-1, y+h-1-1, colorRBOuter);
/*draw corner*/
if(w<6||h<6)
return ST_ERROR_FEATURE_NOT_SUPPORTED;
for(dx=0; dx<5; dx++)
for(dy =0; dy<5-dx; dy++)
STOSD_SetPixel(Handle, x+dx, y+dy, corner_color);
STOSD_SetPixel(Handle, x, y+dy, corner_color);
STOSD_SetPixel(Handle, x+dx, y, corner_color);
for(dx=0; dx<5; dx++)
for(dy =0; dy<5-dx; dy++)
STOSD_SetPixel(Handle, x+w-dx, y+dy, corner_color);
STOSD_SetPixel(Handle, x+w, y+dy, corner_color);
STOSD_SetPixel(Handle, x+w-dx, y, corner_color);
for(dx=0; dx<5; dx++)
for(dy =0; dy<5-dx; dy++)
STOSD_SetPixel(Handle, x+dx, y+h-dy, corner_color);
STOSD_SetPixel(Handle, x, y+h-dy, corner_color);
STOSD_SetPixel(Handle, x+dx, y+h, corner_color);
for(dx=0; dx<5; dx++)
for(dy =0; dy<5-dx; dy++)
STOSD_SetPixel(Handle, x+w-dx, y+h-dy, corner_color);
STOSD_SetPixel(Handle, x+w, y+h-dy, corner_color);
STOSD_SetPixel(Handle, x+w-dx, y+h, corner_color);
return ST_NO_ERROR;
}
static ST_ErrorCode_t local_drawRoundWindowFrame2(STOSD_RegionHandle_t Handle, U32 x, U32 y, U32 w, U32 h, STOSD_Color_t colorbright,STOSD_Color_t colormiddle,STOSD_Color_t colordark)
{
STOSD_DrawLine( Handle, x+2, y, x+w-1-2, y, colormiddle);
STOSD_DrawLine( Handle, x+1, y+h-1-1, x+w-1-1, y+h-1-1, colormiddle);
STOSD_DrawLine( Handle, x, y+2, x, y+h-1-2, colormiddle);
STOSD_DrawLine( Handle, x+w-1-1, y+1, x+w-1-1, y+h-1-1, colormiddle);
STOSD_DrawLine( Handle, x+1, y+1, x+w-1-1, y+1, colordark);
STOSD_DrawLine( Handle, x+1, y+1, x+1, y+h-1-1, colordark);
STOSD_DrawLine( Handle, x+w-1-1,y+2, x+w-1-1, y+h-1, colorbright);
STOSD_DrawLine( Handle, x+2, y+h-1, x+w-1, y+h-1, colorbright);
}
/*-----------------------------------------
draw a line with 2pixel width with 2 different color
(xLT,yLT) : the left corner coordinate
length : the length of line
colorTorL: top /left line color
*/
static ST_ErrorCode_t local_drawShadowLinewith2Color(STOSD_RegionHandle_t Handle, U32 xLT, U32 yLT, U32 length, BOOL isHorizon, STOSD_Color_t colorTorL,STOSD_Color_t colorBorR)
{
if(TRUE== isHorizon)
{
STOSD_DrawLine( Handle,xLT,yLT,xLT+length-1,yLT,colorTorL); /*top line*/
STOSD_DrawLine( Handle,xLT,yLT+1,xLT+length-1,yLT+1,colorBorR); /*bottom line*/
}
else
{
STOSD_DrawLine( Handle,xLT, yLT, xLT, yLT+length-1, colorTorL);
STOSD_DrawLine( Handle,xLT+1, yLT, xLT+1, yLT+length-1, colorBorR);
}
}
static ST_ErrorCode_t local_drawCornerwith2Color(STOSD_RegionHandle_t Handle, U32 x, U32 y, U8 corner, STOSD_Color_t colorTorL,STOSD_Color_t colorBorR)
{
}
/*------------------------------------------
the darkness of the colors below grow, from left to right
*/
static STOSD_Color_t light,lightblue,bgCHcolor,blue,darkblue;
/*------------------------------------------
draw label
*/
static void drawCHMLableFrame()
{
//EMCFont_Type fontType = EMCFontTypeArray[LangSelect+4];/*test*/
EMCFont_Type fontType = FONT_MYFONT;
if(bChannelManage)
{
/*--------------erase newwork selected label*/
/*left bottem horizontal*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3,CM_LABEL_Y+CM_LABEL_HEIGHT,CM_LABEL_WIDTH+2, TRUE,bgCHcolor, bgCHcolor);
/*left vertical*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+CM_LABEL_WIDTH,CM_LABEL_Y, CM_LABEL_HEIGHT+1, FALSE,bgCHcolor, bgCHcolor);
/*top horizontal*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+CM_LABEL_WIDTH+1,CM_LABEL_Y,CM_LABEL_WIDTH, TRUE,bgCHcolor, bgCHcolor);
/*right vertical*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+2*CM_LABEL_WIDTH,CM_LABEL_Y, CM_LABEL_HEIGHT+1, FALSE,bgCHcolor, bgCHcolor);
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+2*CM_LABEL_WIDTH+1,CM_LABEL_Y, CM_LABEL_HEIGHT, FALSE,bgCHcolor, bgCHcolor);
/*right bottom horizontal*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+2*CM_LABEL_WIDTH,CM_LABEL_Y+CM_LABEL_HEIGHT, CM_WIDTH-3-2*CM_LABEL_WIDTH-3, TRUE,bgCHcolor, bgCHcolor);
/*------------draw labels as program selected */
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3,CM_LABEL_Y, CM_LABEL_WIDTH+1, TRUE,light, light);
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+CM_LABEL_WIDTH,CM_LABEL_Y, CM_ITEM_HEIGHT+1, FALSE,lightblue, darkblue);
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+CM_LABEL_WIDTH+1,CM_LABEL_Y, CM_ITEM_HEIGHT, FALSE,darkblue, darkblue);
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+CM_LABEL_WIDTH,CM_LABEL_Y+CM_LABEL_HEIGHT, CM_WIDTH-3-CM_LABEL_WIDTH-3, TRUE,light, light);
}
else
{
/*---------erase program selected labels*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3,CM_LABEL_Y, CM_LABEL_WIDTH+1, TRUE,bgCHcolor, bgCHcolor);
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+CM_LABEL_WIDTH,CM_LABEL_Y, CM_ITEM_HEIGHT+1, FALSE,bgCHcolor, bgCHcolor);
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+CM_LABEL_WIDTH+1,CM_LABEL_Y, CM_ITEM_HEIGHT, FALSE,bgCHcolor, bgCHcolor);
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+CM_LABEL_WIDTH,CM_LABEL_Y+CM_LABEL_HEIGHT, CM_WIDTH-3-CM_LABEL_WIDTH-3, TRUE,bgCHcolor, bgCHcolor);
/*-------------draw newwork selected label*/
/*left bottem horizontal*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3,CM_LABEL_Y+CM_LABEL_HEIGHT,CM_LABEL_WIDTH+2, TRUE,light, light);
/*left vertical*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+CM_LABEL_WIDTH,CM_LABEL_Y, CM_LABEL_HEIGHT+1, FALSE,light, light);
/*top horizontal*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+CM_LABEL_WIDTH+1,CM_LABEL_Y,CM_LABEL_WIDTH, TRUE,light, light);
/*right vertical*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+2*CM_LABEL_WIDTH,CM_LABEL_Y, CM_LABEL_HEIGHT+1, FALSE,light, darkblue);
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+2*CM_LABEL_WIDTH+1,CM_LABEL_Y, CM_LABEL_HEIGHT, FALSE,darkblue, darkblue);
/*right bottom horizontal*/
local_drawShadowLinewith2Color(Handle_ProviewWindow, CM_X+3+2*CM_LABEL_WIDTH,CM_LABEL_Y+CM_LABEL_HEIGHT, CM_WIDTH-3-2*CM_LABEL_WIDTH-3, TRUE,light, light);
}
/* erase the headline in label*/
STOSD_FillRectangle(Handle_ProviewWindow, CM_X+3, CM_LABEL_HEADLINE_Y, CM_WIDTH-6,CM_ITEM_HEIGHT-4, bgCHcolor);
if(bChannelManage)
{
EMC_DrawTextRectangle(Handle_ProviewWindow,
CM_ITEM_NUM_X,CM_LABEL_HEADLINE_Y,CM_ITEM_NUM_WIDTH,CM_ITEM_HEIGHT-4,
"No.", JLEFT,fontType,FALSE,
whitecolor,bgCHcolor,bgCHcolor);
EMC_DrawTextRectangle(Handle_ProviewWindow,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -