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

DVD

开发平台:

Others

  1. /* **************************************************************************************
  2.  *  Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
  3.  *  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
  4.  *
  5.  *  File: $Workfile: MS_Multi_ex.c $             
  6.  *
  7.  * Description:
  8.  * ============
  9.  * 
  10.  * 
  11.  * Log:
  12.  * ====
  13.  * $Revision: 13 $
  14.  * Last Modified by $Author: Rogerl $ at $Modtime: 03-06-14 21:39 $ 
  15.  ****************************************************************************************
  16.  * Updates:
  17.  ****************************************************************************************
  18.  * $Log: /SourceCode/I64_Common/I64_Reference/UI/Menu_sys/MS_Multi_ex.c $
  19.  * 
  20.  * 13    03-06-14 22:19 Rogerl
  21.  * Tune scrollable indicate arrows
  22.  * 
  23.  * 12    03-05-07 19:12 Frankm
  24.  * up and down arrows.
  25.  * 
  26.  * 11    03-03-26 15:48 Rogerl
  27.  * Add support to scrollable choice
  28.  * 
  29.  * 10    03-03-07 19:57 Rogerl
  30.  * Fix Rectangel around choices
  31.  * 
  32.  * 9     03-03-07 17:18 Rogerl
  33.  * Fix Frame display error
  34.  * 
  35.  * 8     3/05/03 4:51p Rinata
  36.  * Add frame to choice list
  37.  * 
  38.  * 7     03-02-20 22:24 Rogerl
  39.  * Fix help text remain garbage bug
  40.  * 
  41.  * 6     03-02-19 15:57 Janeg
  42.  * Fix open password verify page error.
  43.  * 
  44.  * 5     03-02-14 16:05 Rogerl
  45.  * Add MS_EXT_HELP_CHOICE implementation
  46.  * 
  47.  * 4     03-02-09 14:27 Rogerl
  48.  * Change choice_ex default alignment to ALIGN_LEFT_PAD
  49.  * 
  50.  * 3     03-01-27 20:04 Rogerl
  51.  * Show current choice in act color, change current selection until enter
  52.  * pressed
  53.  * 
  54.  * 2     03-01-18 12:08 Rogerl
  55.  * Handle MS_UOP_ENTER
  56.  * 
  57.  * 1     03-01-17 11:54 Rogerl
  58.  * Add New widgets: MS_COMBO_BUTTON,MS_EXT_BUTTON,MS_choice_ex,ms_slider_e
  59.  * x
  60.  * 
  61.  * 11    23/04/02 9:39 Nirm
  62.  * - Added dependency in "Config.h".
  63.  * 
  64.  * 10    11/03/02 12:51 Nirm
  65.  * Debug message in case of memory allocation failure.
  66.  * 
  67.  * 9     2/27/02 7:02a Tomasp
  68.  * Changed get_blk/rel_blk to malloc,free.
  69.  * 
  70.  * 7     16/01/02 8:57 Nirm
  71.  * Fixed debug-messages.
  72.  * 
  73.  * 6     13/01/02 16:38 Atai
  74.  * Remove old Defines
  75.  * 
  76.  * 5     9/01/02 18:23 Nirm
  77.  * Corrected Include-Paths.
  78.  * 
  79.  * 4     30/12/01 10:02 Atai
  80.  * add explicit casting
  81.  * 
  82.  * 3     23/12/01 17:47 Atai
  83.  * 
  84.  * 2     23/12/01 17:43 Atai
  85.  * Code cleaning
  86.  **************************************************************************************** */
  87. #include "Config.h" // Global Configuration - do not remove!
  88. #ifdef D_PUSHABLE_MENU  //add by Tom for multi language
  89. #ifdef _DEBUG
  90. #include "DebugDbgMain.h"
  91. #undef IFTRACE
  92. #define IFTRACE if (gTraceMenu)
  93. #endif //_DEBUG
  94. #include <stdio.h>
  95. #include <stdlib.h>
  96. #include <string.h>
  97. #include "Includesysdefs.h"
  98. #include "Decoderosdrendr.h"
  99. #include "UIMenu_Sysosd_drv.h"
  100. #include "UIMenu_SysMS_WDGT.H"
  101. #include "UIMenu_Sysms_lib.h"
  102. #ifdef CHOICE_SCROLL_ARROW
  103. #if 0
  104. CONST BYTE down_arrow_btn[]={ 20, 28
  105. , 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xb8, 0xfc, 0xfc, 0x9c, 0xee, 0x1c, 0x08, 0x1c
  106. , 0xee, 0x1c, 0x18, 0x1c, 0xce, 0x1c, 0x38, 0x1c, 0xae, 0x1c, 0x48, 0x1c, 0xae, 0x1c, 0x58, 0x1c
  107. , 0x8e, 0x1c, 0x78, 0x1c, 0x6e, 0x1c, 0x98, 0x1c, 0x4e, 0x1c, 0xa8, 0x1c, 0x4e, 0x1c, 0xb8, 0x1c
  108. , 0x2e, 0x1c, 0xd8, 0x1c, 0x0e, 0x1c, 0xe8, 0x4c, 0xf8, 0x2c, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8
  109. , 0xf8, 0xf8, 0x08
  110. };
  111. CONST BYTE up_arrow_btn[]={ 20, 28
  112. , 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x78, 0x1c, 0xf8, 0x18, 0x1c, 0xf8, 0x18, 0x2c, 0xf8, 0x1c, 0x0e
  113. , 0x1c, 0xe8, 0x1c, 0x1e, 0x1c, 0xc8, 0x1c, 0x2e, 0x1c, 0xb8, 0x1c, 0x4e, 0x1c, 0xa8, 0x1c, 0x5e
  114. , 0x1c, 0x88, 0x1c, 0x7e, 0x1c, 0x68, 0x1c, 0x9e, 0x1c, 0x58, 0x1c, 0xae, 0x1c, 0x38, 0x1c, 0xbe
  115. , 0x1c, 0x28, 0x1c, 0xde, 0xfc, 0xfc, 0xac, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8
  116. , 0xf8, 0xf8, 0x38
  117. };
  118. #else
  119. CONST BYTE down_arrow_btn[]={ 20, 28
  120. , 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xbb, 0xfc, 0xfc, 0x9c, 0xee, 0x1c, 0x0b, 0x1c
  121. , 0xee, 0x1c, 0x1b, 0x1c, 0xce, 0x1c, 0x3b, 0x1c, 0xae, 0x1c, 0x4b, 0x1c, 0xae, 0x1c, 0x5b, 0x1c
  122. , 0x8e, 0x1c, 0x7b, 0x1c, 0x6e, 0x1c, 0x9b, 0x1c, 0x4e, 0x1c, 0xab, 0x1c, 0x4e, 0x1c, 0xbb, 0x1c
  123. , 0x2e, 0x1c, 0xdb, 0x1c, 0x0e, 0x1c, 0xeb, 0x4c, 0xfb, 0x2c, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb
  124. , 0xfb, 0xfb, 0x0b
  125. };
  126. CONST BYTE up_arrow_btn[]={ 20, 28
  127. , 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0x7b, 0x1c, 0xfb, 0x1b, 0x1c, 0xfb, 0x1b, 0x2c, 0xfb, 0x1c, 0x0e
  128. , 0x1c, 0xeb, 0x1c, 0x1e, 0x1c, 0xcb, 0x1c, 0x2e, 0x1c, 0xbb, 0x1c, 0x4e, 0x1c, 0xab, 0x1c, 0x5e
  129. , 0x1c, 0x8b, 0x1c, 0x7e, 0x1c, 0x6b, 0x1c, 0x9e, 0x1c, 0x5b, 0x1c, 0xae, 0x1c, 0x3b, 0x1c, 0xbe
  130. , 0x1c, 0x2b, 0x1c, 0xde, 0xfc, 0xfc, 0xac, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb
  131. , 0xfb, 0xfb, 0x3b
  132. };
  133. #endif
  134. #endif
  135. #define CHOICE_HEIGHT MS_LINE_HEIGHT
  136. #define LAST_CHOICE (choice->text_list->size-1)
  137. static WORD choice_base = 0;
  138. static BYTE choice_cusor = 0;
  139. //  Support external display
  140. static void choice_display_open_value(MS_CHOICE *pmsc, WORD wItemNum, char focus )
  141. {
  142.   OSD_PutText(
  143.   pmsc->choice_pos.x,
  144. #ifdef D_MS_EXTENSIONS
  145. MS_CHOICE_OPEN_VALUE_POS_Y(pmsc, wItemNum),
  146. #else
  147.   pmsc->choice_pos.y + CHOICE_HEIGHT * wItemNum,
  148. #endif // D_MS_EXTENSIONS
  149.   pmsc->choice_pos.w,
  150. #ifdef D_MS_EXTENSIONS
  151.   pmsc->choice_pos.h,
  152. #else
  153.   CHOICE_HEIGHT,
  154. #endif // D_MS_EXTENSIONS
  155. #ifdef D_MS_EXTENSIONS
  156.   FORE_COLOR( pmsc, focus ),
  157. #else
  158.   FG_COLOR(pmsc->widget.color),
  159. #endif
  160.   BACK_COLOR((MS_WIDGET *) pmsc, focus ),
  161.   (void *)pmsc->text_list->head[wItemNum],
  162.   MS_JUST(pmsc),
  163.   !C_ASCII);
  164. }
  165. //  Pass focus, use full color
  166. #ifdef D_MS_EXTENSIONS
  167. static void choice_display_closed_value(MS_CHOICE *pmsc, char focus)
  168. #else
  169. static void choice_display_closed_value(MS_CHOICE *pmsc, WORD back_color)
  170. #endif // D_MS_EXTENSIONS
  171. {
  172.   OSD_SetOrigin( (MS_WIDGET *) pmsc->widget.parent );
  173.   
  174.   OSD_PutText(
  175.   pmsc->widget.pos.x,
  176.   pmsc->widget.pos.y,
  177.   pmsc->widget.pos.w,
  178.   pmsc->widget.pos.h,
  179. #ifdef D_MS_EXTENSIONS
  180.   FORE_COLOR( pmsc, focus),
  181.   BACK_COLOR( pmsc, focus),
  182. #else
  183.   FG_COLOR(pmsc->widget.color),
  184.   back_color,
  185. #endif
  186.   (void *)pmsc->text_list->head[pmsc->current_choice],
  187.   ALIGN_CENTER,
  188.   !C_ASCII);
  189. }
  190. #ifdef D_MS_EXTENSIONS
  191. static void display_open_choice(MS_CHOICE *choice, char focus)
  192. {
  193. unsigned short i;
  194. // Can only do this if width is specified
  195. if ( IS_OPENABLE_LIST(choice) )
  196. {
  197. OSD_SetOrigin( (MS_WIDGET *) choice->widget.parent );
  198. for (i=0;i < LAST_CHOICE + 1;i++)
  199. {
  200. choice_display_open_value( choice, i, ((choice->current_choice == i) ? focus : !C_FOCUSED) );
  201. }
  202. }
  203. }
  204. static void display_closed_choice (MS_WIDGET *widget, char focus)
  205. {
  206. MS_CHOICE *choice = (MS_CHOICE *)widget;
  207. OSD_PutText(widget->pos.x,
  208. widget->pos.y,
  209. widget->pos.w,
  210. widget->pos.h,
  211. #ifdef D_MS_EXTENSIONS
  212. FORE_COLOR(widget, focus),
  213. #else
  214. FG_COLOR(widget->color),
  215. #endif
  216. BACK_COLOR(widget, focus),
  217. (void *)choice->text_list->head[choice->current_choice],
  218. //  Allow all alignments
  219. #ifdef D_MS_EXTENSIONS
  220. MS_JUST(widget),
  221. #else
  222. ALIGN_CENTER,
  223. #endif // D_MS_EXTENSIONS
  224. !C_ASCII);
  225. }
  226. #endif // D_MS_EXTENSIONS
  227. #ifdef D_MS_EXTENSIONS
  228. static void display (MS_WIDGET *widget, char focus)
  229. {
  230. MS_CHOICE *choice = (MS_CHOICE *)widget;
  231. // Fix display of open toggle
  232. if ( IS_OPENABLE_LIST(choice) && MS_IS_CHOICE_OPEN(choice) )
  233.   display_open_choice(widget, focus);
  234. else
  235.   display_closed_choice(widget, focus);
  236. }
  237. #else
  238. static void display (MS_WIDGET *widget, char focus)
  239. {
  240. MS_CHOICE *choice = (MS_CHOICE *)widget;
  241. OSD_PutText(widget->pos.x,
  242. widget->pos.y,
  243. widget->pos.w,
  244. widget->pos.h,
  245. FG_COLOR(widget->color),
  246. BACK_COLOR(widget, focus),
  247. (void *)choice->text_list->head[choice->current_choice],
  248. // Allow all alignments
  249. #ifdef D_MS_EXTENSIONS
  250. MS_JUST(pmsc),
  251. #else
  252. ALIGN_CENTER,  //ALIGN_LEFT,  For choice_pos  Tom.li
  253. #endif // D_MS_EXTENSIONS
  254. !C_ASCII);
  255. }
  256. #endif // D_MS_EXTENSIONS
  257. //  Support toggle with arrows, wraparound
  258. #ifdef D_MS_EXTENSIONS
  259. static void increment_choice(MS_CHOICE *choice)
  260. {
  261.   if ( choice->current_choice < LAST_CHOICE )
  262. choice->current_choice ++;
  263.   else
  264. choice->current_choice = 0;
  265. }
  266. static void decrement_choice(MS_CHOICE *choice)
  267. {
  268.   if ( choice->current_choice )
  269. choice->current_choice --;
  270.   else
  271. choice->current_choice = LAST_CHOICE;
  272. }
  273. #endif // D_MS_EXTENSIONS
  274. static int choice_previous(MS_CHOICE *choice)
  275. {
  276. BYTE i,ucBgColor;
  277. #ifdef D_MS_EXTENSIONS
  278.   if (  IS_OPENABLE_LIST(choice) && !MS_IS_CHOICE_OPEN(choice) )
  279. #else
  280.   if ( !MS_IS_CHOICE_OPEN(choice) )
  281. #endif // D_MS_EXTENSIONS
  282. {
  283. return 0;
  284. }
  285. #ifdef D_MS_EXTENSIONS
  286. if ( !MS_IS_CHOICE_WRAP(choice) && (choice->current_choice == 0) )
  287.   return 0;
  288. #endif // D_MS_EXTENSIONS
  289. if ( IS_OPENABLE_LIST(choice) )
  290. {
  291. #ifdef D_MS_EXTENSIONS
  292. #else
  293. if (0!= choice_cusor)
  294. #endif // D_MS_EXTENSIONS
  295. {
  296. #ifdef D_MS_EXTENSIONS
  297. choice_display_open_value(choice, choice->current_choice, !C_FOCUSED);
  298. decrement_choice(choice);
  299. choice_display_open_value(choice, choice->current_choice, C_FOCUSED);
  300. // When open, don't perform action on next/previous
  301. #else // D_MS_EXTENSIONS
  302. OSD_PutText(
  303. choice->choice_pos.x,
  304. choice->choice_pos.y + choice_cusor * CHOICE_HEIGHT,
  305. choice->choice_pos.w,
  306. CHOICE_HEIGHT,
  307. FG_COLOR(choice->widget.color),
  308. ((choice_cusor+choice_base) != choice->current_choice )? BG_COLOR(choice->widget.color):ACT_COLOR(choice->widget.color),
  309. (void *)choice->text_list->head[choice_cusor+choice_base],
  310. MS_JUST(choice),
  311. !C_ASCII);
  312. // choice->current_choice --;
  313. choice_cusor --;
  314. OSD_PutText(
  315. choice->choice_pos.x,
  316. // choice->choice_pos.y+choice->current_choice * CHOICE_HEIGHT,
  317. choice->choice_pos.y+choice_cusor * CHOICE_HEIGHT,
  318. choice->choice_pos.w,
  319. CHOICE_HEIGHT,
  320. FG_COLOR(choice->widget.color),
  321. FOCUS_COLOR(choice->widget.color),
  322. // (void *)choice->text_list->head[choice->current_choice],
  323. (void *)choice->text_list->head[choice_cusor+choice_base],
  324. MS_JUST(choice),
  325. !C_ASCII);
  326. #endif // D_MS_EXTENSIONS
  327. }
  328. else if(MS_IS_CHOICE_SCROLLABLE(choice)) // Choice is scrollable
  329. {
  330. if(choice_base > 0)    // Scroll UP
  331. {
  332. choice_base --;
  333. for ( i=0;i<MS_GET_CHOICE_SCROLL_RANGE(choice);i++)
  334. {
  335. if (i == 0)
  336. ucBgColor = FOCUS_COLOR(choice->widget.color);
  337. else
  338. if (choice->current_choice == (i+choice_base))
  339. {
  340. ucBgColor = ACT_COLOR(choice->widget.color);
  341. }
  342. else 
  343. ucBgColor = BG_COLOR(choice->widget.color);
  344. OSD_PutText(
  345. choice->choice_pos.x,
  346. choice->choice_pos.y+CHOICE_HEIGHT*i,
  347. choice->choice_pos.w,
  348. CHOICE_HEIGHT,
  349. FG_COLOR(choice->widget.color),
  350. ucBgColor,
  351. (void *)choice->text_list->head[i+choice_base],
  352. MS_JUST(choice),
  353. !C_ASCII);
  354. }
  355. }
  356. }
  357. }
  358. else
  359. {
  360. #ifdef D_MS_EXTENSIONS
  361. decrement_choice(choice);
  362. // Use full color and pass focus
  363. choice_display_closed_value(choice, C_FOCUSED);
  364. //  Perform action on UP/LEFT; Allow NULL actions
  365. if ( !MS_IS_CHOICE_ENTER(choice) && !MS_IS_CHOICE_ACTION_ON_ENTER(choice) )
  366. {
  367.   if ( choice->action )
  368. choice->action(choice->current_choice);
  369. }
  370. #else
  371. if (choice->current_choice) {
  372. choice->current_choice --;
  373. }
  374. else {
  375. choice->current_choice = LAST_CHOICE;
  376. }
  377. OSD_PutText(
  378. choice->widget.pos.x,
  379. choice->widget.pos.y,
  380. choice->widget.pos.w,
  381. choice->widget.pos.h,
  382. FG_COLOR(choice->widget.color),
  383. FOCUS_COLOR(choice->widget.color),
  384. (void *)choice->text_list->head[choice->current_choice],
  385. ALIGN_CENTER,
  386. !C_ASCII);
  387. #endif // D_MS_EXTENSIONS
  388. }
  389. return 1;
  390. }
  391. #ifdef D_MS_EXTENSIONS
  392. #else
  393. #define choice_down   choice_next
  394. #endif // D_MS_EXTENSIONS
  395. static int choice_next(MS_CHOICE *choice)
  396. {
  397. BYTE i,ucBgColor;
  398. WORD lastchoice;
  399. #ifdef D_MS_EXTENSIONS
  400.   if ( IS_OPENABLE_LIST(choice) && !MS_IS_CHOICE_OPEN(choice) )
  401. #else
  402.   if ( !MS_IS_CHOICE_OPEN(choice) )
  403. #endif // D_MS_EXTENSIONS
  404. {
  405. return 0;
  406. }
  407. #ifdef D_MS_EXTENSIONS
  408. if ( !MS_IS_CHOICE_WRAP(choice) && (choice->current_choice == LAST_CHOICE) )
  409.   return 0;
  410. #endif // D_MS_EXTENSIONS
  411.   if ( IS_OPENABLE_LIST(choice) )
  412.   {
  413. #ifdef D_MS_EXTENSIONS
  414. #else
  415. if(MS_IS_CHOICE_SCROLLABLE(choice))
  416. lastchoice = MS_GET_CHOICE_SCROLL_RANGE(choice) -1;
  417. else
  418. lastchoice = choice->text_list->size -1;
  419. // if (choice->current_choice < LAST_CHOICE)
  420. // if ((choice_cusor) < LAST_CHOICE)
  421. if ((choice_cusor) < lastchoice)
  422. #endif // D_MS_EXTENSIONS
  423. {
  424. #ifdef D_MS_EXTENSIONS
  425. choice_display_open_value(choice, choice->current_choice, !C_FOCUSED);
  426. increment_choice(choice);
  427. choice_display_open_value(choice, choice->current_choice, C_FOCUSED);
  428. #else // D_MS_EXTENSIONS
  429. OSD_PutText(
  430. choice->choice_pos.x,
  431. // choice->choice_pos.y + choice->current_choice * CHOICE_HEIGHT,
  432. choice->choice_pos.y + choice_cusor * CHOICE_HEIGHT,
  433. choice->choice_pos.w,
  434. CHOICE_HEIGHT,
  435. FG_COLOR(choice->widget.color),
  436. // BG_COLOR(choice->widget.color),
  437. ((choice_cusor+choice_base)!=choice->current_choice)?BG_COLOR(choice->widget.color):ACT_COLOR(choice->widget.color),
  438. // (void *)choice->text_list->head[choice->current_choice],
  439. (void *)choice->text_list->head[choice_cusor+choice_base],
  440. MS_JUST(choice),
  441. !C_ASCII);
  442. // choice->current_choice ++;
  443. choice_cusor ++;
  444. OSD_PutText(
  445. choice->choice_pos.x,
  446. // choice->choice_pos.y + choice->current_choice * CHOICE_HEIGHT,
  447. choice->choice_pos.y + choice_cusor * CHOICE_HEIGHT,
  448. choice->choice_pos.w,
  449. CHOICE_HEIGHT,
  450. FG_COLOR(choice->widget.color),
  451. FOCUS_COLOR(choice->widget.color),
  452. // (void *)choice->text_list->head[choice->current_choice],
  453. (void *)choice->text_list->head[choice_cusor+choice_base],
  454. MS_JUST(choice),
  455. !C_ASCII);
  456. #endif // D_MS_EXTENSIONS
  457. }
  458. else
  459. if(MS_IS_CHOICE_SCROLLABLE(choice))
  460. {
  461. if( (choice_cusor+choice_base)< (choice->text_list->size-1))
  462.     {  // scroll Down
  463. choice_base ++;
  464. for ( i=0;i<MS_GET_CHOICE_SCROLL_RANGE(choice);i++)
  465. {
  466. if (i == (MS_GET_CHOICE_SCROLL_RANGE(choice)-1))
  467. ucBgColor = FOCUS_COLOR(choice->widget.color);
  468. else
  469. if (choice->current_choice == (i+choice_base))
  470. {
  471. ucBgColor = ACT_COLOR(choice->widget.color);
  472. }
  473. else 
  474. ucBgColor = BG_COLOR(choice->widget.color);
  475. OSD_PutText(
  476. choice->choice_pos.x,
  477. choice->choice_pos.y+CHOICE_HEIGHT*i,
  478. choice->choice_pos.w,
  479. CHOICE_HEIGHT,
  480. FG_COLOR(choice->widget.color),
  481. ucBgColor,
  482. (void *)choice->text_list->head[i+choice_base],
  483. MS_JUST(choice),
  484. !C_ASCII);
  485. }
  486.    
  487.     }
  488. }
  489. }
  490. else
  491. // Choice is a toggle
  492. {
  493. #ifdef D_MS_EXTENSIONS
  494.   increment_choice(choice);
  495.   choice_display_closed_value(choice, C_FOCUSED);
  496. if ( !MS_IS_CHOICE_ENTER(choice) && !MS_IS_CHOICE_ACTION_ON_ENTER(choice) )
  497.     {
  498. if ( choice->action )
  499.   choice->action(choice->current_choice);
  500.   }
  501. #else
  502.   if (choice->current_choice >= LAST_CHOICE) {
  503. choice->current_choice = 0;
  504. }
  505. else {
  506. choice->current_choice ++;
  507. }
  508. OSD_PutText(
  509. choice->widget.pos.x,
  510. choice->widget.pos.y,
  511. choice->widget.pos.w,
  512. choice->widget.pos.h,
  513. FG_COLOR(choice->widget.color),
  514. FOCUS_COLOR(choice->widget.color),
  515. (void *)choice->text_list->head[choice->current_choice],
  516. ALIGN_CENTER,
  517. !C_ASCII);
  518. #endif // D_MS_EXTENSIONS
  519. }
  520. // success
  521. return 1;
  522. }
  523. static void draw_arrow(MS_CHOICE *choice)
  524. {
  525. #ifdef CHOICE_SCROLL_ARROW
  526.                if(MS_IS_CHOICE_SCROLLABLE(choice))
  527.                {
  528.                       WORD listitems = MS_GET_CHOICE_SCROLL_RANGE(choice);
  529.                       WORD totalitems = choice->text_list->size;
  530.                       if (totalitems > listitems)
  531.                       {
  532.                             if (choice_base > 0)
  533.                                    OSD_DrawBitmap(choice->choice_pos.x+C_THICKNESS, choice->choice_pos.y+C_THICKNESS,(char*)up_arrow_btn,0x0B,(0 == choice_cusor)?FOCUS_COLOR(choice->widget.color):0x0B);
  534.                             if (choice_base< (totalitems-listitems))
  535.                              OSD_DrawBitmap(choice->choice_pos.x+C_THICKNESS, choice->choice_pos.y+CHOICE_HEIGHT*(listitems-1),(char*)down_arrow_btn,0x0B,(choice_cusor == (listitems-1))?FOCUS_COLOR(choice->widget.color):0x0B);
  536.                       }
  537.                }
  538. #endif 
  539. }
  540. #ifdef D_MS_EXTENSIONS
  541. static void open_choice(MS_CHOICE *choice, MS_UOP uop)
  542. #else
  543. static void open_choice(MS_CHOICE *choice,char  focus)
  544. #endif // D_MS_EXTENSIONS
  545. {
  546. extern MS_SCREEN *screen;
  547. #ifdef D_MS_EXTENSIONS
  548. #else
  549. unsigned short i;
  550. unsigned char ucBgColor ;
  551. WORD listitems;
  552. #endif // D_MS_EXTENSIONS
  553. ((MS_WIDGET *)choice)->attr |= MS_CHOICE_OPEN;
  554. if ( IS_OPENABLE_LIST(choice) ) {
  555. #ifdef D_MS_EXTENSIONS
  556.   display_open_choice(choice, C_FOCUSED);
  557. #else
  558. if (NO_PARENT !=  choice->widget.parent )
  559. OSD_SetOrigin( (MS_WIDGET *) choice->widget.parent );
  560. else
  561. OSD_SetOrigin( (MS_WIDGET *) screen );
  562. if (focus)
  563. choice_cusor = choice->current_choice;
  564. else
  565. choice_cusor = 0;
  566. choice_base = 0;
  567. listitems = choice->text_list->size;
  568. if(MS_IS_CHOICE_SCROLLABLE(choice))
  569. {
  570. listitems = MS_GET_CHOICE_SCROLL_RANGE(choice);
  571. if (choice->current_choice >= MS_GET_CHOICE_SCROLL_RANGE(choice))
  572. {
  573. choice_base = choice->current_choice - MS_GET_CHOICE_SCROLL_RANGE(choice) +1;
  574. choice_cusor = MS_GET_CHOICE_SCROLL_RANGE(choice)-1;
  575. }
  576. }
  577. for (i=0;i<listitems;i++) {
  578. if (choice->current_choice != (i+choice_base))
  579. {
  580. ucBgColor = BG_COLOR(choice->widget.color);
  581. }
  582. else 
  583. if (focus)
  584. ucBgColor = FOCUS_COLOR(choice->widget.color);
  585. else
  586. ucBgColor = ACT_COLOR(choice->widget.color);
  587. OSD_PutText(
  588. choice->choice_pos.x,
  589. choice->choice_pos.y+CHOICE_HEIGHT*i,
  590. choice->choice_pos.w,
  591. CHOICE_HEIGHT,
  592. FG_COLOR(choice->widget.color),
  593. ucBgColor,
  594. (void *)choice->text_list->head[i+choice_base],
  595. MS_JUST(choice),
  596. !C_ASCII);
  597. }
  598.               draw_arrow(choice);
  599. #endif // D_MS_EXTENSIONS
  600. }
  601. else {
  602. #ifdef D_MS_EXTENSIONS
  603.   switch (uop)
  604.   {
  605.   case MS_UOP_LEFT:
  606.   case MS_UOP_UP:
  607. choice_previous(choice);
  608. break;
  609.   case MS_UOP_ENTER:
  610.   case MS_UOP_RIGHT:
  611.   case MS_UOP_DOWN:
  612. choice_next(choice);
  613. break;
  614.   }
  615. #else
  616. choice_next(choice);
  617. #endif // D_MS_EXTENSIONS
  618. }
  619. }
  620. static void close_choice(MS_CHOICE *choice)
  621. {
  622. ((MS_WIDGET *)choice)->attr &= (unsigned char) ~MS_CHOICE_OPEN;
  623. if ( IS_OPENABLE_LIST(choice) ) {
  624.   OSD_SetOrigin( (MS_WIDGET*)((MS_WIDGET *) choice)->parent );
  625. OSD_PutRect(
  626. choice->choice_pos.x,
  627. choice->choice_pos.y,
  628. choice->choice_pos.w,
  629. #ifdef D_MS_EXTENSIONS
  630. choice->text_list->size * choice->choice_pos.h,
  631. #else
  632. choice->text_list->size*CHOICE_HEIGHT,
  633. #endif // D_MS_EXTENSIONS
  634. BG_COLOR(((MS_WIDGET *)choice)->parent->widget.color)
  635. );
  636. display((MS_WIDGET *)choice, C_FOCUSED);
  637. }
  638. }
  639. MS_UOP choice_ex_user_op(MS_WIDGET *widget, MS_UOP uop, char param) 
  640. {
  641. MS_CHOICE *choice = (MS_CHOICE *)widget;
  642. switch (uop) {
  643. case MS_UOP_DELETE:
  644.   uop = MS_UOP_NOP;
  645.   break;
  646. case MS_UOP_DISPLAY:
  647. // Don't display current choice
  648.   display(widget,param);
  649.    //open_choice(choice,param);
  650. // Add Frame Rect
  651. //if(MS_IS_CHOICE_SCROLLABLE(choice))
  652. //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,MS_GET_CHOICE_SCROLL_RANGE(choice)*CHOICE_HEIGHT,FORE_COLOR(widget, param), C_THICKNESS);
  653. //else
  654. //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,choice->text_list->size*CHOICE_HEIGHT,FORE_COLOR(widget, param), C_THICKNESS);
  655.   uop = MS_UOP_NOP;
  656.   break;
  657. case MS_UOP_UP:
  658. if ( IS_OPENABLE_LIST(choice) )
  659. {
  660. if ( choice_previous(choice) )
  661. {
  662. // Add Frame Rect
  663. draw_arrow(choice);
  664. //if(MS_IS_CHOICE_SCROLLABLE(choice))
  665. //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,MS_GET_CHOICE_SCROLL_RANGE(choice)*CHOICE_HEIGHT,BACK_COLOR(widget, C_FOCUSED), C_THICKNESS);
  666. //else
  667. //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,choice->text_list->size*CHOICE_HEIGHT,BACK_COLOR(widget, C_FOCUSED), C_THICKNESS);
  668.   uop = MS_UOP_NOP;
  669. }
  670. }
  671. break;
  672. case MS_UOP_LEFT:
  673. if (MS_IS_CHOICE_OPEN(choice)) {
  674. uop=MS_UOP_NOP;
  675. }
  676. break;
  677. case MS_UOP_DOWN:
  678. if ( IS_OPENABLE_LIST(choice) ) {
  679. if (choice_down(choice)) {
  680. // Add Frame Rect
  681.                             draw_arrow(choice);
  682. //if(MS_IS_CHOICE_SCROLLABLE(choice))
  683. //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,MS_GET_CHOICE_SCROLL_RANGE(choice)*CHOICE_HEIGHT,BACK_COLOR(widget, C_FOCUSED), C_THICKNESS);
  684. //else
  685. //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,choice->text_list->size*CHOICE_HEIGHT,BACK_COLOR(widget, C_FOCUSED), C_THICKNESS);
  686. uop = MS_UOP_NOP;
  687. }
  688. }
  689. break;
  690. case MS_UOP_ENTER:
  691. if (MS_IS_CHOICE_OPEN(choice)) {
  692. if (NULL != choice->action )
  693. {
  694. // Don't change current choice is no action() active
  695. choice->current_choice = choice_cusor+choice_base;
  696. //open_choice(choice,C_FOCUSED);
  697. close_choice(choice);
  698. // Add Frame Rect
  699. //if(MS_IS_CHOICE_SCROLLABLE(choice))
  700. //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,MS_GET_CHOICE_SCROLL_RANGE(choice)*CHOICE_HEIGHT,BACK_COLOR(widget, C_FOCUSED), C_THICKNESS);
  701. //else
  702. //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,choice->text_list->size*CHOICE_HEIGHT,BACK_COLOR(widget, C_FOCUSED), C_THICKNESS);
  703. choice->action(choice->current_choice);
  704. uop = MS_UOP_NOP;
  705. }
  706. }
  707. else
  708. {
  709. open_choice(choice,C_FOCUSED);
  710. }
  711. break;
  712. }
  713. return uop;
  714. }
  715. #ifdef D_PUSHABLE_MENU
  716. MS_CHOICE *MS_create_choice_ex(CONST MS_POS *pos, MS_COLOR color, CONST MS_TEXT_LIST *text_list, CONST MS_POS *choice_pos, void (* action)(int), unsigned char attr)
  717. #else
  718. MS_CHOICE *MS_create_choice_ex(CONST MS_POS *pos, MS_COLOR color, CONST MS_TEXT_LIST *text_list,  void (* action)(int), unsigned char attr)
  719. #endif
  720. {
  721. MS_CHOICE *choice;
  722. dbg_printf(("MS_create_choicen"));
  723. choice = (MS_CHOICE far*)malloc(sizeof(MS_CHOICE));
  724. #ifdef _DEBUG
  725. if (NULL == choice) {
  726. tr_printf(("FATAL: MS_create_choice() Failed: Low system resources.n"));
  727. return NULL;
  728. }
  729. #endif //_DEBUG
  730. choice->widget.pos = *pos;
  731. choice->widget.parent = NO_PARENT;
  732. choice->widget.color = color;
  733. choice->text_list = text_list;
  734. choice->action = action;
  735. choice->current_choice = 0;
  736. #ifdef D_PUSHABLE_MENU
  737.         choice->choice_pos = *choice_pos;
  738. #else
  739. choice->choice_pos = *pos;
  740. #endif
  741. choice->widget.user_op = choice_ex_user_op;
  742. choice->widget.attr = attr;
  743. choice->widget.attrh = ALIGN_CENTER;
  744. return (MS_CHOICE *)choice;
  745. }
  746. #ifdef D_PUSHABLE_MENU
  747. MS_CHOICE *MS_create_choice_ex_scroll(CONST MS_POS *pos, MS_COLOR color, CONST MS_TEXT_LIST *text_list, CONST MS_POS *choice_pos, void (* action)(int), unsigned char attr,BYTE visible_items)
  748. #else
  749. MS_CHOICE *MS_create_choice_ex_scroll(CONST MS_POS *pos, MS_COLOR color, CONST MS_TEXT_LIST *text_list,  void (* action)(int), 
  750.                                       unsigned char attr, BYTE visible_items)
  751. #endif
  752. {
  753. MS_CHOICE *choice;
  754. dbg_printf(("MS_create_choice_scroll()n"));
  755. #ifdef D_PUSHABLE_MENU
  756.         choice = MS_create_choice_ex( pos, color, text_list,choice_pos, action, attr);
  757. #else
  758. choice = MS_create_choice_ex( pos, color, text_list, action, attr);
  759. #endif
  760. #ifdef _DEBUG
  761. if (NULL == choice) {
  762. tr_printf(("FATAL: MS_create_choice_scroll() Failed: Low system resources.n"));
  763. return NULL;
  764. }
  765. #endif //_DEBUG
  766. choice->widget.attr |= MS_CHOICE_SCROLLABLE;
  767. MS_SET_CHOICE_SCROLL_RANGE(choice,visible_items);
  768. return (MS_CHOICE *)choice;
  769. }
  770. MS_UOP ext_help_choice_user_op(MS_WIDGET *widget, MS_UOP uop, char param) 
  771. {
  772. MS_EXT_HELP_CHOICE *ext_help_choice = (MS_EXT_HELP_CHOICE *)widget;
  773. //MS_CHOICE *choice = (MS_CHOICE *)widget;
  774. switch (uop) {
  775. case MS_UOP_DELETE:
  776.   uop = MS_UOP_NOP;
  777.   break;
  778. case MS_UOP_DISPLAY:
  779. uop = choice_ex_user_op( widget, uop, param);
  780. // OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,widget->pos.h,FORE_COLOR(widget, param), C_THICKNESS);
  781. if (C_FOCUSED != param)
  782. break;
  783. case MS_UOP_UP:
  784. case MS_UOP_DOWN:
  785. uop = choice_ex_user_op( widget, uop, param);
  786. OSD_PutRect(
  787. ext_help_choice->helptext->widget.pos.x,
  788. ext_help_choice->helptext->widget.pos.y,
  789. ext_help_choice->helptext->widget.pos.w,
  790. ext_help_choice->helptext->widget.pos.h,
  791. BG_COLOR(ext_help_choice->helptext->widget.color));
  792. OSD_PutText(
  793. ext_help_choice->helptext->widget.pos.x,
  794. ext_help_choice->helptext->widget.pos.y,
  795. ext_help_choice->helptext->widget.pos.w,
  796. ext_help_choice->helptext->widget.pos.h,
  797. FG_COLOR(ext_help_choice->helptext->widget.color),
  798. BG_COLOR(ext_help_choice->helptext->widget.color),
  799. (void *)ext_help_choice->on_help_list->head[choice_cusor+choice_base],
  800. MS_JUST(ext_help_choice->helptext),
  801. !C_ASCII);
  802. // OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,widget->pos.h,BACK_COLOR(widget, 1), C_THICKNESS);
  803. break;
  804. case MS_UOP_ENTER:
  805. OSD_PutRect(
  806. ext_help_choice->helptext->widget.pos.x,
  807. ext_help_choice->helptext->widget.pos.y,
  808. ext_help_choice->helptext->widget.pos.w,
  809. ext_help_choice->helptext->widget.pos.h,
  810. BG_COLOR(ext_help_choice->helptext->widget.color));
  811. OSD_PutText(
  812. ext_help_choice->helptext->widget.pos.x,
  813. ext_help_choice->helptext->widget.pos.y,
  814. ext_help_choice->helptext->widget.pos.w,
  815. ext_help_choice->helptext->widget.pos.h,
  816. FG_COLOR(ext_help_choice->helptext->widget.color),
  817. BG_COLOR(ext_help_choice->helptext->widget.color),
  818. (void *)ext_help_choice->done_help_list->head[choice_cusor+choice_base],
  819. MS_JUST(ext_help_choice->helptext),
  820. !C_ASCII);
  821. // OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,widget->pos.h,BACK_COLOR(widget, 1), C_THICKNESS);
  822. // Action at last
  823. uop = choice_ex_user_op( widget, uop, param);
  824. break;
  825. case MS_UOP_CLEAR:
  826.        OSD_PutRect(
  827. ext_help_choice->helptext->widget.pos.x,
  828. ext_help_choice->helptext->widget.pos.y,
  829. ext_help_choice->helptext->widget.pos.w,
  830. ext_help_choice->helptext->widget.pos.h,
  831. BG_COLOR(ext_help_choice->helptext->widget.color));
  832. uop = MS_UOP_NOP;
  833.        break;           
  834.       
  835. default:
  836. uop = choice_ex_user_op(widget,uop,param);
  837. break;
  838. }
  839. return uop;
  840. }
  841. MS_EXT_HELP_CHOICE *MS_create_ext_help_choice(CONST MS_POS *pos, MS_COLOR color, 
  842. CONST MS_TEXT_LIST *text_list,  
  843. void (* action)(int),unsigned char attr,
  844.                                         MS_STATIC *helptext, 
  845.                                         CONST MS_TEXT_LIST *on_help_list,
  846.                                         CONST MS_TEXT_LIST *done_help_list
  847.                                         )
  848. {
  849. MS_EXT_HELP_CHOICE *choice;
  850. dbg_printf(("MS_create_ext_help_choice()n"));
  851. choice = (MS_EXT_HELP_CHOICE *)malloc(sizeof(MS_EXT_HELP_CHOICE));
  852. #ifdef _DEBUG
  853. if (NULL == choice) {
  854. tr_printf(("FATAL: MS_create_ext_help_choice() Failed: Low system resources.n"));
  855. return NULL;
  856. }
  857. #endif //_DEBUG
  858. choice->choice.widget.pos = *pos;
  859. choice->choice.widget.parent = NO_PARENT;
  860. choice->choice.widget.color = color;
  861. choice->choice.text_list = text_list;
  862. choice->choice.action = action;
  863. choice->choice.current_choice = 0;
  864. choice->choice.choice_pos = *pos;
  865. choice->choice.widget.user_op = ext_help_choice_user_op;
  866. choice->choice.widget.attr = attr;
  867. choice->choice.widget.attrh = ALIGN_LEFT_PAD;
  868. choice -> helptext = helptext;
  869. choice-> on_help_list = on_help_list;
  870. choice-> done_help_list = done_help_list;
  871. return (MS_EXT_HELP_CHOICE *)choice;
  872. }
  873. MS_EXT_HELP_CHOICE *MS_create_ext_help_choice_scroll(CONST MS_POS *pos, MS_COLOR color, 
  874. CONST MS_TEXT_LIST *text_list,  
  875. void (* action)(int),unsigned char attr,
  876.                                         MS_STATIC *helptext, 
  877.                                         CONST MS_TEXT_LIST *on_help_list,
  878.                                         CONST MS_TEXT_LIST *done_help_list,
  879.                                         BYTE visible_items)
  880. {
  881. MS_EXT_HELP_CHOICE *choice;
  882. dbg_printf(("MS_create_ext_help_choice_scroll()n"));
  883. choice = MS_create_ext_help_choice( pos, color,  text_list, action,attr, helptext, on_help_list, done_help_list);
  884. #ifdef _DEBUG
  885. if (NULL == choice) {
  886. tr_printf(("FATAL: MS_create_ext_help_choice_scroll() Failed: Low system resources.n"));
  887. return NULL;
  888. }
  889. #endif //_DEBUG
  890. choice->choice.widget.attr |= MS_CHOICE_SCROLLABLE;
  891. MS_SET_CHOICE_SCROLL_RANGE(choice,visible_items);
  892. return (MS_EXT_HELP_CHOICE *)choice;
  893. }
  894. #endif  //#ifdef D_PUSHABLE_MENU