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

📄 mmichineseinput.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/*******************************************************************************

					CONDAT (UK)

********************************************************************************                                                                              

 This software product is the property of Condat (UK) Ltd and may not be
 disclosed to any third party without the express permission of the owner.                                 
                                                                              
********************************************************************************

 $Project name:	Basic MMI                                                      
 $Project code:	BMI (6349)                                                           
 $Module:		MmiChineseInput
 $File:		    MmiChineseInput.c
 $Revision:		1.0                                                       
                                                                              
 $Author:		Condat(UK)                                                         
 $Date:		    25/10/00                                                      
                                                                               
********************************************************************************
                                                                              
 Description:MMI Chinese Input handling.
 

                        
********************************************************************************

 $History: MmiChineseInput.c

	25/10/00			Original Condat(UK) BMI version.	
03/10/02		Replaced most of the file with version on 3.3.3 line (MC, SPR 1242)
	   
 $End

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


/*******************************************************************************
                                                                              
                                Include Files
                                                                              
*******************************************************************************/
#include <stdio.h>
#include <string.h>

#if defined (NEW_FRAME)

#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"

#else

#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"

#endif


#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
/* SPR#1428 - SH - New Editor changes */
#ifndef NEW_EDITOR
#include "mfw_edt.h"
#endif
#include "mfw_tim.h"
#include "mfw_phb.h"
#include "mfw_sms.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_lng.h"
#include "mfw_sat.h"
#include "mfw_kbd.h"
#include "mfw_nm.h"

#include "dspl.h"

#include "ksd.h"
#include "psa.h"

#include "MmiMain.h"
#include "MmiDummy.h"
#include "MmiMmi.h"

#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiMenu.h"
#include "MmiSoftKeys.h"
#include "MMIChineseInput.h"

#include "MmiSmsBroadcast.h"
#include "MmiSmsMenu.h"
#include "MmiSmsSend.h"
#include "MmiColours.h"

/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
#include "ATBCommon.h"
#include "ATBDisplay.h"
#include "ATBEditor.h"
#include "AUIEditor.h"
#include "AUISymbol.h"
#else
#include "MmiLatinPredText.h"
#endif

#define CHINESE_KEYPAD_TIME 			1000	/*one second*/
#define	MAX_PHONEBOOK_ENTRY_SIZE		10  
#define	LOWER_CASE_ASCII_OFFSET			97		/*ASCII code for 'a'*/
#define  EZITEXT_OUTPUT_OFFSET			0xF400 	/*Add to ASCII to get display code for Jospeh's pinyin font*/

#define CHI_FONT_WIDTH				12/*mc SPR1319*/

/* SPR#1428 - SH - New Editor: don't use SymbolChar */
#ifndef NEW_EDITOR
extern int SymbolChar;
#endif

/*MC 15/07/02 Keypad counters; keep track of how many times a key has been pressed*/
static char Counter[KCD_STAR];

/*MC 15/07/02 Keypad counters; keep track of how many times a key has been pressed*/
static char Counter[KCD_STAR];

static const unsigned char TextIconeZiTextSmall[] =
{
	0x03,
	0x03,
	0x18,
	0x7c,
	0xcc,
	0x08,
	0x10,
	0x0c
};
USHORT  TEXT_BUFFER_EDIT_SIZE;

/*mc SPR1319, makes it easier to keep track of the mfw editor*/
#ifdef LSCREEN
/* SPR#1428 - SH - New Editor changes */
  #ifdef NEW_EDITOR
	 T_ED_DATA *editor_pointer;
  #else /* NEW_EDITOR */
	 T_MFW_HND* editor_pointer;
  #endif /* NEW_EDITOR */
#endif

const char	StrokePrompt[]	= {0x7B, 0x14, 0x52, 0x12, 0x00, 0x3A, 0x00, 0x00};
const char	PinYinPrompt[]	= {0x62, 0xFC, 0x97, 0xF3, 0x00, 0x3A, 0x00, 0x00};
ZI8WCHAR const ZiStrokeKeyMap[10][3] =   /* table for PINYIN */
{
  {0,	ZI8_STROKE_MORE},
  {1, 	ZI8_STROKE_OVER},
  {2, 	ZI8_STROKE_DOWN},
  {3, 	ZI8_STROKE_LEFT},
  {4,  	ZI8_STROKE_DOT},
  {5, 	ZI8_STROKE_OVER_DOWN},
  {6, 	ZI8_STROKE_CURVED_HOOK},
  {7, 	ZI8_STROKE_DOWN_OVER},
  {8, 	ZI8_STROKE_MORE},
  {9, 	ZI8_STROKE_OVER_DOWN_OVER},
};

ZI8WCHAR const ZiPinYinKeyMap[9][6] =   /* table for PINYIN */
{
  {ZI8_CODE_TONES_1,	ZI8_CODE_TONES_2, 	ZI8_CODE_TONES_3, 	ZI8_CODE_TONES_4,	ZI8_CODE_TONES_5,	5},
  {ZI8_CODE_PINYIN_A, 	ZI8_CODE_PINYIN_B, 	ZI8_CODE_PINYIN_C, 	0, 					0, 					3},
  {ZI8_CODE_PINYIN_D, 	ZI8_CODE_PINYIN_E, 	ZI8_CODE_PINYIN_F, 	0,					0,					3},
  {ZI8_CODE_PINYIN_G, 	ZI8_CODE_PINYIN_H, 	ZI8_CODE_PINYIN_I, 	0,					0,					3},
  {ZI8_CODE_PINYIN_J,  	ZI8_CODE_PINYIN_K, 	ZI8_CODE_PINYIN_L, 	0,					0,					3},
  {ZI8_CODE_PINYIN_M, 	ZI8_CODE_PINYIN_N, 	ZI8_CODE_PINYIN_O, 	0,					0,					3},
  {ZI8_CODE_PINYIN_P, 	ZI8_CODE_PINYIN_Q, 	ZI8_CODE_PINYIN_R, 	ZI8_CODE_PINYIN_S,	0, 					4},
  {ZI8_CODE_PINYIN_T, 	ZI8_CODE_PINYIN_U, 	ZI8_CODE_PINYIN_V, 	0,					0, 					3},
  {ZI8_CODE_PINYIN_W, 	ZI8_CODE_PINYIN_X, 	ZI8_CODE_PINYIN_Y,	ZI8_CODE_PINYIN_Z,	0, 					4},
};

typedef struct _IME_DATA
{
    int				CandidateCursor;	/* the indication of the current candidate highlighted */
    unsigned short 	TextBufferCount;         // Total number of characters contained in the wszTextBuffer.
    unsigned char	candidates;			/* last returned number of candidates */
    int				TextCursor;			/* the current test cursor */
    PZI8WCHAR		pTextBuffer;		/* the start of the text buffer */
    int				TextBufferEditSize;	/*  */
    int				TextBufferSize;		/*  */
    unsigned char	moreCount;			/* keeps track of the more count */
    PZI8WCHAR		pDisplayElementBuffer;
    ZI8UCHAR		EditorMode;			     // To store current editor mode i.e. stroke, PinYin
    unsigned char	InputScreenType;        // This variable is to state the different screen type. 
    PZI8GETPARAM	pGetParam;			/* pointer to Zi8GetParam */
} IME_DATA, * PIME_DATA;

typedef struct
{
    T_MMI_CONTROL		mmi_control;
    T_MFW_HND 		    parent_win;
    T_MFW_HND       	input_win;
    T_MFW_HND       	input_kbd;
    USHORT          	Identifier;

    ZI8UCHAR 		   	version;	
    ZI8WCHAR* 		   	wszTextBuffer;/*[TEXT_BUFFER_EDIT_SIZE + 1];*/	/* TEXT_BUFFER_EDIT_SIZE = 80 */
    ZI8WCHAR 		   	DisplayElementBuffer[TEXT_BUFFER_EXTRA_SPACE + 1];	/* TEXT_BUFFER_EXTRA_SPACE = 20 */
    ZI8WCHAR 		   	wszElementBuffer[TEXT_BUFFER_EXTRA_SPACE + 1];		/* TEXT_BUFFER_EXTRA_SPACE = 20 */
    ZI8GETPARAM 	   	GetParam;
    IME_DATA 		   	Ime;
    ZI8WCHAR 		   	wcCandidates[CANDIDATES_PER_GROUP+1];			/* CANDIDATES_PER_GROUP = 7 */
	ZI8WCHAR			StartOfDisplayIndex;
    ZI8WCHAR		   	HighlightedCandidate[2];  // This arrary is used to store the highlighted character pointed by CandidateCursor
	ZI8WCHAR		   	CursorPosition[2];  //Used to show the cursor Position in the composed text.
	ZI8UCHAR			NumberOfKeyPress;
	CHAR				PerviousKeyPress;
	T_MFW_HND		    options_win;
    /* Start of variable decleared for dummy functions. This is to be removed when eZiText code is received*/
    /* End */
  	 T_CHINESE_DATA		Callback_Data;
	/*MC 15/07/02 keypad timer for Pinyin*/
	T_MFW_HND			KeyPad_Timer_Handle;
#ifdef LSCREEN
  #ifdef NEW_EDITOR	/* SPR#1428 - SH - New Editor changes */
	T_ED_DATA			*editor;
	T_ED_ATTR			editor_attr;
  #else /* NEW_EDITOR */
	T_MFW_HND			editor;/*mc SPR1319, using mfw_editor for colour display*/
	MfwEdtAttr			editor_attr;
  #endif /* NEW_EDITOR */
#endif /* LSCREEN */
} T_chinese_input;


static T_MFW_HND 	chinese_input_create 		(T_MFW_HND  parent_win);

static void	chinese_input_exec			(T_MFW_HND  win, USHORT event, SHORT value, void * parameter);
static int	chinese_input_win_cb		(T_MFW_EVENT event, T_MFW_WIN * win);
static int	chinese_input_kbd_cb		(T_MFW_EVENT event, T_MFW_KBD * keyboard);

/*mc 15/07/02*/
static int chinese_pinyin_timer_cb (MfwEvt e, MfwTim *t);

/* Initialize the defined structure */
void IMEInitialize(PIME_DATA pIME, PZI8GETPARAM pGetParam, PZI8WCHAR wszTextBuffer, int TextBufferEditSize,
				  int TextBufferSize, PZI8WCHAR wcCandidates, PZI8WCHAR wszElementBuffer, PZI8WCHAR DisplayElementBuffer);
void IMECursorLeft(PIME_DATA pIME); /* move the cadidate cursor left */
void IMECursorRight(PIME_DATA pIME); /* move the cadidate cursor right */
void IMESelectCandidate(PIME_DATA pIME, PZI8WCHAR wszElementBuffer); /* Select the candidate at sursor */
void IMEMore(PIME_DATA pIME); /* get the next group of candidates */
void IMEKeyPress(PIME_DATA pIME, ZI8WCHAR wcStroke); /* enter the stroke and get new candidates */
void IMEClear(PIME_DATA pIME, PZI8WCHAR wszElementBuffer); /* Clear the last stroke entered */
void CandidateHighlightDisplayContorl(PIME_DATA pIME, PZI8WCHAR HighlightedCandidate);
void TextCursorDisplayContorl(PIME_DATA pIME, PZI8WCHAR CursorPosition, int InsertLine);
void IMEChangeMode(PIME_DATA pIME, PZI8GETPARAM pGetParam);
void DataConvert(PIME_DATA pIME);
ZI8WCHAR Uni_strlen(PZI8WCHAR String);

/*****************************Functions*****************************************/
/*******************************************************************************

 $Function:    	LatinChar

 $Description:	Returns true if character is in ASCII range
 
 $Returns:		UBYTE (TRUE/FALSE)	

 $Arguments:	Wide char in Ezitext format (not our display format)
 
*******************************************************************************/
UBYTE LatinChar(ZI8WCHAR char_code)
{	//if last byte is 0x00 and first byte is between 0x20 and 0x7E
	if ((char_code% 0x100 == 0)&&(char_code>=0x2000) && (char_code<0x7F00))
		return TRUE;
	else
		return FALSE;
}

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

 $Function:    	chinese_input

 $Description:	starts chinese editor
 
 $Returns:		Window handle

 $Arguments:	parebt window, editor attribute structure
 
*******************************************************************************/
T_MFW_HND chinese_input (T_MFW_HND parent_win, T_CHINESE_DATA* chinese_data)
{
    T_MFW_HND	win;
    win = chinese_input_create (parent_win);
    if(win NEQ NULL)
    {
        SEND_EVENT (win, CHINESE_INPUT_INIT, 0, chinese_data);
    }
    return win;
}


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

 $Function:    	chinese_input_create

 $Description:	Creates chinese editor window
 
 $Returns:		Dialogue info win

 $Arguments:	parent win
 
*******************************************************************************/
static T_MFW_HND chinese_input_create (T_MFW_HND parent_win)
{
    T_MFW_WIN     *  win_data;
    T_chinese_input  *  data = (T_chinese_input *)ALLOC_MEMORY (sizeof (T_chinese_input));

    TRACE_EVENT ("chinese_input_create()");

    data->input_win = win_create (parent_win, 0, E_WIN_VISIBLE, (T_MFW_CB)chinese_input_win_cb);
    if(data->input_win EQ 0)
        return 0;
  	/* Create window handler */
    data->mmi_control.dialog	= (T_DIALOG_FUNC)chinese_input_exec;
    data->mmi_control.data		= data;
    data->parent_win    		= parent_win;
    win_data             		= ((T_MFW_HDR *)data->input_win)->data;
    win_data->user        		= (void *)data;

    /*MC 15/07/02 create timer for pinyin multitap*/
    data->KeyPad_Timer_Handle	= tim_create(data->input_win, CHINESE_KEYPAD_TIME, (MfwCb)chinese_pinyin_timer_cb);
    memset( Counter, 0, sizeof(char)*KCD_STAR);/*MC set counters to 0*/

⌨️ 快捷键说明

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