ms_open.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:10k
源码类别:

DVD

开发平台:

Others

  1. /***********************************************************************/
  2. /* File:    */
  3. /*   Copyright (c) 2000 ZORAN Corporation, All Rights Reserved    */
  4. /*   THIS IS PROPRIETARY SOURCE CODE OF ZORAN CORPORATION             */
  5. /*    */
  6. /* ===========                                                         */
  7. /* Descripton:                                                         */
  8. /* ===========                                                         */
  9. /*                                                                     */
  10. /* Log:                                                                */
  11. /* ===                                                                 */
  12. /* $Name: V_1_09 V_1_08 V_1_07 $                                                            
  13. /* $Header: /SourceCode/I64_Common/I64_Reference/UI/Menu_sys/ms_open.c 3     03-06-19 16:33 Wesleyj $                                                          
  14. /* $Log: /SourceCode/I64_Common/I64_Reference/UI/Menu_sys/ms_open.c $                        
  15.  * 
  16.  * 3     03-06-19 16:33 Wesleyj
  17.  * Remove customer related include
  18.  * 
  19.  * 2     03-03-04 11:36 Hannahh
  20.  * remove customer name from all project.
  21.  * 
  22.  * 1     03-01-14 14:40 Mikelv
  23.  *new setup menu
  24. /* Revision 1.3  2001/07/27 07:19:15  dingming                        
  25. /* Revision 1.1  2001/03/14 03:20:51  cliff                        
  26. /* Initial revision                        
  27. /* Revision 1.18  2001/03/09 03:01:16  leslie                        
  28. /* Fixed MS_create_choice for non-MILLENO                        
  29. /* Revision 1.17  2001/03/09 18:29:43  charlie                        
  30. /* Call action in choice_previous for toggle                        
  31. /* Revision 1.16  2001/03/09 05:12:07  charlie                        
  32. /* Changed MS_create_choice text_list parameter to non-const                        
  33. /* Revision 1.15  2001/02/26 20:05:08  charlie                        
  34. /* Defined choice_down when D_MS_EXTENSIONS not defined                        
  35. /* Revision 1.14  2001/02/26 19:56:59  charlie                        
  36. /* Revision 1.13  2001/02/24 02:16:28  charlie                        
  37. /* Added MS_CHOICE_KEEP_OPEN, MS_CHOICE_LR,                        
  38. /* MS_CHOICE_UD, wraparound.                        
  39. /* Revision 1.12  2000/11/16 23:05:14  charlie                        
  40. /* Use C_FOCUSED, C_ASCII, BACK_COLOR                        
  41. /* Revision 1.11  2000/11/09 04:36:22  cliff                        
  42. /***********************************************************************/
  43. //#include <stdio.h>
  44. //#include <stdlib.h>
  45. //#include <string.h>
  46. //#include "sysdefs.h"
  47. //#include "osd_drv.h"
  48. //#include "ms_wdgt.h"
  49. //#include "ms_lib.h"
  50. //#include "....decoderosdrendr.h"
  51. #include <stdio.h>
  52. #include <stdlib.h>
  53. #include <string.h>
  54. #include "menumenu_var.h"
  55. #include "uimenu_sysms_lib.h"
  56. #include "Includesysdefs.h"
  57. #include "Decoderosdrendr.h"
  58. #include "UIMenu_Sysosd_drv.h"
  59. #include "UIMenu_Sysms_wdgt.h"
  60. #define CHOICE_HEIGHT MS_LINE_HEIGHT
  61. #define LAST_CHOICE (choice->text_list->size-1)
  62. static void display (MS_OPEN_CHOICE *choice, char focus)
  63. {
  64. MS_WIDGET *widget = (MS_WIDGET *)choice;
  65. OSD_PutText(widget->pos.x,
  66. widget->pos.y,
  67. widget->pos.w,
  68. widget->pos.h,
  69. FG_COLOR(widget->color),
  70. BACK_COLOR(widget, focus),
  71. (void *)choice->text,
  72. ALIGN_CENTER,
  73. !C_ASCII);
  74. }
  75. static int choice_previous(MS_OPEN_CHOICE *choice)
  76. {
  77. MS_COLOR backcolor = choice->widget.color;
  78. choice->widget.color = I_COLOR;
  79.    if ( !MS_IS_CHOICE_OPEN(choice) )
  80. {
  81. choice->widget.color = backcolor;
  82. return 0;
  83. }
  84. if ( IS_OPENABLE_LIST(choice) )
  85. {
  86. if (choice->current_choice)
  87. {
  88. OSD_PutText(
  89. choice->choice_pos.x,
  90. choice->choice_pos.y + choice->current_choice * CHOICE_HEIGHT,
  91. choice->choice_pos.w,
  92. CHOICE_HEIGHT,
  93. FG_COLOR(choice->widget.color),
  94. BG_COLOR(choice->widget.color),
  95. (void *)choice->text_list->head[choice->current_choice],
  96. MS_JUST(choice),
  97. !C_ASCII);
  98. choice->current_choice --;
  99. OSD_PutText(
  100. choice->choice_pos.x,
  101. choice->choice_pos.y+choice->current_choice * CHOICE_HEIGHT,
  102. choice->choice_pos.w,
  103. CHOICE_HEIGHT,
  104. FG_COLOR(choice->widget.color),
  105. FOCUS_COLOR(choice->widget.color),
  106. (void *)choice->text_list->head[choice->current_choice],
  107. MS_JUST(choice),
  108. !C_ASCII);
  109. }
  110. }
  111. else
  112. // <<< ZORAN CDE0309 : Code robustness
  113. // Choice is a toggle
  114. {
  115. if (choice->current_choice) {
  116. choice->current_choice --;
  117. }
  118. else {
  119. choice->current_choice = LAST_CHOICE;
  120. }
  121. OSD_PutText(
  122. choice->widget.pos.x,
  123. choice->widget.pos.y,
  124. choice->widget.pos.w,
  125. choice->widget.pos.h,
  126. FG_COLOR(choice->widget.color),
  127. FOCUS_COLOR(choice->widget.color),
  128. (void *)choice->text_list->head[choice->current_choice],
  129. ALIGN_CENTER,
  130. !C_ASCII);
  131. }
  132. choice->widget.color = backcolor;
  133. return 1;
  134. }
  135. #define choice_down   choice_next
  136. static int choice_next(MS_OPEN_CHOICE *choice)
  137. {
  138. MS_COLOR backcolor = choice->widget.color;
  139. choice->widget.color = I_COLOR;
  140.    if ( !MS_IS_CHOICE_OPEN(choice) )
  141. {
  142. choice->widget.color = backcolor;
  143. return 0;
  144. }
  145.    if ( IS_OPENABLE_LIST(choice) )
  146.    {
  147. if (choice->current_choice < LAST_CHOICE)
  148. {
  149. OSD_PutText(
  150. choice->choice_pos.x,
  151. choice->choice_pos.y + choice->current_choice * CHOICE_HEIGHT,
  152. choice->choice_pos.w,
  153. CHOICE_HEIGHT,
  154. FG_COLOR(choice->widget.color),
  155. BG_COLOR(choice->widget.color),
  156. (void *)choice->text_list->head[choice->current_choice],
  157. MS_JUST(choice),
  158. !C_ASCII);
  159. choice->current_choice ++;
  160. OSD_PutText(
  161. choice->choice_pos.x,
  162. choice->choice_pos.y + choice->current_choice * CHOICE_HEIGHT,
  163. choice->choice_pos.w,
  164. CHOICE_HEIGHT,
  165. FG_COLOR(choice->widget.color),
  166. FOCUS_COLOR(choice->widget.color),
  167. (void *)choice->text_list->head[choice->current_choice],
  168. MS_JUST(choice),
  169. !C_ASCII);
  170. }
  171. }
  172. else
  173. // Choice is a toggle
  174. {
  175.   if (choice->current_choice >= LAST_CHOICE) {
  176. choice->current_choice = 0;
  177. }
  178. else {
  179. choice->current_choice ++;
  180. }
  181. OSD_PutText(
  182. choice->widget.pos.x,
  183. choice->widget.pos.y,
  184. choice->widget.pos.w,
  185. choice->widget.pos.h,
  186. FG_COLOR(choice->widget.color),
  187. FOCUS_COLOR(choice->widget.color),
  188. (void *)choice->text_list->head[choice->current_choice],
  189. ALIGN_CENTER,
  190. !C_ASCII);
  191. }
  192. // success
  193. choice->widget.color = backcolor;
  194. return 1;
  195. }
  196. // ZORAN CDE0222 >>>
  197. static void open_choice(MS_OPEN_CHOICE *choice)
  198. {
  199. unsigned short i;
  200. MS_COLOR backcolor = choice->widget.color;
  201. choice->widget.color = I_COLOR;
  202. ((MS_WIDGET *)choice)->attr |= MS_CHOICE_OPEN;
  203. if ( IS_OPENABLE_LIST(choice) ) 
  204. {
  205. for (i=0;i<choice->text_list->size;i++) {
  206. OSD_PutText(
  207. choice->choice_pos.x,
  208. choice->choice_pos.y+CHOICE_HEIGHT*i,
  209. choice->choice_pos.w,
  210. CHOICE_HEIGHT,
  211. FG_COLOR(choice->widget.color),
  212. BACK_COLOR((MS_WIDGET *) choice, ((choice->current_choice == i) == C_FOCUSED)),
  213. (void *)choice->text_list->head[i],
  214. MS_JUST(choice),
  215. !C_ASCII);
  216. }
  217. }
  218. else 
  219. {
  220. choice_next(choice);
  221. }
  222. choice->widget.color = backcolor;
  223. }
  224. static void close_choice(MS_OPEN_CHOICE *choice)
  225. {
  226. ((MS_WIDGET *)choice)->attr &= (unsigned char) ~MS_CHOICE_OPEN;
  227. if ( IS_OPENABLE_LIST(choice) ) {
  228. OSD_PutRect(
  229. choice->choice_pos.x,
  230. choice->choice_pos.y,
  231. choice->choice_pos.w,
  232. choice->text_list->size*CHOICE_HEIGHT,
  233. BG_COLOR(((MS_WIDGET *)choice)->parent->widget.color)
  234. );
  235. display((MS_WIDGET *)choice,1);
  236. }
  237. }
  238. MS_UOP open_choice_user_op(MS_WIDGET *widget,MS_UOP uop,char param) 
  239. {
  240. MS_OPEN_CHOICE *choice = (MS_OPEN_CHOICE *)widget;
  241. switch (uop) {
  242. case MS_UOP_DELETE:
  243. return 0;
  244. case MS_UOP_DISPLAY:
  245. // MS_DIALOG * dialog = (MS_DIALOG *)screen;
  246. // display(widget,param);
  247. display(choice,param);
  248. widget->attr &= (unsigned char) ~MS_CHOICE_OPEN;
  249. uop = 0;
  250. if(screen->dialog.pwli_focus->widget != widget)
  251. break;
  252. case MS_UOP_ENTER:
  253. if (MS_IS_CHOICE_OPEN(choice)) 
  254. {
  255. if ( IS_TOGGLE(choice) ) 
  256. {
  257. choice_down(choice);
  258. }
  259. // OSD_PutText(widget->pos.x,widget->pos.y,widget->pos.w,widget->pos.h,widget->color.foreground,widget->color.activate,(void *)choice->text_list->head[choice->current_choice],1);
  260. choice->action(choice->current_choice);
  261. // OSD_PutText(widget->pos.x,widget->pos.y,widget->pos.w,widget->pos.h,widget->color.background,widget->color.foreground,(void *)choice->text_list->head[choice->current_choice],1);
  262. // Re-test in case the action changed the screen
  263. // if ( MS_IS_CHOICE_OPEN(choice) )
  264. // {
  265. //   close_choice(choice);
  266. // }
  267. }
  268. else 
  269. {
  270. open_choice(choice);
  271. if ( IS_TOGGLE(choice) )
  272. {
  273.   choice->action(choice->current_choice);
  274.   close_choice(choice);
  275. }
  276. }
  277. uop=0;
  278. break;
  279. case MS_UOP_UP:
  280. if ( IS_OPENABLE_LIST(choice) )
  281. {
  282. if ( choice_previous(choice) )
  283. {
  284.   uop = 0;
  285. }
  286. }
  287. break;
  288. case MS_UOP_RIGHT:
  289. {
  290. close_choice(choice);
  291. }
  292. break;
  293. case MS_UOP_LEFT:
  294. if (MS_IS_CHOICE_OPEN(choice)) {
  295. uop=0;
  296. }
  297. break;
  298. case MS_UOP_DOWN:
  299. if ( IS_OPENABLE_LIST(choice) ) {
  300. if (choice_down(choice)) {
  301. uop=0;
  302. }
  303. }
  304. break;
  305. }
  306. return uop;
  307. }
  308. MS_OPEN_CHOICE *MS_create_open_choice(const MS_POS *pos, MS_COLOR color, const MS_TEXT_LIST *text_list, const MS_POS *choice_pos, void (* action)(int), unsigned char attr,void * text)
  309. {
  310. MS_OPEN_CHOICE *choice;
  311. choice = (MS_OPEN_CHOICE *)malloc(sizeof(MS_OPEN_CHOICE));
  312. choice->widget.pos = *pos;
  313. choice->widget.parent = NO_PARENT;
  314. choice->widget.color = color;
  315. choice->text_list = text_list;
  316. choice->action = action;
  317. choice->current_choice = 0;
  318. choice->choice_pos = *choice_pos;
  319. choice->widget.user_op = open_choice_user_op;
  320. choice->widget.attr = attr;
  321. choice->text = text;
  322. choice->widget.attrh = ALIGN_CENTER;
  323. return choice;
  324. }