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

📄 pinyinwb.c

📁 好记星的控件,包括button,list,对文件操作
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************/
/*																		 */
/* 				Copyright (C) 2004 SHENZHEN MEIJIN CO.LTD           	 */
/*																		 */
/* FILE NAME:	PinYinWB.c                                        		 */
/* MODULE NAME:	拼音和五笔输入法        								 */
/* DESCRIPTION:	输入法													 */
/*																		 */
/*************************************************************************/
/* 	  DTAE	     AUTHOR	    VERSION    				REMARKS       		 */
/* =========== ==========  =========  ===================================*/
/* 2004-12-18  Bingle      Ver 1.00   笔点机							 */
/* 2007-04-05  mann        Ver 1.1    针对6X8系列无数字键进行修改		 */
/*************************************************************************/
#include "Kernel.h"
#include "ImeIn.h"

UINT8   g_byPYShengPressed;
UINT8	g_pIMEPyIndexBuffer[IM_INBUFF_LEN];
UINT8	g_pIMEWordBuffer[IM_WORD_MAX*2];		//IM_WORD_MAX*2
UINT16 	g_pIMECurIndex;
UINT16	g_pIMEWbOrderNum;
UINT16	g_pIMEWordIndexNum;						//用于五笔取数据

VOID _PinYinDrawGraph(UINT uType);
char Char2Num(UINT uChar);

/****************************************************************************/
/* FUNCTION:   _IMEHandleEvent												*/
/* DESCRIPTION:输入法消息处理公共函数										*/
/* INPUTS:     uType,当前输入法类型										*/
/*				pEvent,消息结构												*/
/* OUTPUTS:    pEvent														*/
/* RETURN:     消息处理结果												*/
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse		2003-04-04     创建初始版本                                 */
/****************************************************************************/
FOR_IME_ALL


INT _IMEHandleEvent(IMEGUI_STRUCT *pApGui,  UINT *pEvent, UINT *pParam,UINT uType)
{
	BOOL bClearMsg;
	UINT16 wMsgX;
	UINT inputlen;
	char cC2N;
	
	bClearMsg = FALSE;
	wMsgX = (UINT16)*pParam;

	if (*pEvent == EVENT_DRAW)
	{
		g_mInputBox.refresh = IME_NEED_REFRESH;
	}
	else if(*pEvent == EVENT_KEY|| *pEvent==EVENT_KEYREPEAT)
	{
		BOOL bDirectOut;
		bDirectOut = FALSE;
		if(g_mInputBox.state == IM_INPUT_ERROR)
		{
			__ResetIME();
		}

		if(wMsgX == MVK_ESCAPE)
		{
			if(g_mInputBox.state == IM_INPUT_NULL)
			{
				return 0;
			}
			else
			{
				__ResetIME();
				bClearMsg = TRUE;
			}
		}
		else if (wMsgX == ' ')
		{
			bDirectOut = FALSE;
		}
		else if(wMsgX == MVK_DELETE || wMsgX == MVK_BACKSPACE)
		{
			if(g_mInputBox.state == IM_INPUT_NULL || g_mInputBox.state == IM_INPUT_LX)
			{
				return 0;
			}

			else if(g_mInputBox.state == IM_INPUT_ZC || g_mInputBox.state == IM_INPUT_DOING)
			{
					g_pIMEInBuffer[--g_pIMEInputednum] = 0;
					if (g_pIMEInputednum == 0)
					{
						__ResetIME();
					}
					else
					{
						_PyWbGetData(uType);
						g_mInputBox.state = IM_INPUT_DOING;
					}

					g_mInputBox.refresh = IME_NEED_REFRESH;
					bClearMsg = TRUE;
			}
			else
			{
				__ResetIME();
			}
		}

		__IMEGetChar(pEvent,pParam);
		if(pApGui->uCurrentIme != IME_JAPANESE){    //added by Liang Ruhui at 2007-07-09
			__ImeConvertCase(pEvent,pParam);
		}
		wMsgX = (UINT16)*pParam;
		if(!bDirectOut)
		{
			switch (g_mInputBox.state)
			{
				case IM_INPUT_NULL:
					if (MyIsAlpha(wMsgX))//(wMsgX >= 'a' && wMsgX <= 'z')
					{
						g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)wMsgX;
						g_mInputBox.state = IM_INPUT_DOING;
						_PyWbGetData(uType);
						g_mInputBox.refresh = IME_NEED_REFRESH;
						bClearMsg = TRUE;
					}
					break;

				case IM_INPUT_DOING:	/*正在输入*/
					if (wMsgX == ' ')
					{
						if (uType == IME_WUBI)
						{
							*pParam = '1';
							wMsgX = '1';
							bClearMsg = !_IMEGetSelectWord(pEvent,pParam);
							break;
						}
						else if(uType == IME_JAPANESE){
							if(g_pIMEWordNum == 1){
								*pParam = '1';
								wMsgX = '1';
								bClearMsg = !_IMEGetSelectWord(pEvent,pParam);
							}
							else if(g_pIMEWordNum > 1){
								/*输入状态,左右键用来输入选字模式*/
								g_mInputBox.state = IM_INPUT_ZC;	/*转入选字模式,并更新显示*/
								g_mInputBox.refresh = TRUE;
								bClearMsg = TRUE;								
							}
							else{
								bClearMsg = TRUE;
							}
							break;							
						}
						else if (uType == IME_PINYIN)
						{
							g_mInputBox.state = IM_INPUT_ZC;
						}
						else
						{
							break;
						}
					}
					else if (MyIsAlpha(wMsgX))//(wMsgX >= 'a' && wMsgX <= 'z')
					{
						if (uType == IME_WUBI)
						{
							inputlen = IMWB_INPUT_LEN;
						}
						else
						{
							inputlen = IMPY_INPUT_LEN;
						}

						if (g_pIMEInputednum < inputlen)
						{
							if (uType == IME_PINYIN)
							{
								UINT8 *pTail;

								pTail = &g_pIMEInBuffer[g_pIMEInputednum - 1];
								if (!MyIsAlpha(*pTail))
								{
									bClearMsg = TRUE;
									break;
								}
							}
							g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)wMsgX;
							_PyWbGetData(uType);

							if( uType == IME_WUBI && g_pIMEInputednum == IMWB_INPUT_LEN)
							{
								if (g_pIMEWordNum == 1 )
								{
									*pParam = '1';
									_IMEGetSelectWord(pEvent,pParam);
									return 0;
								}
								else
								{
									g_mInputBox.state = IM_INPUT_ZC;
									g_mInputBox.refresh = TRUE;
								}
							}
							
						}
						bClearMsg = TRUE;
						break;
					}
					else if(wMsgX == MVK_LEFT || wMsgX == MVK_RIGHT || wMsgX == MVK_ENTER )
					{
						/*输入状态,左右键用来输入选字模式*/
						g_mInputBox.state = IM_INPUT_ZC;	/*转入选字模式,并更新显示*/
						g_mInputBox.refresh = TRUE;
						bClearMsg = TRUE;
						break;
					}
				case IM_INPUT_LX:		//联想状态
				case IM_INPUT_LXZC:
				case IM_INPUT_ZC:		/*选择字词*/

					if(wMsgX == MVK_LEFT || wMsgX == MVK_RIGHT)
					{
						/*选字模式,左右键用来进行翻页*/
						g_mInputBox.refresh = _imLeftRight(pEvent,pParam);
						bClearMsg = TRUE;
					}
					else if (wMsgX == ' ')
					{
						if ((uType == IME_WUBI))
						{
							*pParam = '1';
							wMsgX = '1';
							bClearMsg = !_IMEGetSelectWord(pEvent,pParam);
							break;
						}
						else if ((uType == IME_PINYIN)  || (uType == IME_JAPANESE))
						{
							UINT8 *pTail;
							UINT8 tone;
							UINT loopCount;
							
							if (g_pIMEInputednum <= IMPY_INPUT_LEN)
							{
								loopCount = 0;
check_tone:
								pTail = &g_pIMEInBuffer[g_pIMEInputednum - 1];
								if (MyIsAlpha(*pTail))
								{
									if((g_pIMEInputednum == 0)
										|| (g_pIMEInputednum == IMPY_INPUT_LEN))
									{
										bClearMsg = TRUE;
										break;
									}
									g_pIMEInBuffer[g_pIMEInputednum++] = '1';
								}
								else
								{
									tone = *pTail - '0';
									if (tone == 5)
									{
										tone = 1;
									}
									else
									{
										tone ++;
									}
									tone += '0';
									g_pIMEInBuffer[g_pIMEInputednum - 1] = tone;
								}
								if(!_PyWbGetData(uType))
								{
									loopCount ++;
									if (loopCount <= 4)
									{
										goto check_tone;
									}
									else
									{
										g_pIMEInBuffer[--g_pIMEInputednum] = 0;
										_PyWbGetData(uType);
									}
								}
								bClearMsg = TRUE;
							}
						}
					}
					else if (MyIsAlpha(wMsgX))//(wMsgX >= 'a' && wMsgX <= 'z')
					{
						cC2N = Char2Num(wMsgX);		// 将字符键映射到数字
						
						if(cC2N > '0' && cC2N <= '0' + g_pIMEWordTypeNum)
						{

⌨️ 快捷键说明

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