MS_Combo_Btn.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:9k
- /* **************************************************************************************
- * Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: MS_Combo_Btn.c $
- *
- * Description:
- * ============
- * bitmaps buttons
- *
- * Log:
- * ====
- * $Revision: 7 $
- * Last Modified by $Author: Rogerl $ at $Modtime: 03-02-20 22:14 $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /SourceCode/I64_Common/I64_Reference/UI/Menu_sys/MS_Combo_Btn.c $
- *
- * 7 03-02-20 22:24 Rogerl
- * Fix help text remain garbage bug
- *
- * 6 03-02-14 16:01 Rogerl
- * Don't show helptext when combo_button is in companion
- *
- * 5 03-02-11 16:35 Rogerl
- * Add MS_COMBO_ICON_BUTTON support
- *
- * 4 03-02-09 14:28 Rogerl
- * Fix combo button companion display
- *
- * 3 03-01-27 17:31 Rogerl
- * Show act color when in companion
- *
- * 2 03-01-18 12:07 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
- *
- * 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_COMBO_BUTTON 1
- #ifdef USE_COMBO_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_COMBO_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 ;
- if( TRUE!= ((MS_COMBO_BUTTON *)widget)->is_in_companion)
- {
- ucBgColor = BACK_COLOR( widget, focus );
- }
- else
- {
- ucBgColor = ACT_COLOR( widget->color );
- }
-
- 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)
- {
- OSD_PutRect(
- ((MS_COMBO_BUTTON *)widget)->helptext->widget.pos.x,
- ((MS_COMBO_BUTTON *)widget)->helptext->widget.pos.y,
- ((MS_COMBO_BUTTON *)widget)->helptext->widget.pos.w,
- ((MS_COMBO_BUTTON *)widget)->helptext->widget.pos.h,
- BG_COLOR(((MS_COMBO_BUTTON *)widget)->helptext->widget.color));
- MS_CALL_USER_OP(((MS_COMBO_BUTTON *)widget)->helptext, MS_UOP_DISPLAY, !focus);
- }
- else
- {
- if (NO_PARENT == widget->parent )
- {
- MS_hide(((MS_COMBO_BUTTON *)widget)->helptext, (MS_DIALOG *) screen);
- }
- else
- {
- MS_hide(((MS_COMBO_BUTTON *)widget)->helptext, widget->parent);
- }
- }
- }
- MS_UOP combo_button_user_op(MS_WIDGET *widget,MS_UOP uop,char param)
- {
- MS_COMBO_BUTTON *button = (MS_COMBO_BUTTON *)widget;
- switch (uop)
- {
- case MS_UOP_DELETE:
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_DISPLAY:
- display(widget,param);
- if (NULL != button->companion)
- if (C_FOCUSED == param)
- {
- MS_CALL_USER_OP(button->companion,MS_UOP_DISPLAY,(TRUE == button->is_in_companion)?C_FOCUSED:!C_FOCUSED);
- }
- else
- {
- if (NO_PARENT == widget->parent)
- {
- MS_hide(button->companion, (MS_DIALOG *) screen);
- }
- else
- {
- MS_hide(button->companion, widget->parent);
- }
- }
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_RIGHT:
- if (NULL != button->companion)
- if (FALSE == button->is_in_companion)
- {
- button->is_in_companion = TRUE;
- display(widget,!C_FOCUSED);
- MS_CALL_USER_OP(button->companion,MS_UOP_DISPLAY,C_FOCUSED);
- }
-
- uop = MS_UOP_NOP;
- break;
-
- case MS_UOP_LEFT:
- if (NULL != button->companion)
- if (TRUE == button->is_in_companion)
- {
- MS_CALL_USER_OP(button->companion,MS_UOP_CLEAR,!C_FOCUSED);
- button->is_in_companion = FALSE;
- display(widget,C_FOCUSED);
- MS_CALL_USER_OP(button->companion,MS_UOP_DISPLAY,!C_FOCUSED);
- }
-
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_UP:
- case MS_UOP_DOWN:
- if (NULL != button->companion)
- if (TRUE == button->is_in_companion)
- {
- return MS_CALL_USER_OP(button->companion,uop,param);
- }
- break;
-
- case MS_UOP_ENTER:
- if (NULL != button->companion)
- if (TRUE == button->is_in_companion)
- {
- return MS_CALL_USER_OP(button->companion,uop,param);
- }
- if (NULL != button ->action )
- {
- button->action();
- uop = MS_UOP_NOP;
- }
- break;
- }
- return uop;
- }
- void MS_init_combo_button(MS_COMBO_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,
- unsigned char attrh,
- MS_STATIC * helptext,
- MS_WIDGET *companion)
- {
- #ifdef _DEBUG
- if (NULL == msb) {
- tr_printf(("FATAL: MS_init_combo_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 = combo_button_user_op;
- ((MS_WIDGET *)msb)->attrh = attrh;
- msb->helptext = helptext;
- msb->companion = companion;
- msb->is_in_companion = FALSE;
-
- }
- MS_COMBO_BUTTON *MS_create_combo_button(MS_POS *pos, MS_COLOR color,
- MS_UOP (*user_op)(MS_WIDGET *,MS_UOP,char),
- void *text,
- void (* action)(void),
- unsigned char attr,
- unsigned char attrh,
- MS_STATIC * helptext,
- MS_WIDGET *companion)
- {
- MS_COMBO_BUTTON *msb;
-
- dbg_printf(("MS_create_combo_buttonn"));
- msb = (MS_COMBO_BUTTON *) malloc (sizeof(MS_COMBO_BUTTON));
- #ifdef _DEBUG
- if (NULL == msb) {
- tr_printf(("FATAL: MS_create_combo_button() Failed: Low system resources.n"));
- return NULL;
- }
- #endif //_DEBUG
- MS_init_combo_button(msb, pos, color, user_op, text, action, attr,attrh,helptext,companion);
- return msb;
- }
- MS_UOP combo_icon_button_user_op(MS_WIDGET *widget,MS_UOP uop,char param)
- {
- MS_COMBO_ICON_BUTTON *button = (MS_COMBO_ICON_BUTTON *)widget;
- switch (uop)
- {
- case MS_UOP_DELETE:
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_DISPLAY:
- combo_button_user_op(widget, MS_UOP_DISPLAY, param);
- if (NULL != button->icon)
- MS_CALL_USER_OP(button->icon, MS_UOP_DISPLAY, param);
- uop = MS_UOP_NOP;
- break;
- case MS_UOP_RIGHT:
- case MS_UOP_LEFT:
- case MS_UOP_UP:
- case MS_UOP_DOWN:
- case MS_UOP_ENTER:
- default:
- return combo_button_user_op(widget, uop, param);
- break;
- }
- return uop;
- }
- void MS_init_combo_icon_button(MS_COMBO_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,
- unsigned char attrh,
- MS_STATIC * helptext,
- MS_WIDGET *companion,
- MS_WIDGET *icon)
- {
- #ifdef _DEBUG
- if (NULL == msb) {
- tr_printf(("FATAL: MS_init_combo_icon_button() Failed: NULL control.n"));
- return;
- }
- #endif
-
- MS_init_combo_button((MS_COMBO_BUTTON*)msb, pos, color, user_op, text, action, attr,attrh,helptext,companion);
- if (NULL != user_op)
- ((MS_WIDGET *)msb)->user_op = user_op;
- else
- ((MS_WIDGET *)msb)->user_op = combo_icon_button_user_op;
- msb->icon = icon;
- }
- MS_COMBO_ICON_BUTTON *MS_create_combo_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,
- unsigned char attrh,
- MS_STATIC * helptext,
- MS_WIDGET *companion,
- MS_WIDGET *icon)
- {
- MS_COMBO_ICON_BUTTON *msb;
-
- dbg_printf(("MS_create_combo_icon_buttonn"));
- msb = (MS_COMBO_ICON_BUTTON *) malloc (sizeof(MS_COMBO_ICON_BUTTON));
- #ifdef _DEBUG
- if (NULL == msb) {
- tr_printf(("FATAL: MS_create_combo_icon_button() Failed: Low system resources.n"));
- return NULL;
- }
- #endif //_DEBUG
- MS_init_combo_icon_button(msb, pos, color, user_op, text, action, attr,attrh,helptext,companion,icon);
- return msb;
- }
- #endif // USE_COMBO_BUTTON