📄 mmitextinput.c
字号:
/*******************************************************************************
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: MmiTextInput
$File: MmiTextInput.c
$Revision: 1.0
$Author: sunsj
$Date: 2003/12/04
********************************************************************************
Description:MMI text Input handling.
********************************************************************************
$History: MmiTextInput.c
$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"
#include "mfw_edt.h"
#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 "MmiTextInput.h"
#include "Mmieditor_i.h"
#include "MmiSmsBroadcast.h"
#include "MmiSmsMenu.h"
#include "MmiSmsSend.h"
#include "Mmisat_i.h"
#include "Mmisymbol.h"
/* 2004/06 sunsj modify for icon manage */
#include "mmiiconresource.h"
//#define TDTRACE 1
#include "mmiutilapi.h"
/****************************************************************************************
GLOBAL DEFINE
*****************************************************************************************/
#define MaxPinYin 402
#define MAX_TEXT_INPUT_MODE SHUZI_INPUT_MODE
/***********************************************************************************************
************************************************************************************************/
static const unsigned char TextIconeZiTextSmall[] =
{
0x03,
0x03,
0x18,
0x7c,
0xcc,
0x08,
0x10,
0x0c
};
int test = ELEMENT_LINE;
static const char StrokePrompt[] = {0x7B, 0x14, 0x52, 0x12, 0x00, 0x3A, 0x00, 0x00};
static const char PinYinPrompt[] = {0x62, 0xFC, 0x97, 0xF3, 0x00, 0x3A, 0x00, 0x00};
/* 2003/12/22 sunsj modify table */
static 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_WILDCARD},
{9, ZI8_STROKE_OVER_DOWN_OVER},
};
static 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},
};
static const char * PinyinTable[MaxPinYin] = {
"a","ai","an","ang","ao","ba","bai","ban","bang","bao",
"bei","ben","beng","bi","bian","biao","bie","bin","bing","bo",
"bu","ca","cai","can","cang","cao","ce","cen","ceng","cha",
"chai","chan","chang","chao","che","chen","cheng","chi","chong","chou",
"chu","chuai","chuan","chuang","chui","chun","chuo","ci","cong","cou",
"cu","cuan","cui","cun","cuo","da","dai","dan","dang","dao",
"de","deng","di","dia","dian","diao","die","ding","diu","dong",
"dou","du","duan","dui","dun","duo","e","ei","en","er",
"fa","fan","fang","fei","fen","feng","fo","fou","fu","ga",
"gai","gan","gang","gao","ge","gei","gen","geng","gong","gou",
"gu","gua","guai","guan","guang","gui","gun","guo","ha","hai",
"han","hang","hao","he","hei","hen","heng","hong","hou","hu",
"hua","huai","huan","huang","hui","hun","huo","ji","jia","jian",
"jiang","jiao","jie","jin","jing","jiong","jiu","ju","juan","jue",
"jun","ka","kai","kan","kang","kao","ke","ken","keng","kong",
"kou","ku","kua","kuai","kuan","kuang","kui","kun","kuo","la",
"lai","lan","lang","lao","le","lei","leng","li","lia","lian",
"liang","liao","lie","lin","ling","liu","long","lou","lu","luan",
"lue","lun","luo","lv","ma","mai","man","mang","mao","me",
"mei","men","meng","mi","mian","miao","mie","min","ming","miu",
"mo","mou","mu","na","nai","nan","nang","nao","ne","nei",
"nen","neng","ni","nian","niang","niao","nie","nin","ning","niu",
"nong","nou","nu","nuan","nue","nuo","nv","o","ou","pa",
"pai","pan","pang","pao","pei","pen","peng","pi","pian","piao",
"pie","pin","ping","po","pou","pu","qi","qia","qian","qiang",
"qiao","qie","qin","qing","qiong","qiu","qu","quan","que","qun",
"ran","rang","rao","re","ren","reng","ri","rong","rou","ru",
"ruan","rui","run","ruo","sa","sai","san","sang","sao","se",
"sen","seng","sha","shai","shan","shang","shao","she","shen","sheng",
"shi","shou","shu","shua","shuai","shuan","shuang","shui","shun","shuo",
"si","song","sou","su","suan","sui","sun","suo","ta","tai",
"tan","tang","tao","te","teng","ti","tian","tiao","tie","ting",
"tong","tou","tu","tuan","tui","tun","tuo","wa","wai","wan",
"wang","wei","wen","weng","wo","wu","xi","xia","xian","xiang",
"xiao","xie","xin","xing","xiong","xiu","xu","xuan","xue","xun",
"ya","yan","yang","yao","ye","yi","yin","ying","yo","yong",
"you","yu","yuan","yue","yun","za","zai","zan","zang","zao",
"ze","zei","zen","zeng","zha","zhai","zhan","zhang","zhao","zhe",
"zhen","zheng","zhi","zhi","zhong","zhou","zhu","zhua","zhuai","zhuan",
"zhuang","zhui","zhun","zhuo","zi","zong","zou","zu","zuan","zui","zun","zuo"
};
static UBYTE ec_editControls [KCD_MAX] = /* edit control keys: */
{
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'*', '#', ecNone, ecNone, ecUp, ecDown, ecLeft, ecRight,
ecNone, ecNone, ecEnter, ecNone, ecNone, ecNone,
ecNone, ecNone, ecEnter
};
const static char * l_editAlphaL[14] = // lowercase key 0123456789*#
{
"\'\"/.+-=0", " ,.?!:1", "abc2", "def3", //key 0,1,2,3
"ghi4", "jkl5", "mno6", "pqrs7", //key 4,5,6,7
"tuv8", "wxyz9", "*#%&@ ", " \'\"/","\0","\0" //key 8,9,*,#
};
const static char * l_editAlphaU[14] = // uppercase key 0123456789*#
{
"\'\"/.+-=0", " ,.?!:1", "ABC2", "DEF3", //key 0,1,2,3
"GHI4", "JKL5", "MNO6", "PQRS7", //key 4,5,6,7
"TUV8", "WXYZ9", "*#%&@ ", " \'\"/","\0","\0" //key 8,9,*,#
};
static int editor_input_mode;
static USHORT TEXT_BUFFER_EDIT_SIZE;
static UBYTE editAlphaLevel; /* alpha level selected */
static UBYTE editAlphaKey; /* alpha mode current key */
static BOOL FirstEnterEditor;
static MfwHnd TextInputHandle = 0;
static BOOL ComponentFlag = FALSE; /* 2003/12/15 sunsj component flag */
static BOOL input_key_timer_flag = 0; /* 2004/06/28 sunsj add */
/***********************************************************************************************
************************************************************************************************/
static T_MFW_HND text_input_create (T_MFW_HND parent_win);
static void text_input_exec_cb (T_MFW_HND win, USHORT event, SHORT value, T_EDITOR_DATA * parameter);
static int text_input_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
static int text_input_kbd_cb (T_MFW_EVENT event, T_MFW_KBD * keyboard);
static int text_input_tim_cb (T_MFW_EVENT event, T_MFW_TIM *tc);
static int text_input_key_tim_cb (T_MFW_EVENT event, T_MFW_TIM *tc);
/* Initialize the defined structure */
static void IMEInitialize(pIME_DATA pIME, PZI8GETPARAM pGetParam, PZI8WCHAR wszTextBuffer, int TextBufferEditSize,
int TextBufferSize, PZI8WCHAR wcCandidates, PZI8WCHAR wszElementBuffer, PZI8WCHAR DisplayElementBuffer);
static void IMECursorLeft(pIME_DATA pIME); /* move the candidate cursor left */
static void IMECursorRight(pIME_DATA pIME); /* move the candidate cursor right */
static void IMESelectCandidate(pIME_DATA pIME, PZI8WCHAR wszElementBuffer); /* Select the candidate at cursor */
static void IMEMore(pIME_DATA pIME); /* get the next group of candidates */
static void IMEKeyPress(pIME_DATA pIME, ZI8WCHAR wcStroke); /* enter the stroke and get new candidates */
static void IMEClear(pIME_DATA pIME, PZI8WCHAR wszElementBuffer); /* Clear the last stroke entered */
static void CandidateHighlightDisplayContorl(pIME_DATA pIME, PZI8WCHAR HighlightedCandidate);
static void TextCursorDisplayContorl(pIME_DATA pIME, PZI8WCHAR CursorPosition, int InsertLine);
static void IMEChangeMode(pIME_DATA pIME, PZI8GETPARAM pGetParam);
static void DataConvert(pIME_DATA pIME);
static ZI8WCHAR Uni_strlen(PZI8WCHAR String);
static void Zi_onekey_keypress(pIME_DATA pIME , PZI8WCHAR key_map); /* enter the key and get pinyin and candidate */
static int Zi_GetElementCandidates(pIME_DATA pIME); /* getcandidate through element */
static void UnicodeConver(USHORT* inputString, USHORT* outputString);
static void Zi_onekey_clear(pIME_DATA pIME); /* clear element or text */
static void IMECandidatePageUp(pIME_DATA pIME); /* page up candidate */
static void IMECandidatePageDown(pIME_DATA pIME); /* page down candidate */
static void DisplayPinyinElement(pIME_DATA pIME); /* display pinyin element */
static void IMESetDefaultValue(pIME_DATA pIME); /* reset IME value */
static int GetKeyEventConfig( T_TEXT_INPUT* textEditorData );
static void ChangeDisplayArea( MfwHnd TexInputHandle, int DisplayArea, T_TEXT_INPUT* textEditorData );
static void DrawPromptIcon( int InputMode );
static void EditorSoftkey(T_TEXT_INPUT *data); /* 2004/03/23 sunsj add */
static void DisplayOtherArea(T_TEXT_INPUT *data); /* 2004/03/23 sunsj add */
/***********************************************************************************************
************************************************************************************************/
static 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: text_input
$Description:
$Returns:
$Arguments:
*******************************************************************************/
T_MFW_HND text_input (T_MFW_HND parent_win, T_EDITOR_DATA* text_input_data)
{
T_MFW_HND win;
win = text_input_create (parent_win);
if( win NEQ NULL )
{
SEND_EVENT (win, TEXT_INPUT_INIT, 0, text_input_data);
}
return win;
}
/*******************************************************************************
$Function: text_input_create
$Description:
$Returns: Dialogue info win
$Arguments: parent win
*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -