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

📄 imemng.c

📁 好记星的控件,包括button,list,对文件操作
💻 C
字号:
/****************************************************************************/
/*                                                                          */
/*              Copyright (C) 2003 SHENZHEN MEIJIN CO.LTD                   */
/*                                                                          */
/* FILE NAME:   ImeManag.c                                                  */
/* MODULE NAME: 输入法 Input Method Editor                                  */
/* DESCRIPTION: 输入法                                                      */
/*                                                                          */
/****************************************************************************/
/*    DTAE       AUTHOR     VERSION                 REMARKS                 */
/* =========== ==========  =========  ======================================*/
/*  Qorse      2003-03-25     创建初始版本									*/
/*  谢永良   2003-06-13     删除函数ID号和模块调用                          */
/****************************************************************************/


#include "Kernel.h"
#include "ImeIn.h"
MIMEManager g_mImeManager;

/****************************************************************************/
/* FUNCTION:   ImeModInitial                                              */
/* DESCRIPTION:模块初始化                                                  */
/* INPUTS:     pEvent      初始化消息                                      */
/* OUTPUTS:    NONE														*/
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse      2003-03-25     创建初始版本									*/
/****************************************************************************/

BOOL ImeInitialize(VOID)
{
	_ImeInitialize(ImeGetSystem(),0);
    return TRUE;
}

MIMEManager* ImeGetSystem()
{
    return (MIMEManager*)&g_mImeManager;
}

/****************************************************************************/
/* FUNCTION:   ImeGetCurrent                                              */
/* DESCRIPTION:得到当前输入法                                              */
/* INPUTS:     pApGui  指定的 AP Gui 										*/
/* OUTPUTS:    该窗口的当前输入法											*/
/* RETURN:     当前输入法ID                                                */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse      2003-03-25     创建初始版本									*/
/****************************************************************************/
UINT ImeGetCurrent(VOID)
{
	return ImeGetDefault();
}

/*
UINT ImeGetCurrent(IMEGUI_STRUCT *pApGui)
{
	return ImeGetDefault();
  if(!pApGui)
    {
		pApGui = (IMEGUI_STRUCT *)GetApHandle();
	}
    return pApGui->uCurrentIme;
*/

/****************************************************************************/
/* FUNCTION:   ImeSetCurrent                                              */
/* DESCRIPTION:设置当前输入法                                              */
/* INPUTS:     pApGui  指定的AP GUI 										*/
/*				uImeId  输入法ID                                    */
/* OUTPUTS:    NONE														*/
/* RETURN:     成功返回TRUE,否则返回FALSE                                 */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse      2003-03-25     创建初始版本									*/
/****************************************************************************/
BOOL ImeSetCurrent( UINT uImeId)
{
	IMEGUI_STRUCT *pApGui;
	UINT32	 dwParam;
	
	if( ImeSetDefault(uImeId))
	{
		pApGui = (IMEGUI_STRUCT *)GetApHandle();
		pApGui->uCurrentIme = uImeId;
		if (g_mImeManager.ImeOnChangeFunc)
		{
			g_mImeManager.ImeOnChangeFunc(uImeId);
		}	
		pApGui->wImeOption &= ~IME_OPTION_NOSWITCH;
		//	dwParam	=  ((UINT16)(uImeId==IME_NONE?0:tempIM.uHeight)<<16) | (UINT16 )uImeId;
		dwParam	=  ((UINT16)(CM_IME_SELECTED) | (UINT16 )uImeId<<16 );
		MsgPost((APGUI_STRUCT_MODEL *)NULL,EVENT_COMMAND,dwParam);
		return TRUE;
		
	}
	return FALSE;
}
/*
BOOL ImeSetCurrent(IMEGUI_STRUCT *pApGui, UINT uImeId)
{
    MInputME tempIM;
	UINT32	 dwParam;
    if (g_mImeManager.uCount == 0)
    {
        return FALSE;
    }
    if(!pApGui)
    {
		pApGui = (IMEGUI_STRUCT *)GetApHandle();
    }
	
    //参数有效性验证
	tempIM.uType = uImeId;

	if (uImeId!= IME_NONE && !ImeGetInfo(&tempIM))
    {
        return FALSE;
    }
	pApGui->uCurrentIme = uImeId;
    if (g_mImeManager.ImeOnChangeFunc)
	{
		g_mImeManager.ImeOnChangeFunc(uImeId);
	}	
	pApGui->wImeOption &= ~IME_OPTION_NOSWITCH;
//	dwParam	=  ((UINT16)(uImeId==IME_NONE?0:tempIM.uHeight)<<16) | (UINT16 )uImeId;
	dwParam	=  ((UINT16)(CM_IME_SELECTED) | (UINT16 )uImeId<<16 );
	MsgPost((APGUI_STRUCT_MODEL *)NULL,EVENT_COMMAND,dwParam);
	return TRUE;
}
*/
/****************************************************************************/
/* FUNCTION:   ImSetOnlyOne                                                */
/* DESCRIPTION:锁定当前输入法                                              */
/* INPUTS:     pApGui  指定的AP GUI										*/
/*				uImeId  输入法ID                                    */
/* OUTPUTS:    NONE														*/
/* RETURN:     成功返回TRUE,否则返回FALSE                                 */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse      2003-03-25     创建初始版本									*/
/****************************************************************************/
BOOL ImSetOnlyOne(IMEGUI_STRUCT *pApGui, UINT uImeId)
{
    if(!pApGui)
    {
		pApGui = (IMEGUI_STRUCT *)GetApHandle();
    }

//    if (ImeSetCurrent(pApGui, uImeId))
	if (ImeSetCurrent(uImeId))
		{
		pApGui->wImeOption |= IME_OPTION_NOSWITCH;  
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

/****************************************************************************/
/* FUNCTION:   ImeGetInfo                                                 */
/* DESCRIPTION:得到输入法的信息                                            */
/* INPUTS:     输入法ID                                                    */
/* OUTPUTS:    pInfo		                                                */
/* RETURN:     成功返回TRUE,否则返回FALSE			                        */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse      2003-03-25     创建初始版本									*/
/****************************************************************************/
BOOL ImeGetInfo(MInputME *pInfo)
{
    UINT i;

    if (pInfo->uType == IME_NONE)
    {
        return FALSE;
    }

    for (i = 0; i < g_mImeManager.uCount; i++)
	{
		if(g_mImeManager.maInputME[i].uType == pInfo->uType)/*ID相符*/
		{
			memmove((UINT8*)pInfo, (UINT8*)(g_mImeManager.maInputME + i),sizeof(MInputME));

			return TRUE;
		}
	}

    return FALSE;
}
/****************************************************************************/
/* FUNCTION:   ImeSetOptions                                               */
/* DESCRIPTION:设置输入法选项                                              */
/* INPUTS:    pApGui      AP pointer										*/
/*				dwOptions        输入法选项                                 */
/* OUTPUTS:    NONE														*/
/* RETURN:     成功返回TRUE,否则返回FALSE                                 */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse      2003-03-25     创建初始版本									*/
/****************************************************************************/
BOOL     ImeSetOptions(IMEGUI_STRUCT *pApGui,UINT16 wOptions)
{
    if(!pApGui)
    {
		pApGui = (IMEGUI_STRUCT *)GetApHandle();
    }
	
	
    pApGui->wImeOption = wOptions;
	return TRUE;
}

/****************************************************************************/
/* FUNCTION:   ImeManagerHandleEvent                                       */
/* DESCRIPTION:输入法管理的消息处理函数                                    */
/* INPUTS:     pApGui      AP pointer  									*/
/*              pEvent      消息指针                                        */
/* OUTPUTS:    NONE														*/
/* RETURN:     消息处理函数返回值                                          */
/****************************************************************************/
/*  NAME           DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*  Qorse      2003-03-25     创建初始版本									*/
/****************************************************************************/
UINT32 IMeManager(IMEGUI_STRUCT *pApGui,  UINT *pEvent, UINT *pParam)
{
    MInputME tempIM;
	UINT i;
/*	if definified EVENT_KEYUP, not comment thest code
	if (*pEvent == EVENT_KEYUP)
	{
		*pParam = EVENT_NOTHING;
		return 0;
	}
*/
    if (!pApGui)
    {
		pApGui = (IMEGUI_STRUCT *)GetApHandle();
    }
	tempIM.uType = pApGui->uCurrentIme;

	if(*pEvent==EVENT_KEY && *pParam == MVK_IME
		|| *pEvent==EVENT_IME && ( LOWORD(*pParam)==IME_ACTION_SWITCH ))
	{
		*pEvent = EVENT_NOTHING;
	
        if(pApGui->wImeOption & IME_OPTION_NOSWITCH)
        {
            return 0;
        }
		if(g_mImeManager.ImeSwitchFunc)	/*有切换界面*/
		{
			return g_mImeManager.ImeSwitchFunc(&g_mImeManager);
		}
		else							/*直接切换*/
		{
			for(i=0;i<g_mImeManager.uCount;i++)
			{
				if(g_mImeManager.maInputME[i].uType == pApGui->uCurrentIme)
                {
                    break;
                }
			}
//            return ImeSetCurrent(pApGui,g_mImeManager.maInputME[(++i)%g_mImeManager.uCount].uType);	//???++i
            return ImeSetCurrent(g_mImeManager.maInputME[(++i)%g_mImeManager.uCount].uType);	//???++i
		}
	}
	else if(*pEvent==EVENT_IME && LOWORD(*pParam)==IME_ACTION_SETCURRENT)
	{
//		ImeSetCurrent (pApGui,(UINT)(HIWORD(*pParam)) );
		ImeSetCurrent ((UINT)(HIWORD(*pParam)) );
		*pEvent = EVENT_NOTHING;
	}
	else if(ImeGetInfo(&tempIM))	/*转交至输入法的消息处理函数*/
	{
		g_mImeManager.uImeCurrentType = pApGui->uCurrentIme;
		if(tempIM.fpImeHandleFunc)	/*参数有效性检查*/
        {
            return (tempIM.fpImeHandleFunc)((IMEGUI_STRUCT*)pApGui,pEvent,pParam);
        }
	}

	return 0;	
}

⌨️ 快捷键说明

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