ms_open.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:10k
- /***********************************************************************/
- /* File: */
- /* Copyright (c) 2000 ZORAN Corporation, All Rights Reserved */
- /* THIS IS PROPRIETARY SOURCE CODE OF ZORAN CORPORATION */
- /* */
- /* =========== */
- /* Descripton: */
- /* =========== */
- /* */
- /* Log: */
- /* === */
- /* $Name: V_1_09 V_1_08 V_1_07 $
- /* $Header: /SourceCode/I64_Common/I64_Reference/UI/Menu_sys/ms_open.c 3 03-06-19 16:33 Wesleyj $
- /* $Log: /SourceCode/I64_Common/I64_Reference/UI/Menu_sys/ms_open.c $
- *
- * 3 03-06-19 16:33 Wesleyj
- * Remove customer related include
- *
- * 2 03-03-04 11:36 Hannahh
- * remove customer name from all project.
- *
- * 1 03-01-14 14:40 Mikelv
- *new setup menu
- /* Revision 1.3 2001/07/27 07:19:15 dingming
- /* Revision 1.1 2001/03/14 03:20:51 cliff
- /* Initial revision
- /* Revision 1.18 2001/03/09 03:01:16 leslie
- /* Fixed MS_create_choice for non-MILLENO
- /* Revision 1.17 2001/03/09 18:29:43 charlie
- /* Call action in choice_previous for toggle
- /* Revision 1.16 2001/03/09 05:12:07 charlie
- /* Changed MS_create_choice text_list parameter to non-const
- /* Revision 1.15 2001/02/26 20:05:08 charlie
- /* Defined choice_down when D_MS_EXTENSIONS not defined
- /* Revision 1.14 2001/02/26 19:56:59 charlie
- /* Revision 1.13 2001/02/24 02:16:28 charlie
- /* Added MS_CHOICE_KEEP_OPEN, MS_CHOICE_LR,
- /* MS_CHOICE_UD, wraparound.
- /* Revision 1.12 2000/11/16 23:05:14 charlie
- /* Use C_FOCUSED, C_ASCII, BACK_COLOR
- /* Revision 1.11 2000/11/09 04:36:22 cliff
- /***********************************************************************/
- //#include <stdio.h>
- //#include <stdlib.h>
- //#include <string.h>
- //#include "sysdefs.h"
- //#include "osd_drv.h"
- //#include "ms_wdgt.h"
- //#include "ms_lib.h"
- //#include "....decoderosdrendr.h"
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "menumenu_var.h"
- #include "uimenu_sysms_lib.h"
- #include "Includesysdefs.h"
- #include "Decoderosdrendr.h"
- #include "UIMenu_Sysosd_drv.h"
- #include "UIMenu_Sysms_wdgt.h"
- #define CHOICE_HEIGHT MS_LINE_HEIGHT
- #define LAST_CHOICE (choice->text_list->size-1)
- static void display (MS_OPEN_CHOICE *choice, char focus)
- {
- MS_WIDGET *widget = (MS_WIDGET *)choice;
- 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,
- ALIGN_CENTER,
- !C_ASCII);
- }
- static int choice_previous(MS_OPEN_CHOICE *choice)
- {
- MS_COLOR backcolor = choice->widget.color;
- choice->widget.color = I_COLOR;
- if ( !MS_IS_CHOICE_OPEN(choice) )
- {
- choice->widget.color = backcolor;
- return 0;
- }
- if ( IS_OPENABLE_LIST(choice) )
- {
- if (choice->current_choice)
- {
- OSD_PutText(
- choice->choice_pos.x,
- choice->choice_pos.y + choice->current_choice * CHOICE_HEIGHT,
- choice->choice_pos.w,
- CHOICE_HEIGHT,
- FG_COLOR(choice->widget.color),
- BG_COLOR(choice->widget.color),
- (void *)choice->text_list->head[choice->current_choice],
- MS_JUST(choice),
- !C_ASCII);
- choice->current_choice --;
- OSD_PutText(
- choice->choice_pos.x,
- choice->choice_pos.y+choice->current_choice * 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],
- MS_JUST(choice),
- !C_ASCII);
- }
- }
- else
- // <<< ZORAN CDE0309 : Code robustness
- // Choice is a toggle
- {
- 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);
- }
- choice->widget.color = backcolor;
- return 1;
- }
- #define choice_down choice_next
- static int choice_next(MS_OPEN_CHOICE *choice)
- {
- MS_COLOR backcolor = choice->widget.color;
- choice->widget.color = I_COLOR;
- if ( !MS_IS_CHOICE_OPEN(choice) )
- {
- choice->widget.color = backcolor;
- return 0;
- }
- if ( IS_OPENABLE_LIST(choice) )
- {
- if (choice->current_choice < LAST_CHOICE)
- {
- OSD_PutText(
- choice->choice_pos.x,
- choice->choice_pos.y + choice->current_choice * CHOICE_HEIGHT,
- choice->choice_pos.w,
- CHOICE_HEIGHT,
- FG_COLOR(choice->widget.color),
- BG_COLOR(choice->widget.color),
- (void *)choice->text_list->head[choice->current_choice],
- MS_JUST(choice),
- !C_ASCII);
- choice->current_choice ++;
- OSD_PutText(
- choice->choice_pos.x,
- choice->choice_pos.y + choice->current_choice * 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],
- MS_JUST(choice),
- !C_ASCII);
- }
- }
- else
- // Choice is a toggle
- {
- 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);
- }
- // success
- choice->widget.color = backcolor;
- return 1;
- }
- // ZORAN CDE0222 >>>
- static void open_choice(MS_OPEN_CHOICE *choice)
- {
- unsigned short i;
- MS_COLOR backcolor = choice->widget.color;
- choice->widget.color = I_COLOR;
- ((MS_WIDGET *)choice)->attr |= MS_CHOICE_OPEN;
- if ( IS_OPENABLE_LIST(choice) )
- {
- for (i=0;i<choice->text_list->size;i++) {
- OSD_PutText(
- choice->choice_pos.x,
- choice->choice_pos.y+CHOICE_HEIGHT*i,
- choice->choice_pos.w,
- CHOICE_HEIGHT,
- FG_COLOR(choice->widget.color),
- BACK_COLOR((MS_WIDGET *) choice, ((choice->current_choice == i) == C_FOCUSED)),
- (void *)choice->text_list->head[i],
- MS_JUST(choice),
- !C_ASCII);
- }
- }
- else
- {
- choice_next(choice);
- }
- choice->widget.color = backcolor;
-
- }
- static void close_choice(MS_OPEN_CHOICE *choice)
- {
- ((MS_WIDGET *)choice)->attr &= (unsigned char) ~MS_CHOICE_OPEN;
- if ( IS_OPENABLE_LIST(choice) ) {
- OSD_PutRect(
- choice->choice_pos.x,
- choice->choice_pos.y,
- choice->choice_pos.w,
- choice->text_list->size*CHOICE_HEIGHT,
- BG_COLOR(((MS_WIDGET *)choice)->parent->widget.color)
- );
- display((MS_WIDGET *)choice,1);
- }
- }
- MS_UOP open_choice_user_op(MS_WIDGET *widget,MS_UOP uop,char param)
- {
- MS_OPEN_CHOICE *choice = (MS_OPEN_CHOICE *)widget;
- switch (uop) {
- case MS_UOP_DELETE:
- return 0;
- case MS_UOP_DISPLAY:
- // MS_DIALOG * dialog = (MS_DIALOG *)screen;
- // display(widget,param);
- display(choice,param);
- widget->attr &= (unsigned char) ~MS_CHOICE_OPEN;
- uop = 0;
- if(screen->dialog.pwli_focus->widget != widget)
- break;
- case MS_UOP_ENTER:
- if (MS_IS_CHOICE_OPEN(choice))
- {
- if ( IS_TOGGLE(choice) )
- {
- choice_down(choice);
- }
- // 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);
- choice->action(choice->current_choice);
- // 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);
- // Re-test in case the action changed the screen
- // if ( MS_IS_CHOICE_OPEN(choice) )
- // {
- // close_choice(choice);
- // }
- }
- else
- {
- open_choice(choice);
- if ( IS_TOGGLE(choice) )
- {
- choice->action(choice->current_choice);
- close_choice(choice);
- }
- }
- uop=0;
- break;
- case MS_UOP_UP:
- if ( IS_OPENABLE_LIST(choice) )
- {
- if ( choice_previous(choice) )
- {
- uop = 0;
- }
- }
- break;
- case MS_UOP_RIGHT:
- {
- close_choice(choice);
- }
- break;
- case MS_UOP_LEFT:
- if (MS_IS_CHOICE_OPEN(choice)) {
- uop=0;
- }
- break;
- case MS_UOP_DOWN:
- if ( IS_OPENABLE_LIST(choice) ) {
- if (choice_down(choice)) {
- uop=0;
- }
- }
- break;
- }
- return uop;
- }
- 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)
- {
- MS_OPEN_CHOICE *choice;
- choice = (MS_OPEN_CHOICE *)malloc(sizeof(MS_OPEN_CHOICE));
- 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;
- choice->choice_pos = *choice_pos;
- choice->widget.user_op = open_choice_user_op;
- choice->widget.attr = attr;
- choice->text = text;
- choice->widget.attrh = ALIGN_CENTER;
- return choice;
- }