MS_Ext_Btn.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:6k
- /* **************************************************************************************
- * Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: MS_Ext_Btn.c $
- *
- * Description:
- * ============
- * bitmaps buttons
- *
- * Log:
- * ====
- * $Revision: 2 $
- * Last Modified by $Author: Rogerl $ at $Modtime: 03-02-11 14:48 $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /SourceCode/I64_Common/I64_Reference/UI/Menu_sys/MS_Ext_Btn.c $
- *
- * 2 03-02-11 16:36 Rogerl
- * Add MS_EXT_ICON_BUTTON support
- *
- * 1 03-01-17 11:54 Rogerl
- * Add New widgets: MS_COMBO_BUTTON,MS_EXT_BUTTON,MS_choice_ex,ms_slider_e
- * x
- *
- * 3 23/04/02 9:39 Nirm
- * - Added dependency in "Config.h".
- *
- * 2 4/22/02 18:22 Rinata
- * add USE_SMALL_ext_BUTTONS buttons
- *
- * 1 4/22/02 14:46 Rinata
- *
- *
- *****************************************************************************************/
- #include "Config.h" // Global Configuration - do not remove!
- #define USE_EXT_BUTTON 1
- #ifdef USE_EXT_BUTTON
- #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
- extern MS_SCREEN *screen;
- static void display (MS_WIDGET *widget, char focus)
- {
- wchar_t *text = ((MS_EXT_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) );
- if (focus)
- {
- MS_CALL_USER_OP(&((MS_EXT_BUTTON *)widget)->helptext, MS_UOP_DISPLAY, !focus);
- }
- else
- {
- MS_hide(&((MS_EXT_BUTTON *)widget)->helptext, (MS_DIALOG *) screen);
- }
-
- }
- MS_UOP ext_button_user_op(MS_WIDGET *widget,MS_UOP uop,char param)
- {
- MS_EXT_BUTTON *button = (MS_EXT_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;
- }
- return uop;
- }
- void MS_init_ext_button(MS_EXT_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_ext_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 = ext_button_user_op;
- ((MS_WIDGET *)msb)->attrh = ALIGN_CENTER;
- }
- MS_EXT_BUTTON *MS_create_ext_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_EXT_BUTTON *msb;
-
- dbg_printf(("MS_create_ext_buttonn"));
- msb = (MS_EXT_BUTTON *) malloc (sizeof(MS_EXT_BUTTON));
- #ifdef _DEBUG
- if (NULL == msb) {
- tr_printf(("FATAL: MS_create_ext_button() Failed: Low system resources.n"));
- return NULL;
- }
- #endif //_DEBUG
- MS_init_ext_button(msb, pos, color, user_op, text, action, attr);
- return msb;
- }
- MS_UOP ext_icon_button_user_op(MS_WIDGET *widget,MS_UOP uop,char param)
- {
- MS_EXT_ICON_BUTTON *button = (MS_EXT_ICON_BUTTON *)widget;
- switch (uop)
- {
- case MS_UOP_DELETE:
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_DISPLAY:
- display(widget,param);
- if (NULL != button->icon)
- MS_CALL_USER_OP(button->icon, uop, param);
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_ENTER:
- button->button.action();
- uop = MS_UOP_NOP;
- break;
- }
- return uop;
- }
- void MS_init_ext_icon_button(MS_EXT_ICON_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,
- MS_WIDGET *widget)
- {
- #ifdef _DEBUG
- if (NULL == msb) {
- tr_printf(("FATAL: MS_init_ext_icon_button() Failed: NULL control.n"));
- return;
- }
- #endif
-
- MS_init_ext_button((MS_EXT_BUTTON*)msb, pos, color, user_op, text, action, attr);
- if (NULL != user_op)
- ((MS_WIDGET *)msb)->user_op = user_op;
- else
- ((MS_WIDGET *)msb)->user_op = ext_icon_button_user_op;
- msb->icon = widget;
-
- }
- MS_EXT_ICON_BUTTON *MS_create_ext_icon_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_WIDGET * widget)
- {
- MS_EXT_ICON_BUTTON *msb;
-
- dbg_printf(("MS_create_ext_icon_buttonn"));
- msb = (MS_EXT_ICON_BUTTON *) malloc (sizeof(MS_EXT_ICON_BUTTON));
- #ifdef _DEBUG
- if (NULL == msb) {
- tr_printf(("FATAL: MS_create_ext_icon_button() Failed: Low system resources.n"));
- return NULL;
- }
- #endif //_DEBUG
- MS_init_ext_icon_button(msb, pos, color, user_op, text, action, attr,widget);
- return msb;
- }
- #endif // USE_EXT_BUTTON