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

📄 mmidict.c

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

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

	TRACE_FUNCTION ("E2CShow_destroy()");

	if (data)
	{
		winDelete ( data->win );
		FREE_MEMORY( (void *) data, sizeof( tDictStandard ) );
	}
}



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

 $Function:    	E2CShow_win_cb

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
static int E2CShow_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
{
	tDictStandard *data = (tDictStandard *) win->user;

    TRACE_FUNCTION ("E2CShow_win_cb()");
	/* Handle the visible event, otherwise return MFW_EVENT_PASSED
	*/
	switch( event)
    {
        case MfwWinVisible:
		{
			/* Window visible
			*/
			dspl_BitBlt( menuup[FlashSettingData.theme].area.px,menuup[FlashSettingData.theme].area.py,
           		menuup[FlashSettingData.theme].area.sx,menuup[FlashSettingData.theme].area.sy,0,menuup[FlashSettingData.theme].icons,0);
			dspl_colorTextOut((120-8*wstrBitlen(MmiRsrcGetText(TxtEngToChn)))/2, 1, DSPL_TXTATTR_TRANSPARENT, MmiRsrcGetText(TxtEngToChn), 0xffffff );
		    data->properties.callback( data->win, WIN_UPDATE);
		}
		break;

        default:
		{
			/* unabel to handle event, pass handling of event back up tree
			*/
			return MFW_EVENT_PASSED;
		}
    }

	/* if we get here, we have handled the event
	*/
    return MFW_EVENT_CONSUMED;
}


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

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

 $Function:    	E2CShow_dialog

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
static void E2CShow_dialog(T_MFW_HND win, USHORT event, SHORT value, void *parameter)
{
    T_MFW_WIN		*win_data	= ((T_MFW_HDR *) win)->data;
    tDictStandard	*data		= (tDictStandard *) win_data->user;
	tdictInputSpecifics	*properties = (tdictInputSpecifics *) parameter;

    TRACE_FUNCTION ("E2CShow_dialog()");

	/* Handle the input event, ew only deal with initialise and
	   destroy of the window in here
	*/
    switch( event )
	{
		case SET_INIT:
		{
			// Initialise the input window
			data->properties.text			= properties->text;
			data->properties.left_soft_key	= properties->left_soft_key;
			data->properties.right_soft_key	= properties->right_soft_key;
			data->properties.callback		= properties->callback;
			data->properties.parent_callback  = properties->parent_callback;

			/* show the window
			*/
			winShow( data->win );
    		
		}
		break;

		case SET_DESTROY:
		{
			/* destroy the input window
			*/
			E2CShow_destroy( win );
		}
		break;
	}
}

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

 $Function:    	E2CShow_keyEvent

 $Description:	 keyboard event handler
 
 $Returns:		

 $Arguments:	
 				
*******************************************************************************/

static int E2CShow_kbd_cb (MfwEvt e, MfwKbd *k)
{
    T_MFW_HND       win			= mfwParent( mfw_header() );
    T_MFW_WIN		*win_data	= ((T_MFW_HDR *) win)->data;
    tDictStandard	*data		= (tDictStandard *) win_data->user;

    TRACE_FUNCTION ("E2CShow_kbd_cb()");
	/* Handle the key press
	*/
    switch (k->code)
    {
		case KCD_RIGHT:
		{
 		       l_opt = 0;//for back show selecting before 2002-12-9
			l_startline = 0;
			
            		data->properties.callback( data->win, SET_CLEAR );
		}
		break;
		case KCD_HUP:
		{
			T_MFW_HND parent_win = data->parent_win;
            data->properties.callback( data->win, SET_CLEAR );
            
            SEND_EVENT( parent_win, SET_DESTROY, 0, 0 );
            parent_win = 0;
		}
		break;
		case KCD_MNUUP:
		   	if(l_startline)
		   		l_startline--;//hxl try on the phone ,but phone poweron again
		   	else if(l_index>0)
		   		l_index--;
		    data->properties.callback( data->win, WIN_UPDATE);
		    break;
		    
		case KCD_MNUDOWN:
		{
			int i,j;
			char buf[57];
			i = strlen(dict_eng(l_index));
			j = strlen(dict_yb(l_index));
			/*
			if(j) {
				if(i<=14 && i+j>12)
					sprintf(buf,"%-14s<%s>",dict_eng(l_index),dict_yb(l_index));
				else
					sprintf(buf,"%s<%s>",dict_eng(l_index),dict_yb(l_index));
			} else
				sprintf(buf,"%s",dict_eng(l_index));
			for(i=0;GetListLine(buf,i);i++);*/
			for(i=0;GetListLine(dict_eng(l_index),i);i++);
			if(j)
				for(j=0;GetListLine(dict_yb(l_index),j);j++);
			
			if(GetListLine(dict_chn(l_index), l_startline+LIST_COL-2-i-j))
				l_startline++;
			else if(dict_eng(l_index+1)) {
				l_startline = 0;
				l_index++;
			}
			data->properties.callback( data->win, WIN_UPDATE);
		}
		break;
		case KCD_2:
		case KCD_3:
		case KCD_4:
		case KCD_5:
		case KCD_6:
		case KCD_7:
		case KCD_8:
		case KCD_9:
		{
			T_MFW_HND parentwin=data->parent_win;//delete for return one layer 2002-12-9
			USHORT kcode=k->code;
			//l_e2cshow_input=1;
            data->properties.parent_callback( parentwin, SET_KEY, kcode);
            data->properties.callback( data->win, SET_CLEAR );
            
			
		//	return MFW_EVENT_PASSED;
		}
		break;
		default:
			break;
    }
    
	/* always consume the event
	*/
    return MFW_EVENT_CONSUMED;
}




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

 $Function:     E2CShowCB

 $Description:  default call back for name entry

 $Returns:    None

 $Arguments:  win, handle of parent window, reason, for invocation

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

void E2CShowCB( T_MFW_HND win, UBYTE reason )
{
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tDictStandard   *data       = (tDictStandard *) win_data->user;

    TRACE_FUNCTION ("E2CShowCB()");
    
    switch ( reason )
    {
    	case WIN_UPDATE:
    	{
			U8 omitflag=0;
			UINT32  OldBackColor;
			
		    dspl_Clear(0,18,120,142);

			displaySoftKeys( data->properties.left_soft_key, data->properties.right_soft_key );

			if(l_index<0){
				SetListItem(MmiRsrcGetText(TxtNotFound),1,0);
			}
			else if(l_index>=0) {
				int engline,i,j;
				int ybline=0;
				char buf[29];//57
				char yb_buf[29];
				char test[20];
				memset(buf,0,29);
				memset(yb_buf,0,29);
		   		//get engline
		   		for(engline=0;GetListLine(dict_eng(l_index),engline);engline++);
		   		//get ybline
		   		yb_codeconvert(dict_yb(l_index),buf);
		   		j=strlen(buf);
		   		if(j){
		   			sprintf(yb_buf,"<%s>",buf);
		   			for(ybline=0;GetListLine(yb_buf,ybline);ybline++);
		   		}
		   		
		   		sprintf(test,"idx:%d",l_index);
		   		TRACE_EVENT(test);
		   		
			   	for(i=0;i<LIST_COL-2;i++) {
			   		if(GetListLine(dict_eng(l_index),l_startline+i)){
						SetListItem(GetListLine(dict_eng(l_index), l_startline+i),i+1,0);
			   		}else if(j&&GetListLine(yb_buf,l_startline+i-engline)){
			   			set_font_type(YB8X16_FONT);
						SetListItem(GetListLine(yb_buf, l_startline+i-engline),i+1,0);
			   		}else{
			   			SetListItem(GetListLine(dict_chn(l_index), l_startline+i-engline-ybline),i+1,0);
			   		}
			   	}	
			   	if(GetListLine(dict_chn(l_index), l_startline+i-engline-ybline))
					omitflag = 1;
    			if(omitflag) 
    				dspl_TextOut(0, (LIST_COL-1)*18, 0,"...");
			}
    	}
    	break;
    	case SET_CLEAR:
            /* Both right and clear can do the same task here
            */
            SEND_EVENT( win, SET_DESTROY, 0, 0 );
            win = 0;
    	break;
        default:
        {
            /* otherwise no action to be performed
            */
        break;
        }
    }
}



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

 $Function:    	DictChnToEngEntry

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
int DictChnToEngEntry(MfwMnu *m, MfwMnuItem *i ) 
{
    T_MFW_HND win = mfw_parent(mfw_header());
	tdictInputSpecifics DefaultParameters;
	T_dict	*dict;

	TRACE_FUNCTION ("DictChnToEngEntry()");
	
	//init the parameter
	l_index=-2;
	l_startline = 0;
	l_opt = 0;
	MODE = CHN;
	
	/* allocate memory for our control block
	*/
	if ( ( dict = (T_dict *) ALLOC_MEMORY( sizeof( T_dict ) ) ) == NULL )
		return NULL;

    memset( dict->edt_buf_ChnWord, '\0', WORD_MAX_LEN+2 ); 

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

}

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

 $Function:    	C2EInput_Start

 $Description:	

 $Returns:		

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

	TRACE_FUNCTION ("C2EInput_Start()");

	/* allocate window, and if successful initialise it
	*/
	if ( ( win = C2EInput_create( parent_window ,dict) ) != NULL )
		DictChnEditEntry( win);
	
	return win;
}


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

 $Function:    	C2EInput_create

 $Description:	

 $Returns:		

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

	TRACE_FUNCTION ("C2EInput_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) C2EInput_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) C2EInput_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;

	/* And return the handle of the newly created window
	*/
    return data->win;

}

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

 $Function:    	C2EInput_destroy

 $Description:	

 $Returns:		

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

	TRACE_FUNCTION ("C2EInput_destroy()");

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


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

 $Function:    	C2EInput_win_cb

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
static int C2EInput_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
{
	tDictStandard *data = (tDictStandard *) win->user;

    TRACE_FUNCTION ("C2EInput_win_cb()");

⌨️ 快捷键说明

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