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

📄 mmibookinputwindow.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	/* always consume the event
	*/
    return MFW_EVENT_CONSUMED;
}






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

 $Function:		bookInputKbdLongCB

 $Description:	Keyboard long event handler
 
 $Returns:		MFW_EVENT_CONSUMED always

 $Arguments:	e, event, k, key handle
 
*******************************************************************************/

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

    TRACE_FUNCTION ("bookInputKbdLongCB()");


    /* subpress unwanted longpresses (mfw throws more than one long press event for one long press on a key)*/
    if ( e & KEY_LONG )
    {
	   	if ( DoNextLongPress EQ FALSE )
	       DoNextLongPress = TRUE; 
		else
	       DoNextLongPress = FALSE; 
    }
    if ( !DoNextLongPress )
        return MFW_EVENT_CONSUMED;      /* don't do current long press */

	

	/* Handling the long keypress events needs to deal with a 
	   number of characters in the input window, not just the
	   normal clear event
	*/
	
	/* if the event is long key clear and the buffer is not empty then
	   clear the buffer.  Otherwise if the buffer is empty then destroy
	   the input editor
	*/

	switch(k->code)
	{
		case KCD_HUP:	
		{
		    MfwEdt *edt;

			/* get edit control block
			*/
			edt = ((MfwHdr *) data->edt)->data;
	
			/* if buffer empty then kill the editor window, otherwise clear the buffer
			*/
			if ( edt->attr->text[0] )
			{
				char *c_ptr = data->properties.edt_attr_input->text;
				memset( c_ptr, '\0', strlen( c_ptr ) );
				edtReset( data->edt );
				edtShow( data->edt );
			}
			else
				bookInputDestroy( data->win );
		}
		break;

		case KCD_HASH:
			edtChar( data->edt, ecBack );
			edtChar( data->edt, 'p' );
		break;

		case KCD_0:
			edtChar( data->edt, ecBack );
			edtChar( data->edt, '+' );
		break;


		default:
		if (MODE EQ NAME)
		{
			
			if (UPPER_CASE EQ FALSE)
			{
				TRACE_EVENT("UPPER_CASE EQ FALSE");
				UPPER_CASE = TRUE;
				upCase = FALSE;	
				displaySoftKeys_edition (TxtLowercase, TxtNull ,TxtNull);														

			}
			else
			{
			    TRACE_EVENT("UPPER_CASE EQ TRUE");
				UPPER_CASE = FALSE;		
				upCase = TRUE;
				displaySoftKeys_edition (TxtUppercase, TxtNull ,TxtNull);														
			}
			edtChar(data->edt, ecBack);
		}
			break;
			
	}

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





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

 $Function:		bookInputCreate

 $Description:	Create the input window and asociate it's handlers
 
 $Returns:		handle of new window, or NULL if failure

 $Arguments:	parent, handle of the parent window
 
*******************************************************************************/

static T_MFW_HND bookInputCreate( MfwHnd parent )
{
    T_MFW_WIN		*parent_win_data    = ( (T_MFW_HDR *) parent )->data;
    tBookStandard   *parent_data        = (tBookStandard *) parent_win_data->user;
	T_phbk			*phbk               = parent_data->phbk;
	T_MFW_WIN		*win_data;
	tBookStandard	*data;

	TRACE_FUNCTION ("bookInputCreate()");

	/* allocate memory for our control block
	*/
	if ( ( data = (tBookStandard *) ALLOC_MEMORY( sizeof( tBookStandard ) ) ) == NULL )
		return NULL;

	/* Create the window if we can
	*/
	if ( ( data->win = win_create( parent, 0, E_WIN_VISIBLE, (T_MFW_CB) bookInputWindowCB ) ) == NULL )
	{
		FREE_MEMORY( (void *)data, sizeof( tBookStandard ) );
		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) bookInputDialog;
    data->mmi_control.data		= data;
    win_data					= ((T_MFW_HDR *)data->win)->data;
 	win_data->user				= (void *) data;
	data->phbk					= phbk;
	data->parent_win			= parent;

	/* create keyboards and menus for our window
	*/
	data->kbd		= kbdCreate( data->win, KEY_ALL,            (MfwCb) bookInputKbdCB );
    data->kbd_long	= kbdCreate( data->win, KEY_ALL | KEY_LONG, (MfwCb) bookInputKbdLongCB );

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





/*******************************************************************************
                                                                              
                                Public Methods
                                                                              
*******************************************************************************/

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

 $Function:		bookInputStart

 $Description:	Start the input handler
 
 $Returns:		Handle of newly created window, or NULL if failure

 $Arguments:	parent, parent window handle, properties, input window property
				control block.
 
*******************************************************************************/

MfwHnd bookInputStart( MfwHnd parent,tInputSpecifics *properties )
{
	T_MFW_HND win;

	TRACE_FUNCTION ("bookInputStart()");

	/* allocate window, and if successful initialise it
	*/
	if ( ( win = bookInputCreate( parent ) ) != NULL )
		SEND_EVENT( win, INPUT_INIT, 0, properties );
	return win;
}


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

 $Function:		bookInputStartNumberEditor

 $Description:	Start the input handler using default properties
 
 $Returns:		Handle of newly created window, or NULL if failure

 $Arguments:	parent, parent window handle, buffer, input buffer
 
*******************************************************************************/

MfwHnd bookInputStartNumberEditor( MfwHnd parent, void *buffer )
{
    T_MFW_HND	    win         = parent;
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
    tBookStandard   *data       = (tBookStandard *) win_data->user;
    T_phbk          *Phbk       = data->phbk;
    tInputSpecifics DefaultParameters;

	TRACE_FUNCTION ("bookInputStartNumberEditor()");
	MODE = NUMBER;
	
    /* Set up the default parameters for the input window
    */
	bookSetEditAttributes( NUMBER_EDITOR, COLOUR_EDITOR_XX, 0, edtCurBar1, 0, 
		(char *) buffer, NUMBER_LENGTH, &Phbk->edt_attr_number );

	DefaultParameters.abc               = FALSE;
	DefaultParameters.text              = TxtEnterNumber;
	DefaultParameters.edt_attr_input    = &Phbk->edt_attr_number;
	DefaultParameters.left_soft_key     = TxtSoftOK;
	DefaultParameters.right_soft_key    = TxtDelete;//Changed text
	// dunno if that changes softkey functionality
	DefaultParameters.callback          = bookAddNumberCB;

	/* allocate window, and if successful initialise it
	*/
    return bookInputStart( parent, &DefaultParameters );
}



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

 $Function:		bookInputStartNameEditor

 $Description:	Start the input handler using default properties
 
 $Returns:		Handle of newly created window, or NULL if failure

 $Arguments:	parent, parent window handle, buffer, input buffer
 
*******************************************************************************/

MfwHnd bookInputStartNameEditor( MfwHnd parent, void *buffer )
{
    T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) parent )->data;
    tBookStandard   *data       = (tBookStandard *) win_data->user;
    T_phbk          *Phbk       = data->phbk;

    tInputSpecifics DefaultParameters;

	MODE = NAME;

	TRACE_FUNCTION ("bookInputStartNameEditor()");

    /* Set up the default parameters for the input window */

    /*MC 1957, name strings should use MAX_ALPHA_LEN*/
	bookSetEditAttributes( NUMBER_EDITOR, COLOUR_EDITOR_XX, 0, edtCurBar1, 0, 
		(char *) buffer, MAX_ALPHA_LEN, &Phbk->edt_attr_name );

 /*SPR 1434*/

 /*SPR 1526, changed #ifdef to #if*/
#if defined(CHINESE_MMI) && defined(EASY_TEXT_ENABLED)
/*MC, the chinese editor MUST have a unicode string as input*/
/*MC , SPR 1242 merged in from b-sample build*/
	if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
	{	T_CHINESE_DATA chinese_data;
		chinese_data.TextString = (char*) Phbk->edt_buf_name;
		if (chinese_data.TextString[0]== 0)//if, empty string
		{	chinese_data.TextString[0] = 0x80;//give string Unicode tag
			chinese_data.TextString[1] = 0x7F;
		}
		else
		{	char l_name[MAX_ALPHA_LEN];
			int ascii_len = strlen(chinese_data.TextString);
			int i;
			if (chinese_data.TextString[0]!= 0x80)/*If ASCII string*/
			{	memset(l_name, '\0', MAX_ALPHA_LEN);
				l_name[0] = 0x80;//give Unicode tag
				l_name[1] = 0x7F;	
				/*convert ascii string to unicode*/
				{	for (i =0; i < (ascii_len); i++) 
						{	if ((2+2*i+1)>=MAX_ALPHA_LEN)
								break;
							l_name[2+2*i] = 0x00; 
							l_name[2+2*i+1] = chinese_data.TextString[i]; 
						}
						if ((2+2*i+1)<=MAX_ALPHA_LEN)
						{	l_name[2+2*i] = 0x00;		//double null termination
							l_name[2+2*i+1] = 0x00;
						}
				}
				memcpy(chinese_data.TextString, l_name, MAX_ALPHA_LEN);
			}
		}
		/*MC end*/

		chinese_data.Callback = (T_EDIT_CB)bookAddNameCB;
		chinese_data.Identifier = INPUT_LEFT ;
		chinese_data.LeftSoftKey = TxtSave;
		chinese_data.DestroyEditor = TRUE;
		chinese_data.EditorSize = (USHORT)((MAX_ALPHA_LEN-4)/2);//i.e.8
		return chinese_input(parent, &chinese_data);
	}
	else
#endif
	{
		DefaultParameters.abc               = TRUE;
		DefaultParameters.text              = TxtEnterName;
		DefaultParameters.edt_attr_input    = &Phbk->edt_attr_name;
		DefaultParameters.left_soft_key     = TxtSoftOK;
		DefaultParameters.right_soft_key    = TxtDelete;//Changed text - MC
		DefaultParameters.callback          = bookAddNameCB;

		/* allocate window, and if successful initialise it
		*/
   		return bookInputStart( parent, &DefaultParameters );
	}
}



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

 $Function:		bookInputDestroy

 $Description:	Destroy Input Window
 
 $Returns:		None

 $Arguments:	Handle of window to be destroyed
 
*******************************************************************************/

void bookInputDestroy( MfwHnd window )
{
	T_MFW_WIN     *win  = ((T_MFW_HDR *) window)->data;
	tBookStandard *data = (tBookStandard *) win->user;

	TRACE_FUNCTION ("bookInputDestroy()");

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

#endif /* NEW_EDITOR */

/*******************************************************************************
                                                                              
                                End of File
                                                                              
*******************************************************************************/

⌨️ 快捷键说明

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