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

📄 mmidict.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
/*******************************************************************************

					CONDAT (UK)

********************************************************************************                                                                              

 This software product is the property of Condat (UK) Ltd and may not be
 disclosed to any third party without the express permission of the owner.                                 
                                                                              
********************************************************************************

 $Project name:	Basic MMI                                                      
 $Project code:	BMI (6349)                                                           
 $Module:		Supplementary services
 $File:		    Mmidict.c
 $Revision:		1.0                                                       
                                                                              
 $Author:		hxl(Mobile Innovation)                                                         
 $Date:		    28/06/02                                                      
                                                                               
********************************************************************************
                                                                              
 Description

    This module provides the supplementary services functionality

  
********************************************************************************
 $History: Mmidict.c

	01/08/02 			huangxl creat.	
	   
 $End

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


/******************************************************************************
                                                                              
                                Include Files
                                                                              
*******************************************************************************/

#define BUGS 0

#define ENTITY_MFW
/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#if defined (NEW_FRAME)

#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"

#else

#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"

#endif

#include "mfw_sys.h"

#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_lng.h"
#include "mfw_edt.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_tim.h"

#include "mfw_sim.h"
#include "mfw_cm.h"
#include "mfw_nm.h"
#include "mfw_phb.h"
#include "mfw_mme.h"
#include "mfw_sat.h"
#include "mfw_sms.h"

#include "dspl.h"

#include "ksd.h"
#include "psa.h"

#include "MmiMain.h"
#include "MmiBookController.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiLists.h"



#include "MmiMenu.h"
#include "MmiCall.h"
#include "MmiIcons.h"
#include "MmiIdle.h"

#include "MmiSoftKeys.h"
#include "MmiSounds.h"
#include "MmiIdle.h"
#include "MmiNetwork.h"
#include "MmiSat_i.h"
#include "MmiAoc.h"

#include "gdi.h"
#include "audio.h"

#include "cus_aci.h"
#include "p_sim.h"
#include "mfw_ffs.h"
#include "MmiTimers.h"

#include "rtc_api.h"
#include "mmihz.h"
#include "mmieditor.h"
#include "mmiusersymbolinput.h" 
#include "Mmidict.h"
#include "Mmidictfunc.h"

#ifdef EASY_TEXT_ENABLED
#include "MmiChineseInput.h"
#endif

#define LIST_COL	8
#define LIST_LEN	15

typedef enum{
	searched_chn=DictDummy,
	search_chn,
	searched_fail
}DICTIDTIFY;

//move from el630dict---------------------------------------------------
static S16	l_index;  // index of current word and in START it is the position of setting
static U8	l_startline; // the start line of word for display
static S8	l_opt; // it is a reused variable;
					// for WIN_UPDATE,it is the selection of list
					// for TEST_START&RECITE_START, it is a flag of changing configurate
					// for RECITE, it's a flag of displaying Chinese
					// for TEST, it is the index of selection,0:Q,1:A,2:B,3:C,4:D
static U16	l_booktotal; //the total word of current book
static S16	l_indexofbook; // the word index of current book
static U8	l_test_true_cnt; // it is the true count of testing;
							// in recite,it also used for sequence of chinese and english->0:EC;1:CE;2:list
static S16	l_test_opt[4];
static U8   l_lastkey;
//static U8	l_e2cshow_input;//if it is 1,indicate the e2cinput_win_show will clear edit buffer first
static const int l_booktext[] = {
		TxtSchool,
		TxtCET4,
		TxtCET6,
		TxtGraduate,
		TxtTOEFL,
		TxtGRE,
		TxtBusiness,
		TxtMBA
};
static const char l_book[] = {
	BOOK_SCHOOL,
	BOOK_CET4,
	BOOK_CET6,
	BOOK_GRADUATE,
	BOOK_TOEFL,
	BOOK_GRE,
	BOOK_BUSINESS,
	BOOK_MBA
};

static UBYTE DicteditAlpha [8]=           /* alpha mode characters    */
{
    'a', 'd','g','j','m','p','t','w'
};

extern	INT8	g_norejectkeyflag;//add for editor 2002-12-27

void dictSetEditAttributes(
    U16  winPx,   U16 winPy, U16 winSx, U16 winSy,
	U8   fgColor, U8  font,  U8  mode,  U8  *controls,
	char *text,   U16 size,
	MfwEdtAttr*   attr);
static char *  GetListLine(char*buf,int line);
static void SetListItem( char*buf,int listnum,UBYTE invers);
static S16 GenIndex(int range0,int range1,unsigned int rand);
static void GenTestOption(void);
void yb_codeconvert(char* in,char* out);

T_MFW_HND E2CInput_Start (T_MFW_HND parent_window,tdictInputSpecifics *properties,T_dict *dict);
T_MFW_HND E2CInput_create (T_MFW_HND parent_window,T_dict *dict);
void E2CInput_destroy (T_MFW_HND own_window);
static void E2CInput_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
static int E2CInput_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static int E2CInput_kbd_cb (MfwEvt e, MfwKbd *k);
void InputEngWordCB( T_MFW_HND win, UBYTE reason , USHORT identifier);
static void	E2CInputShowUpdate(T_MFW_WIN * win);
static int C2EEdit_tim_cb( MfwEvt e, MfwTim *tc );

MfwHnd E2CShowWinEntry(T_MFW_HND win);
T_MFW_HND E2CShowWinStart (T_MFW_HND parent_window,tdictInputSpecifics *properties );
T_MFW_HND E2CShow_create (T_MFW_HND parent_window);
void E2CShow_destroy (T_MFW_HND own_window);
static int E2CShow_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static void E2CShow_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
static int E2CShow_kbd_cb (MfwEvt e, MfwKbd *k);
void E2CShowCB( T_MFW_HND win, UBYTE reason );



T_MFW_HND C2EInput_Start (T_MFW_HND parent_window,tdictInputSpecifics *properties ,T_dict *dict);
T_MFW_HND C2EInput_create (T_MFW_HND parent_window,T_dict *dict);
void C2EInput_destroy (T_MFW_HND own_window);
static int C2EInput_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static void C2EInput_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
//static int C2EInput_kbd_cb (MfwEvt e, MfwKbd *k);
static MfwHnd DictShowInformation( MfwHnd parent, int txtId, int txtId2, char *str, unsigned long time,USHORT identifier,T_VOID_FUNC cb_function );
static int Dict_Inofrmation_cb(T_MFW_HND win, USHORT identifier, USHORT reason);

int DictChnEditEntry(T_MFW_HND win);
void dict_loadEditDefault(T_EDITOR_DATA *editor_data);
void InputChnWordCB( T_MFW_HND win, USHORT Identifier, UBYTE reason );

MfwHnd C2EShowWinEntry(T_MFW_HND win,T_dict *dict);
T_MFW_HND C2EShowWinStart (T_MFW_HND parent_window,tdictInputSpecifics *properties,T_dict *dict );
T_MFW_HND C2EShow_create (T_MFW_HND parent_window,T_dict *dict);
void C2EShow_destroy (T_MFW_HND own_window);
static int C2EShow_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static void C2EShow_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
static int C2EShow_kbd_cb (MfwEvt e, MfwKbd *k);
static int C2EShow_tim_cb( MfwEvt e, MfwTim *tc );
void C2EShowCB( T_MFW_HND win, UBYTE reason );

T_MFW_HND TestStart_Init (T_MFW_HND parent_window,tdictInputSpecifics *properties );
T_MFW_HND TestStart_create (T_MFW_HND parent_window);
void TestStart_destroy (T_MFW_HND own_window);
static int TestStart_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static void TestStart_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
static int TestStart_kbd_cb (MfwEvt e, MfwKbd *k);
void TestStartCB( T_MFW_HND win, UBYTE reason );

MfwHnd TestWinEntry(T_MFW_HND win);
T_MFW_HND Test_Init (T_MFW_HND parent_window,tdictInputSpecifics *properties,T_dict *dict);// 
T_MFW_HND Test_create (T_MFW_HND parent_window,T_dict *dict);//
void Test_destroy (T_MFW_HND own_window);
static int Test_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static void Test_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
static int Test_kbd_cb (MfwEvt e, MfwKbd *k);
void TestCB( T_MFW_HND win, UBYTE reason );

MfwHnd TestPromptWinEntry(T_MFW_HND win);
T_MFW_HND TestPrompt_Init (T_MFW_HND parent_window,tdictInputSpecifics *properties );
T_MFW_HND TestPrompt_create (T_MFW_HND parent_window);
void TestPrompt_destroy (T_MFW_HND own_window);
static int TestPrompt_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static void TestPrompt_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
static int TestPrompt_kbd_cb (MfwEvt e, MfwKbd *k);
static int TestPrompt_tim_cb( MfwEvt e, MfwTim *tc );
void TestPromptCB( T_MFW_HND win, UBYTE reason );

MfwHnd TestResultWinEntry(T_MFW_HND win);
T_MFW_HND TestResult_Init (T_MFW_HND parent_window,tdictInputSpecifics *properties );
T_MFW_HND TestResult_create (T_MFW_HND parent_window);
void TestResult_destroy (T_MFW_HND own_window);
static int TestResult_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static void TestResult_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
static int TestResult_kbd_cb (MfwEvt e, MfwKbd *k);
void TestResultCB( T_MFW_HND win, UBYTE reason );

T_MFW_HND Recite_create (T_MFW_HND parent_window);
void Recite_destroy (T_MFW_HND own_window);
static void Recite_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
T_MFW_HND Recite_Init (T_MFW_HND parent_window,tdictInputSpecifics *properties );
static int Recite_kbd_cb (MfwEvt e, MfwKbd *k);
static int Recite_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
void ReciteCB( T_MFW_HND win, UBYTE reason );


T_MFW_HND ReciteEnd_create (T_MFW_HND parent_window);
void ReciteEnd_destroy (T_MFW_HND own_window);
static void ReciteEnd_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
T_MFW_HND ReciteEnd_Init (T_MFW_HND parent_window,tdictInputSpecifics *properties );
static int ReciteEnd_kbd_cb (MfwEvt e, MfwKbd *k);
static int ReciteEnd_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
MfwHnd ReciteEndWinEntry(T_MFW_HND win);
void ReciteEndCB( T_MFW_HND win, UBYTE reason );

T_MFW_HND ReciteStart_create (T_MFW_HND parent_window);
void ReciteStart_destroy (T_MFW_HND own_window);
static void ReciteStart_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter);
T_MFW_HND ReciteStart_Init (T_MFW_HND parent_window,tdictInputSpecifics *properties );
static int ReciteStart_kbd_cb (MfwEvt e, MfwKbd *k);
static int ReciteStart_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
MfwHnd ReciteWinEntry(T_MFW_HND win);
void ReciteStartCB( T_MFW_HND win, UBYTE reason );


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

 $Function:    	DictEngToChnEntry

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
//char edt_buf[WORD_MAX_LEN];
//MfwEdtAttr attr;		/* Editor attributes */
int DictEngToChnEntry(MfwMnu *m, MfwMnuItem *i ) 
{
    T_MFW_HND win = mfw_parent(mfw_header());
	tdictInputSpecifics DefaultParameters;
	T_dict	*dict;
	int	j=0;

	TRACE_FUNCTION ("DictEngToChnEntry()");
	
	//init the parameter
	l_index=0;
	l_startline = 0;
	l_opt = -1;//hxl add for select the second word when edit is blank 2002-12-9
	MODE = ENG;
	l_booktotal=0;
	for(j=0;j<(sizeof(l_booktext)/sizeof(int));j++)
		l_booktotal+=dict_getTotalByBook(l_book[j]);
	/* allocate memory for our control block
	*/
	if ( ( dict = (T_dict *) ALLOC_MEMORY( sizeof( T_dict ) ) ) == NULL )
		return NULL;

    memset( dict->edt_buf_EngWord, '\0', WORD_MAX_LEN ); 
	dictSetEditAttributes( 0, 18, 120, 16, 0, 0, edtCurBar1, 0, 
		dict->edt_buf_EngWord , WORD_MAX_LEN+3, &dict->edt_attr_EngWord);

	
	DefaultParameters.abc               = LOWERCASE_MODE;
	DefaultParameters.text              = TxtE2CGreeting;
	DefaultParameters.edt_attr_input    = &dict->edt_attr_EngWord;
	DefaultParameters.left_soft_key     = TxtSoftOK;
	DefaultParameters.right_soft_key    = TxtSoftBack;//Changed text ,TxtDelete
	// dunno if that changes softkey functionality
	DefaultParameters.parent_callback	= InputEngWordCB;

	//allocate window, and if successful initialise it
    if(E2CInput_Start( win, &DefaultParameters, dict )==NULL)
		FREE_MEMORY( (void *)dict, sizeof( T_dict ) );
    
	return MFW_EVENT_CONSUMED;

}

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

 $Function:    	E2CInput_Start

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
T_MFW_HND E2CInput_Start (T_MFW_HND parent_window,tdictInputSpecifics *properties ,T_dict *dict)
{
	T_MFW_HND win;

	TRACE_FUNCTION ("E2CInput_Start()");

	/* allocate window, and if successful initialise it
	*/
	if ( ( win = E2CInput_create( parent_window ,dict) ) != NULL )
		SEND_EVENT( win, SET_INIT, 0, properties );
	
	return win;
}


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

 $Function:    	E2CInput_create

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
T_MFW_HND E2CInput_create (T_MFW_HND parent_window,T_dict *dict)
{
	T_MFW_WIN		*win_data;
	tDictStandard	*data;

	TRACE_FUNCTION ("E2CInput_create()");
	
	/* allocate memory for our control block
	*/
	if ( ( data = (tDictStandard *) ALLOC_MEMORY( sizeof( tDictStandard ) ) ) == NULL )
		return NULL;

	/* Create the window if we can
	*/
	if ( ( data->win = win_create( parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB) E2CInput_win_cb ) ) == NULL )
	{
		FREE_MEMORY( (void *)data, sizeof( tDictStandard ) );
		return NULL;
	}

	/* Okay, we have created the control block and the window, so
	   we now need to configure the dialog and data pointers
	*/
    data->mmi_control.dialog	= (T_DIALOG_FUNC) E2CInput_dialog;
    data->mmi_control.data		= data;
    win_data					= ((T_MFW_HDR *)data->win)->data;
 	win_data->user				= (void *) data;
 	data->dict					= dict;
	data->parent_win			= parent_window;
	
	g_norejectkeyflag=1;//add for editor 2002-12-27

	/* create keyboards and menus for our window
	*/
	data->kbd		= kbdCreate( data->win, KEY_ALL ,            (MfwCb) E2CInput_kbd_cb );
	data->tim		= timCreate(data->win,   300,         (MfwCb) C2EEdit_tim_cb);
	/* And return the handle of the newly created window
	*/
    return data->win;

}

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

 $Function:    	E2CInput_destroy

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
void E2CInput_destroy (T_MFW_HND own_window)
{
	T_MFW_WIN     *win  = ((T_MFW_HDR *) own_window)->data;
	tDictStandard *data = (tDictStandard *) win->user;

	TRACE_FUNCTION ("bookInputDestroy()");

	if (data)
	{
		ec_editDeactivate();
        edtDelete(data->edt);
		g_norejectkeyflag=0;//add for editor 2002-12-27

		winDelete ( data->win );
		FREE_MEMORY( (void *)data->dict, sizeof( T_dict ) );
		FREE_MEMORY( (void *)data, sizeof( tDictStandard ) );
	}
}


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

⌨️ 快捷键说明

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