Exemplo n.º 1
0
void SelectCandFromCandlist( HIMC hIMC, WORD wParam)
{
	if( wParam >= _T('0') && wParam <= _T('9') ){
		DWORD dwIdx;
		LPTSTR lpConvStr;
	    LPINPUTCONTEXT lpIMC;
		LPCANDIDATEINFO lpCandInfo;
		LPCANDIDATELIST lpCandList;
		LPCOMPOSITIONSTRING lpCompStr;

		lpIMC = ImmLockIMC(hIMC);
		lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
		lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
		lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);

	    if( wParam == (WORD)_T('0') ) dwIdx=9;
		else dwIdx = wParam - _T('1');
		if(dwIdx < lpCandList->dwPageSize ) {
			dwIdx += lpCandList->dwPageStart;
			if( dwIdx < (lpCandList->dwCount + 2) && lpCandList->dwCount){
				lpConvStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szConvCompStr;
				_tcscpy(lpConvStr,GETLPCANDSTR(lpCandList,dwIdx));
				MakeResultString(hIMC,TRUE);
			}
		}
		ImmUnlockIMCC(lpIMC->hCompStr);
		ImmUnlockIMCC(lpIMC->hCandInfo);
		ImmUnlockIMC(hIMC);
	}
	return;
}
Exemplo n.º 2
0
Arquivo: imm32.c Projeto: krofna/wine
static void test_ImmDestroyIMCC(void)
{
    HIMCC imcc;
    DWORD ret, count, size;
    VOID *p;

    imcc = ImmCreateIMCC(sizeof(CANDIDATEINFO));
    count = ImmGetIMCCLockCount(imcc);
    ok(count == 0, "expect 0, returned %d\n", count);
    p = ImmLockIMCC(imcc);
    ok(p != NULL, "ImmLockIMCC failed!\n");
    count = ImmGetIMCCLockCount(imcc);
    ok(count == 1, "expect 1, returned %d\n", count);
    size = ImmGetIMCCSize(imcc);
    ok(size == sizeof(CANDIDATEINFO), "returned %d\n", size);
    p = ImmDestroyIMCC(imcc);
    ok(p == NULL, "Destroy a locked IMCC should success!\n");
    p = ImmLockIMCC(imcc);
    ok(p == NULL, "Lock a destroyed IMCC should fail!\n");
    ret = ImmUnlockIMCC(imcc);
    ok(ret == FALSE, "Unlock a destroyed IMCC should return FALSE!\n");
    count = ImmGetIMCCLockCount(imcc);
    ok(count == 0, "Get lock count of a destroyed IMCC should return 0!\n");
    size = ImmGetIMCCSize(imcc);
    ok(size == 0, "Get size of a destroyed IMCC should return 0!\n");
    SetLastError(0xdeadbeef);
    p = ImmDestroyIMCC(imcc);
    ok(p != NULL, "returned NULL\n");
    ret = GetLastError();
    ok(ret == ERROR_INVALID_HANDLE, "wrong last error %08x!\n", ret);
}
Exemplo n.º 3
0
BOOL MakeResultString( HIMC hIMC,BOOL fFlag)
{
    GENEMSG GnMsg;
    LPCOMPOSITIONSTRING lpCompStr;
    LPINPUTCONTEXT lpIMC;
	LPTSTR lpConvStr,lpPreResultStr;
	LPCANDIDATEINFO lpCandInfo;
	LPCANDIDATELIST lpCandList;
/*
    if (!IsCompStr(hIMC))
        return FALSE;
*/	
	wConversionMode = 0;
	dwCurPhraseAttrib=0;

    lpIMC = ImmLockIMC(hIMC);
    lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
	lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
	lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);

	if(fFlag) {
		lpConvStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szConvCompStr;
		lpPreResultStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr;
		_tcscpy(lpPreResultStr,lpConvStr);

		if(wConversionSet & CONVERSION_SET_BIG5) gb2big(lpConvStr);

		_tcscpy(GETLPRESULTSTR(lpCompStr),lpConvStr);
		
		lpCompStr->dwResultStrLen = _tcslen(lpConvStr);
	}
	else{
		*GETLPRESULTSTR(lpCompStr) = _T('\0');
		lpCompStr->dwResultStrLen = 0;
	}

	lpCandList->dwCount = 0;
    lpCompStr->dwCompStrLen = 0;

	_tcscpy(GETLPCANDSTR(lpCandList,0),_T(""));
	_tcscpy(GETLPCANDSTR(lpCandList,1),_T(""));
	
	ImmUnlockIMCC(lpIMC->hCompStr);
	ImmUnlockIMCC(lpIMC->hCandInfo);
	
	GnMsg.msg = WM_IME_COMPOSITION;
	GnMsg.wParam = 0;
	GnMsg.lParam = GCS_RESULTSTR;
	GenerateMessage(hIMC, lpdwCurTransKey,(LPGENEMSG)&GnMsg);
	
	GnMsg.msg = WM_IME_ENDCOMPOSITION;
	GnMsg.wParam = 0;
	GnMsg.lParam = 0;
	GenerateMessage(hIMC, lpdwCurTransKey,(LPGENEMSG)&GnMsg);
	
    ImmUnlockIMC(hIMC);
    return TRUE;
}
Exemplo n.º 4
0
bool fill_result(input_context& ic, const wstring& wstr_result)
{
    HIMCC               hMem;
    LPCOMPOSITIONSTRING lpCompStr;
    DWORD               dwSize;

    dwSize = sizeof(COMPOSITIONSTRING) +  (wstr_result.size() + 1) * sizeof(WORD);

    if (!ic->hCompStr) {
        ic->hCompStr = ImmCreateIMCC(dwSize);
		if (!ic->hCompStr) {
			return false;
		}

		lpCompStr = (LPCOMPOSITIONSTRING) ImmLockIMCC(ic->hCompStr);
		if (!lpCompStr) {
			return false;
		}
		lpCompStr->dwSize = dwSize;
		ImmUnlockIMCC(ic->hCompStr);
	}

	lpCompStr = (LPCOMPOSITIONSTRING) ImmLockIMCC(ic->hCompStr);
	if (!lpCompStr) {
		return false;
	}

	if (dwSize > lpCompStr->dwSize) {
		ImmUnlockIMCC(ic->hCompStr);
		hMem = ImmReSizeIMCC(ic->hCompStr, dwSize);
		if (!hMem) {
			return false;
		}
		if (ic->hCompStr != hMem) {
			ImmDestroyIMCC(ic->hCompStr);
			ic->hCompStr = hMem;
		}

		lpCompStr = (LPCOMPOSITIONSTRING) ImmLockIMCC(ic->hCompStr);
		if (!lpCompStr) {
			return false;
		}
		lpCompStr->dwSize = dwSize;
	}

    dwSize = lpCompStr->dwSize; //save it

	memset(lpCompStr, 0, dwSize);
	lpCompStr->dwSize = dwSize;
	lpCompStr->dwResultStrLen = wstr_result.size();
	lpCompStr->dwResultStrOffset = sizeof(COMPOSITIONSTRING);
	memcpy((char *)lpCompStr+sizeof(COMPOSITIONSTRING), wstr_result.c_str(), wstr_result.size() * sizeof(wchar_t));

	ImmUnlockIMCC(ic->hCompStr);	
    return true;
}
Exemplo n.º 5
0
Arquivo: ime.c Projeto: AmesianX/wine
void IME_SetCursorPos(DWORD pos)
{
    LPINPUTCONTEXT lpIMC;
    LPCOMPOSITIONSTRING compstr;

    if (!hSelectedFrom)
        return;

    lpIMC = LockRealIMC(FROM_X11);
    if (!lpIMC)
        return;

    compstr = ImmLockIMCC(lpIMC->hCompStr);
    if (!compstr)
    {
        UnlockRealIMC(FROM_X11);
        return;
    }

    compstr->dwCursorPos = pos;
    ImmUnlockIMCC(lpIMC->hCompStr);
    UnlockRealIMC(FROM_X11);
    GenerateIMEMessage(FROM_X11, WM_IME_COMPOSITION, pos, GCS_CURSORPOS);
    return;
}
Exemplo n.º 6
0
Arquivo: ime.c Projeto: Kelimion/wine
void IME_SetResultString(LPWSTR lpResult, DWORD dwResultLen)
{
    HIMC imc;
    LPINPUTCONTEXT lpIMC;
    HIMCC newCompStr;
    LPIMEPRIVATE myPrivate;

    imc = RealIMC(FROM_X11);
    lpIMC = ImmLockIMC(imc);
    if (lpIMC == NULL)
        return;

    newCompStr = updateResultStr(lpIMC->hCompStr, lpResult, dwResultLen);
    ImmDestroyIMCC(lpIMC->hCompStr);
    lpIMC->hCompStr = newCompStr;

    myPrivate = ImmLockIMCC(lpIMC->hPrivate);
    if (!myPrivate->bInComposition)
        GenerateIMEMessage(imc, WM_IME_STARTCOMPOSITION, 0, 0);
    GenerateIMEMessage(imc, WM_IME_COMPOSITION, 0, GCS_RESULTSTR);
    if (!myPrivate->bInComposition)
        GenerateIMEMessage(imc, WM_IME_ENDCOMPOSITION, 0, 0);
    ImmUnlockIMCC(lpIMC->hPrivate);

    ImmUnlockIMC(imc);
}
Exemplo n.º 7
0
BOOL GenerateMessage(HIMC hIMC, LPDWORD lpdwTransKey,LPGENEMSG lpGeneMsg)
{
    LPINPUTCONTEXT lpIMC;

	if( (lpIMC = ImmLockIMC(hIMC)) == NULL ) return FALSE;
	
    if (lpdwTransKey){
		ImmUnlockIMC(hIMC);
        return GenerateMessageToTransKey(lpdwTransKey,lpGeneMsg);
	}
    
    if (IsWindow(lpIMC->hWnd))
    {
        LPDWORD lpdw;
        if (!(lpIMC->hMsgBuf = ImmReSizeIMCC(lpIMC->hMsgBuf,
			sizeof(DWORD) * (lpIMC->dwNumMsgBuf +1) * 3)))
            return FALSE;
		
        if (!(lpdw = (LPDWORD)ImmLockIMCC(lpIMC->hMsgBuf)))
            return FALSE;
		
        lpdw += (lpIMC->dwNumMsgBuf) * 3;
        *((LPGENEMSG)lpdw) = *lpGeneMsg;
        ImmUnlockIMCC(lpIMC->hMsgBuf);
        lpIMC->dwNumMsgBuf++;
		
        ImmGenerateMessage(hIMC);
    }
	ImmUnlockIMC(hIMC);
    return TRUE;
}
Exemplo n.º 8
0
Arquivo: ime.c Projeto: AmesianX/wine
static void DefaultIMEComposition(HIMC hIMC, HWND hwnd, LPARAM lParam)
{
    TRACE("IME message WM_IME_COMPOSITION 0x%lx\n", lParam);
    if (lParam & GCS_RESULTSTR)
    {
        LPCOMPOSITIONSTRING compstr;
        LPBYTE compdata;
        LPWSTR ResultStr;
        HIMCC newCompStr;
        LPINPUTCONTEXT lpIMC;

        lpIMC = LockRealIMC(hIMC);
        if (lpIMC == NULL)
            return;

        TRACE("Posting result as IME_CHAR\n");
        compdata = ImmLockIMCC(lpIMC->hCompStr);
        compstr = (LPCOMPOSITIONSTRING)compdata;
        ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset);
        GenerateIMECHARMessages(hIMC, ResultStr, compstr->dwResultStrLen);
        ImmUnlockIMCC(lpIMC->hCompStr);

        /* clear the buffer */
        newCompStr = updateResultStr(lpIMC->hCompStr, NULL, 0);
        ImmDestroyIMCC(lpIMC->hCompStr);
        lpIMC->hCompStr = newCompStr;
        UnlockRealIMC(hIMC);
    }
    else
        UpdateDefaultIMEWindow(hIMC, hwnd);
}
Exemplo n.º 9
0
HRESULT WeaselIME::_Initialize()
{
	LPINPUTCONTEXT lpIMC = ImmLockIMC(m_hIMC);
	if(!lpIMC)
		return E_FAIL;

	lpIMC->fOpen = TRUE;

	HIMCC& hIMCC = lpIMC->hCompStr;
	if (!hIMCC)
		hIMCC = ImmCreateIMCC(sizeof(CompositionInfo));
	else
		hIMCC = ImmReSizeIMCC(hIMCC, sizeof(CompositionInfo));
	if(!hIMCC)
	{
		ImmUnlockIMC(m_hIMC);
		return E_FAIL;
	}

	CompositionInfo* pInfo = (CompositionInfo*)ImmLockIMCC(hIMCC);
	if (!pInfo)
	{
		ImmUnlockIMC(m_hIMC);
		return E_FAIL;
	}

	pInfo->Reset();
	ImmUnlockIMCC(hIMCC);
	ImmUnlockIMC(m_hIMC);

	return S_OK;
}
Exemplo n.º 10
0
Arquivo: ime.c Projeto: AmesianX/wine
static void GenerateIMEMessage(HIMC hIMC, UINT msg, WPARAM wParam,
                               LPARAM lParam)
{
    LPINPUTCONTEXT lpIMC;
    LPTRANSMSG lpTransMsg;

    lpIMC = LockRealIMC(hIMC);
    if (lpIMC == NULL)
        return;

    lpIMC->hMsgBuf = ImmReSizeIMCC(lpIMC->hMsgBuf, (lpIMC->dwNumMsgBuf + 1) *
                                    sizeof(TRANSMSG));
    if (!lpIMC->hMsgBuf)
        return;

    lpTransMsg = ImmLockIMCC(lpIMC->hMsgBuf);
    if (!lpTransMsg)
        return;

    lpTransMsg += lpIMC->dwNumMsgBuf;
    lpTransMsg->message = msg;
    lpTransMsg->wParam = wParam;
    lpTransMsg->lParam = lParam;

    ImmUnlockIMCC(lpIMC->hMsgBuf);
    lpIMC->dwNumMsgBuf++;

    ImmGenerateMessage(RealIMC(hIMC));
    UnlockRealIMC(hIMC);
}
Exemplo n.º 11
0
Arquivo: ime.c Projeto: AmesianX/wine
static void UpdateDefaultIMEWindow(HIMC hIMC, HWND hwnd)
{
    LPCOMPOSITIONSTRING compstr;
    LPINPUTCONTEXT lpIMC;

    lpIMC = LockRealIMC(hIMC);
    if (lpIMC == NULL)
        return;

    if (lpIMC->hCompStr)
        compstr = ImmLockIMCC(lpIMC->hCompStr);
    else
        compstr = NULL;

    if (compstr == NULL || compstr->dwCompStrLen == 0)
        ShowWindow(hwnd,SW_HIDE);
    else
    {
        ShowWindow(hwnd,SW_SHOWNOACTIVATE);
        RedrawWindow(hwnd, NULL, NULL, RDW_ERASENOW | RDW_INVALIDATE);
    }

    if (compstr != NULL)
        ImmUnlockIMCC(lpIMC->hCompStr);

    lpIMC->hWnd = GetFocus();
    UnlockRealIMC(hIMC);
}
Exemplo n.º 12
0
Arquivo: ime.c Projeto: AmesianX/wine
void IME_SetCompositionStatus(BOOL fOpen)
{
    HIMC imc;
    LPINPUTCONTEXT lpIMC;
    LPIMEPRIVATE myPrivate;

    imc = RealIMC(FROM_X11);
    lpIMC = ImmLockIMC(imc);
    if (lpIMC == NULL)
        return;

    myPrivate = ImmLockIMCC(lpIMC->hPrivate);

    if (fOpen && !myPrivate->bInComposition)
    {
        GenerateIMEMessage(imc, WM_IME_STARTCOMPOSITION, 0, 0);
    }
    else if (!fOpen && myPrivate->bInComposition)
    {
        ShowWindow(myPrivate->hwndDefault, SW_HIDE);
        ImmDestroyIMCC(lpIMC->hCompStr);
        lpIMC->hCompStr = ImeCreateBlankCompStr();
        GenerateIMEMessage(imc, WM_IME_ENDCOMPOSITION, 0, 0);
    }
    myPrivate->bInComposition = fOpen;

    ImmUnlockIMCC(lpIMC->hPrivate);
    ImmUnlockIMC(imc);
}
Exemplo n.º 13
0
HRESULT WeaselIME::_EndComposition(LPCWSTR composition)
{
	if (composition)
	{
		LPINPUTCONTEXT lpIMC;
		LPCOMPOSITIONSTRING lpCompStr;

		lpIMC = ImmLockIMC(m_hIMC);
		if (!lpIMC)
			return E_FAIL;

		lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
		if (!lpCompStr)
		{
			ImmUnlockIMC(m_hIMC);
			return E_FAIL;
		}

		CompositionInfo* pInfo = (CompositionInfo*)lpCompStr;
		wcscpy_s(pInfo->szResultStr, composition);
		lpCompStr->dwResultStrLen = wcslen(pInfo->szResultStr);

		ImmUnlockIMCC(lpIMC->hCompStr);
		ImmUnlockIMC(m_hIMC);

		_AddIMEMessage(WM_IME_COMPOSITION, 0, GCS_COMP|GCS_RESULTSTR);
	}
	_AddIMEMessage(WM_IME_ENDCOMPOSITION, 0, 0);
	_AddIMEMessage(WM_IME_NOTIFY, IMN_CLOSECANDIDATE, 0);

	m_composing = false;
	return S_OK;
}
Exemplo n.º 14
0
trans_msg::trans_msg(input_context& ic) :
	m_ic_ptr(&ic),
	m_trans_msg_ptr(NULL)
{
	if (ic->hMsgBuf) {
		m_trans_msg_ptr = (LPTRANSMSG)ImmLockIMCC(ic->hMsgBuf);
	}
}
Exemplo n.º 15
0
bool CompString::lock()
{
    if (!cs_ && imc_->hCompStr) {
        cs_ = (COMPOSITIONSTRING*)ImmLockIMCC(imc_->hCompStr);
        updateBufferWrappers();
    }
    return cs_ != NULL;
}
Exemplo n.º 16
0
void DeleteCharBackward(HIMC hIMC,WORD wParam)
{
	if(wConversionMode & CONVERSION_MODE_PHRASETOCHAR){
		MakeResultString(hIMC,FALSE);
	}
	else if( wConversionMode & CONVERSION_MODE_I   || 
			 wConversionMode & CONVERSION_MODE_U   ||
			 wConversionMode & CONVERSION_MODE_V ) {

	    LPINPUTCONTEXT lpIMC;
		LPCANDIDATEINFO lpCandInfo;
		LPCANDIDATELIST lpCandList;
		LPCOMPOSITIONSTRING lpCompStr;
		GENEMSG GnMsg;
		LPTSTR lpStr;

		lpIMC = ImmLockIMC(hIMC);
		lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
		lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
		lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);

		if( !lpCandList->dwCount ) MakeResultString(hIMC,FALSE);
		else{
			lpCandList->dwCount = 0;

			lpStr = GETLPCOMPSTR(lpCompStr);
			lpStr = CharPrev(lpStr,lpStr + _tcslen(lpStr));
			*lpStr= _T('\0');

			lpStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPaintCompStr;
			lpStr = CharPrev(lpStr,lpStr + _tcslen(lpStr));
			*lpStr= _T('\0');

			GnMsg.msg = WM_IME_COMPOSITION;
			GnMsg.wParam = 0;
			GnMsg.lParam = GCS_COMPSTR;
			GenerateMessage(hIMC, lpdwCurTransKey,(LPGENEMSG)&GnMsg);
		}
		ImmUnlockIMCC(lpIMC->hCompStr);
		ImmUnlockIMCC(lpIMC->hCandInfo);
		ImmUnlockIMC(hIMC);
	}
	else AddChar(hIMC,wParam,EDIT_BACK);
	return;
}
Exemplo n.º 17
0
Arquivo: imm32.c Projeto: krofna/wine
static void test_ImmGetIMCCLockCount(void)
{
    HIMCC imcc;
    DWORD count, g_count, ret, i;
    VOID *p;

    imcc = ImmCreateIMCC(sizeof(CANDIDATEINFO));
    count = ImmGetIMCCLockCount(imcc);
    ok(count == 0, "expect 0, returned %d\n", count);
    ImmLockIMCC(imcc);
    count = ImmGetIMCCLockCount(imcc);
    ok(count == 1, "expect 1, returned %d\n", count);
    ret = ImmUnlockIMCC(imcc);
    ok(ret == FALSE, "expect FALSE, ret %d\n", ret);
    count = ImmGetIMCCLockCount(imcc);
    ok(count == 0, "expect 0, returned %d\n", count);
    ret = ImmUnlockIMCC(imcc);
    ok(ret == FALSE, "expect FALSE, ret %d\n", ret);
    count = ImmGetIMCCLockCount(imcc);
    ok(count == 0, "expect 0, returned %d\n", count);

    p = ImmLockIMCC(imcc);
    ok(GlobalHandle(p) == imcc, "expect %p, returned %p\n", imcc, GlobalHandle(p));

    for (i = 0; i < GMEM_LOCKCOUNT * 2; i++)
    {
        ImmLockIMCC(imcc);
        count = ImmGetIMCCLockCount(imcc);
        g_count = GlobalFlags(imcc) & GMEM_LOCKCOUNT;
        ok(count == g_count, "count %d, g_count %d\n", count, g_count);
    }
    count = ImmGetIMCCLockCount(imcc);
    ok(count == GMEM_LOCKCOUNT, "expect GMEM_LOCKCOUNT, returned %d\n", count);

    for (i = 0; i < GMEM_LOCKCOUNT - 1; i++)
        GlobalUnlock(imcc);
    count = ImmGetIMCCLockCount(imcc);
    ok(count == 1, "expect 1, returned %d\n", count);
    GlobalUnlock(imcc);
    count = ImmGetIMCCLockCount(imcc);
    ok(count == 0, "expect 0, returned %d\n", count);

    ImmDestroyIMCC(imcc);
}
Exemplo n.º 18
0
void MoveCandWindow(HWND hUIWnd,LPUIEXTRA lpUIExtra, LPINPUTCONTEXT lpIMC)
{
	if (!IsWindow(lpUIExtra->uiCand.hWnd))
		CreateCandWindow( hUIWnd, lpUIExtra);

	if (IsWindow(lpUIExtra->uiCand.hWnd))
	{
	    LPCANDIDATEINFO lpCandInfo;
	    LPCANDIDATELIST lpCandList;
		HDC hDC;
		HFONT oldFont;
		SIZE sz;
		LPTSTR lpStr;

		sz.cx = 0;
		sz.cy = 0;

		if (lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo))
		{
			lpCandList = (LPCANDIDATELIST)((LPSTR)lpCandInfo  + lpCandInfo->dwOffset[0]);
			if( lpCandList->dwCount <= 0) {
				ShowWindow(lpUIExtra->uiCand.hWnd, SW_HIDE);
				ImmUnlockIMCC(lpIMC->hCandInfo);
				return;
			}
			lpStr = GETLPCANDSTR(lpCandList,1);
			hDC = GetDC(lpUIExtra->uiCand.hWnd);
			oldFont = SelectObject(hDC, hUIFont);
			GetTextExtentPoint(hDC,lpStr,_tcslen(lpStr),&sz);
			SelectObject(hDC, oldFont);
			ReleaseDC(lpUIExtra->uiCand.hWnd,hDC);
			if(_tcslen(lpStr))	sz.cx += 3*sz.cx/_tcslen(lpStr);
			ImmUnlockIMCC(lpIMC->hCandInfo);
		}
		if(wConversionSet & CONVERSION_SET_SHAPE) {	
			sz.cx = sizeCand[1].cx;
			sz.cy = sizeCand[1].cy;
		}
		else{
			if(sz.cx < lpUIExtra->uiCand.sz.cx)
					sz.cx = lpUIExtra->uiCand.sz.cx;
			sz.cy = lpUIExtra->uiCand.sz.cy;
		}

		GetCandPosFromCompWnd(lpUIExtra,&sz);

		MoveWindow(lpUIExtra->uiCand.hWnd,
			lpUIExtra->uiCand.pt.x,
			lpUIExtra->uiCand.pt.y,
			sz.cx,
			sz.cy,
			TRUE);
		ShowWindow(lpUIExtra->uiCand.hWnd,SW_SHOWNOACTIVATE);
		InvalidateRect(lpUIExtra->uiCand.hWnd,NULL,FALSE);
	}
}
Exemplo n.º 19
0
Arquivo: ime.c Projeto: AmesianX/wine
static HIMCC ImeCreateBlankCompStr(void)
{
    HIMCC rc;
    LPCOMPOSITIONSTRING ptr;
    rc = ImmCreateIMCC(sizeof(COMPOSITIONSTRING));
    ptr = ImmLockIMCC(rc);
    memset(ptr,0,sizeof(COMPOSITIONSTRING));
    ptr->dwSize = sizeof(COMPOSITIONSTRING);
    ImmUnlockIMCC(rc);
    return rc;
}
Exemplo n.º 20
0
Arquivo: ime.c Projeto: AmesianX/wine
INT IME_GetCursorPos(void)
{
    LPINPUTCONTEXT lpIMC;
    INT rc = 0;
    LPCOMPOSITIONSTRING compstr;

    if (!hSelectedFrom)
        return rc;

    lpIMC = LockRealIMC(FROM_X11);
    if (lpIMC)
    {
        compstr = ImmLockIMCC(lpIMC->hCompStr);
        rc = compstr->dwCursorPos;
        ImmUnlockIMCC(lpIMC->hCompStr);
    }
    UnlockRealIMC(FROM_X11);
    return rc;
}
Exemplo n.º 21
0
HRESULT WeaselIME::_AddIMEMessage(UINT msg, WPARAM wp, LPARAM lp)
{
	if(!m_hIMC)
		return S_FALSE;

	LPINPUTCONTEXT lpIMC = (LPINPUTCONTEXT)ImmLockIMC(m_hIMC);
	if(!lpIMC)
		return E_FAIL;

	HIMCC hBuf = ImmReSizeIMCC(lpIMC->hMsgBuf, 
		sizeof(TRANSMSG) * (lpIMC->dwNumMsgBuf + 1));
	if(!hBuf)
	{
		ImmUnlockIMC(m_hIMC);
		return E_FAIL;
	}
	lpIMC->hMsgBuf = hBuf;

	LPTRANSMSG pBuf = (LPTRANSMSG)ImmLockIMCC(hBuf);
	if(!pBuf)
	{
		ImmUnlockIMC(m_hIMC);
		return E_FAIL;
	}

	DWORD last = lpIMC->dwNumMsgBuf;
	pBuf[last].message = msg;
	pBuf[last].wParam = wp;
	pBuf[last].lParam = lp;
	lpIMC->dwNumMsgBuf++;
	ImmUnlockIMCC(hBuf);

	ImmUnlockIMC(m_hIMC);

	if (!ImmGenerateMessage(m_hIMC))
	{
		return E_FAIL;
	}

	return S_OK;
}
Exemplo n.º 22
0
bool CompString::create()
{
    HIMCC& handle = imc_->hCompStr;

    if (!handle) {
        handle = ImmCreateIMCC(sizeof(myCompStr));
        if (!handle)
            return false;
    } else if (ImmGetIMCCSize(handle) < sizeof(myCompStr)) {
        HIMCC temp = ImmReSizeIMCC(handle, sizeof(myCompStr));
        if (!temp)
            return false;
        handle = temp;
    }

    cs_ = (COMPOSITIONSTRING*)ImmLockIMCC(handle);
    if (!cs_)
        return false;

    ZeroMemory(cs_, sizeof(myCompStr));

    cs_->dwSize = sizeof(myCompStr);

    cs_->dwCompReadAttrOffset = (DWORD)(UINT_PTR)&((myCompStr*)0)->compReadAttr;
    cs_->dwCompReadClauseOffset = (DWORD)(UINT_PTR)&((myCompStr*)0)->compReadClause;
    cs_->dwCompReadStrOffset = (DWORD)(UINT_PTR)&((myCompStr*)0)->compReadStr;

    cs_->dwCompAttrOffset = (DWORD)(UINT_PTR)&((myCompStr*)0)->compAttr;
    cs_->dwCompClauseOffset = (DWORD)(UINT_PTR)&((myCompStr*)0)->compClause;
    cs_->dwCompStrOffset = (DWORD)(UINT_PTR)&((myCompStr*)0)->compStr;

    cs_->dwResultReadClauseOffset = (DWORD)(UINT_PTR)&((myCompStr*)0)->resultReadClause;
    cs_->dwResultReadStrOffset = (DWORD)(UINT_PTR)&((myCompStr*)0)->resultReadStr;

    cs_->dwResultClauseOffset = (DWORD)(UINT_PTR)&((myCompStr*)0)->resultClause;
    cs_->dwResultStrOffset = (DWORD)(UINT_PTR)&((myCompStr*)0)->resultStr;

    ImmUnlockIMCC(handle);

    return true;
}
Exemplo n.º 23
0
Arquivo: ime.c Projeto: AmesianX/wine
void IME_SetResultString(LPWSTR lpResult, DWORD dwResultLen)
{
    HIMC imc;
    LPINPUTCONTEXT lpIMC;
    HIMCC newCompStr;
    LPIMEPRIVATE myPrivate;
    BOOL inComp;

    imc = RealIMC(FROM_X11);
    lpIMC = ImmLockIMC(imc);
    if (lpIMC == NULL)
        return;

    newCompStr = updateCompStr(lpIMC->hCompStr, NULL, 0);
    ImmDestroyIMCC(lpIMC->hCompStr);
    lpIMC->hCompStr = newCompStr;

    newCompStr = updateResultStr(lpIMC->hCompStr, lpResult, dwResultLen);
    ImmDestroyIMCC(lpIMC->hCompStr);
    lpIMC->hCompStr = newCompStr;

    myPrivate = ImmLockIMCC(lpIMC->hPrivate);
    inComp = myPrivate->bInComposition;
    ImmUnlockIMCC(lpIMC->hPrivate);

    if (!inComp)
    {
        ImmSetOpenStatus(imc, TRUE);
        GenerateIMEMessage(imc, WM_IME_STARTCOMPOSITION, 0, 0);
    }

    GenerateIMEMessage(imc, WM_IME_COMPOSITION, 0, GCS_COMPSTR);
    GenerateIMEMessage(imc, WM_IME_COMPOSITION, lpResult[0], GCS_RESULTSTR|GCS_RESULTCLAUSE);
    GenerateIMEMessage(imc, WM_IME_ENDCOMPOSITION, 0, 0);

    if (!inComp)
        ImmSetOpenStatus(imc, FALSE);

    ImmUnlockIMC(imc);
}
Exemplo n.º 24
0
UINT WINNLSTranslateMessage(
    INT       iNum,        // number of messages in the source buffer
    PTRANSMSG pTransMsg,   // source buffer that contains 4.0 style messages
    HIMC      hImc,        // input context handle
    BOOL      fAnsi,       // TRUE if pdwt contains ANSI messages
    DWORD     dwLangId )   // language ID ( KOREAN or JAPANESE )
{
    LPINPUTCONTEXT      pInputContext;
    LPCOMPOSITIONSTRING pCompStr;
    UINT uiRet = 0;

    pInputContext = ImmLockIMC(hImc);
    if (pInputContext == NULL) {
        return uiRet;
    }

    pCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC( pInputContext->hCompStr );

    if (dwLangId == LANG_KOREAN) {
        uiRet = WINNLSTranslateMessageK((UINT)iNum,
                                        pTransMsg,
                                        pInputContext,
                                        pCompStr,
                                        fAnsi );
    } else if ( dwLangId == LANG_JAPANESE ) {
        uiRet = WINNLSTranslateMessageJ((UINT)iNum,
                                        pTransMsg,
                                        pInputContext,
                                        pCompStr,
                                        fAnsi );
    }

    if (pCompStr != NULL) {
        ImmUnlockIMCC(pInputContext->hCompStr);
    }
    ImmUnlockIMC(hImc);

    return uiRet;
}
Exemplo n.º 25
0
Arquivo: ime.c Projeto: AmesianX/wine
static void GenerateIMECHARMessages(HIMC hIMC, LPWSTR String, DWORD length)
{
    LPINPUTCONTEXT lpIMC;
    LPTRANSMSG lpTransMsg;
    DWORD i;

    if (length <= 0)
        return;

    lpIMC = LockRealIMC(hIMC);
    if (lpIMC == NULL)
        return;

    lpIMC->hMsgBuf = ImmReSizeIMCC(lpIMC->hMsgBuf,
                                  (lpIMC->dwNumMsgBuf + length) *
                                    sizeof(TRANSMSG));
    if (!lpIMC->hMsgBuf)
        return;

    lpTransMsg = ImmLockIMCC(lpIMC->hMsgBuf);
    if (!lpTransMsg)
        return;

    lpTransMsg += lpIMC->dwNumMsgBuf;
    for (i = 0; i < length; i++)
    {
        lpTransMsg->message = WM_IME_CHAR;
        lpTransMsg->wParam = String[i];
        lpTransMsg->lParam = 1;
        lpTransMsg ++;
    }

    ImmUnlockIMCC(lpIMC->hMsgBuf);
    lpIMC->dwNumMsgBuf+=length;

    ImmGenerateMessage(RealIMC(hIMC));
    UnlockRealIMC(hIMC);
}
Exemplo n.º 26
0
BOOL IsCandidate(HIMC hIMC)
{
    LPINPUTCONTEXT lpIMC;
    LPCANDIDATEINFO lpCandInfo;
	LPCANDIDATELIST lpCandList;
    BOOL fRet = FALSE;

    if (!(lpIMC = ImmLockIMC(hIMC)))
        return FALSE;

    if (ImmGetIMCCSize(lpIMC->hCandInfo) < sizeof (CANDIDATEINFO)){
		ImmUnlockIMC(hIMC);
        return FALSE;
	}

    lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
	lpCandList = (LPCANDIDATELIST)((LPBYTE)lpCandInfo  + lpCandInfo->dwOffset[0]);

    fRet = (lpCandList->dwCount > 0);

    ImmUnlockIMCC(lpIMC->hCandInfo);
	ImmUnlockIMC(hIMC);
    return fRet;
}
Exemplo n.º 27
0
BOOL IsCompStr(HIMC hIMC)
{
    LPINPUTCONTEXT lpIMC;
    LPCOMPOSITIONSTRING lpCompStr;
    BOOL fRet = FALSE;

    if (!(lpIMC = ImmLockIMC(hIMC)))
        return FALSE;

    if (ImmGetIMCCSize(lpIMC->hCompStr) < sizeof (COMPOSITIONSTRING))
    {
        ImmUnlockIMC(hIMC);
        return FALSE;
    }

    lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);

    fRet = (lpCompStr->dwCompStrLen > 0);

    ImmUnlockIMCC(lpIMC->hCompStr);
    ImmUnlockIMC(hIMC);

    return fRet;
}
Exemplo n.º 28
0
Arquivo: ime.c Projeto: AmesianX/wine
BOOL WINAPI ImeSelect(HIMC hIMC, BOOL fSelect)
{
    LPINPUTCONTEXT lpIMC;
    TRACE("%p %s\n",hIMC,(fSelect)?"TRUE":"FALSE");

    if (hIMC == FROM_X11)
    {
        ERR("ImeSelect should never be called from X11\n");
        return FALSE;
    }

    if (!hIMC)
        return TRUE;

    /* not selected */
    if (!fSelect)
        return IME_RemoveFromSelected(hIMC);

    IME_AddToSelected(hIMC);

    /* Initialize our structures */
    lpIMC = LockRealIMC(hIMC);
    if (lpIMC != NULL)
    {
        LPIMEPRIVATE myPrivate;
        myPrivate = ImmLockIMCC(lpIMC->hPrivate);
        myPrivate->bInComposition = FALSE;
        myPrivate->bInternalState = FALSE;
        myPrivate->textfont = NULL;
        myPrivate->hwndDefault = NULL;
        ImmUnlockIMCC(lpIMC->hPrivate);
        UnlockRealIMC(hIMC);
    }

    return TRUE;
}
Exemplo n.º 29
0
void OpenCand(HWND hUIWnd)
{
    LPUIPRIV        lpUIPriv;
    HIMC            hIMC;
    LPINPUTCONTEXT  lpIMC;
    LPCANDIDATEINFO lpCandInfo;
    int             nCandWi, nCandHi;
    POINT           ptNew;

    lpUIPriv = (LPUIPRIV)GetWindowLong(hUIWnd, IMMGWL_PRIVATE);
    if (!lpUIPriv) { return; }

    lpUIPriv->lpCandList = NULL;

    hIMC = (HIMC)GetWindowLong(hUIWnd, IMMGWL_IMC);
    if (!hIMC) {
        return;
    }

    lpIMC = (LPINPUTCONTEXT)ImmLockIMC(hIMC);
    if (!lpIMC) {
        return;
    }

    if (!lpIMC->hCandInfo) {
        ImmUnlockIMC(hIMC);
        return;
    }

    lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
    if (!lpCandInfo) {
        ImmUnlockIMC(hIMC);
        return;
    }

    lpUIPriv->lpCandList = (LPCANDIDATELIST)((LPBYTE)lpCandInfo +
                                             lpCandInfo->dwOffset[0]);

    if (lpUIPriv->lpCandList->dwPageSize > MAX_PAGESIZE) {
        lpUIPriv->lpCandList->dwPageSize = MAX_PAGESIZE;
    }

    lpUIPriv->dwPageSize = lpUIPriv->lpCandList->dwCount > lpUIPriv->lpCandList->dwPageSize ?
                           lpUIPriv->lpCandList->dwPageSize : lpUIPriv->lpCandList->dwCount;
    lpUIPriv->lpCandList->dwPageSize = lpUIPriv->dwPageSize;

    if (!lpUIPriv->hCandWnd) {
        lpUIPriv->hCandWnd = CreateWindowEx(
            WS_EX_NOACTIVATE|WS_EX_TOPMOST,
            v_szCandClassName, NULL,
            WS_POPUP|WS_BORDER|WS_NOTIFY|CLS_FRACTION,
            0, 0, 50, 50,
            hUIWnd, (HMENU)NULL, lpUIPriv->hInst, NULL);

        if (!lpUIPriv->hCandWnd) {
            lpUIPriv->lpCandList = NULL;
            ImmUnlockIMCC(lpIMC->hCandInfo);
            goto OpenCandUnlockIMCC;
        }

    }

    lpUIPriv->fdwUIFlags |= UI_CAND_ALREADY_OPEN;

    nCandWi = lpUIPriv->nCandWi;
    nCandHi = lpUIPriv->nCandHi;

    CalcCandSize(lpUIPriv->hCandWnd);

    if (nCandWi != lpUIPriv->nCandWi ||
        nCandHi != lpUIPriv->nCandHi) {
        SetWindowPos(lpUIPriv->hCandWnd, HWND_TOPMOST, 0, 0,
                     lpUIPriv->nCandWi, lpUIPriv->nCandHi,
                     SWP_NOACTIVATE|SWP_NOMOVE); //|SWP_NOZORDER);
        SetWindowPos(lpUIPriv->hScrBar, NULL,
                     lpUIPriv->rcCandText.right, lpUIPriv->rcCandText.top,
                     g_sImeUIG.cxVScroll, (lpUIPriv->rcCandText.bottom - lpUIPriv->rcCandText.top),
                     SWP_NOACTIVATE|SWP_NOZORDER);
    }

    if (IsWindowVisible(lpUIPriv->hCompWnd)) {
        ptNew.x = lpUIPriv->ptComp.x;
        ptNew.y = lpUIPriv->ptComp.y + lpUIPriv->nCompHi - g_sImeUIG.cyBorder;
    } else {
        ptNew = lpIMC->cfCandForm[0].ptCurrentPos;
        ClientToScreen(lpIMC->hWnd, &ptNew);
    }

    //AdjustCandWnd(lpUIPriv->hCandWnd, ptNew);
	SetCandPosition(lpUIPriv->hCandWnd);

    ShowCand(hUIWnd, SW_SHOWNOACTIVATE);

OpenCandUnlockIMCC:
    ImmUnlockIMCC(lpIMC->hCandInfo);

    ImmUnlockIMC(hIMC);

    return;
}
Exemplo n.º 30
0
void ChangeCand(HWND hUIWnd)
{
    LPUIPRIV        lpUIPriv;
    HIMC            hIMC;
    CONST INPUTCONTEXT * lpIMC;
    LPCANDIDATEINFO lpCandInfo;
    LPCANDIDATELIST lpCandList;
    int             nCandWi, nCandHi;

    lpUIPriv = (LPUIPRIV)GetWindowLong(hUIWnd, IMMGWL_PRIVATE);
    if (!lpUIPriv) {
        return;
    }

    if (!(lpUIPriv->fdwUIFlags & UI_CAND_ALREADY_OPEN)) {
        return;
    }

    hIMC = (HIMC)GetWindowLong(hUIWnd, IMMGWL_IMC);
    if (!hIMC) {
        return;
    }

    lpIMC = (CONST INPUTCONTEXT *)ImmLockIMC(hIMC);
    if (!lpIMC) {
        return;
    }

    if (!lpIMC->hCandInfo) {
        ImmUnlockIMC(hIMC);
        return;
    }

    lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
    if (!lpCandInfo) {
        goto ChangeCandUnlockIMCC;
    }

    lpCandList = (LPCANDIDATELIST)((LPBYTE)lpCandInfo + lpCandInfo->dwOffset[0]);

    lpUIPriv->lpCandList = lpCandList;

    nCandWi = lpUIPriv->nCandWi;
    nCandHi = lpUIPriv->nCandHi;

    CalcCandSize(lpUIPriv->hCandWnd);

    if (nCandWi != lpUIPriv->nCandWi ||
        nCandHi != lpUIPriv->nCandHi) {
        SetWindowPos(lpUIPriv->hCandWnd, NULL, 0, 0,
                     lpUIPriv->nCandWi, lpUIPriv->nCandHi,
                     SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
        SetWindowPos(lpUIPriv->hScrBar, NULL,
                     lpUIPriv->rcCandText.right, lpUIPriv->rcCandText.top,
                     g_sImeUIG.cxVScroll, (lpUIPriv->rcCandText.bottom - lpUIPriv->rcCandText.top),
                     SWP_NOACTIVATE|SWP_NOZORDER);
    }

    InvalidateRect(lpUIPriv->hCandWnd, NULL, TRUE);
    ShowCand(hUIWnd, SW_SHOWNOACTIVATE);

ChangeCandUnlockIMCC:
    ImmUnlockIMCC(lpIMC->hCandInfo);

    ImmUnlockIMC(hIMC);

    return;
}