⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmisatinput.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 4 页
字号:
                        data->editor_data.mode = E_EDIT_DIGITS_MODE;
;
                    }
                    else
                    {
                        data->editor_data.mode = E_EDIT_ALPHA_MODE;
                    }
                }
            data->editor_data.TextId                 = TxtNull;
            if (txt->len > 0)
                {
                    data->editor_data.TextString     = sat_create_TEXT_ASCIIZ (txt); /* label */

                }
            else
                {
                    data->editor_data.TextString     =  NULL; /* no label */
                }
            data->editor_data.min_enter              = 0; /* get a single key */
            data->editor_data.timeout                = TWENTY_SECS; 
            data->editor_data.Identifier             = event;
            if ((sat_command->qual & SAT_M_INKEY_HELP_AVAIL) NEQ 0)
                {
                    data->editor_data.AlternateLeftSoftKey  = TxtHelp; /* help available */
                }
            else
                {
                    data->editor_data.AlternateLeftSoftKey  = 0;       /* no help available */
                }
            data->editor_data.hide                   = FALSE; 


            /* provide an empty zero terminated buffer */
            data->edt_buffer[0] = '\0'; 
            
            /*
             * Start the Editor
             */
            if (editor_start_common (win, data->edt_buffer, 3, &data->editor_data, (T_EDIT_CB)sat_editor_cb) == NULL)
            {
                sat_res[SAT_ERR_INDEX] = SAT_RES_IMPOSSIBLE;
                sat_res[SAT_AI_INDEX]  = SatResAiNoCause;
                sat_done (sat_command, sat_res, sizeof(T_SAT_RES));
                sat_get_key_destroy (data->win);
            }
#endif /* NEW_EDITOR */
            break;

		/* sbh - all window types are being provided with this event to destroy the window */
		case SAT_DESTROY_WINDOW:
			sat_get_key_destroy (data->win);
			break;
		/* ...sbh */
		
        default:
            TRACE_EVENT ("sim_get_key_exec() unexpected event");
            break;
        }
}

/*********************************************************************
 *
 * SUB WINDOW  SAT_GET_STRING
 *
 *********************************************************************/
#define SAT_GET_STRING_BUFFER_SIZE (UBYTE)255
typedef struct
{
    T_MMI_CONTROL  mmi_control;
    T_MFW_HND      win;
    T_SAT_CMD     *sat_command; /* pointer to sat_command in parent */
#ifdef NEW_EDITOR
	T_AUI_EDITOR_DATA editor_data;	/* SPR#1428 - SH - New Editor data */
#else
    T_EDITOR_DATA  editor_data;
#endif
    char          *edt_buffer; /* buffer for editor */ 
    U16            max_chars;
    T_MFW_HND		kbd;  /* sbh - keyboard handler, so window can be destroyed by user */
    T_MFW_HND chinese_edit_win; /* SPR#1700 - DS - Chinese editor window reference */
    
} T_sat_get_string;

typedef struct {
    T_SAT_TXT txt;
    UBYTE     buffer[1]; /* open array */ 
} T_sat_get_string_result; /* NOTE: txt and buffer shall be packed */

static void sat_get_string_destroy (T_MFW_HND own_window);
static void sat_get_string_exec (T_MFW_HND win, USHORT event, SHORT value, T_SAT_CMD * sat_command);



/*******************************************************************************

 $Function:    	sat_get_string_create

 $Description:	Creation of an instance for the SAT GET STRING dialog.Window must 
 				be available after reception of SAT command,only one instance.

 
 $Returns:		window 

 $Arguments:	parent_window - parent window
*******************************************************************************/
T_MFW_HND sat_get_string_create (T_MFW_HND parent_window)
{
    T_sat_get_string * data = (T_sat_get_string *)ALLOC_MEMORY (sizeof (T_sat_get_string));
    T_MFW_WIN        * win;

    data->win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)sat_win_cb);  // c030 rsa

    if (data->win EQ NULL)
        return NULL;

    /*
     * Create window handler
     */
    data->mmi_control.dialog   = (T_DIALOG_FUNC)sat_get_string_exec;
    data->mmi_control.data     = data;
    win                        = ((T_MFW_HDR *)data->win)->data;
    win->user                  = (MfwUserDataPtr)data;


	data->kbd      = kbdCreate( data->win, KEY_ALL, (T_MFW_CB) sat_kbd_cb); /* sbh - add keyboard handler */

    /*
     * return window handle
     */
    win_show(data->win);
    return data->win;
}

/*******************************************************************************

 $Function:    	sat_get_string_destroy

 $Description:	Destroy the sat get string dialog.

 
 $Returns:		none

 $Arguments:	own_window - current window.
*******************************************************************************/
static void sat_get_string_destroy (T_MFW_HND own_window)
{
    T_MFW_WIN * win_data    = ((T_MFW_HDR *)own_window)->data;
    T_sat_get_string * data = (T_sat_get_string *)win_data->user;

	if (own_window == NULL)
	{
		TRACE_EVENT ("Error : sat_get_string_destroy called with NULL Pointer");
		return;
	}

    TRACE_FUNCTION("sat_get_string_destroy()");

    if (data)
        {
            /*
             * Delete WIN Handler
             */
            win_delete (data->win);
            
            /*
             * Free Memory
             */
             if (((data->sat_command->qual & SAT_M_INPUT_ALPHA) == 1) /* 0=digits, 1=alpha */
		    && (data->sat_command->qual & SAT_M_INPUT_UCS2)	/* Unicode input requested */
	          && (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE))
             {
                FREE_MEMORY ((U8 *)data->edt_buffer, 
                (U16)sizeof(U16) + (data->max_chars * sizeof(U16)));

                /* SPR#1700 - DS - Destroy Chinese editor */
#if defined(CHINESE_MMI) && defined(EASY_TEXT_ENABLED)
		  if (data->chinese_edit_win)
		  {
		      chinese_input_destroy(data->chinese_edit_win);
		      data->chinese_edit_win = NULL;
		  }
#endif /* CHINESE_MMI && EASY_TEXT_ENABLED */
             }
             else /* Ascii */
             {
                FREE_MEMORY ((U8 *)data->edt_buffer,
                data->max_chars * sizeof(char));
             }
                /* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
			sat_destroy_TEXT_ASCIIZ ((char *)data->editor_data.TitleString); /* label */
#else /* NEW_EDITOR */
            sat_destroy_TEXT_ASCIIZ (data->editor_data.TextString); /* label */
#endif /* NEW_EDITOR */

             FREE_MEMORY ((U8 *)data, sizeof (T_sat_get_string));
        }
}


/*******************************************************************************

 $Function:    	sat_get_string_exec

 $Description:	Dialog function for sat_get_string window.

 
 $Returns:		none

 $Arguments:	win - window handle
 				event - window event
 				value - unique id
 				sat_command - Sat Command info.
*******************************************************************************/
static void sat_get_string_exec (T_MFW_HND win, USHORT event, SHORT value, T_SAT_CMD * sat_command)
{
    T_MFW_WIN       * win_data   = ((T_MFW_HDR *)win)->data;
    T_sat_get_string   * data       = (T_sat_get_string *)win_data->user;
    T_SAT_INPUT     * inp;
    T_SAT_TXT      * defRsp;
    T_SAT_RES sat_res;
    /* SPR#1428 - SH - New Editor: store data in these, for efficiency */
#ifdef NEW_EDITOR
	USHORT mode;
	UBYTE *textStr;
#endif

    TRACE_FUNCTION ("sat_get_string_exec()");

    switch (event)
        {
        case SAT_GET_STRING:

            /* SPR#1700 - DS - Modifed to handle Chinese/Unicode
             */
             
            data->sat_command = sat_command; /* save a pointer to the parameter for later use in callbacks */
            inp = (T_SAT_INPUT *)&sat_command->c.inp;

            data->max_chars = (U16)(inp->rspMax)+1;
            
            /* allocate a buffer to hold the edited chars + terminator  */
           if (((data->sat_command->qual & SAT_M_INPUT_ALPHA) == 1) /* 0=digits, 1=alpha */
		    && (data->sat_command->qual & SAT_M_INPUT_UCS2)	/* Unicode input requested */
	          && (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE))
            {
                /* Include slot for unicode tag */
                data->edt_buffer = (char *)ALLOC_MEMORY ((U16)sizeof(U16) + (data->max_chars * sizeof(U16)));
            }
            else /* Ascii */
            {
                data->edt_buffer = (char *)ALLOC_MEMORY (data->max_chars * sizeof(char));
            }
#ifdef TRACE_SAT_STRING
            TRACE_EVENT_P3("rspMax %d, max_chars %d, defRsp.code %02x", inp->rspMax, data->max_chars, inp->defRsp.code);
#endif /* TRACE_SAT_STRING */

            /*MC, SPR940/2 if we are a expecting unicode response. This, of course assumes we're getting the correct DCS*/
            if (inp->defRsp.code == MFW_DCS_UCS2)
            { 	/*we have to put a unicode tag in so the editor knows to use Unicode*/
            	      data->edt_buffer[0]= 0x80; 
			data->edt_buffer[1]= 0x7F;
            }
            
			/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR

#if defined(CHINESE_MMI) && defined(EASY_TEXT_ENABLED)
		/* If chinese is selected use the chinese editor */
		 if (((data->sat_command->qual & SAT_M_INPUT_ALPHA) == 1) /* 0=digits, 1=alpha */
		        && (data->sat_command->qual & SAT_M_INPUT_UCS2)	/* Unicode input requested */
	              && (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
			 && (data->edt_buffer[0]==0x00 || data->edt_buffer[0] ==0x80))
		{
		    T_CHINESE_DATA chinese_data;

		    /* Initialise the Chinese editor window reference */
		    data->chinese_edit_win = NULL;

		    TRACE_EVENT("Setup Chinese SAT String editor");
		
		    chinese_data.TextString = (char*) data->edt_buffer;

                 if (inp->prompt.len > 0)
                {
                    textStr = (UBYTE *)sat_create_TEXT_ASCIIZ (&inp->prompt); /* label */
#ifdef NO_ASCIIZ/*MC SPR 940/2 Add tag to Unicode strings so info dialogue displays them correctly*/
    			 sat_add_unicode_tag_if_needed(textStr);
#endif
                }
                else
                {
                    textStr =  NULL; /* no label */
                }

                defRsp = &inp->defRsp;

#ifdef TRACE_SAT_STRING
            TRACE_EVENT_P2("prompt.len %d, defRsp->len %d", inp->prompt.len, defRsp->len);
#endif /* TRACE_SAT_STRING */              
                
                if (defRsp->len > 0) /* default response available? */
                {
                    /* provide a zero terminated buffer, initially containing the default response */
                    sat_TEXT_to_ASCIIZ (data->edt_buffer, defRsp);
                }
                else
                {
                    /* no default response: provide an empty buffer */
                    data->edt_buffer[0] = '\0';
                }
			
                 /* Setup Chinese editor data */
        	    chinese_data.Callback = (T_AUI_EDIT_CB)sat_editor_cb;
        	    chinese_data.Identifier = event;
        	    chinese_data.LeftSoftKey = TxtSoftOK;
        	    chinese_data.DestroyEditor = FALSE;
        	    chinese_data.EditorSize = data->max_chars-1;
        	    data->chinese_edit_win = chinese_input(win, &chinese_data);
		}
		else
#endif /* CHINESE_MMI && EASY_TEXT_ENABLED */
            {
                 /*
                 * Setup an Editor to get a string 
                 */
                AUI_edit_SetDefault(&data->editor_data);
                AUI_edit_SetDisplay(&data->editor_data, ZONE_FULL_SK_TITLE, COLOUR_EDITOR, EDITOR_FONT);  
          
                if ((sat_command->qual & SAT_M_INPUT_HELP_AVAIL) NEQ 0)
                {
                    AUI_edit_SetAltTextStr(&data->editor_data, inp->rspMin, TxtHelp, FALSE, TxtNull); /* help available */
                }
                else
                {
                	AUI_edit_SetAltTextStr(&data->editor_data, inp->rspMin, TxtNull, FALSE, TxtNull); /* help available */
                }

    			mode = 0;
    			if ((sat_command->qual & SAT_M_INPUT_NOECHO) NEQ 0)
    			{
    				mode |= ED_MODE_HIDDEN;
    			}

    			if ((sat_command->qual & SAT_M_INPUT_ALPHA) EQ 0) /* 0=digits, 1=alpha */
                {
                   /* Don't need to alter mode */
                }
                else
                {
                    mode |= ED_MODE_ALPHA;
                }

                if (inp->prompt.len > 0)
                {
                    textStr = (UBYTE *)sat_create_TEXT_ASCIIZ (&inp->prompt); /* label */
#ifdef NO_ASCIIZ/*MC SPR 940/2 Add tag to Unicode strings so info dialogue displays them correctly*/
    				sat_add_unicode_tag_if_needed(textStr);
#endif
                }
                else
                {
                    textStr =  NULL; /* no label */
                }

                AUI_edit_SetMode(&data->editor_data,mode,ED_CURSOR_UNDERLINE);
                AUI_edit_SetTextStr(&data->editor_data, TxtSoftOK, TxtSoftBack, TxtNull, textStr);
                AUI_edit_SetEvents(&data->editor_data, event, TRUE, TWENTY_SECS, (T_AUI_EDIT_CB)sat_editor_cb);

                defRsp = &inp->defRsp;
                if (defRsp->len > 0) /* default response available? */
                {
                    /* provide a zero terminated buffer, initially containing the default response */
                    sat_TEXT_to_ASCIIZ (data->edt_buffer, defRsp);
                }
                else
                {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -