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

📄 mmidict.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
	/* Handle the visible event, otherwise return MFW_EVENT_PASSED
	*/
	switch( event)
    {
        case MfwWinVisible:
		{
			/* Window visible
			
			*/
		}
		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:    	C2EInput_dialog

 $Description:	

 $Returns:		

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

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

int DictChnEditEntry(T_MFW_HND win)
{
    T_MFW_WIN		*win_data	= ((T_MFW_HDR *) win)->data;
    tDictStandard	*data		= (tDictStandard *) win_data->user;
    T_dict			*dict		=data->dict;
 	T_EDITOR_DATA editor_data;

	TRACE_FUNCTION ("DictChnEditEntry()");
	
	dict_loadEditDefault(&editor_data);

	//editor_attr_init_only( &editor_data.editor_attr,0, 17, 120, 16, TITLE_TOP, TxtChnToEng, 
	//	dict->edt_buf_ChnWord,WORD_MAX_LEN+3,edtCurBar1,0);
	editor_attr_init_fullscr(&editor_data.editor_attr,1, TxtChnToEng, //hxl changed 2003-4-11
		dict->edt_buf_ChnWord,WORD_MAX_LEN+3,edtCurBar1);
	editor_data.LeftSoftKey          = TxtSoftOK;
	editor_data.RightSoftKey         = TxtDelete;
	editor_data.mode				 = PARADISE_MODE;
	editor_data.min_enter				=1;
	editor_data.edtInPbk			=0;
	editor_data.Callback             = (T_EDIT_CB)InputChnWordCB;
	editor_data.destroyEditor		 = FALSE;
	

	//allocate window, and if successful initialise it
    dict->editorwin =editor_start(win, &editor_data); /* start the editor */ 
	
	return MFW_EVENT_CONSUMED;

	
}

void dict_loadEditDefault(T_EDITOR_DATA *editor_data)
{
	    TRACE_FUNCTION ("dict_loadEditDefault()");

		editor_attr_init(&editor_data->editor_attr, NULL, edtCurBar1, 0, 0, 0);
		editor_data->hide 					= FALSE;
		editor_data->min_enter				= 1;  // Avoid to return empty strings
		editor_data->LeftSoftKey          = TxtSoftSelect;
		editor_data->RightSoftKey         = TxtSoftBack;
		editor_data->AlternateLeftSoftKey	= TxtNull;
		editor_data->TextId               = '\0';  
		editor_data->Identifier           =  0; 
		editor_data->TextString           = NULL;  
		editor_data->timeout			  = FOREVER;  // Avoid to return empty strings
		editor_data->mode                 = ALPHA_MODE;
		editor_data->Callback             = NULL;
		editor_data->destroyEditor        = TRUE ; 
}

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

 $Function:     InputChnWordCB

 $Description:  default call back for name entry

 $Returns:    None

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

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

void InputChnWordCB( T_MFW_HND win,  USHORT Identifier, UBYTE reason )
{
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tDictStandard   *data       = (tDictStandard *) win_data->user;
	
    switch ( reason )
    {
        case INFO_KCD_LEFT:
        {
			//editor_destroy(data->dict->editorwin);//edit win destroy
			//data->dict->editorwin = 0;
			
        	if(strlen(data->dict->edt_buf_ChnWord ) == 0)
        		break;
            //l_index = dict_chinese_find_first(data->dict->edt_buf_ChnWord );
            l_index=-2;
            DictShowInformation(win,0,TxtSearching,NULL,1000,search_chn,(T_VOID_FUNC)Dict_Inofrmation_cb);

        }
    	break;

    	case INFO_KCD_RIGHT:
    	case INFO_KCD_HUP:
        {
              TRACE_EVENT("hxl1");
          /* Both right and clear can do the same task here
            */
        
			editor_destroy(data->dict->editorwin);//edit win destroy
			data->dict->editorwin = 0;
			
            SEND_EVENT( win, SET_DESTROY, 0, 0 );//c2einput win destroy
            win = 0;
            TRACE_EVENT("hxl2");
        }
    	break;
    	case INFO_EDT_UPDATE:
        	if(strlen(data->dict->edt_buf_ChnWord ) == 0){
        		data->properties.left_soft_key=TxtNull;
        		data->properties.right_soft_key =TxtSoftBack;
			}else{
        		data->properties.left_soft_key=TxtSoftOK;
				data->properties.right_soft_key =TxtDelete;
			}
			displaySoftKeys( data->properties.left_soft_key, data->properties.right_soft_key );
    	break;
        default:
        {
            /* otherwise no action to be performed
            */
        break;
        }
  }
}

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

 $Function:    	C2EShowWinEntry

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
MfwHnd C2EShowWinEntry(T_MFW_HND win,T_dict *dict)
{
    	tdictInputSpecifics DefaultParameters;

	TRACE_FUNCTION ("C2EShowWinEntry()");
	
	DefaultParameters.text              = TxtChnToEng;
	DefaultParameters.left_soft_key	= TxtNull;//Changed text ,TxtDelete
	DefaultParameters.right_soft_key    = TxtSoftBack;//Changed text ,TxtDelete
	DefaultParameters.callback          = C2EShowCB;

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

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

 $Function:    	C2EShowWinStart

 $Description:	

 $Returns:		

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

	TRACE_FUNCTION ("C2EShowWinStart()");

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


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

 $Function:    	C2EShow_create

 $Description:	

 $Returns:		

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

	TRACE_FUNCTION ("C2EShow_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) C2EShow_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) C2EShow_dialog;
    data->mmi_control.data		= data;
    win_data					= ((T_MFW_HDR *)data->win)->data;
 	win_data->user				= (void *) data;
	data->parent_win			= parent_window;
	data->dict					= dict;
	/* create keyboards and menus for our window
	*/
	data->kbd		= kbdCreate( data->win, KEY_ALL, (MfwCb) C2EShow_kbd_cb );
	data->tim		= timCreate(data->win,   1000,         (MfwCb) C2EShow_tim_cb);
	
	/* And return the handle of the newly created window
	*/

    return data->win;

}





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

 $Function:    	C2EShow_destroy

 $Description:	

 $Returns:		

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

	TRACE_FUNCTION ("C2EShow_destroy()");

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



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

 $Function:    	C2EShow_win_cb

 $Description:	

 $Returns:		

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

    TRACE_FUNCTION ("C2EShow_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(TxtChnToEng)))/2, 1, DSPL_TXTATTR_TRANSPARENT, MmiRsrcGetText(TxtChnToEng), 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:    	C2EShow_dialog

 $Description:	

 $Returns:		

 $Arguments:	
 
*******************************************************************************/
static void C2EShow_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 ("C2EShow_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
			*/
			C2EShow_destroy( win );
		}
		break;
	}
}

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

 $Function:    	C2EShow_keyEvent

 $Description:	 keyboard event handler
 
 $Returns:		

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

static int C2EShow_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 ("C2EShow_kbd_cb()");

	/* Handle the key press
	*/
    switch (k->code)
    {
    	case KCD_RIGHT:
		{
			l_startline = 0;
            //if(l_index==-1)
               //	 timStop(data->tim);	
            
            SEND_EVENT( data->win, SET_DESTROY, 0, 0 );
            data->win = 0;
		}
    	break;
    	case KCD_HUP:
		{
			T_MFW_HND parentwin=data->parent_win;//delete for return one layer 2002-12-9

			l_startline = 0;
            //if(l_index==-1)
               // timStop(data->tim);	
            
            SEND_EVENT( data->win, SET_DESTROY, 0, 0 );
            data->win = 0;
			
            SEND_EVENT( parentwin, SET_DESTROY, 0, 0 );//delete for return one layer 2002-12-9
            parentwin = 0;
		}
		break;
		case KCD_MNUUP:
		   	if(l_startline)
		   		l_startline--;

⌨️ 快捷键说明

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