MS_Multi_ex.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:29k
- /* **************************************************************************************
- * Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: MS_Multi_ex.c $
- *
- * Description:
- * ============
- *
- *
- * Log:
- * ====
- * $Revision: 13 $
- * Last Modified by $Author: Rogerl $ at $Modtime: 03-06-14 21:39 $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /SourceCode/I64_Common/I64_Reference/UI/Menu_sys/MS_Multi_ex.c $
- *
- * 13 03-06-14 22:19 Rogerl
- * Tune scrollable indicate arrows
- *
- * 12 03-05-07 19:12 Frankm
- * up and down arrows.
- *
- * 11 03-03-26 15:48 Rogerl
- * Add support to scrollable choice
- *
- * 10 03-03-07 19:57 Rogerl
- * Fix Rectangel around choices
- *
- * 9 03-03-07 17:18 Rogerl
- * Fix Frame display error
- *
- * 8 3/05/03 4:51p Rinata
- * Add frame to choice list
- *
- * 7 03-02-20 22:24 Rogerl
- * Fix help text remain garbage bug
- *
- * 6 03-02-19 15:57 Janeg
- * Fix open password verify page error.
- *
- * 5 03-02-14 16:05 Rogerl
- * Add MS_EXT_HELP_CHOICE implementation
- *
- * 4 03-02-09 14:27 Rogerl
- * Change choice_ex default alignment to ALIGN_LEFT_PAD
- *
- * 3 03-01-27 20:04 Rogerl
- * Show current choice in act color, change current selection until enter
- * pressed
- *
- * 2 03-01-18 12:08 Rogerl
- * Handle MS_UOP_ENTER
- *
- * 1 03-01-17 11:54 Rogerl
- * Add New widgets: MS_COMBO_BUTTON,MS_EXT_BUTTON,MS_choice_ex,ms_slider_e
- * x
- *
- * 11 23/04/02 9:39 Nirm
- * - Added dependency in "Config.h".
- *
- * 10 11/03/02 12:51 Nirm
- * Debug message in case of memory allocation failure.
- *
- * 9 2/27/02 7:02a Tomasp
- * Changed get_blk/rel_blk to malloc,free.
- *
- * 7 16/01/02 8:57 Nirm
- * Fixed debug-messages.
- *
- * 6 13/01/02 16:38 Atai
- * Remove old Defines
- *
- * 5 9/01/02 18:23 Nirm
- * Corrected Include-Paths.
- *
- * 4 30/12/01 10:02 Atai
- * add explicit casting
- *
- * 3 23/12/01 17:47 Atai
- *
- * 2 23/12/01 17:43 Atai
- * Code cleaning
- **************************************************************************************** */
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef D_PUSHABLE_MENU //add by Tom for multi language
- #ifdef _DEBUG
- #include "DebugDbgMain.h"
- #undef IFTRACE
- #define IFTRACE if (gTraceMenu)
- #endif //_DEBUG
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "Includesysdefs.h"
- #include "Decoderosdrendr.h"
- #include "UIMenu_Sysosd_drv.h"
- #include "UIMenu_SysMS_WDGT.H"
- #include "UIMenu_Sysms_lib.h"
- #ifdef CHOICE_SCROLL_ARROW
- #if 0
- CONST BYTE down_arrow_btn[]={ 20, 28
- , 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xb8, 0xfc, 0xfc, 0x9c, 0xee, 0x1c, 0x08, 0x1c
- , 0xee, 0x1c, 0x18, 0x1c, 0xce, 0x1c, 0x38, 0x1c, 0xae, 0x1c, 0x48, 0x1c, 0xae, 0x1c, 0x58, 0x1c
- , 0x8e, 0x1c, 0x78, 0x1c, 0x6e, 0x1c, 0x98, 0x1c, 0x4e, 0x1c, 0xa8, 0x1c, 0x4e, 0x1c, 0xb8, 0x1c
- , 0x2e, 0x1c, 0xd8, 0x1c, 0x0e, 0x1c, 0xe8, 0x4c, 0xf8, 0x2c, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8
- , 0xf8, 0xf8, 0x08
- };
- CONST BYTE up_arrow_btn[]={ 20, 28
- , 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x78, 0x1c, 0xf8, 0x18, 0x1c, 0xf8, 0x18, 0x2c, 0xf8, 0x1c, 0x0e
- , 0x1c, 0xe8, 0x1c, 0x1e, 0x1c, 0xc8, 0x1c, 0x2e, 0x1c, 0xb8, 0x1c, 0x4e, 0x1c, 0xa8, 0x1c, 0x5e
- , 0x1c, 0x88, 0x1c, 0x7e, 0x1c, 0x68, 0x1c, 0x9e, 0x1c, 0x58, 0x1c, 0xae, 0x1c, 0x38, 0x1c, 0xbe
- , 0x1c, 0x28, 0x1c, 0xde, 0xfc, 0xfc, 0xac, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8
- , 0xf8, 0xf8, 0x38
- };
- #else
- CONST BYTE down_arrow_btn[]={ 20, 28
- , 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xbb, 0xfc, 0xfc, 0x9c, 0xee, 0x1c, 0x0b, 0x1c
- , 0xee, 0x1c, 0x1b, 0x1c, 0xce, 0x1c, 0x3b, 0x1c, 0xae, 0x1c, 0x4b, 0x1c, 0xae, 0x1c, 0x5b, 0x1c
- , 0x8e, 0x1c, 0x7b, 0x1c, 0x6e, 0x1c, 0x9b, 0x1c, 0x4e, 0x1c, 0xab, 0x1c, 0x4e, 0x1c, 0xbb, 0x1c
- , 0x2e, 0x1c, 0xdb, 0x1c, 0x0e, 0x1c, 0xeb, 0x4c, 0xfb, 0x2c, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb
- , 0xfb, 0xfb, 0x0b
- };
- CONST BYTE up_arrow_btn[]={ 20, 28
- , 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0x7b, 0x1c, 0xfb, 0x1b, 0x1c, 0xfb, 0x1b, 0x2c, 0xfb, 0x1c, 0x0e
- , 0x1c, 0xeb, 0x1c, 0x1e, 0x1c, 0xcb, 0x1c, 0x2e, 0x1c, 0xbb, 0x1c, 0x4e, 0x1c, 0xab, 0x1c, 0x5e
- , 0x1c, 0x8b, 0x1c, 0x7e, 0x1c, 0x6b, 0x1c, 0x9e, 0x1c, 0x5b, 0x1c, 0xae, 0x1c, 0x3b, 0x1c, 0xbe
- , 0x1c, 0x2b, 0x1c, 0xde, 0xfc, 0xfc, 0xac, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb
- , 0xfb, 0xfb, 0x3b
- };
- #endif
- #endif
- #define CHOICE_HEIGHT MS_LINE_HEIGHT
- #define LAST_CHOICE (choice->text_list->size-1)
- static WORD choice_base = 0;
- static BYTE choice_cusor = 0;
- // Support external display
- static void choice_display_open_value(MS_CHOICE *pmsc, WORD wItemNum, char focus )
- {
- OSD_PutText(
- pmsc->choice_pos.x,
- #ifdef D_MS_EXTENSIONS
- MS_CHOICE_OPEN_VALUE_POS_Y(pmsc, wItemNum),
- #else
- pmsc->choice_pos.y + CHOICE_HEIGHT * wItemNum,
- #endif // D_MS_EXTENSIONS
- pmsc->choice_pos.w,
- #ifdef D_MS_EXTENSIONS
- pmsc->choice_pos.h,
- #else
- CHOICE_HEIGHT,
- #endif // D_MS_EXTENSIONS
- #ifdef D_MS_EXTENSIONS
- FORE_COLOR( pmsc, focus ),
- #else
- FG_COLOR(pmsc->widget.color),
- #endif
- BACK_COLOR((MS_WIDGET *) pmsc, focus ),
- (void *)pmsc->text_list->head[wItemNum],
- MS_JUST(pmsc),
- !C_ASCII);
- }
- // Pass focus, use full color
- #ifdef D_MS_EXTENSIONS
- static void choice_display_closed_value(MS_CHOICE *pmsc, char focus)
- #else
- static void choice_display_closed_value(MS_CHOICE *pmsc, WORD back_color)
- #endif // D_MS_EXTENSIONS
- {
- OSD_SetOrigin( (MS_WIDGET *) pmsc->widget.parent );
-
- OSD_PutText(
- pmsc->widget.pos.x,
- pmsc->widget.pos.y,
- pmsc->widget.pos.w,
- pmsc->widget.pos.h,
- #ifdef D_MS_EXTENSIONS
- FORE_COLOR( pmsc, focus),
- BACK_COLOR( pmsc, focus),
- #else
- FG_COLOR(pmsc->widget.color),
- back_color,
- #endif
- (void *)pmsc->text_list->head[pmsc->current_choice],
- ALIGN_CENTER,
- !C_ASCII);
- }
- #ifdef D_MS_EXTENSIONS
- static void display_open_choice(MS_CHOICE *choice, char focus)
- {
- unsigned short i;
- // Can only do this if width is specified
- if ( IS_OPENABLE_LIST(choice) )
- {
- OSD_SetOrigin( (MS_WIDGET *) choice->widget.parent );
- for (i=0;i < LAST_CHOICE + 1;i++)
- {
- choice_display_open_value( choice, i, ((choice->current_choice == i) ? focus : !C_FOCUSED) );
- }
- }
- }
- static void display_closed_choice (MS_WIDGET *widget, char focus)
- {
- MS_CHOICE *choice = (MS_CHOICE *)widget;
- OSD_PutText(widget->pos.x,
- widget->pos.y,
- widget->pos.w,
- widget->pos.h,
- #ifdef D_MS_EXTENSIONS
- FORE_COLOR(widget, focus),
- #else
- FG_COLOR(widget->color),
- #endif
- BACK_COLOR(widget, focus),
- (void *)choice->text_list->head[choice->current_choice],
- // Allow all alignments
- #ifdef D_MS_EXTENSIONS
- MS_JUST(widget),
- #else
- ALIGN_CENTER,
- #endif // D_MS_EXTENSIONS
- !C_ASCII);
- }
- #endif // D_MS_EXTENSIONS
- #ifdef D_MS_EXTENSIONS
- static void display (MS_WIDGET *widget, char focus)
- {
- MS_CHOICE *choice = (MS_CHOICE *)widget;
- // Fix display of open toggle
- if ( IS_OPENABLE_LIST(choice) && MS_IS_CHOICE_OPEN(choice) )
- display_open_choice(widget, focus);
- else
- display_closed_choice(widget, focus);
- }
- #else
- static void display (MS_WIDGET *widget, char focus)
- {
- MS_CHOICE *choice = (MS_CHOICE *)widget;
- OSD_PutText(widget->pos.x,
- widget->pos.y,
- widget->pos.w,
- widget->pos.h,
- FG_COLOR(widget->color),
- BACK_COLOR(widget, focus),
- (void *)choice->text_list->head[choice->current_choice],
- // Allow all alignments
- #ifdef D_MS_EXTENSIONS
- MS_JUST(pmsc),
- #else
- ALIGN_CENTER, //ALIGN_LEFT, For choice_pos Tom.li
- #endif // D_MS_EXTENSIONS
- !C_ASCII);
- }
- #endif // D_MS_EXTENSIONS
- // Support toggle with arrows, wraparound
- #ifdef D_MS_EXTENSIONS
- static void increment_choice(MS_CHOICE *choice)
- {
- if ( choice->current_choice < LAST_CHOICE )
- choice->current_choice ++;
- else
- choice->current_choice = 0;
- }
- static void decrement_choice(MS_CHOICE *choice)
- {
- if ( choice->current_choice )
- choice->current_choice --;
- else
- choice->current_choice = LAST_CHOICE;
- }
- #endif // D_MS_EXTENSIONS
- static int choice_previous(MS_CHOICE *choice)
- {
- BYTE i,ucBgColor;
- #ifdef D_MS_EXTENSIONS
- if ( IS_OPENABLE_LIST(choice) && !MS_IS_CHOICE_OPEN(choice) )
- #else
- if ( !MS_IS_CHOICE_OPEN(choice) )
- #endif // D_MS_EXTENSIONS
- {
- return 0;
- }
- #ifdef D_MS_EXTENSIONS
- if ( !MS_IS_CHOICE_WRAP(choice) && (choice->current_choice == 0) )
- return 0;
- #endif // D_MS_EXTENSIONS
- if ( IS_OPENABLE_LIST(choice) )
- {
- #ifdef D_MS_EXTENSIONS
- #else
- if (0!= choice_cusor)
- #endif // D_MS_EXTENSIONS
- {
- #ifdef D_MS_EXTENSIONS
- choice_display_open_value(choice, choice->current_choice, !C_FOCUSED);
- decrement_choice(choice);
- choice_display_open_value(choice, choice->current_choice, C_FOCUSED);
- // When open, don't perform action on next/previous
- #else // D_MS_EXTENSIONS
- OSD_PutText(
- choice->choice_pos.x,
- choice->choice_pos.y + choice_cusor * CHOICE_HEIGHT,
- choice->choice_pos.w,
- CHOICE_HEIGHT,
- FG_COLOR(choice->widget.color),
- ((choice_cusor+choice_base) != choice->current_choice )? BG_COLOR(choice->widget.color):ACT_COLOR(choice->widget.color),
- (void *)choice->text_list->head[choice_cusor+choice_base],
- MS_JUST(choice),
- !C_ASCII);
- // choice->current_choice --;
- choice_cusor --;
- OSD_PutText(
- choice->choice_pos.x,
- // choice->choice_pos.y+choice->current_choice * CHOICE_HEIGHT,
- choice->choice_pos.y+choice_cusor * CHOICE_HEIGHT,
- choice->choice_pos.w,
- CHOICE_HEIGHT,
- FG_COLOR(choice->widget.color),
- FOCUS_COLOR(choice->widget.color),
- // (void *)choice->text_list->head[choice->current_choice],
- (void *)choice->text_list->head[choice_cusor+choice_base],
- MS_JUST(choice),
- !C_ASCII);
- #endif // D_MS_EXTENSIONS
- }
- else if(MS_IS_CHOICE_SCROLLABLE(choice)) // Choice is scrollable
- {
- if(choice_base > 0) // Scroll UP
- {
- choice_base --;
- for ( i=0;i<MS_GET_CHOICE_SCROLL_RANGE(choice);i++)
- {
- if (i == 0)
- ucBgColor = FOCUS_COLOR(choice->widget.color);
- else
- if (choice->current_choice == (i+choice_base))
- {
- ucBgColor = ACT_COLOR(choice->widget.color);
- }
- else
- ucBgColor = BG_COLOR(choice->widget.color);
-
- OSD_PutText(
- choice->choice_pos.x,
- choice->choice_pos.y+CHOICE_HEIGHT*i,
- choice->choice_pos.w,
- CHOICE_HEIGHT,
- FG_COLOR(choice->widget.color),
- ucBgColor,
- (void *)choice->text_list->head[i+choice_base],
- MS_JUST(choice),
- !C_ASCII);
-
- }
- }
- }
- }
- else
- {
- #ifdef D_MS_EXTENSIONS
- decrement_choice(choice);
- // Use full color and pass focus
- choice_display_closed_value(choice, C_FOCUSED);
- // Perform action on UP/LEFT; Allow NULL actions
- if ( !MS_IS_CHOICE_ENTER(choice) && !MS_IS_CHOICE_ACTION_ON_ENTER(choice) )
- {
- if ( choice->action )
- choice->action(choice->current_choice);
- }
- #else
- if (choice->current_choice) {
- choice->current_choice --;
- }
- else {
- choice->current_choice = LAST_CHOICE;
- }
- OSD_PutText(
- choice->widget.pos.x,
- choice->widget.pos.y,
- choice->widget.pos.w,
- choice->widget.pos.h,
- FG_COLOR(choice->widget.color),
- FOCUS_COLOR(choice->widget.color),
- (void *)choice->text_list->head[choice->current_choice],
- ALIGN_CENTER,
- !C_ASCII);
- #endif // D_MS_EXTENSIONS
- }
- return 1;
- }
- #ifdef D_MS_EXTENSIONS
- #else
- #define choice_down choice_next
- #endif // D_MS_EXTENSIONS
- static int choice_next(MS_CHOICE *choice)
- {
- BYTE i,ucBgColor;
- WORD lastchoice;
- #ifdef D_MS_EXTENSIONS
- if ( IS_OPENABLE_LIST(choice) && !MS_IS_CHOICE_OPEN(choice) )
- #else
- if ( !MS_IS_CHOICE_OPEN(choice) )
- #endif // D_MS_EXTENSIONS
- {
- return 0;
- }
- #ifdef D_MS_EXTENSIONS
- if ( !MS_IS_CHOICE_WRAP(choice) && (choice->current_choice == LAST_CHOICE) )
- return 0;
- #endif // D_MS_EXTENSIONS
- if ( IS_OPENABLE_LIST(choice) )
- {
- #ifdef D_MS_EXTENSIONS
- #else
- if(MS_IS_CHOICE_SCROLLABLE(choice))
- lastchoice = MS_GET_CHOICE_SCROLL_RANGE(choice) -1;
- else
- lastchoice = choice->text_list->size -1;
-
- // if (choice->current_choice < LAST_CHOICE)
- // if ((choice_cusor) < LAST_CHOICE)
- if ((choice_cusor) < lastchoice)
- #endif // D_MS_EXTENSIONS
- {
- #ifdef D_MS_EXTENSIONS
- choice_display_open_value(choice, choice->current_choice, !C_FOCUSED);
- increment_choice(choice);
- choice_display_open_value(choice, choice->current_choice, C_FOCUSED);
- #else // D_MS_EXTENSIONS
- OSD_PutText(
- choice->choice_pos.x,
- // choice->choice_pos.y + choice->current_choice * CHOICE_HEIGHT,
- choice->choice_pos.y + choice_cusor * CHOICE_HEIGHT,
- choice->choice_pos.w,
- CHOICE_HEIGHT,
- FG_COLOR(choice->widget.color),
- // BG_COLOR(choice->widget.color),
- ((choice_cusor+choice_base)!=choice->current_choice)?BG_COLOR(choice->widget.color):ACT_COLOR(choice->widget.color),
- // (void *)choice->text_list->head[choice->current_choice],
- (void *)choice->text_list->head[choice_cusor+choice_base],
- MS_JUST(choice),
- !C_ASCII);
- // choice->current_choice ++;
- choice_cusor ++;
- OSD_PutText(
- choice->choice_pos.x,
- // choice->choice_pos.y + choice->current_choice * CHOICE_HEIGHT,
- choice->choice_pos.y + choice_cusor * CHOICE_HEIGHT,
- choice->choice_pos.w,
- CHOICE_HEIGHT,
- FG_COLOR(choice->widget.color),
- FOCUS_COLOR(choice->widget.color),
- // (void *)choice->text_list->head[choice->current_choice],
- (void *)choice->text_list->head[choice_cusor+choice_base],
- MS_JUST(choice),
- !C_ASCII);
- #endif // D_MS_EXTENSIONS
- }
- else
- if(MS_IS_CHOICE_SCROLLABLE(choice))
- {
- if( (choice_cusor+choice_base)< (choice->text_list->size-1))
- { // scroll Down
- choice_base ++;
- for ( i=0;i<MS_GET_CHOICE_SCROLL_RANGE(choice);i++)
- {
- if (i == (MS_GET_CHOICE_SCROLL_RANGE(choice)-1))
- ucBgColor = FOCUS_COLOR(choice->widget.color);
- else
- if (choice->current_choice == (i+choice_base))
- {
- ucBgColor = ACT_COLOR(choice->widget.color);
- }
- else
- ucBgColor = BG_COLOR(choice->widget.color);
-
- OSD_PutText(
- choice->choice_pos.x,
- choice->choice_pos.y+CHOICE_HEIGHT*i,
- choice->choice_pos.w,
- CHOICE_HEIGHT,
- FG_COLOR(choice->widget.color),
- ucBgColor,
- (void *)choice->text_list->head[i+choice_base],
- MS_JUST(choice),
- !C_ASCII);
-
- }
-
- }
- }
- }
- else
- // Choice is a toggle
- {
- #ifdef D_MS_EXTENSIONS
- increment_choice(choice);
- choice_display_closed_value(choice, C_FOCUSED);
- if ( !MS_IS_CHOICE_ENTER(choice) && !MS_IS_CHOICE_ACTION_ON_ENTER(choice) )
- {
- if ( choice->action )
- choice->action(choice->current_choice);
- }
- #else
- if (choice->current_choice >= LAST_CHOICE) {
- choice->current_choice = 0;
- }
- else {
- choice->current_choice ++;
- }
- OSD_PutText(
- choice->widget.pos.x,
- choice->widget.pos.y,
- choice->widget.pos.w,
- choice->widget.pos.h,
- FG_COLOR(choice->widget.color),
- FOCUS_COLOR(choice->widget.color),
- (void *)choice->text_list->head[choice->current_choice],
- ALIGN_CENTER,
- !C_ASCII);
- #endif // D_MS_EXTENSIONS
- }
- // success
- return 1;
- }
- static void draw_arrow(MS_CHOICE *choice)
- {
- #ifdef CHOICE_SCROLL_ARROW
- if(MS_IS_CHOICE_SCROLLABLE(choice))
- {
- WORD listitems = MS_GET_CHOICE_SCROLL_RANGE(choice);
- WORD totalitems = choice->text_list->size;
- if (totalitems > listitems)
- {
- if (choice_base > 0)
- 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);
- if (choice_base< (totalitems-listitems))
- 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);
- }
- }
- #endif
- }
- #ifdef D_MS_EXTENSIONS
- static void open_choice(MS_CHOICE *choice, MS_UOP uop)
- #else
- static void open_choice(MS_CHOICE *choice,char focus)
- #endif // D_MS_EXTENSIONS
- {
- extern MS_SCREEN *screen;
- #ifdef D_MS_EXTENSIONS
- #else
- unsigned short i;
- unsigned char ucBgColor ;
- WORD listitems;
- #endif // D_MS_EXTENSIONS
- ((MS_WIDGET *)choice)->attr |= MS_CHOICE_OPEN;
- if ( IS_OPENABLE_LIST(choice) ) {
- #ifdef D_MS_EXTENSIONS
- display_open_choice(choice, C_FOCUSED);
- #else
- if (NO_PARENT != choice->widget.parent )
- OSD_SetOrigin( (MS_WIDGET *) choice->widget.parent );
- else
- OSD_SetOrigin( (MS_WIDGET *) screen );
- if (focus)
- choice_cusor = choice->current_choice;
- else
- choice_cusor = 0;
-
- choice_base = 0;
- listitems = choice->text_list->size;
- if(MS_IS_CHOICE_SCROLLABLE(choice))
- {
- listitems = MS_GET_CHOICE_SCROLL_RANGE(choice);
- if (choice->current_choice >= MS_GET_CHOICE_SCROLL_RANGE(choice))
- {
- choice_base = choice->current_choice - MS_GET_CHOICE_SCROLL_RANGE(choice) +1;
- choice_cusor = MS_GET_CHOICE_SCROLL_RANGE(choice)-1;
- }
- }
-
- for (i=0;i<listitems;i++) {
- if (choice->current_choice != (i+choice_base))
- {
- ucBgColor = BG_COLOR(choice->widget.color);
- }
- else
- if (focus)
- ucBgColor = FOCUS_COLOR(choice->widget.color);
- else
- ucBgColor = ACT_COLOR(choice->widget.color);
-
- OSD_PutText(
- choice->choice_pos.x,
- choice->choice_pos.y+CHOICE_HEIGHT*i,
- choice->choice_pos.w,
- CHOICE_HEIGHT,
- FG_COLOR(choice->widget.color),
- ucBgColor,
- (void *)choice->text_list->head[i+choice_base],
- MS_JUST(choice),
- !C_ASCII);
- }
- draw_arrow(choice);
- #endif // D_MS_EXTENSIONS
- }
- else {
- #ifdef D_MS_EXTENSIONS
- switch (uop)
- {
- case MS_UOP_LEFT:
- case MS_UOP_UP:
- choice_previous(choice);
- break;
- case MS_UOP_ENTER:
- case MS_UOP_RIGHT:
- case MS_UOP_DOWN:
- choice_next(choice);
- break;
- }
- #else
- choice_next(choice);
- #endif // D_MS_EXTENSIONS
- }
- }
- static void close_choice(MS_CHOICE *choice)
- {
- ((MS_WIDGET *)choice)->attr &= (unsigned char) ~MS_CHOICE_OPEN;
- if ( IS_OPENABLE_LIST(choice) ) {
- OSD_SetOrigin( (MS_WIDGET*)((MS_WIDGET *) choice)->parent );
- OSD_PutRect(
- choice->choice_pos.x,
- choice->choice_pos.y,
- choice->choice_pos.w,
- #ifdef D_MS_EXTENSIONS
- choice->text_list->size * choice->choice_pos.h,
- #else
- choice->text_list->size*CHOICE_HEIGHT,
- #endif // D_MS_EXTENSIONS
- BG_COLOR(((MS_WIDGET *)choice)->parent->widget.color)
- );
- display((MS_WIDGET *)choice, C_FOCUSED);
- }
- }
- MS_UOP choice_ex_user_op(MS_WIDGET *widget, MS_UOP uop, char param)
- {
- MS_CHOICE *choice = (MS_CHOICE *)widget;
- switch (uop) {
- case MS_UOP_DELETE:
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_DISPLAY:
- // Don't display current choice
- display(widget,param);
- //open_choice(choice,param);
- // Add Frame Rect
- //if(MS_IS_CHOICE_SCROLLABLE(choice))
- //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);
- //else
- //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,choice->text_list->size*CHOICE_HEIGHT,FORE_COLOR(widget, param), C_THICKNESS);
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_UP:
- if ( IS_OPENABLE_LIST(choice) )
- {
- if ( choice_previous(choice) )
- {
- // Add Frame Rect
- draw_arrow(choice);
- //if(MS_IS_CHOICE_SCROLLABLE(choice))
- //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);
- //else
- //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,choice->text_list->size*CHOICE_HEIGHT,BACK_COLOR(widget, C_FOCUSED), C_THICKNESS);
- uop = MS_UOP_NOP;
- }
- }
- break;
- case MS_UOP_LEFT:
- if (MS_IS_CHOICE_OPEN(choice)) {
- uop=MS_UOP_NOP;
- }
- break;
- case MS_UOP_DOWN:
- if ( IS_OPENABLE_LIST(choice) ) {
- if (choice_down(choice)) {
- // Add Frame Rect
- draw_arrow(choice);
- //if(MS_IS_CHOICE_SCROLLABLE(choice))
- //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);
- //else
- //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,choice->text_list->size*CHOICE_HEIGHT,BACK_COLOR(widget, C_FOCUSED), C_THICKNESS);
- uop = MS_UOP_NOP;
- }
- }
- break;
- case MS_UOP_ENTER:
- if (MS_IS_CHOICE_OPEN(choice)) {
- if (NULL != choice->action )
- {
- // Don't change current choice is no action() active
- choice->current_choice = choice_cusor+choice_base;
- //open_choice(choice,C_FOCUSED);
- close_choice(choice);
- // Add Frame Rect
- //if(MS_IS_CHOICE_SCROLLABLE(choice))
- //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);
- //else
- //OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,choice->text_list->size*CHOICE_HEIGHT,BACK_COLOR(widget, C_FOCUSED), C_THICKNESS);
- choice->action(choice->current_choice);
- uop = MS_UOP_NOP;
- }
- }
- else
- {
- open_choice(choice,C_FOCUSED);
- }
- break;
- }
- return uop;
- }
- #ifdef D_PUSHABLE_MENU
- 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)
- #else
- 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)
- #endif
- {
- MS_CHOICE *choice;
- dbg_printf(("MS_create_choicen"));
- choice = (MS_CHOICE far*)malloc(sizeof(MS_CHOICE));
- #ifdef _DEBUG
- if (NULL == choice) {
- tr_printf(("FATAL: MS_create_choice() Failed: Low system resources.n"));
- return NULL;
- }
- #endif //_DEBUG
- choice->widget.pos = *pos;
- choice->widget.parent = NO_PARENT;
- choice->widget.color = color;
- choice->text_list = text_list;
- choice->action = action;
- choice->current_choice = 0;
- #ifdef D_PUSHABLE_MENU
- choice->choice_pos = *choice_pos;
- #else
- choice->choice_pos = *pos;
- #endif
- choice->widget.user_op = choice_ex_user_op;
- choice->widget.attr = attr;
- choice->widget.attrh = ALIGN_CENTER;
- return (MS_CHOICE *)choice;
- }
- #ifdef D_PUSHABLE_MENU
- 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)
- #else
- MS_CHOICE *MS_create_choice_ex_scroll(CONST MS_POS *pos, MS_COLOR color, CONST MS_TEXT_LIST *text_list, void (* action)(int),
- unsigned char attr, BYTE visible_items)
- #endif
- {
- MS_CHOICE *choice;
- dbg_printf(("MS_create_choice_scroll()n"));
- #ifdef D_PUSHABLE_MENU
- choice = MS_create_choice_ex( pos, color, text_list,choice_pos, action, attr);
- #else
- choice = MS_create_choice_ex( pos, color, text_list, action, attr);
- #endif
- #ifdef _DEBUG
- if (NULL == choice) {
- tr_printf(("FATAL: MS_create_choice_scroll() Failed: Low system resources.n"));
- return NULL;
- }
- #endif //_DEBUG
- choice->widget.attr |= MS_CHOICE_SCROLLABLE;
- MS_SET_CHOICE_SCROLL_RANGE(choice,visible_items);
- return (MS_CHOICE *)choice;
- }
- MS_UOP ext_help_choice_user_op(MS_WIDGET *widget, MS_UOP uop, char param)
- {
- MS_EXT_HELP_CHOICE *ext_help_choice = (MS_EXT_HELP_CHOICE *)widget;
- //MS_CHOICE *choice = (MS_CHOICE *)widget;
- switch (uop) {
- case MS_UOP_DELETE:
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_DISPLAY:
- uop = choice_ex_user_op( widget, uop, param);
- // OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,widget->pos.h,FORE_COLOR(widget, param), C_THICKNESS);
- if (C_FOCUSED != param)
- break;
- case MS_UOP_UP:
- case MS_UOP_DOWN:
- uop = choice_ex_user_op( widget, uop, param);
- OSD_PutRect(
- ext_help_choice->helptext->widget.pos.x,
- ext_help_choice->helptext->widget.pos.y,
- ext_help_choice->helptext->widget.pos.w,
- ext_help_choice->helptext->widget.pos.h,
- BG_COLOR(ext_help_choice->helptext->widget.color));
- OSD_PutText(
- ext_help_choice->helptext->widget.pos.x,
- ext_help_choice->helptext->widget.pos.y,
- ext_help_choice->helptext->widget.pos.w,
- ext_help_choice->helptext->widget.pos.h,
- FG_COLOR(ext_help_choice->helptext->widget.color),
- BG_COLOR(ext_help_choice->helptext->widget.color),
- (void *)ext_help_choice->on_help_list->head[choice_cusor+choice_base],
- MS_JUST(ext_help_choice->helptext),
- !C_ASCII);
- // OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,widget->pos.h,BACK_COLOR(widget, 1), C_THICKNESS);
- break;
- case MS_UOP_ENTER:
- OSD_PutRect(
- ext_help_choice->helptext->widget.pos.x,
- ext_help_choice->helptext->widget.pos.y,
- ext_help_choice->helptext->widget.pos.w,
- ext_help_choice->helptext->widget.pos.h,
- BG_COLOR(ext_help_choice->helptext->widget.color));
- OSD_PutText(
- ext_help_choice->helptext->widget.pos.x,
- ext_help_choice->helptext->widget.pos.y,
- ext_help_choice->helptext->widget.pos.w,
- ext_help_choice->helptext->widget.pos.h,
- FG_COLOR(ext_help_choice->helptext->widget.color),
- BG_COLOR(ext_help_choice->helptext->widget.color),
- (void *)ext_help_choice->done_help_list->head[choice_cusor+choice_base],
- MS_JUST(ext_help_choice->helptext),
- !C_ASCII);
- // OSD_FrameRect(widget->pos.x,widget->pos.y,widget->pos.w,widget->pos.h,BACK_COLOR(widget, 1), C_THICKNESS);
- // Action at last
- uop = choice_ex_user_op( widget, uop, param);
- break;
-
- case MS_UOP_CLEAR:
- OSD_PutRect(
- ext_help_choice->helptext->widget.pos.x,
- ext_help_choice->helptext->widget.pos.y,
- ext_help_choice->helptext->widget.pos.w,
- ext_help_choice->helptext->widget.pos.h,
- BG_COLOR(ext_help_choice->helptext->widget.color));
- uop = MS_UOP_NOP;
- break;
-
- default:
- uop = choice_ex_user_op(widget,uop,param);
- break;
- }
- return uop;
- }
- MS_EXT_HELP_CHOICE *MS_create_ext_help_choice(CONST MS_POS *pos, MS_COLOR color,
- CONST MS_TEXT_LIST *text_list,
- void (* action)(int),unsigned char attr,
- MS_STATIC *helptext,
- CONST MS_TEXT_LIST *on_help_list,
- CONST MS_TEXT_LIST *done_help_list
- )
- {
- MS_EXT_HELP_CHOICE *choice;
- dbg_printf(("MS_create_ext_help_choice()n"));
- choice = (MS_EXT_HELP_CHOICE *)malloc(sizeof(MS_EXT_HELP_CHOICE));
- #ifdef _DEBUG
- if (NULL == choice) {
- tr_printf(("FATAL: MS_create_ext_help_choice() Failed: Low system resources.n"));
- return NULL;
- }
- #endif //_DEBUG
- choice->choice.widget.pos = *pos;
- choice->choice.widget.parent = NO_PARENT;
- choice->choice.widget.color = color;
- choice->choice.text_list = text_list;
- choice->choice.action = action;
- choice->choice.current_choice = 0;
- choice->choice.choice_pos = *pos;
- choice->choice.widget.user_op = ext_help_choice_user_op;
- choice->choice.widget.attr = attr;
- choice->choice.widget.attrh = ALIGN_LEFT_PAD;
- choice -> helptext = helptext;
- choice-> on_help_list = on_help_list;
- choice-> done_help_list = done_help_list;
-
- return (MS_EXT_HELP_CHOICE *)choice;
- }
- MS_EXT_HELP_CHOICE *MS_create_ext_help_choice_scroll(CONST MS_POS *pos, MS_COLOR color,
- CONST MS_TEXT_LIST *text_list,
- void (* action)(int),unsigned char attr,
- MS_STATIC *helptext,
- CONST MS_TEXT_LIST *on_help_list,
- CONST MS_TEXT_LIST *done_help_list,
- BYTE visible_items)
- {
- MS_EXT_HELP_CHOICE *choice;
- dbg_printf(("MS_create_ext_help_choice_scroll()n"));
- choice = MS_create_ext_help_choice( pos, color, text_list, action,attr, helptext, on_help_list, done_help_list);
- #ifdef _DEBUG
- if (NULL == choice) {
- tr_printf(("FATAL: MS_create_ext_help_choice_scroll() Failed: Low system resources.n"));
- return NULL;
- }
- #endif //_DEBUG
- choice->choice.widget.attr |= MS_CHOICE_SCROLLABLE;
- MS_SET_CHOICE_SCROLL_RANGE(choice,visible_items);
- return (MS_EXT_HELP_CHOICE *)choice;
- }
- #endif //#ifdef D_PUSHABLE_MENU