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

📄 ime1.c

📁 好记星的控件,包括button,list,对文件操作
💻 C
📖 第 1 页 / 共 2 页
字号:
	nMsgtype = *pEvent;
	nMsgx = *pParam;;
	c2n = Char2Num(nMsgx);

	if (nMsgtype == EVENT_DRAW)
	{
		if (g_mInputBox.state == IM_INPUT_NULL)
		{
			ImGetBiShouDataAddr();
		}
 		_BushouDrawGraph();
	}

	else if (nMsgtype == EVENT_KEY || nMsgtype == EVENT_CHAR|| nMsgtype==EVENT_KEYREPEAT)
	{
		switch (g_mInputBox.state)
		{
			case IM_INPUT_NULL:
				if (c2n >= '0' && c2n <= '9')
				{
					g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)c2n;
					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;
					}

					_BushouDrawGraph();
					/*GraphClearRect(pDC, 100,0,120,IM_HEIGHT);
					GraphDrawText(pDC,100,0,20,IM_HEIGHT,g_pIMEInBuffer);*/
					*pEvent = EVENT_NOTHING;
				}
				else if(c2n >= '0' && c2n <= '9')
				{
					if (g_pIMEInputednum < 2)
					{
						if (!(g_pIMEInBuffer[0] == '0' && c2n== '0'))
						{
							g_pIMEInBuffer[g_pIMEInputednum++]=(UINT8)c2n;
							GraphDrawText(g_mInputBox.rect.x+100, g_mInputBox.rect.y, 20, IM_HEIGHT, g_pIMEInBuffer);
						}
					}

					*pEvent = EVENT_NOTHING;
				}
				else if(nMsgx ==MVK_ENTER)
				{
					if (!_imBushouGetData())
					{
						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;
					}

					_BushouDrawGraph();
					*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(c2n >= '0' && c2n <= '9' && g_mInputBox.state == IM_INPUT_ERROR){
					memset(g_pIMEInBuffer,0,IM_INBUFF_LEN);
					g_pIMEInputednum = 0;
					g_pIMEBushouState = 0;
					g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)c2n;
					g_mInputBox.state = IM_INPUT_DOING;
					_BushouDrawGraph();
					*pEvent = EVENT_NOTHING;
				}
				else if(c2n > '0' && c2n <= '0' +g_pIMEWordTypeNum && g_mInputBox.state == IM_INPUT_ZC)
				{
					if (_imBushouGetedData((UINT16)(c2n- '0')))
					{
						memset(g_pIMEInBuffer,0,IM_INBUFF_LEN);
						g_pIMEInputednum = 0;
						g_mInputBox.state = IM_INPUT_NULL;
						if (g_pIMEBushouState == 0)
						{								
							g_pIMEBushouState = 1;
							*pEvent = EVENT_NOTHING;
						}
						else{
							WRITE_WORD(&getedzi,
                                MAKEWORD(g_pIMEOutWordBuf[1], g_pIMEOutWordBuf[0]));

                            if (_ImGetAssociation(getedzi))
							{
								g_mInputBox.state = IM_INPUT_LX;
							}
							else
							{
								memset(g_pIMEInBuffer,0,IM_INBUFF_LEN);
							}


							*pEvent = EVENT_IMESTR;
							*pParam = (UINT)g_pIMEOutWordBuf;								
							g_pIMEBushouState = 0;
						}

						_BushouDrawGraph();
					}
				}
				else if(nMsgx ==MVK_LEFT || nMsgx ==MVK_RIGHT)
				{
				//	if(pEvent->yParam !=MVK_SHIFT)			???
					{
						if (_imLeftRight(pEvent,pParam))
						{
							_BushouDrawGraph();
						}
						*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);
				_BushouDrawGraph();
		}
	}
	else if( nMsgtype == EVENT_INITIALIZE )
	{
		__InitialIME();
	}	
	
	return 0;
}
/****************************************************************************/
/* FUNCTION:   _NanJianDrawGraph											*/
/* DESCRIPTION:难检输入法显示函数											*/
/* INPUTS:     NONE														*/
/* OUTPUTS:    NONE														*/
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Zfs			2003-04-08     创建初始版本                                 */
/****************************************************************************/
FOR_IME_NANJIAN
void _NanJianDrawGraph(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_NANJIAN);
			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_NANJIAN);
			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_NANJIAN);
				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;
			}
			_imDrawArrow();
			break;

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

/****************************************************************************/
/* FUNCTION:   _NanJianHandleEvent											*/
/* DESCRIPTION:难检输入法的消息处理函数									*/
/* INPUTS:     pEvent,消息													*/
/* OUTPUTS:    NONE														*/
/* RETURN:     消息处理函数返回值                                          */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Zfs			2003-04-08     创建初始版本                                 */
/****************************************************************************/
FOR_IME_NANJIAN
INT _NanJianHandleEvent(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 (nMsgtype == EVENT_DRAW){
 		_NanJianDrawGraph();
	}
	else if (nMsgtype == EVENT_KEY|| nMsgtype == EVENT_CHAR || nMsgtype==EVENT_KEYREPEAT)
	{
		switch (g_mInputBox.state){
			case IM_INPUT_NULL:
				if (c2n >= '0' && c2n <= '9'){
					g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)c2n;
					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(c2n >= '0' && c2n <= '9')
				{
					if (g_pIMEInputednum < 2)
					{
						if (!(g_pIMEInBuffer[0] == '0' && c2n == '0'))
						{
							g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)c2n;
							GraphDrawText(g_mInputBox.rect.x+100, g_mInputBox.rect.y, 20, IM_HEIGHT,g_pIMEInBuffer);
						}
					}

					*pEvent = EVENT_NOTHING;
				}
				else if(nMsgx==MVK_ENTER)
				{
					_imNanjianGetData();
					_NanJianDrawGraph();
					*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(c2n >= '0' && c2n <= '9' && g_mInputBox.state == IM_INPUT_ERROR){
					memset(g_pIMEInBuffer,0,IM_INBUFF_LEN);
					g_pIMEInputednum = 0;
					g_pIMEInBuffer[g_pIMEInputednum++] = (UINT8)c2n;
					g_mInputBox.state = IM_INPUT_DOING;
					_NanJianDrawGraph();
					*pEvent = EVENT_NOTHING;
				}
				else if(c2n > '0' && c2n <= '0' + g_pIMEWordTypeNum && g_mInputBox.state == IM_INPUT_ZC){
					if (_imOutputData((UINT16)(c2n -'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;
						}

						_NanJianDrawGraph();
					}
				}
				else if(nMsgx ==MVK_LEFT || nMsgx ==MVK_RIGHT)
				{
					//if(pEvent->yParam !=MVK_SHIFT)??
					{
						if (_imLeftRight(pEvent,pParam))
						{
							_NanJianDrawGraph();
						}
						*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);
				_NanJianDrawGraph();
		}
//		if((nMsgx >= 'a' && nMsgx <= 'z') ||
//			(nMsgx >= 'A' && nMsgx <= 'Z')){
//			*pEvent = EVENT_NOTHING;
//		}
	}
	else if( nMsgtype == EVENT_INITIALIZE )
	{
		__InitialIME();
	}	
	
	return 0;
}

/****************************************************************************/
/* FUNCTION:   _BushouLXProc												*/
/* DESCRIPTION:部首联想处理函数											*/
/* INPUTS:     nMsgx														*/
/* OUTPUTS:    NONE														*/
/****************************************************************************/
void _BushouLXProc(UINT* pEvent,UINT *pParam)
{
	UINT16 nMsgx;
	char	c2n;
	
	nMsgx = (UINT16)(*pParam);
	c2n = Char2Num(nMsgx);
	
	if(c2n >= '0' && c2n<= '9')
	{
		g_mInputBox.state = IM_INPUT_NULL;
		if(c2n > '0' && c2n <= '0' + g_pIMEWordTypeNum)
		{
			*pParam = c2n;
			g_mInputBox.refresh = _IMEGetSelectWord(pEvent,pParam);
		}
	}
	else if(nMsgx ==MVK_LEFT || nMsgx ==MVK_RIGHT)
	{
		//if(pEvent->yParam !=MVK_SHIFT)		//??
		{
			g_mInputBox.refresh = _imLeftRight(pEvent,pParam);
			*pEvent = EVENT_NOTHING;
		}
	}	
	else if((nMsgx >= 'a' && nMsgx <= 'z') ||
		(nMsgx >= 'A' && nMsgx <= 'Z'))
	{
		*pEvent = EVENT_NOTHING;
	}
}

⌨️ 快捷键说明

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