MS_BTN.C
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:5k
- /* **************************************************************************************
- * Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: MS_BTN.C $
- *
- * Description:
- * ============
- * manipulation of menu buttons
- *
- * Log:
- * ====
- * $Revision: 4 $
- * Last Modified by $Author: Williaml $ at $Modtime: 04-03-30 11:13 $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /I76/I76_Common/I76_Reference/UI/Menu_sys/MS_BTN.C $
- *
- * 4 04-03-30 11:14 Williaml
- * add the switch D_DIRECTION_KEY_IN_SETUP_MENU for using
- * up/down/left/right key select or open the set up menu
- *
- * 3 03-01-09 4:43 Leslie
- * Unicode support
- *
- * 12 23/04/02 9:39 Nirm
- * - Added dependency in "Config.h".
- *
- * 11 11/03/02 12:41 Nirm
- * Debug message in case of memory allocation failure.
- *
- * 10 11/03/02 12:27 Nirm
- * Debug message in case of memory allocation failure.
- *
- * 9 2/27/02 7:02a Tomasp
- * Changed get_blk/rel_blk to malloc,free.
- *
- * 8 18/02/02 20:41 Nirm
- * Exported essential methods.
- *
- * 7 14/02/02 18:11 Nirm
- * - Fixed handling of strings that reside in the SDRAM;
- * - Fixed prototype of MS_create_button().
- *
- * 5 16/01/02 8:57 Nirm
- * Fixed debug-messages.
- *
- * 4 9/01/02 18:23 Nirm
- * Corrected Include-Paths.
- *
- * 3 30/12/01 9:58 Atai
- * Add explicit casting
- *
- * 2 25/12/01 10:27 Atai
- * Code cleaning
- **************************************************************************************** */
- #include "Config.h" // Global Configuration - do not remove!
- #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 "PlaycoreScPadScMgr.h"
- #include "UIMenu_Sysms_lib.h"
- #include "UIMenu_Sysosd_drv.h"
- #include "UIMenu_Sysms_wdgt.h"
- #define MS_MAX_ASCII_BUTTON_TEXT_LENGTH (MS_STATIC_MAX_LENGTH/2)
- //add by wl03304
- #ifdef D_DIRECTION_KEY_IN_SETUP_MENU
- extern void load_defaults_action(void);
- #endif
- //add by wl033004
- static void display (MS_WIDGET *widget, char focus)
- {
- wchar_t *text = ((MS_BUTTON *)widget)->present.text;
- // We need a character for ESCSQ_FONT0 (at the beginning) and a NULL_CHAR at the end
- wchar_t str[MS_MAX_ASCII_BUTTON_TEXT_LENGTH + 2];
- unsigned char ucBgColor = BACK_COLOR( widget, focus );
- if (MS_IS_USE_SC(widget)) {
- if ( NULL_HANDLE != (WORD)text )
- sc_GetBytes((WORD)text, 0, MS_MAX_ASCII_BUTTON_TEXT_LENGTH, (BYTE*)str);
- }
- if ( MS_IS_ASCII(widget) )
- {
- if (MS_IS_USE_SC(widget)) {
- if (NULL_HANDLE != (WORD)text) {
- text= str;
- }
- else
- text= NULL;
- }
- if (NULL == text)
- text= "";
- }
-
- OSD_PutText(
- widget->pos.x,
- widget->pos.y,
- widget->pos.w,widget->pos.h,
- #ifdef D_MS_EXTENSIONS
- FOREGROUND_COLOR(widget->color, focus),
- #else
- FG_COLOR(widget->color),
- #endif // MS_EXTENSIONS
- ucBgColor,
- text, MS_JUST(widget), MS_IS_ASCII(widget) );
- }
- MS_UOP button_user_op(MS_WIDGET *widget,MS_UOP uop,char param)
- {
- MS_BUTTON *button = (MS_BUTTON *)widget;
- switch (uop)
- {
- case MS_UOP_DELETE:
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_DISPLAY:
- display(widget,param);
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_ENTER:
- button->action();
- uop = MS_UOP_NOP;
- break;
- //add by wl033004
- #ifdef D_DIRECTION_KEY_IN_SETUP_MENU
- case MS_UOP_DOWN:
- if( (g_ui_active_menu_id == SETUP_MENU_ID)&&(button->action != load_defaults_action) )
- {
- button->action();
- uop = MS_UOP_NOP;
- }
- break;
- #endif
- //add by wl033004
- }
- return uop;
- }
- void MS_init_button(MS_BUTTON *msb, MS_POS *pos,MS_COLOR color,
- MS_UOP (*user_op)(MS_WIDGET *,MS_UOP,char),
- void *text,void (* action)(void),
- unsigned char attr)
- {
- #ifdef _DEBUG
- if (NULL == msb) {
- tr_printf(("FATAL: MS_init_button() Failed: NULL control.n"));
- return;
- }
- #endif
-
- ((MS_WIDGET *)msb)->pos = *pos;
- ((MS_WIDGET *)msb)->parent = NO_PARENT;
- msb->present.text = text;
- msb->action = action;
- ((MS_WIDGET *)msb)->attr = attr;
- ((MS_WIDGET *)msb)->color = color;
- if (NULL != user_op)
- ((MS_WIDGET *)msb)->user_op = user_op;
- else
- ((MS_WIDGET *)msb)->user_op = button_user_op;
- ((MS_WIDGET *)msb)->attrh = ALIGN_CENTER;
- }
- MS_BUTTON *MS_create_button(MS_POS *pos, MS_COLOR color,
- MS_UOP (*user_op)(MS_WIDGET *,MS_UOP,char),
- void *text,
- void (* action)(void),
- unsigned char attr)
- {
- MS_BUTTON *msb;
-
- dbg_printf(("MS_create_buttonn"));
- msb = (MS_BUTTON *) malloc (sizeof(MS_BUTTON));
- #ifdef _DEBUG
- if (NULL == msb) {
- tr_printf(("FATAL: MS_create_button() Failed: Low system resources.n"));
- return NULL;
- }
- #endif //_DEBUG
- MS_init_button(msb, pos, color, user_op, text, action, attr);
- return msb;
- }