123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- /*****************************************************************************
- ** app_guiobj_dtv_prognum.c: DTV Program Number Source Code
- **
- ** Description: This file implements DTV Program Number gui object
- **
- ** Copyright(c) 2011 Sunplus Technologies - All Rights Reserved
- **
- ** Author : kun.dai
- **
- ** $Id$
- *****************************************************************************/
- /********************************************************************
- Including Files
- ********************************************************************/
- #include "app_gui.h"
- #include "app_event.h"
- #include "app_data_setting.h"
- #include "app_menumgr.h"
- #include "gobj_mgr.h"
- #include "sysapp_table.h"
- #include "sysapp_if.h"
-
- #include "app_video.h"
- #include "app_audio.h"
- #include "app_scart.h"
-
- #include "app_fileplayer_event.h"
-
- #include "AL_Multimedia_Player_IF.h"
- #include "AL_Multimedia_FileSystem_IF.h"
-
- /******** Sys app internal header files **************/
- #include "MM_selectFileNum.h"
- #include "MM_popmsg_gui.h"
- #ifdef SUPPORT_MEDIA_NUMBER_PLAY
- /********************************************************************
- Macros
- ********************************************************************/
- #define APP_GUIOBJ_SELECTFILE_DEBUG
- #ifdef APP_GUIOBJ_SELECTFILE_DEBUG
- #undef DEBF
- #define DEBF(fmt, arg...) UMFDBG(0,"[MM SelectFileNum][%s:%d]"fmt, __FUNCTION__, __LINE__, ##arg)
- #else
- #define DEBF(fmt, arg...)
- #endif
- #define PROGNUM_REMAIN_TIME 20
- /********************************************************************
- Main Function Declaration
- ********************************************************************/
- static INT32 _MM_SelectFileNum_OnCreate(void **pPrivateData , UINT32 dParameter);
- static INT32 _MM_SelectFileNum_OnRelease(void *pPrivateData);
- static INT32 _MM_SelectFileNum_OnFocused(void *pPrivateData);
- static INT32 _MM_SelectFileNum_OnLoseFocus(void *pPrivateData);
- static INT32 _MM_SelectFileNum_OnTimerUpdate(void *pPrivateData, InteractiveData_t *pPostEventData);
- static INT32 _MM_SelectFileNum_OnEvent(UINT32 dEventID, UINT32 dParam, void *pPrivateData, InteractiveData_t *pPostEventData);
- /********************************************************************
- Global Variables
- ********************************************************************/
- const GUI_Object_Definition_t stMMSelectFileZap=
- {
- GUI_OBJ_CAN_BE_FOCUSED,
- GUI_OBJ_UPDATE_PERIOD, //100 ms
- _MM_SelectFileNum_OnCreate,
- _MM_SelectFileNum_OnRelease,
- _MM_SelectFileNum_OnFocused,
- _MM_SelectFileNum_OnLoseFocus,
- _MM_SelectFileNum_OnTimerUpdate,
- _MM_SelectFileNum_OnEvent,
- };
- static char g_szInputNum[20];
- static INT32 g_i32Timer;
- static INT32 g_i32EVENT10_Timer = -1;
- static UINT8 g_u8InputPattern = 4;
- static UINT8 g_u8InputNumLen = 0;
- static UINT8 g_u8ZeroCnt = 0;
- static UINT32 g_u32InputNum = 0;
- //static HWND h_Text_Input;
- static Boolean g_bOnfocused = FALSE;
- static RegionHandle_t g_dRegionHandle;
- static void _MM_SelectFileNum_InputEnd(void)
- {
- DEBF(" %s is called.\n", __FUNCTION__);
- SYSAPP_IF_SendGlobalEventWithIndex(SYS_APP_FILE_PLAYER, FILE_INTRA_EVENT_SELECT_ZAPPING, g_u32InputNum);
- g_u8ZeroCnt = 0;
- g_u8InputNumLen = 0;
- g_u32InputNum = 0;
- g_i32Timer = -1;
- /* clear fav type */
- //APP_GUIOBJ_DVB_Playback_ClearFavType();
- }
- static void _MM_SelectFileNum_Update(UINT32 InputNum)
- {
- DEBF(" %s is called.\n", __FUNCTION__);
- UINT8 count = 0;
- HWND h_Text_Input = NULL;
- GUI_FUNC_CALL(GEL_GetHandle(IDM_SelectFileNum_control, FilePlayer_E_IDC_TEXT_SelectNum_Text, &h_Text_Input));
- if (InputNum == UI_EVENT_10 - UI_EVENT_0)
- {
- g_u8InputPattern++;
- if (g_u8InputPattern > 4)
- {
- g_u8InputPattern = 1;
- }
- memset(g_szInputNum,0x0,sizeof(g_szInputNum));
- for (count = 0; count < g_u8InputPattern; count ++)
- {
- g_szInputNum[count] = '_';
- }
- g_szInputNum[count] = '\0';
- GUI_FUNC_CALL( GEL_SetParam(h_Text_Input, PARAM_DYNAMIC_STRING, &g_szInputNum));
- g_i32Timer = -1;
- g_u32InputNum = 0;
- g_u8InputNumLen = 0;
- g_i32EVENT10_Timer = 0;
- }
- else
- {
- if (g_u8InputNumLen == 0)
- {
- g_u32InputNum = InputNum;
- }
- else
- {
- g_u32InputNum = g_u32InputNum * 10 + InputNum;
- }
- UINT8 *selectFile = NULL;
- selectFile = Font_getStrByID(NULL, TV_IDS_String_SelectNum);
-
- memset(g_szInputNum,0x0,sizeof(g_szInputNum));
- if (g_u8ZeroCnt == 3)
- {
- snprintf(g_szInputNum,sizeof(g_szInputNum), "%s:000%d", selectFile, g_u32InputNum);
- }
- else if (g_u8ZeroCnt == 2)
- {
- snprintf(g_szInputNum,sizeof(g_szInputNum), "%s:00%d", selectFile, g_u32InputNum);
- }
- else if (g_u8ZeroCnt == 1)
- {
- snprintf(g_szInputNum,sizeof(g_szInputNum), "%s:0%d", selectFile, g_u32InputNum);
- }
- else
- {
- snprintf(g_szInputNum,sizeof(g_szInputNum), "%s:%d", selectFile, g_u32InputNum);
- }
- GUI_FUNC_CALL(GEL_SetParam(h_Text_Input, PARAM_DYNAMIC_STRING, &g_szInputNum));
- if ((InputNum == 0) && (g_u8ZeroCnt == g_u8InputNumLen))
- {
- g_u8ZeroCnt++;
- }
- g_u8InputNumLen ++;
- if (g_u8InputNumLen == g_u8InputPattern)
- {
- g_u8InputNumLen = 0;
- g_u8ZeroCnt = 0;
- g_i32Timer = PROGNUM_REMAIN_TIME;
- }
- else
- {
- g_i32Timer = 0;
- }
- g_i32EVENT10_Timer = -1;
- }
-
- GUI_FUNC_CALL(GEL_SendMsg(h_Text_Input, WM_PAINT, 0));
- GUI_FUNC_CALL(GEL_UpdateOSD());
- }
- static void _MM_SelectFileNum_OpenMenu(UINT32 InputNum)
- {
- DEBF(" %s is called.\n", __FUNCTION__);
- /* Get the region index and create the region */
- g_dRegionHandle = APP_GuiMgr_ActivateRegion(IDM_SelectFileNum_window, OSD_MEDIAPROJECT, FALSE);
- /* Create a window */
- GUI_FUNC_CALL(GEL_CreateMenu(IDM_SelectFileNum_window, g_dRegionHandle));
- _MM_SelectFileNum_Update(InputNum);
- /* Draw a window */
- GUI_FUNC_CALL(GEL_ShowMenu(IDM_SelectFileNum_window));
- GUI_FUNC_CALL(GEL_UpdateOSD());
- }
- static void _MM_SelectFileNum_CloseMenu(void)
- {
- DEBF(" %s is called.\n", __FUNCTION__);
- /* Get the region index and create the region */
- GUI_FUNC_CALL(GEL_DestroyMenu(IDM_SelectFileNum_window, TRUE));
- }
- /********************************************************************
- State Machine Functions
- ********************************************************************/
- /*****************************************************************************
- ** FUNCTION : _MM_SelectFileNum_OnCreate
- **
- ** DESCRIPTION :
- ** DTV ProgNum Gui Object Create
- **
- ** PARAMETERS :
- ** pPrivateData - User Data
- ** dParameter - Special Parameter
- **
- ** RETURN VALUES:
- ** SP_SUCCESS
- *****************************************************************************/
- INT32 _MM_SelectFileNum_OnCreate(void **pPrivateData , UINT32 dParameter)
- {
- DEBF(" %s is called.\n", __FUNCTION__);
- g_u8ZeroCnt = 0;
- g_u8InputNumLen = 0;
- g_u32InputNum = 0;
- g_i32Timer = -1;
- g_i32EVENT10_Timer = -1;
- memset(g_szInputNum,0x0,sizeof(g_szInputNum));
- _MM_SelectFileNum_OpenMenu(dParameter);
- return SP_SUCCESS;
- }
- /*****************************************************************************
- ** FUNCTION : _MM_SelectFileNum_OnRelease
- **
- ** DESCRIPTION :
- ** DTV ProgNum Gui Object Release
- **
- ** PARAMETERS :
- ** pPrivateData - User Data
- **
- ** RETURN VALUES:
- ** SP_SUCCESS
- *****************************************************************************/
- INT32 _MM_SelectFileNum_OnRelease(void *pPrivateData)
- {
- DEBF(" %s is called.\n", __FUNCTION__);
- _MM_SelectFileNum_CloseMenu();
- return SP_SUCCESS;
- }
- /*****************************************************************************
- ** FUNCTION : _MM_SelectFileNum_OnFocused
- **
- ** DESCRIPTION :
- ** DTV ProgNum Gui Object Focused
- **
- ** PARAMETERS :
- ** pPrivateData - User Data
- **
- ** RETURN VALUES:
- ** SP_SUCCESS
- *****************************************************************************/
- INT32 _MM_SelectFileNum_OnFocused(void *pPrivateData)
- {
- DEBF(" %s is called.\n", __FUNCTION__);
- g_bOnfocused = TRUE;
- return SP_SUCCESS;
- }
- /*****************************************************************************
- ** FUNCTION : _MM_SelectFileNum_OnLoseFocus
- **
- ** DESCRIPTION :
- ** DTV ProgNum Gui Object Lose Focused
- **
- ** PARAMETERS :
- ** pPrivateData - User Data
- **
- ** RETURN VALUES:
- ** SP_SUCCESS
- *****************************************************************************/
- INT32 _MM_SelectFileNum_OnLoseFocus(void *pPrivateData)
- {
- DEBF(" %s is called.\n", __FUNCTION__);
- g_bOnfocused = FALSE;
- return SP_SUCCESS;
- }
- /*****************************************************************************
- ** FUNCTION : _MM_SelectFileNum_OnTimerUpdate
- **
- ** DESCRIPTION :
- ** DTV ProgNum Timer Update
- **
- ** PARAMETERS :
- ** pPrivateData - User Data
- ** pPostEventData - Post Event Data
- **
- ** RETURN VALUES:
- ** SP_SUCCESS
- *****************************************************************************/
- INT32 _MM_SelectFileNum_OnTimerUpdate(void *pPrivateData, InteractiveData_t *pPostEventData)
- {
- if (g_i32Timer != -1)
- {
- g_i32Timer++;
- }
- if (g_i32Timer >= PROGNUM_REMAIN_TIME)
- {
- _MM_SelectFileNum_InputEnd();
- }
- if (g_i32EVENT10_Timer != -1)
- {
- g_i32EVENT10_Timer ++;
- }
- if (g_i32EVENT10_Timer >= PROGNUM_REMAIN_TIME)
- {
- pPostEventData->dEventID = GUI_OBJECT_CLOSE;
- g_i32EVENT10_Timer = -1;
- return GUI_OBJECT_POST_EVENT;
- }
- return SP_SUCCESS;
- }
- /*****************************************************************************
- ** FUNCTION : _MM_SelectFileNum_OnEvent
- **
- ** DESCRIPTION :
- ** DTV ProgNumGui Object Dispose Event
- **
- ** PARAMETERS :
- ** dEventID - Event ID
- ** dParam - Param of Event
- ** pPrivateData - User Data
- ** pPostEventData - Post Event Data
- **
- ** RETURN VALUES:
- ** SP_SUCCESS
- *****************************************************************************/
- INT32 _MM_SelectFileNum_OnEvent(UINT32 dEventID, UINT32 dParam,
- void *pPrivateData, InteractiveData_t *pPostEventData)
- {
- DEBF(" %s is called.\n", __FUNCTION__);
- if (dEventID & PASS_TO_SYSAPP)
- {
- return GUI_OBJECT_EVENT_BYPASS;
- }
- switch (dEventID)
- {
- case UI_EVENT_0:
- case UI_EVENT_1:
- case UI_EVENT_2:
- case UI_EVENT_3:
- case UI_EVENT_4:
- case UI_EVENT_5:
- case UI_EVENT_6:
- case UI_EVENT_7:
- case UI_EVENT_8:
- case UI_EVENT_9:
- case UI_EVENT_10:
- _MM_SelectFileNum_Update(dEventID - UI_EVENT_0);
- break;
- case UI_EVENT_ENTER:
- _MM_SelectFileNum_InputEnd();
- break;
- default:
- if (g_bOnfocused)
- {
- {
- pPostEventData->dEventID = GUI_OBJECT_CLOSE;
- }
- return GUI_OBJECT_POST_EVENT | GUI_OBJECT_EVENT_BYPASS;
- }
- else
- {
- return GUI_OBJECT_EVENT_BYPASS;
- }
- }
- return GUI_OBJECT_NO_POST_ACTION;
- }
- #endif
- /*****************************************************************************
- ** $Rev$
- **
- *****************************************************************************/
|