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

📄 mmidict.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
		   	else {
		   		int i;
				i = dict_chinese_find_back(data->dict->edt_buf_ChnWord);
				if(i>=0)
					l_index = i;
		   	}
			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 {
				i = dict_chinese_find_next(data->dict->edt_buf_ChnWord);
				if(i>=0) {
					l_startline = 0;
					l_index = i;
				}
			}
		    data->properties.callback( data->win, WIN_UPDATE);
		}
		break;
		default:
			break;
    }
	/* always consume the event
	*/
    return MFW_EVENT_CONSUMED;
}

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

 $Function:     C2EShow_tim_cb

 $Description:  The  time out has occured 

 $Returns:    MFW_EVENT_CONSUMED always

 $Arguments:  e, event, tc timer context

*******************************************************************************/
static int C2EShow_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;
  T_MFW_HND parentwin=data->parent_win;
  
  TRACE_EVENT("C2EShow_tim_cb()");
  // stop running timer.
  if (data->tim != NULL ) {
    tim_delete (data->tim);
   // timStop(data->tim);
  }
  
  SEND_EVENT( data->win, SET_DESTROY, 0, 0 );
  data->win = 0;
  
  //SEND_EVENT( parentwin, SET_DESTROY, 0, 0 );
  //parentwin = 0;
	
  return MFW_EVENT_CONSUMED;
  
}

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

 $Function:     C2EShowCB

 $Description:  default call back for name entry

 $Returns:    None

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

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

void C2EShowCB( T_MFW_HND win, UBYTE reason )
{
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tDictStandard   *data       = (tDictStandard *) win_data->user;
	U8 omitflag=0;
	char	info[50];
	S16		idx;
	
    switch ( reason )
    {
    	case WIN_UPDATE:
    	{
			UINT32 OldBackColor;
			
			displaySoftKeys( data->properties.left_soft_key, data->properties.right_soft_key );
		    dspl_Clear(0,18,120,142);

			if(l_index<0){

				dspl_TextOut(16, 36, 0, MmiRsrcGetText(TxtNotFound));
				timStart(data->tim);
			}
			else if(l_index>=0) {
				int engline,i,j;
				int ybline=0;
				char buf[29];//57
				char yb_buf[29];
				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++);
		   		}
		   		
			   	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))
					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;
        }
    }
}


int DictTestEntry(void)
{
    T_MFW_HND win = mfw_parent(mfw_header());
	tdictInputSpecifics DefaultParameters;

	TRACE_FUNCTION ("DictEngToChnEntry()");
	
	//init the parameter
	l_index=0;
	l_startline = 0;
	l_opt = 0;
	
	DefaultParameters.text				= TxtDictTest;
	DefaultParameters.left_soft_key     = TxtDictStart;
	DefaultParameters.right_soft_key    = TxtChange;
	DefaultParameters.callback          = TestStartCB;

	/* allocate window, and if successful initialise it
	*/
    TestStart_Init( win, &DefaultParameters );

	return MFW_EVENT_CONSUMED;
}

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

 $Function:    	TestStart_Init

 $Description:	

 $Returns:		

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

	TRACE_FUNCTION ("TestStart_Init()");

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

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

 $Function:    	TestStart_create

 $Description:	

 $Returns:		

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

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

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

}

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

 $Function:    	TestStart_destroy

 $Description:	

 $Returns:		

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

	TRACE_FUNCTION ("TestStart_destroy()");

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

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

 $Function:    	TestStart_win_cb

 $Description:	

 $Returns:		

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

    TRACE_FUNCTION ("TestStart_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(TxtDictTest)))/2, 1, DSPL_TXTATTR_TRANSPARENT, MmiRsrcGetText(TxtDictTest), 0xffffff );
		    dspl_Clear(0,96,120,142);
			l_test_true_cnt = 0;
		    l_opt = 0;
	        l_booktotal = dict_getTotalByBook(l_book[FFS_flashData.DictBookIndex]);
		    l_startline = 0;	  	
            //change the softkey
		    if(!l_opt) {
				data->properties.left_soft_key     = TxtDictStart;
				data->properties.right_soft_key    = TxtChange;
    		}else{
				data->properties.left_soft_key     = TxtNull;
				data->properties.right_soft_key    = TxtDictDone;
    		}
		    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:    	TestStart_dialog

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
static void TestStart_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 ("TestStart_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;

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

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

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

 $Function:    	keyEvent

 $Description:	 keyboard event handler
 
 $Returns:		

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

static int TestStart_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;
	char			ascrange[30];
	char			unirange[60];
	static			UBYTE	Ischange=0;
    TRACE_FUNCTION ("TestStart_kbd_cb()");

	/* Handle the key press
	*/
    switch (k->code)
    {
	    case KCD_OK:
	    case KCD_LEFT:
		{

            l_booktotal = dict_getTotalByBook(l_book[FFS_flashData.DictBookIndex]);
	        if(l_opt==1){ //in setting
 				//update config
				if(FFS_flashData.StartGroup>l_booktotal/FFS_flashData.WordEveryGroup)
					FFS_flashData.StartGroup=l_booktotal/FFS_flashData.WordEveryGroup;
                l_opt = 0;
		    	dspl_Clear(0,112,120,128);
            	//change the softkey
				data->properties.left_soft_key     = TxtDictStart;
				data->properties.right_soft_key    = TxtChange;
		    	data->properties.callback( data->win, WIN_UPDATE);
		    	break;
	        }

            l_indexofbook = FFS_flashData.StartGroup*FFS_flashData.WordEveryGroup;
            l_index = dict_getWordByBook(l_indexofbook,l_book[FFS_flashData.DictBookIndex]);
            l_opt = 0;
            GenTestOption();
            l_test_true_cnt = 0;
      		TestWinEntry( data->win );
		}
		break;

		case KCD_HUP:
		{
            SEND_EVENT( data->win, SET_DESTROY, 0, 0 );
            data->win = 0;
		}
		break;

		case KCD_RIGHT:
		{
        	if(l_opt==0) {
                l_opt = 1;
             	//change the softkey
				data->properties.left_soft_key     = TxtDictDone;
             	if((l_index==2)&&(FFS_flashData.StartGroup>10)){
					data->properties.right_soft_key    = TxtDelete;
             	}else
					data->properties.right_soft_key    = TxtNull;
		    

⌨️ 快捷键说明

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