MS_PW.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_PW.C $
- *
- * Description:
- * ============
- * menu system password handling
- *
- * Log:
- * ====
- * $Revision: 4 $
- * Last Modified by $Author: Rogerl $ at $Modtime: 03-04-03 22:09 $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /SourceCode/I64_Common/I64_Reference/UI/Menu_sys/MS_PW.C $
- *
- * 4 03-04-07 11:29 Rogerl
- * Force action at last
- *
- * 3 03-01-09 4:43 Leslie
- * Unicode support
- *
- * 11 5/22/02 8:52a Tomasp
- * Changed include paths.
- *
- * 10 23/04/02 9:39 Nirm
- * - Added dependency in "Config.h".
- *
- * 9 11/03/02 12:52 Nirm
- * Debug message in case of memory allocation failure.
- *
- * 8 2/27/02 7:02a Tomasp
- * Changed get_blk/rel_blk to malloc,free.
- *
- * 6 16/01/02 8:57 Nirm
- * Fixed debug-messages.
- *
- * 5 13/01/02 16:39 Atai
- * Remove old Defines
- *
- * 4 9/01/02 18:23 Nirm
- * Corrected Include-Paths.
- *
- * 3 30/12/01 10:03 Atai
- * Add explicit casting
- *
- * 2 25/12/01 10:52 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 "UIMenu_Sysosd_drv.h"
- #include "UIMenu_Sysms_wdgt.h"
- #define MS_MAX_EDIT 7
- // Assume that the English font set is currently set
- void MS_str_2_hidden_str(wchar_t *in,wchar_t *out)
- {
- while (*in)
- {
- if ((*in <= '9') && (*in >= '0'))
- {
- *out = 0x002a;//UNICODE_STAR;
- }
- else
- *out = 0x002d;//UNICODE_DASH;
-
- out++;
- in++;
- }
- *out = NULL_CHAR;
- }
- static void display (MS_WIDGET *widget, char focus)
- {
- MS_EDIT *edit = (MS_EDIT *)widget;
- wchar_t str[MS_MAX_EDIT+1];
- #ifndef D_MSPW_DISPLAY_WHILE_EDITING
- MS_str_2_hidden_str(edit->present.text,str);
- #endif // D_MSPW_DISPLAY_WHILE_EDITING
- // First time focus, start from beginning of the field
- 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 //D_MS_EXTENSIONS
- BACK_COLOR(widget, focus),
- str,MS_JUST(widget),
- C_ASCII);
- }
- static unsigned char number_select(MS_EDIT *edit,unsigned char num)
- {
- if ( edit_number_select(edit, num) )
- {
- display( (MS_WIDGET *)edit, C_FOCUSED ); // Display the text with the new number;
- }
- return 1;
- }
- // Expose user_op for MS_PASSWORD
- MS_UOP password_user_op(MS_WIDGET *widget,MS_UOP uop,char param)
- {
- switch (uop) {
- case MS_UOP_DELETE:
- return 0;
- case MS_UOP_CLEAR:
- _wcsnset( ((wchar_t *) ((MS_EDIT *)widget)->present.text), L'-', ((MS_EDIT *) widget)->max_width);
- //param = 1;
- param = ( (((MS_DIALOG *) widget->parent)->pwli_focus->widget == widget) ? C_FOCUSED : !C_FOCUSED );
- // Fall through!
- case MS_UOP_DISPLAY:
- ((MS_EDIT *)widget)->current_num = 0;
- display(widget,param);
- return 0;
- case MS_UOP_0:
- case MS_UOP_1:
- case MS_UOP_2:
- case MS_UOP_3:
- case MS_UOP_4:
- case MS_UOP_5:
- case MS_UOP_6:
- case MS_UOP_7:
- case MS_UOP_8:
- case MS_UOP_9:
- {
- number_select((MS_EDIT *)widget,(unsigned char)(uop-MS_UOP_0));
- return MS_UOP_NOP;
- }
- //break;
- }
- if (uop != MS_UOP_ENTER) {
- return uop;
- }
- if((((MS_EDIT *)widget)->current_num != 4)&&(uop == MS_UOP_ENTER))
- {
- _wcsnset( ((wchar_t *) ((MS_EDIT *)widget)->present.text), L'-', ((MS_EDIT *) widget)->max_width);
- param = ( (((MS_DIALOG *) widget->parent)->pwli_focus->widget == widget) ? C_FOCUSED : !C_FOCUSED );
- ((MS_EDIT *)widget)->current_num = 0;
- display(widget,param);
- return 0;
- }
- ((MS_EDIT *)widget)->current_num = 0;
- //Take action at last
- ((MS_EDIT *)widget)->action(((MS_EDIT *)widget)->present.text);
- return MS_UOP_NOP;
- }
- // text must be a valid memory, size "max_width" plus one , ended with ' '
- MS_PASSWORD *MS_create_password(MS_POS *pos,MS_COLOR color,void *text,void (* action)(void *), unsigned char max_width,unsigned char attr)
- {
- MS_PASSWORD *password;
- dbg_printf(("MS_create_passwordn"));
- password = (MS_PASSWORD *)malloc(sizeof(MS_PASSWORD));
- #ifdef _DEBUG
- if (NULL == password) {
- tr_printf(("FATAL: MS_create_password() Failed: Low system resources.n"));
- return NULL;
- }
- #endif //_DEBUG
- ((MS_WIDGET *)password)->pos = *pos;
- ((MS_WIDGET *)password)->parent = NO_PARENT;
- ((MS_EDIT *)password)->present.text = text;
- ((MS_EDIT *)password)->action = action;
- ((MS_EDIT *)password)->max_width = max_width;
- ((MS_EDIT *)password)->current_num = 0;
- ((MS_WIDGET *)password)->attr = attr | MS_ASCII;
- ((MS_WIDGET *)password)->color = color;
- ((MS_WIDGET *)password)->user_op = password_user_op;
-
- ((MS_WIDGET *)password)->attrh = ALIGN_CENTER;
-
- return password;
- }