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

📄 imewin.c

📁 一套在嵌入式系统中使用的拼音输入法
💻 C
📖 第 1 页 / 共 2 页
字号:
{	return _lGUI_pImeWindow->dwData >>28;}static void SetCurrentIme(	int iIme){	_lGUI_pImeWindow->dwData = _lGUI_pImeWindow->dwData & 0x0fffffff | iIme << 28;}//chinese input method operate abstract functioinstatic BOOLLGUIInitIme(){	int iIndex;	PLGUIIme pIme;	iIndex = GetCurrentIme();	pIme = GetImePointerByIndex(iIndex);	if(!pIme)		return false;	return pIme->InitIme();}static void LGUIDestroyIme(){	int iIndex;	PLGUIIme pIme;	iIndex = GetCurrentIme();	pIme = GetImePointerByIndex(iIndex);	if(!pIme)		return;	pIme->DestroyIme();}static void LGUIResetIme(){	int iIndex;	PLGUIIme pIme;	iIndex = GetCurrentIme();	pIme = GetImePointerByIndex(iIndex);	if(!pIme)		return;	pIme->ResetIme();}static BOOLLGUICharArrived(	char ch){	int iIndex;	PLGUIIme pIme;	iIndex = GetCurrentIme();	pIme = GetImePointerByIndex(iIndex);	if(!pIme)		return false;	return pIme->CharArrived(ch);}static voidLGUIFillBackwardSelection(){	int iIndex;	PLGUIIme pIme;	iIndex = GetCurrentIme();	pIme = GetImePointerByIndex(iIndex);	if(!pIme)		return;	pIme->FillBackwardSelection();}static voidLGUIFillForwardSelection(){	int iIndex;	PLGUIIme pIme;	iIndex = GetCurrentIme();	pIme = GetImePointerByIndex(iIndex);	if(!pIme)		return;	pIme->FillForwardSelection();}static BOOLIsChineseIme(	int iIme){	if((iIme == IME_STATUS_ENGLISH) ||		(iIme == IME_STATUS_HANDWRITE))		return false;	else		return true;}static BOOL ReadImeBmp(	HWND hWnd){	PWindowsTree pWin;	char* pEnvStr;	char pString[256];	char* pData;	FILE* fp;	pWin = (PWindowsTree)hWnd;	if(!pWin)		return false;	pData = (char*)malloc(IMEWIN_WIDTH*IMEWIN_HEIGHT*_lGUI_iBytesDataType);	if(!pData)		return false;	pEnvStr=getenv("LGUI_HOME");	if(!pEnvStr)		return false;	strcpy(pString,pEnvStr);	strcat(pString,IMEBMP_BACKGROUND);	fp = fopen(pString,"rb");	if(!fp)		return false;	ReadBmpToBuf(fp,IMEWIN_WIDTH,IMEWIN_HEIGHT,pData);	fclose(fp);	pWin->dwAddData = (DWORD)pData;	return true;}static void FreeImeBmp(	HWND hWnd){	PWindowsTree pWin;	pWin = (PWindowsTree)hWnd;	free((void*)(pWin->dwAddData));}static void RefreshListArea(	HDC hDC){	int iLeft, iTop, iWidth, iHeight;	iLeft = IMEWIN_BORDER;	iTop = IMEWIN_BORDER;	iWidth = IMEWIN_LIST_WIDTH;	iHeight = IMEWIN_HEIGHT - 2*IMEWIN_BORDER;	FillRectangle(hDC,iLeft,iTop,iWidth-iLeft-1,iHeight-iTop-1,RGB_WHITE,RGB_WHITE);}static void RefreshInputArea(	HDC hDC){	int iLeft, iTop, iWidth, iHeight;	iLeft = 2 * IMEWIN_BORDER + IMEWIN_LIST_WIDTH ;	iTop = IMEWIN_BORDER;	iWidth = IMEWIN_INPUT_WIDTH;	iHeight = IMEWIN_HEIGHT - 2*IMEWIN_BORDER;	FillRectangle(hDC,iLeft,iTop,iWidth-iLeft-1,iHeight-iTop-1,RGB_WHITE,RGB_WHITE);}static void InvertLeftKey(	HDC hDC){	char* pData;	int iLeft, iTop, iWidth, iHeight;	int x,y;	pData = (char*)(hDC->pData);	if(!pData)		return;	iLeft = 3 * IMEWIN_BORDER + IMEWIN_LIST_WIDTH + IMEWIN_INPUT_WIDTH;	iTop = IMEWIN_BORDER;	iWidth = IMEWIN_BUTTON_WIDTH * _lGUI_iBytesDataType;	iHeight = IMEWIN_HEIGHT - 2 * IMEWIN_BORDER;	pData+= (iTop * IMEWIN_WIDTH + iLeft) * _lGUI_iBytesDataType;	for(y=0;y<iHeight;y++){		for(x=0;x<iWidth;x++){			*(pData+x) = ~(*(pData+x));		}		pData+= IMEWIN_WIDTH * _lGUI_iBytesDataType;	}}static void InvertRightKey(	HDC hDC){	char* pData;	int iLeft, iTop, iWidth, iHeight;	int x,y;	pData = (char*)(hDC->pData);	if(!pData)		return;	iLeft = 4 * IMEWIN_BORDER + IMEWIN_LIST_WIDTH + IMEWIN_INPUT_WIDTH + IMEWIN_BUTTON_WIDTH;	iTop = IMEWIN_BORDER;	iWidth = IMEWIN_BUTTON_WIDTH * _lGUI_iBytesDataType;	iHeight = IMEWIN_HEIGHT - 2 * IMEWIN_BORDER;	pData+= (iTop * IMEWIN_WIDTH + iLeft) * _lGUI_iBytesDataType;	for(y=0;y<iHeight;y++){		for(x=0;x<iWidth;x++){			*(pData+x) = ~(*(pData+x));		}		pData+= IMEWIN_WIDTH * _lGUI_iBytesDataType;	}}static void SetLeftKeyPressed(	HWND hWnd){	PWindowsTree pWin;	int iValue = 1;	pWin = (PWindowsTree)hWnd;	if(!pWin)		return;	pWin->dwData = pWin->dwData & 0xf0ffffff | iValue << 24;}static void SetRightKeyPressed(	HWND hWnd){	PWindowsTree pWin;	int iValue = 1;	pWin = (PWindowsTree)hWnd;	if(!pWin)		return;	pWin->dwData = pWin->dwData & 0xf0ffffff | iValue << 25;}static void SetNoKeyPressed(	HWND hWnd){	PWindowsTree pWin;	pWin = (PWindowsTree)hWnd;	if(!pWin)		return;	pWin->dwData = pWin->dwData & 0xf0ffffff;}static BOOL IsLeftKeyPressed(	HWND hWnd){	int iValue;	PWindowsTree pWin;	pWin = (PWindowsTree)hWnd;	if(!pWin)		return false;	iValue = (pWin->dwData >> 24 ) & 0x00000f;	if(iValue == IME_LEFT_PRESSED)		return true;	else		return false;}static BOOL IsRightKeyPressed(	HWND hWnd){	int iValue;	PWindowsTree pWin;	pWin = (PWindowsTree)hWnd;	if(!pWin)		return false;	iValue = (pWin->dwData >> 24 ) & 0x00000f;	if(iValue == IME_RIGHT_PRESSED)		return true;	else		return false;}static int IsDbcOrSbc(	HWND hWnd){	PWindowsTree pWin;	pWin = (PWindowsTree)hWnd;	if(!pWin)		return false;	return (pWin->dwData & 0x00f00000)>> 20;}static char* Sbc2Dbc(	char c){	int i;	for(i=0;i<SBC2DBC_TABLE_LENGTH;i++){		if(sbc_dbc_table[i].sbc == c)			break;	}	if(i == SBC2DBC_TABLE_LENGTH)		return NULL;	else		return sbc_dbc_table[i].dbc;}static void RefreshListDisplay(	HWND hWnd){	PWindowsTree pWin;	RECT rcList;	HDC hDC,hDCMem;	HGDIOBJ hFont;	pWin = (PWindowsTree)hWnd;	if(!pWin)		return;	SetRect(&rcList,0,0,IMEWIN_LIST_WIDTH - IMEWIN_BORDER,IMEWIN_HEIGHT - 3 * IMEWIN_BORDER);	hDC = GetWindowDC(hWnd);	if(!hDC)		return;	hDCMem = CreateCompatibleDC(hDC);	if(!hDCMem)		return;	FillRectangle(hDCMem,		rcList.left,rcList.top,rcList.right,rcList.bottom,		RGB_WHITE,RGB_WHITE);	hFont = GetStockObject(FONT_12_12);	SelectObject(hDCMem,hFont);	DeleteObject(hFont);	DrawText(hDCMem, imeDataTable.pListChars, strlen(imeDataTable.pListChars),		&rcList, DT_LEFT | DT_VCENTER);	BitBlt(hDC,		0,		0,		IMEWIN_LIST_WIDTH,		IMEWIN_HEIGHT - 2*IMEWIN_BORDER,		hDCMem,		0,0,		SRCCOPY);	ReleaseDC(hWnd,hDCMem);	ReleaseDC(hWnd,hDC);}static void RefreshInputDisplay(	HWND hWnd){	PWindowsTree pWin;	RECT rcInput;	HDC hDC,hDCMem;	HGDIOBJ hFont;	pWin = (PWindowsTree)hWnd;	if(!pWin)		return;	SetRect(&rcInput,		IMEWIN_BORDER + IMEWIN_LIST_WIDTH,		0,		IMEWIN_BORDER + IMEWIN_LIST_WIDTH + IMEWIN_INPUT_WIDTH,		IMEWIN_HEIGHT - 3 * IMEWIN_BORDER);	hDC = GetWindowDC(hWnd);	if(!hDC)		return;	hDCMem = CreateCompatibleDC(hDC);	if(!hDCMem)		return;	FillRectangle(hDCMem,		rcInput.left,rcInput.top,rcInput.right,rcInput.bottom,		RGB_WHITE,RGB_WHITE);	hFont = GetStockObject(FONT_12_12);	SelectObject(hDCMem,hFont);	DeleteObject(hFont);	DrawText(hDCMem, imeDataTable.pTotalInputChars, 		strlen(imeDataTable.pTotalInputChars), &rcInput, DT_LEFT | DT_VCENTER);	BitBlt(hDC,		IMEWIN_BORDER + IMEWIN_LIST_WIDTH,		0,		IMEWIN_INPUT_WIDTH,		IMEWIN_HEIGHT - 2*IMEWIN_BORDER,		hDCMem,		IMEWIN_BORDER + IMEWIN_LIST_WIDTH,		0,		SRCCOPY);	ReleaseDC(hWnd,hDCMem);	ReleaseDC(hWnd,hDC);}void MoveUpImeWindow(){	MoveWindowTo((HWND)_lGUI_pImeWindow,IMEWIN_LEFT,IMEWIN_TOP);}void MoveDownImeWindow(){	MoveWindowTo((HWND)_lGUI_pImeWindow,IMEWIN_LEFT,DESK_TASKBAR_TOP - IMEWIN_HEIGHT);}void ShowImeWindow(){	if(IsVisible((HWND)_lGUI_pSkbWindow)){		MoveUpImeWindow();	}	else{		MoveDownImeWindow();	}	if(!IsVisible((HWND)_lGUI_pImeWindow))		ShowWindow((HWND)_lGUI_pImeWindow,true);}void HideImeWindow(){	if(IsVisible((HWND)_lGUI_pImeWindow))		ShowWindow((HWND)_lGUI_pImeWindow,false);}void SwitchIme(){	int iCurIme;	PTaskBar pTaskBar;	PTaskBarItem pItemIme;		pTaskBar = (PTaskBar)(_lGUI_pTaskBarWindow->dwAddData);	if(!pTaskBar)		return;	pItemIme = pTaskBar->pItemIme;	if(!pItemIme)		return;	iCurIme = GetCurrentIme();	if(iCurIme == pItemIme->iCurValue)		return;	SetCurrentIme(pItemIme->iCurValue);		switch(pItemIme->iCurValue){	case IME_STATUS_ENGLISH:		HideImeWindow();		break;	case IME_STATUS_HANDWRITE:		if(!IsVisible((HWND)_lGUI_pImeWindow)){			if(IsVisible((HWND)_lGUI_pSkbWindow)){				MoveUpImeWindow();				ShowImeWindow();			}			else{				MoveDownImeWindow();				ShowImeWindow();			}		}		break;	default:		//installed chinese input method including pinyin and wubi etc.		if(!IsVisible((HWND)_lGUI_pImeWindow)){			if(IsVisible((HWND)_lGUI_pSkbWindow)){				MoveUpImeWindow();				ShowImeWindow();			}			else{				MoveDownImeWindow();				ShowImeWindow();			}		}		LGUIInitIme();		break;			}	}void SetDbc(){	_lGUI_pImeWindow->dwData = _lGUI_pImeWindow->dwData | 0x00100000;}void SetSbc(){	_lGUI_pImeWindow->dwData = _lGUI_pImeWindow->dwData & 0xff0fffff;}void SwitchDbc(	BOOL bValue){	if(bValue)		SetDbc();	else		SetSbc();}

⌨️ 快捷键说明

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