?? ime1.c
字號:
/*************************************************************************/
/* */
/* 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 + -