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

📄 ime1.c

📁 好记星的控件,包括button,list,对文件操作
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************/
/*																		 */
/* 				Copyright (C) 2002 SHENZHEN MEIJIN CO.LTD           	 */
/*																		 */
/* FILE NAME:	PrjIme.c                                          		 */
/* MODULE NAME:	输入法 Input Method Editor								 */
/* DESCRIPTION:	输入法													 */
/*																		 */
/*************************************************************************/
/* 	  DTAE	     AUTHOR	    VERSION    				REMARKS       		 */
/* =========== ==========  =========  ===================================*/
/* 2003-03-24  Qorse       Ver 1.00	  学生机(无笔点)			  		 */
/* 2004-12-18  Bingle      Ver 2.00   笔点机                             */
/*************************************************************************/
#include "Kernel.h"
#include "ImeIn.h"

UINT16	g_pIMEBushouWordLen, g_pIMEBushouWordIndex;
UINT16	g_pIMEBushou_bhbh, g_pIMEBushou_bsb, g_pIMEBushou_bs;
UINT16	g_pIMEBushou_bh, g_pIMEBushou_hz;
extern char Char2Num(UINT uChar);


void _BushouLXProc(UINT* pEvent,UINT *pParam);

void _BihuaHandleEvPredo(UINT *pEvent, UINT *pParam)
{
	UINT16 nMsgx;
	
	nMsgx = *pParam;
	if(*pEvent == EVENT_KEY|| *pEvent== EVENT_CHAR)
	{
		if(g_mInputBox.state == IM_INPUT_ERROR)
		{
			__ResetIME();
		}
		
		if(nMsgx ==MVK_ESCAPE)
		{
			if(g_mInputBox.state == IM_INPUT_NULL && g_pIMEBushouState == 0)
			{
				return;
			}
			else
			{
				__ResetIME();
				g_pIMEBushouState = 0;
				MsgPost(NULL,EVENT_DRAW,0);
				*pEvent = EVENT_NOTHING;
			}
		}
	}
	
	__IMEGetChar(pEvent,pParam);
}
/****************************************************************************/
/* FUNCTION:   _BihuaDrawGraph												*/
/* DESCRIPTION:笔画输入法显示函数											*/
/* INPUTS:     NONE														*/
/* OUTPUTS:    NONE														*/
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Zfs			2003-04-08     创建初始版本                                 */
/****************************************************************************/
FOR_IME_BIHUA
void _BihuaDrawGraph(void)
{
	UINT16 width,tempnum, i;
	UINT32 addr;

	width = g_mInputBox.rect.width;
	GraphDisableRefresh();
	
	switch (g_mInputBox.state){
		case IM_INPUT_NULL:
		case IM_INPUT_DOING:
			__ImeDrawInputBoxHead(IME_BIHUA);
			GraphDrawText(g_mInputBox.rect.x+IM_HEIGHT, g_mInputBox.rect.y, 90, IM_HEIGHT,"笔画数:");
			GraphDrawText(g_mInputBox.rect.x+100, g_mInputBox.rect.y, 20, IM_HEIGHT,g_pIMEInBuffer);
			break;
		case IM_INPUT_ZC:
			__ImeDrawInputBoxHead(IME_BIHUA);
			memset(g_pIMEOutBuffer,0,IM_OUTBUFF_LEN);
			tempnum = g_pIMEWordNum - g_pIMECandiPos;
			if (tempnum > g_pIMEWordTypeNum)
			{
				tempnum = g_pIMEWordTypeNum;
			}


			addr = (UINT32)g_pIMEDataAddr + g_pIMECandiPos * 2;
			for(i = 0; i < tempnum; i ++)
			{
				ImeDrawIndexNum((UINT8)i,IME_BIHUA);
				memmove(g_pIMEOutBuffer,(UINT8 *)addr,2);
				GraphDrawText(g_mInputBox.rect.x+IME_CANDI_X + i*IME_CANDI_INTERVAL, g_mInputBox.rect.y, 0, 0,g_pIMEOutBuffer);
				addr += 2;
			}


			//addr = (UINT32)g_pIMEDataAddr + g_pIMECandiPos * 2;
			//memcpy(g_pIMEOutBuffer,(UINT8 *)addr,tempnum * 2);
			//GraphDrawText(pDC,16,0,width - 16,IM_HEIGHT,g_pIMEOutBuffer);
			_imDrawArrow();
			break;

		case IM_INPUT_ERROR:
			__ImeDrawInputBoxHead(IME_BIHUA);
			GraphDrawText(g_mInputBox.rect.x+16, g_mInputBox.rect.y, 80, IM_HEIGHT,"查无此字!");
			break;
		case IM_INPUT_LX:
			_ImeDrawGraph(IME_BIHUA);
	}

	/*GraphInvertRect(pDC, 0,0,pDC->dcHeight - 1,pDC->dcHeight - 1);*/
	GraphEnableRefresh();
}

/****************************************************************************/
/* FUNCTION:   _BiHuaHandleEvent											*/
/* DESCRIPTION:笔画输入法的消息处理函数									*/
/* INPUTS:     pEvent,消息													*/
/* OUTPUTS:    NONE														*/
/* RETURN:     消息处理函数返回值                                          */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Zfs			2003-04-08     创建初始版本                                 */
/****************************************************************************/
FOR_IME_BIHUA
INT _BiHuaHandleEvent(IMEGUI_STRUCT *pApGui,  UINT *pEvent, UINT *pParam)
{
	UINT16 nMsgx, getedzi;
	UINT32 nMsgtype;
	char	c2n;
    
	_BihuaHandleEvPredo(pEvent,pParam);
	nMsgtype = *pEvent;
	nMsgx = (UINT16)*pParam;
	c2n = Char2Num(nMsgx);	
	if(c2n != -1)
	{
		nMsgx = c2n;
	}

	if (nMsgtype == EVENT_DRAW){
		_BihuaDrawGraph();
	}
	else if (nMsgtype == EVENT_KEY || *pEvent == EVENT_CHAR|| nMsgtype==EVENT_KEYREPEAT){
		switch (g_mInputBox.state){
			case IM_INPUT_NULL:
				if (nMsgx >= '0' && nMsgx <= '9'){
					g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)nMsgx;
					g_mInputBox.state = IM_INPUT_DOING;
					GraphDrawText(g_mInputBox.rect.x+100, g_mInputBox.rect.y, 20, IM_HEIGHT,g_pIMEInBuffer);
					*pEvent = EVENT_NOTHING;
				}
				else if((nMsgx >= 'a' && nMsgx <= 'z') ||
					(nMsgx >= 'A' && nMsgx <= 'Z'))
				{
					*pEvent = EVENT_NOTHING;
				}
				
				break;
			case IM_INPUT_DOING:
				if (nMsgx ==MVK_BACKSPACE || nMsgx ==MVK_DELETE){
					g_pIMEInBuffer[--g_pIMEInputednum] = 0;
					if (g_pIMEInputednum == 0)
					{
						g_mInputBox.state = IM_INPUT_NULL;
					}
					GraphClearRect(g_mInputBox.rect.x+100,g_mInputBox.rect.y,
						g_mInputBox.rect.x+120,g_mInputBox.rect.y+IM_HEIGHT);
					GraphDrawText(g_mInputBox.rect.x+100, g_mInputBox.rect.y, 20, IM_HEIGHT,g_pIMEInBuffer);
					*pEvent = EVENT_NOTHING;
				}
				else if(nMsgx >= '0' && nMsgx <= '9'){
					if (g_pIMEInputednum < 2){
						if (!(g_pIMEInBuffer[0] == '0' && nMsgx== '0')){
							g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)nMsgx;
							GraphDrawText(g_mInputBox.rect.x+100, g_mInputBox.rect.y, 20, IM_HEIGHT,g_pIMEInBuffer);
						}
					}
					*pEvent = EVENT_NOTHING;
				}
				else if(nMsgx ==MVK_ENTER){
					if (!_imBihuaGetData()){
						g_mInputBox.state = IM_INPUT_ERROR;
//						g_pIMETimer = TimCreateTimer(NULL,IME_ENGLISH_TIMERID,1000,1000,pCallBackBushou);
//						TimStartTimer(g_pIMETimer);
					}
					else
					{
						g_mInputBox.state = IM_INPUT_ZC;
					}
					_BihuaDrawGraph();
					*pEvent = EVENT_NOTHING;
				}
				else if((nMsgx >= 'a' && nMsgx <= 'z') ||
					(nMsgx >= 'A' && nMsgx <= 'Z'))
				{
					*pEvent = EVENT_NOTHING;
				}
				break;
			case IM_INPUT_ERROR:
			case IM_INPUT_ZC:
				if(nMsgx >= '0' && nMsgx <= '9' && g_mInputBox.state == IM_INPUT_ERROR){
					memset(g_pIMEInBuffer,0,IM_INBUFF_LEN);
					g_pIMEInputednum = 0;
					g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)nMsgx;
					g_mInputBox.state = IM_INPUT_DOING;
					_BihuaDrawGraph();
					*pEvent = EVENT_NOTHING;
				}
				else if(nMsgx > '0' && nMsgx <= '0' + g_pIMEWordTypeNum && g_mInputBox.state == IM_INPUT_ZC){
					if (_imOutputData((UINT16)(nMsgx - '0'),&getedzi,pEvent))
					{
						memset(g_pIMEInBuffer,0,IM_INBUFF_LEN);
						g_pIMEInputednum = 0;
						g_mInputBox.state = IM_INPUT_NULL;

						if (_ImGetAssociation(getedzi))
						{
							g_mInputBox.state = IM_INPUT_LX;
						}
		
						_BihuaDrawGraph();
					}
				}
				else if(nMsgx ==MVK_LEFT || nMsgx ==MVK_RIGHT)
				{
				//	if(pEvent->yParam !=MVK_SHIFT)   ??
					{
						if (_imLeftRight(pEvent,pParam))
						{
							_BihuaDrawGraph();
						}
						*pEvent = EVENT_NOTHING;
						return 0;
					}
				}
				else if((nMsgx >= 'a' && nMsgx <= 'z') ||
					(nMsgx >= 'A' && nMsgx <= 'Z'))
				{
					*pEvent = EVENT_NOTHING;
				}
				break;
			case IM_INPUT_LX:
				_BushouLXProc(pEvent,pParam);
				_BihuaDrawGraph();
				break;
		}
	}
	else if( nMsgtype == EVENT_INITIALIZE )
	{
		__InitialIME();
	}	
	
	return 0;
}
BOOL _imBushouGetedData(UINT16 cIndex)
{
	UINT32 pAddr;
	
	if (cIndex)
	{
		cIndex --;
	}
	else
	{
		cIndex = 9;
	}
	if (g_pIMECandiPos + cIndex >= g_pIMEWordNum)
	{
		return FALSE;
	}
	g_pIMEBushouWordIndex = g_pIMECandiPos + cIndex;
	pAddr = (UINT32)g_pIMEDataAddr + g_pIMEBushouWordIndex * g_pIMEBushouWordLen;
	memset(g_pIMEOutWordBuf,0,3);
	memcpy(g_pIMEOutWordBuf,(UINT8 *)pAddr,sizeof(UINT16));
	
	return TRUE;
}

/****************************************************************************/
/* FUNCTION:   _BuShouDrawGraph											*/
/* DESCRIPTION:部首输入法显示函数											*/
/* INPUTS:     NONE														*/
/* OUTPUTS:    NONE														*/
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Zfs			2003-04-08     创建初始版本                                 */
/****************************************************************************/
FOR_IME_BUSHOU
void _BushouDrawGraph(void)
{
	UINT16 pWidth,pNumber,i;
	UINT32 pAddr;
	UINT8 tmpStr[12];

	pWidth = g_mInputBox.rect.width;
	GraphDisableRefresh();
	ImeDrawSplit();
	GraphClearRect(g_mInputBox.rect.x,g_mInputBox.rect.y,
		g_mInputBox.rect.x +pWidth - 1,g_mInputBox.rect.y+IM_HEIGHT);
	GraphDrawText(g_mInputBox.rect.x, g_mInputBox.rect.y, 16, IM_HEIGHT, "部");

	switch (g_mInputBox.state){
		case IM_INPUT_NULL:
			if (!g_pIMEBushouState)
			{
				GraphDrawText(g_mInputBox.rect.x, g_mInputBox.rect.y, 90, IM_HEIGHT,"部部首笔画:");
			}
			else{
				sprintf(tmpStr,"部 %s余下:",g_pIMEOutWordBuf);
				GraphDrawText(g_mInputBox.rect.x, g_mInputBox.rect.y, 90, IM_HEIGHT,tmpStr);
				GraphInvertRect(g_mInputBox.rect.x+22,g_mInputBox.rect.y,
					g_mInputBox.rect.x+78,g_mInputBox.rect.y+g_mInputBox.rect.height - 1);
			}
			break;
		case IM_INPUT_DOING:
			if (!g_pIMEBushouState){
				GraphDrawText(g_mInputBox.rect.x, g_mInputBox.rect.y, 90, IM_HEIGHT, "部部首笔画:");
			}
			else{
				sprintf(tmpStr,"部 %s余下:",g_pIMEOutWordBuf);
				GraphDrawText(g_mInputBox.rect.x, g_mInputBox.rect.y, 90, IM_HEIGHT, tmpStr);
				GraphInvertRect(g_mInputBox.rect.x+22,g_mInputBox.rect.y,
					g_mInputBox.rect.x+78,g_mInputBox.rect.y+g_mInputBox.rect.height - 1);
			}
			GraphDrawText(g_mInputBox.rect.x+100, g_mInputBox.rect.y, 20, IM_HEIGHT, g_pIMEInBuffer);
			break;
		case IM_INPUT_ZC:
			memset(g_pIMEOutBuffer,0,IM_OUTBUFF_LEN);
			pNumber = g_pIMEWordNum - g_pIMECandiPos;
			if (pNumber > g_pIMEWordTypeNum)
				pNumber = g_pIMEWordTypeNum;
			pAddr = (UINT32)g_pIMEDataAddr + g_pIMECandiPos * g_pIMEBushouWordLen;

			for (i = 0; i < pNumber; i++){
				memcpy(g_pIMEOutBuffer,(UINT8 *)pAddr,2);
				pAddr += g_pIMEBushouWordLen;
				ImeDrawIndexNum((UINT8)i,IME_BUSHOU);
				GraphDrawText(g_mInputBox.rect.x+IME_CANDI_X+i*IME_CANDI_INTERVAL, g_mInputBox.rect.y,
					0, 0, g_pIMEOutBuffer);
			}

			_imDrawArrow();
			break;
		case IM_INPUT_ERROR:
			if (g_pIMEBushouState)
			{
				GraphDrawText(g_mInputBox.rect.x+16, g_mInputBox.rect.y, 80, IM_HEIGHT, "查无此字!");
			}
			else
			{
				GraphDrawText(g_mInputBox.rect.x+16, g_mInputBox.rect.y, 90, IM_HEIGHT,"查无此部首!");
			}
			break;
		case IM_INPUT_LX:
			_ImeDrawGraph(IME_BUSHOU);
			GraphEnableRefresh();
			return;

	}

	GraphInvertRect(g_mInputBox.rect.x,g_mInputBox.rect.y,
		g_mInputBox.rect.x+g_mInputBox.rect.height - 2,g_mInputBox.rect.y+g_mInputBox.rect.height - 1);
	GraphEnableRefresh();
}

/****************************************************************************/
/* FUNCTION:   _BuShouHandleEvent											*/
/* DESCRIPTION:部首输入法的消息处理函数									*/
/* INPUTS:     pEvent,消息													*/
/* OUTPUTS:    NONE														*/
/* RETURN:     消息处理函数返回值                                          */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Zfs			2003-04-08     创建初始版本                                 */
/****************************************************************************/
FOR_IME_BUSHOU
INT _BuShouHandleEvent(IMEGUI_STRUCT *pApGui,  UINT *pEvent, UINT *pParam)
{
	UINT16 nMsgx;
	UINT32 nMsgtype;
	UINT16 getedzi;
	char	c2n;
    
	_BihuaHandleEvPredo(pEvent,pParam);

⌨️ 快捷键说明

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