MM_selectFileNum.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /*****************************************************************************
  2. ** app_guiobj_dtv_prognum.c: DTV Program Number Source Code
  3. **
  4. ** Description: This file implements DTV Program Number gui object
  5. **
  6. ** Copyright(c) 2011 Sunplus Technologies - All Rights Reserved
  7. **
  8. ** Author : kun.dai
  9. **
  10. ** $Id$
  11. *****************************************************************************/
  12. /********************************************************************
  13. Including Files
  14. ********************************************************************/
  15. #include "app_gui.h"
  16. #include "app_event.h"
  17. #include "app_data_setting.h"
  18. #include "app_menumgr.h"
  19. #include "gobj_mgr.h"
  20. #include "sysapp_table.h"
  21. #include "sysapp_if.h"
  22. #include "app_video.h"
  23. #include "app_audio.h"
  24. #include "app_scart.h"
  25. #include "app_fileplayer_event.h"
  26. #include "AL_Multimedia_Player_IF.h"
  27. #include "AL_Multimedia_FileSystem_IF.h"
  28. /******** Sys app internal header files **************/
  29. #include "MM_selectFileNum.h"
  30. #include "MM_popmsg_gui.h"
  31. #ifdef SUPPORT_MEDIA_NUMBER_PLAY
  32. /********************************************************************
  33. Macros
  34. ********************************************************************/
  35. #define APP_GUIOBJ_SELECTFILE_DEBUG
  36. #ifdef APP_GUIOBJ_SELECTFILE_DEBUG
  37. #undef DEBF
  38. #define DEBF(fmt, arg...) UMFDBG(0,"[MM SelectFileNum][%s:%d]"fmt, __FUNCTION__, __LINE__, ##arg)
  39. #else
  40. #define DEBF(fmt, arg...)
  41. #endif
  42. #define PROGNUM_REMAIN_TIME 20
  43. /********************************************************************
  44. Main Function Declaration
  45. ********************************************************************/
  46. static INT32 _MM_SelectFileNum_OnCreate(void **pPrivateData , UINT32 dParameter);
  47. static INT32 _MM_SelectFileNum_OnRelease(void *pPrivateData);
  48. static INT32 _MM_SelectFileNum_OnFocused(void *pPrivateData);
  49. static INT32 _MM_SelectFileNum_OnLoseFocus(void *pPrivateData);
  50. static INT32 _MM_SelectFileNum_OnTimerUpdate(void *pPrivateData, InteractiveData_t *pPostEventData);
  51. static INT32 _MM_SelectFileNum_OnEvent(UINT32 dEventID, UINT32 dParam, void *pPrivateData, InteractiveData_t *pPostEventData);
  52. /********************************************************************
  53. Global Variables
  54. ********************************************************************/
  55. const GUI_Object_Definition_t stMMSelectFileZap=
  56. {
  57. GUI_OBJ_CAN_BE_FOCUSED,
  58. GUI_OBJ_UPDATE_PERIOD, //100 ms
  59. _MM_SelectFileNum_OnCreate,
  60. _MM_SelectFileNum_OnRelease,
  61. _MM_SelectFileNum_OnFocused,
  62. _MM_SelectFileNum_OnLoseFocus,
  63. _MM_SelectFileNum_OnTimerUpdate,
  64. _MM_SelectFileNum_OnEvent,
  65. };
  66. static char g_szInputNum[20];
  67. static INT32 g_i32Timer;
  68. static INT32 g_i32EVENT10_Timer = -1;
  69. static UINT8 g_u8InputPattern = 4;
  70. static UINT8 g_u8InputNumLen = 0;
  71. static UINT8 g_u8ZeroCnt = 0;
  72. static UINT32 g_u32InputNum = 0;
  73. //static HWND h_Text_Input;
  74. static Boolean g_bOnfocused = FALSE;
  75. static RegionHandle_t g_dRegionHandle;
  76. static void _MM_SelectFileNum_InputEnd(void)
  77. {
  78. DEBF(" %s is called.\n", __FUNCTION__);
  79. SYSAPP_IF_SendGlobalEventWithIndex(SYS_APP_FILE_PLAYER, FILE_INTRA_EVENT_SELECT_ZAPPING, g_u32InputNum);
  80. g_u8ZeroCnt = 0;
  81. g_u8InputNumLen = 0;
  82. g_u32InputNum = 0;
  83. g_i32Timer = -1;
  84. /* clear fav type */
  85. //APP_GUIOBJ_DVB_Playback_ClearFavType();
  86. }
  87. static void _MM_SelectFileNum_Update(UINT32 InputNum)
  88. {
  89. DEBF(" %s is called.\n", __FUNCTION__);
  90. UINT8 count = 0;
  91. HWND h_Text_Input = NULL;
  92. GUI_FUNC_CALL(GEL_GetHandle(IDM_SelectFileNum_control, FilePlayer_E_IDC_TEXT_SelectNum_Text, &h_Text_Input));
  93. if (InputNum == UI_EVENT_10 - UI_EVENT_0)
  94. {
  95. g_u8InputPattern++;
  96. if (g_u8InputPattern > 4)
  97. {
  98. g_u8InputPattern = 1;
  99. }
  100. memset(g_szInputNum,0x0,sizeof(g_szInputNum));
  101. for (count = 0; count < g_u8InputPattern; count ++)
  102. {
  103. g_szInputNum[count] = '_';
  104. }
  105. g_szInputNum[count] = '\0';
  106. GUI_FUNC_CALL( GEL_SetParam(h_Text_Input, PARAM_DYNAMIC_STRING, &g_szInputNum));
  107. g_i32Timer = -1;
  108. g_u32InputNum = 0;
  109. g_u8InputNumLen = 0;
  110. g_i32EVENT10_Timer = 0;
  111. }
  112. else
  113. {
  114. if (g_u8InputNumLen == 0)
  115. {
  116. g_u32InputNum = InputNum;
  117. }
  118. else
  119. {
  120. g_u32InputNum = g_u32InputNum * 10 + InputNum;
  121. }
  122. UINT8 *selectFile = NULL;
  123. selectFile = Font_getStrByID(NULL, TV_IDS_String_SelectNum);
  124. memset(g_szInputNum,0x0,sizeof(g_szInputNum));
  125. if (g_u8ZeroCnt == 3)
  126. {
  127. snprintf(g_szInputNum,sizeof(g_szInputNum), "%s:000%d", selectFile, g_u32InputNum);
  128. }
  129. else if (g_u8ZeroCnt == 2)
  130. {
  131. snprintf(g_szInputNum,sizeof(g_szInputNum), "%s:00%d", selectFile, g_u32InputNum);
  132. }
  133. else if (g_u8ZeroCnt == 1)
  134. {
  135. snprintf(g_szInputNum,sizeof(g_szInputNum), "%s:0%d", selectFile, g_u32InputNum);
  136. }
  137. else
  138. {
  139. snprintf(g_szInputNum,sizeof(g_szInputNum), "%s:%d", selectFile, g_u32InputNum);
  140. }
  141. GUI_FUNC_CALL(GEL_SetParam(h_Text_Input, PARAM_DYNAMIC_STRING, &g_szInputNum));
  142. if ((InputNum == 0) && (g_u8ZeroCnt == g_u8InputNumLen))
  143. {
  144. g_u8ZeroCnt++;
  145. }
  146. g_u8InputNumLen ++;
  147. if (g_u8InputNumLen == g_u8InputPattern)
  148. {
  149. g_u8InputNumLen = 0;
  150. g_u8ZeroCnt = 0;
  151. g_i32Timer = PROGNUM_REMAIN_TIME;
  152. }
  153. else
  154. {
  155. g_i32Timer = 0;
  156. }
  157. g_i32EVENT10_Timer = -1;
  158. }
  159. GUI_FUNC_CALL(GEL_SendMsg(h_Text_Input, WM_PAINT, 0));
  160. GUI_FUNC_CALL(GEL_UpdateOSD());
  161. }
  162. static void _MM_SelectFileNum_OpenMenu(UINT32 InputNum)
  163. {
  164. DEBF(" %s is called.\n", __FUNCTION__);
  165. /* Get the region index and create the region */
  166. g_dRegionHandle = APP_GuiMgr_ActivateRegion(IDM_SelectFileNum_window, OSD_MEDIAPROJECT, FALSE);
  167. /* Create a window */
  168. GUI_FUNC_CALL(GEL_CreateMenu(IDM_SelectFileNum_window, g_dRegionHandle));
  169. _MM_SelectFileNum_Update(InputNum);
  170. /* Draw a window */
  171. GUI_FUNC_CALL(GEL_ShowMenu(IDM_SelectFileNum_window));
  172. GUI_FUNC_CALL(GEL_UpdateOSD());
  173. }
  174. static void _MM_SelectFileNum_CloseMenu(void)
  175. {
  176. DEBF(" %s is called.\n", __FUNCTION__);
  177. /* Get the region index and create the region */
  178. GUI_FUNC_CALL(GEL_DestroyMenu(IDM_SelectFileNum_window, TRUE));
  179. }
  180. /********************************************************************
  181. State Machine Functions
  182. ********************************************************************/
  183. /*****************************************************************************
  184. ** FUNCTION : _MM_SelectFileNum_OnCreate
  185. **
  186. ** DESCRIPTION :
  187. ** DTV ProgNum Gui Object Create
  188. **
  189. ** PARAMETERS :
  190. ** pPrivateData - User Data
  191. ** dParameter - Special Parameter
  192. **
  193. ** RETURN VALUES:
  194. ** SP_SUCCESS
  195. *****************************************************************************/
  196. INT32 _MM_SelectFileNum_OnCreate(void **pPrivateData , UINT32 dParameter)
  197. {
  198. DEBF(" %s is called.\n", __FUNCTION__);
  199. g_u8ZeroCnt = 0;
  200. g_u8InputNumLen = 0;
  201. g_u32InputNum = 0;
  202. g_i32Timer = -1;
  203. g_i32EVENT10_Timer = -1;
  204. memset(g_szInputNum,0x0,sizeof(g_szInputNum));
  205. _MM_SelectFileNum_OpenMenu(dParameter);
  206. return SP_SUCCESS;
  207. }
  208. /*****************************************************************************
  209. ** FUNCTION : _MM_SelectFileNum_OnRelease
  210. **
  211. ** DESCRIPTION :
  212. ** DTV ProgNum Gui Object Release
  213. **
  214. ** PARAMETERS :
  215. ** pPrivateData - User Data
  216. **
  217. ** RETURN VALUES:
  218. ** SP_SUCCESS
  219. *****************************************************************************/
  220. INT32 _MM_SelectFileNum_OnRelease(void *pPrivateData)
  221. {
  222. DEBF(" %s is called.\n", __FUNCTION__);
  223. _MM_SelectFileNum_CloseMenu();
  224. return SP_SUCCESS;
  225. }
  226. /*****************************************************************************
  227. ** FUNCTION : _MM_SelectFileNum_OnFocused
  228. **
  229. ** DESCRIPTION :
  230. ** DTV ProgNum Gui Object Focused
  231. **
  232. ** PARAMETERS :
  233. ** pPrivateData - User Data
  234. **
  235. ** RETURN VALUES:
  236. ** SP_SUCCESS
  237. *****************************************************************************/
  238. INT32 _MM_SelectFileNum_OnFocused(void *pPrivateData)
  239. {
  240. DEBF(" %s is called.\n", __FUNCTION__);
  241. g_bOnfocused = TRUE;
  242. return SP_SUCCESS;
  243. }
  244. /*****************************************************************************
  245. ** FUNCTION : _MM_SelectFileNum_OnLoseFocus
  246. **
  247. ** DESCRIPTION :
  248. ** DTV ProgNum Gui Object Lose Focused
  249. **
  250. ** PARAMETERS :
  251. ** pPrivateData - User Data
  252. **
  253. ** RETURN VALUES:
  254. ** SP_SUCCESS
  255. *****************************************************************************/
  256. INT32 _MM_SelectFileNum_OnLoseFocus(void *pPrivateData)
  257. {
  258. DEBF(" %s is called.\n", __FUNCTION__);
  259. g_bOnfocused = FALSE;
  260. return SP_SUCCESS;
  261. }
  262. /*****************************************************************************
  263. ** FUNCTION : _MM_SelectFileNum_OnTimerUpdate
  264. **
  265. ** DESCRIPTION :
  266. ** DTV ProgNum Timer Update
  267. **
  268. ** PARAMETERS :
  269. ** pPrivateData - User Data
  270. ** pPostEventData - Post Event Data
  271. **
  272. ** RETURN VALUES:
  273. ** SP_SUCCESS
  274. *****************************************************************************/
  275. INT32 _MM_SelectFileNum_OnTimerUpdate(void *pPrivateData, InteractiveData_t *pPostEventData)
  276. {
  277. if (g_i32Timer != -1)
  278. {
  279. g_i32Timer++;
  280. }
  281. if (g_i32Timer >= PROGNUM_REMAIN_TIME)
  282. {
  283. _MM_SelectFileNum_InputEnd();
  284. }
  285. if (g_i32EVENT10_Timer != -1)
  286. {
  287. g_i32EVENT10_Timer ++;
  288. }
  289. if (g_i32EVENT10_Timer >= PROGNUM_REMAIN_TIME)
  290. {
  291. pPostEventData->dEventID = GUI_OBJECT_CLOSE;
  292. g_i32EVENT10_Timer = -1;
  293. return GUI_OBJECT_POST_EVENT;
  294. }
  295. return SP_SUCCESS;
  296. }
  297. /*****************************************************************************
  298. ** FUNCTION : _MM_SelectFileNum_OnEvent
  299. **
  300. ** DESCRIPTION :
  301. ** DTV ProgNumGui Object Dispose Event
  302. **
  303. ** PARAMETERS :
  304. ** dEventID - Event ID
  305. ** dParam - Param of Event
  306. ** pPrivateData - User Data
  307. ** pPostEventData - Post Event Data
  308. **
  309. ** RETURN VALUES:
  310. ** SP_SUCCESS
  311. *****************************************************************************/
  312. INT32 _MM_SelectFileNum_OnEvent(UINT32 dEventID, UINT32 dParam,
  313. void *pPrivateData, InteractiveData_t *pPostEventData)
  314. {
  315. DEBF(" %s is called.\n", __FUNCTION__);
  316. if (dEventID & PASS_TO_SYSAPP)
  317. {
  318. return GUI_OBJECT_EVENT_BYPASS;
  319. }
  320. switch (dEventID)
  321. {
  322. case UI_EVENT_0:
  323. case UI_EVENT_1:
  324. case UI_EVENT_2:
  325. case UI_EVENT_3:
  326. case UI_EVENT_4:
  327. case UI_EVENT_5:
  328. case UI_EVENT_6:
  329. case UI_EVENT_7:
  330. case UI_EVENT_8:
  331. case UI_EVENT_9:
  332. case UI_EVENT_10:
  333. _MM_SelectFileNum_Update(dEventID - UI_EVENT_0);
  334. break;
  335. case UI_EVENT_ENTER:
  336. _MM_SelectFileNum_InputEnd();
  337. break;
  338. default:
  339. if (g_bOnfocused)
  340. {
  341. {
  342. pPostEventData->dEventID = GUI_OBJECT_CLOSE;
  343. }
  344. return GUI_OBJECT_POST_EVENT | GUI_OBJECT_EVENT_BYPASS;
  345. }
  346. else
  347. {
  348. return GUI_OBJECT_EVENT_BYPASS;
  349. }
  350. }
  351. return GUI_OBJECT_NO_POST_ACTION;
  352. }
  353. #endif
  354. /*****************************************************************************
  355. ** $Rev$
  356. **
  357. *****************************************************************************/