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

📄 mmidict.c

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

 $Description:	

 $Returns:		

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

    TRACE_FUNCTION ("E2CInput_win_cb()");
	/* Handle the visible event, otherwise return MFW_EVENT_PASSED
	*/
	switch( event)
    {
        case MfwWinVisible:
		{
			//UINT32 OldBackColor;
			/* Window visible
			*/
			//if(l_e2cshow_input)
			//	break;
			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(TxtE2CGreeting)))/2, 1, DSPL_TXTATTR_TRANSPARENT, MmiRsrcGetText(TxtE2CGreeting), 0xffffff );
			dspl_Clear(0,34,120,142);
			displaySoftKeys( data->properties.left_soft_key, data->properties.right_soft_key );
			
			if (  strlen(data->properties.edt_attr_input->text)> 0){
				l_index =dict_english_find(data->properties.edt_attr_input->text);
			}
			l_opt = 0;//hxl 0220
			data->properties.parent_callback( data->win, WIN_UPDATE,0 );//hxl changed for back show selecting before 2002-12-9
		}
		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:    	E2CInput_dialog

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
static void E2CInput_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 ("E2CInput_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.abc			= properties->abc;
			data->properties.text			= properties->text;
			data->properties.edt_attr_input	= properties->edt_attr_input;
			data->properties.left_soft_key	= properties->left_soft_key;
			data->properties.right_soft_key	= properties->right_soft_key;
			data->properties.parent_callback	= properties->parent_callback;
            data->edt						= edtCreate( data->win, data->properties.edt_attr_input, 0, 0 );

			/* activate our editor, stopping any others before doing so
			*/
			ec_editDeactivate();
		    ec_editActivate(data->edt, data->properties.abc);//
			edtChar( data->edt, ecBottom );

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

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

 $Function:    	keyEvent

 $Description:	 keyboard event handler
 
 $Returns:		

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

static int E2CInput_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;
	int	i=0;
  	static	uint8	oldlen=0;
  TRACE_FUNCTION ("E2CInput_kbd_cb()");
	/* make sure the active editor is ours
	*/

    if ( getactiveEditor() != data->edt )
        ec_editActivate( data->edt, data->properties.abc );
    

	/* Handle the key press
	*/
    switch (k->code)
    {
		case KCD_MNUUP:
		{
			if(l_opt>0)
				l_opt --;
			else if((l_index-LIST_COL+3)>=0){
			    l_index-=LIST_COL-3;
			    l_opt=0;
			}else{
			    l_opt=0;
			    l_index=0;
			}
			data->properties.parent_callback( data->win, WIN_UPDATE ,0);
		}
		break;

	    case KCD_MNUDOWN:
		{
			if(l_opt<(LIST_COL-4)) {
			    if(dict_eng(l_index+l_opt+1))
			    	l_opt ++;
			} else if(dict_eng(l_index+LIST_COL-3)) {
				l_index+=LIST_COL-3;
				l_opt=0;
			}else{
				l_opt=0;
				l_index=0;
			}
			data->properties.parent_callback( data->win, WIN_UPDATE,0 );
		}
		break;

	    case KCD_LEFT:
	    case KCD_OK:
		{
			/* select the entry using the parent window callback
			*/
		    data->properties.parent_callback( data->win, SET_LEFT ,0);
		   
		}
		break;

		case KCD_HUP:
		{
            data->properties.parent_callback( data->win, SET_CLEAR,0 );
		}
		break;

		case KCD_RIGHT:
		{
			//If we have any data input, delete the char before cursor
			if ( strlen(data->properties.edt_attr_input->text) > 0 ){
				edtChar( data->edt, ecBack );
				//if no char ,change the rightkey
				if(strlen(data->properties.edt_attr_input->text) == 0){
					data->properties.right_soft_key =TxtSoftBack;
					l_index=0;//for meue_up_down show from "a";2002-12-9
					l_opt = 0;
				}
				E2CInputShowUpdate( win_data );
			}else{
				data->properties.parent_callback( data->win, SET_CLEAR,0 );
			}
			 
		}
		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:
		{
			//If we  input first, softkey show delete
			data->properties.right_soft_key =TxtDelete;
		    ec_editEventKey( e, k );
			if(oldlen!=strlen(data->properties.edt_attr_input->text) ){
				E2CInputShowUpdate( win_data);
				oldlen=strlen(data->properties.edt_attr_input->text);
			}else{
				if(data->tim!= NULL)
					timStop(data->tim);
				timStart(data->tim);
			}
		}
		break;
	    default:
			break;
    }

	/* always consume the event
	*/
    return MFW_EVENT_CONSUMED;
}

static void	E2CInputShowUpdate(T_MFW_WIN * win)
{
	tDictStandard *data = (tDictStandard *) win->user;
	int	len=strlen(data->properties.edt_attr_input->text);

	dspl_Clear(0,34,120,142);

	if(len<=1){
		displaySoftKeys( data->properties.left_soft_key, data->properties.right_soft_key );
	}	
	if (len> 0){
		l_index =(dict_english_find(data->properties.edt_attr_input->text));
		l_opt = 0;
	}
	
	data->properties.parent_callback( data->win, WIN_UPDATE,0 );//hxl changed for back show selecting before 2002-12-9

}


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

 $Function:     C2EEdit_tim_cb

 $Description:  The  time out has occured 

 $Returns:    MFW_EVENT_CONSUMED always

 $Arguments:  e, event, tc timer context

*******************************************************************************/
static int C2EEdit_tim_cb( MfwEvt e, MfwTim *tc )
{
  T_MFW_HND win = mfw_parent(mfw_header());
  T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
  tDictStandard	*data		= (tDictStandard *) win_data->user;

  TRACE_EVENT("TestPrompt_tim_cb()");
  // stop running timer.
  if (data->tim != NULL ) {
    timStop(data->tim);
  }
	E2CInputShowUpdate( win_data);

  return MFW_EVENT_CONSUMED;
  
}

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

 $Function:     InputEngWordCB

 $Description:  default call back for name entry

 $Returns:    None

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

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

void InputEngWordCB( T_MFW_HND win, UBYTE reason, USHORT identifier)
{

    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tDictStandard   *data       = (tDictStandard *) win_data->user;

    TRACE_FUNCTION ("InputEngWordCB()");

    switch ( reason )
    {
        case SET_LEFT:
        {
        	if((strlen(data->properties.edt_attr_input->text) == 0)&&(l_opt==-1))//for select word don't show e2c err 2002-12-9
        		break;
    		l_index += l_opt;
    		l_opt = 0;//hxl 0220
      		data->dict->e2cshow_win=E2CShowWinEntry( win );
        }
    	break;

    	case SET_CLEAR:
        {
            /* Both right and clear can do the same task here
            */
            
            SEND_EVENT( win, SET_DESTROY, 0, 0 );
            win = 0;
        }
    	break;
    	case WIN_UPDATE://WIN_UPDATE printscreen
    	{
    		int i;
    		if(l_opt<=0){
				for(i=0;i<LIST_COL-3;i++)
					SetListItem(dict_eng((l_index+i)),2+i,l_opt==i);
    		}else{
				SetListItem(dict_eng((l_index+l_opt-1)),2+l_opt-1,0);
				SetListItem(dict_eng((l_index+l_opt)),2+l_opt,1);
				if(l_opt<LIST_COL-4)
					SetListItem(dict_eng((l_index+l_opt+1)),2+l_opt+1,0);
    		}
    		if(l_opt<2){
				dspl_Clear(0, 34, 120, 34);
				dspl_DrawLine(0, 34, 119, 34);
    		}
    	}
    	break;
    	case SET_KEY:
		{

			//If we  input first, softkey show delete
			data->properties.right_soft_key =TxtDelete;
			memset(data->properties.edt_attr_input->text ,'\0', WORD_MAX_LEN ); 
			edtChar( data->edt, DicteditAlpha[identifier-2]);
			
			E2CInputShowUpdate( win_data);
		}
    	break;
        default:
        {
            /* otherwise no action to be performed
            */
        break;
        }
  }}

MfwHnd E2CShowWinEntry(T_MFW_HND win)
{
    tdictInputSpecifics DefaultParameters;

	TRACE_FUNCTION ("E2CShowWinEntry()");
	
	//l_e2cshow_input=0;
   
	DefaultParameters.text              = TxtEngToChn;
	DefaultParameters.left_soft_key	= TxtNull;//Changed text ,TxtDelete
	DefaultParameters.right_soft_key    = TxtSoftBack;//Changed text ,TxtDelete
	DefaultParameters.callback          = E2CShowCB;
	DefaultParameters.parent_callback	= InputEngWordCB;

	// allocate window, and if successful initialise it
	return E2CShowWinStart( win, &DefaultParameters );
    
}

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

 $Function:    	E2CShowWinStart

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
T_MFW_HND E2CShowWinStart (T_MFW_HND parent_window,tdictInputSpecifics *properties)
{
	T_MFW_HND win;

	TRACE_FUNCTION ("E2CShowWinStart()");

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


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

 $Function:    	E2CShow_create

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
T_MFW_HND E2CShow_create (T_MFW_HND parent_window)
{
	T_MFW_WIN		*win_data;
	tDictStandard	*data;

	TRACE_FUNCTION ("E2CShow_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) E2CShow_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) E2CShow_dialog;
    data->mmi_control.data		= data;
    win_data					= ((T_MFW_HDR *)data->win)->data;
 	win_data->user				= (void *) data;
	data->parent_win			= parent_window;

	/* create keyboards and menus for our window
	*/
	data->kbd		= kbdCreate( data->win, KEY_ALL, (MfwCb) E2CShow_kbd_cb );

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

}





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

 $Function:    	E2CShow_destroy

 $Description:	

 $Returns:		

⌨️ 快捷键说明

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