Changes in crossover-wine-src-6.1.0 except for configure
[wine/hacks.git] / dlls / imm32 / imm.c
blob87ff687321d2fc54a3fa87358a411e28f79af26b
1 /*
2 * IMM32 library
4 * Copyright 1998 Patrik Stridvall
5 * Copyright 2002, 2003 CodeWeavers, Aric Stewart
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "winuser.h"
28 #include "winerror.h"
29 #include "wine/debug.h"
30 #include "imm.h"
31 #include "winnls.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(imm);
35 #define FROM_IME 0xcafe1337
37 static void (*pX11DRV_ForceXIMReset)(HWND);
39 typedef struct tagInputContextData
41 LPBYTE CompositionString;
42 LPBYTE CompositionReadingString;
43 LPBYTE ResultString;
44 LPBYTE ResultReadingString;
45 DWORD dwCompStringSize; /* buffer size */
46 DWORD dwCompStringLength; /* string length (in bytes) */
47 DWORD dwCompReadStringSize;
48 DWORD dwResultStringSize;
49 DWORD dwResultReadStringSize;
50 HWND hwnd;
51 BOOL bOpen;
52 BOOL bInternalState;
53 BOOL bRead;
54 BOOL bInComposition;
55 LOGFONTW font;
56 HFONT textfont;
57 COMPOSITIONFORM CompForm;
58 } InputContextData;
60 static InputContextData *root_context = NULL;
61 static HWND hwndDefault = NULL;
62 static HANDLE hImeInst;
63 static const WCHAR WC_IMECLASSNAME[] = {'I','M','E',0};
64 static ATOM atIMEClass = 0;
66 /* MSIME messages */
67 static UINT WM_MSIME_SERVICE;
68 static UINT WM_MSIME_RECONVERTOPTIONS;
69 static UINT WM_MSIME_MOUSE;
70 static UINT WM_MSIME_RECONVERTREQUEST;
71 static UINT WM_MSIME_RECONVERT;
72 static UINT WM_MSIME_QUERYPOSITION;
73 static UINT WM_MSIME_DOCUMENTFEED;
76 * prototypes
78 static LRESULT WINAPI IME_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
79 LPARAM lParam);
80 static void UpdateDataInDefaultIMEWindow(HWND hwnd);
81 static void ImmInternalPostIMEMessage(UINT, WPARAM, LPARAM);
82 static void ImmInternalSetOpenStatus(BOOL fOpen);
84 static VOID IMM_PostResult(InputContextData *data)
86 unsigned int i;
87 TRACE("Posting result as IME_CHAR\n");
89 for (i = 0; i < data->dwResultStringSize / sizeof (WCHAR); i++)
90 ImmInternalPostIMEMessage (WM_IME_CHAR, ((WCHAR*)data->ResultString)[i],
91 1);
93 /* clear the buffer */
94 if (data->dwResultStringSize)
95 HeapFree(GetProcessHeap(),0,data->ResultString);
96 data->dwResultStringSize = 0;
97 data->ResultString = NULL;
100 static void IMM_Register(void)
102 WNDCLASSW wndClass;
103 ZeroMemory(&wndClass, sizeof(WNDCLASSW));
104 wndClass.style = CS_GLOBALCLASS | CS_IME | CS_HREDRAW | CS_VREDRAW;
105 wndClass.lpfnWndProc = (WNDPROC) IME_WindowProc;
106 wndClass.cbClsExtra = 0;
107 wndClass.cbWndExtra = 0;
108 wndClass.hInstance = hImeInst;
109 wndClass.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
110 wndClass.hIcon = NULL;
111 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW +1);
112 wndClass.lpszMenuName = 0;
113 wndClass.lpszClassName = WC_IMECLASSNAME;
114 atIMEClass = RegisterClassW(&wndClass);
117 static void IMM_Unregister(void)
119 if (atIMEClass) {
120 UnregisterClassW(WC_IMECLASSNAME, NULL);
124 static void IMM_RegisterMessages(void)
126 WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService");
127 WM_MSIME_RECONVERTOPTIONS = RegisterWindowMessageA("MSIMEReconvertOptions");
128 WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation");
129 WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest");
130 WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert");
131 WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition");
132 WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed");
136 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved)
138 HMODULE x11drv;
140 TRACE("%p, %x, %p\n",hInstDLL,fdwReason,lpReserved);
141 switch (fdwReason)
143 case DLL_PROCESS_ATTACH:
144 DisableThreadLibraryCalls(hInstDLL);
145 hImeInst = hInstDLL;
146 IMM_RegisterMessages();
147 x11drv = GetModuleHandleA("winex11.drv");
148 if (x11drv) pX11DRV_ForceXIMReset = (void *)GetProcAddress( x11drv, "ForceXIMReset");
149 break;
150 case DLL_PROCESS_DETACH:
151 if (hwndDefault)
153 DestroyWindow(hwndDefault);
154 hwndDefault = 0;
156 IMM_Unregister();
157 break;
159 return TRUE;
162 /* for posting messages as the IME */
163 static void ImmInternalPostIMEMessage(UINT msg, WPARAM wParam, LPARAM lParam)
165 HWND target = GetFocus();
166 if (!target)
167 PostMessageW(root_context->hwnd,msg,wParam,lParam);
168 else
169 PostMessageW(target, msg, wParam, lParam);
172 static LRESULT ImmInternalSendIMENotify(WPARAM notify, LPARAM lParam)
174 HWND target;
176 target = root_context->hwnd;
177 if (!target) target = GetFocus();
179 if (target)
180 return SendMessageW(target, WM_IME_NOTIFY, notify, lParam);
182 return 0;
185 static void ImmInternalSetOpenStatus(BOOL fOpen)
187 TRACE("Setting internal state to %s\n",(fOpen)?"OPEN":"CLOSED");
189 root_context->bOpen = fOpen;
190 root_context->bInternalState = fOpen;
192 if (fOpen == FALSE)
194 ShowWindow(hwndDefault,SW_HIDE);
196 if (root_context->dwCompStringSize)
197 HeapFree(GetProcessHeap(),0,root_context->CompositionString);
198 if (root_context->dwCompReadStringSize)
199 HeapFree(GetProcessHeap(),0,root_context->CompositionReadingString);
200 if (root_context->dwResultStringSize)
201 HeapFree(GetProcessHeap(),0,root_context->ResultString);
202 if (root_context->dwResultReadStringSize)
203 HeapFree(GetProcessHeap(),0,root_context->ResultReadingString);
204 root_context->dwCompStringSize = 0;
205 root_context->dwCompStringLength = 0;
206 root_context->CompositionString = NULL;
207 root_context->dwCompReadStringSize = 0;
208 root_context->CompositionReadingString = NULL;
209 root_context->dwResultStringSize = 0;
210 root_context->ResultString = NULL;
211 root_context->dwResultReadStringSize = 0;
212 root_context->ResultReadingString = NULL;
214 else
215 ShowWindow(hwndDefault, SW_SHOWNOACTIVATE);
217 ImmInternalSendIMENotify(IMN_SETOPENSTATUS, 0);
221 /***********************************************************************
222 * ImmAssociateContext (IMM32.@)
224 HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
226 InputContextData *data = (InputContextData*)hIMC;
228 WARN("(%p, %p): semi-stub\n", hWnd, hIMC);
230 if (!hIMC)
231 return NULL;
234 * WINE SPECIFIC! MAY CONFLICT
235 * associate the root context we have an XIM created
237 if (hWnd == 0x000)
239 root_context = (InputContextData*)hIMC;
243 * If already associated just return
245 if (data->hwnd == hWnd)
246 return hIMC;
248 if (IsWindow(data->hwnd))
251 * Post a message that your context is switching
253 SendMessageW(data->hwnd, WM_IME_SETCONTEXT, FALSE, ISC_SHOWUIALL);
256 data->hwnd = hWnd;
258 if (IsWindow(data->hwnd))
261 * Post a message that your context is switching
263 SendMessageW(data->hwnd, WM_IME_SETCONTEXT, TRUE, ISC_SHOWUIALL);
267 * TODO: We need to keep track of the old context associated
268 * with a window and return it for now we will return NULL;
270 return NULL;
273 /***********************************************************************
274 * ImmAssociateContextEx (IMM32.@)
276 BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags)
278 FIXME("(%p, %p, %d): stub\n", hWnd, hIMC, dwFlags);
279 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
280 return FALSE;
283 /***********************************************************************
284 * ImmConfigureIMEA (IMM32.@)
286 BOOL WINAPI ImmConfigureIMEA(
287 HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData)
289 FIXME("(%p, %p, %d, %p): stub\n",
290 hKL, hWnd, dwMode, lpData
292 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
293 return FALSE;
296 /***********************************************************************
297 * ImmConfigureIMEW (IMM32.@)
299 BOOL WINAPI ImmConfigureIMEW(
300 HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData)
302 FIXME("(%p, %p, %d, %p): stub\n",
303 hKL, hWnd, dwMode, lpData
305 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
306 return FALSE;
309 /***********************************************************************
310 * ImmCreateContext (IMM32.@)
312 HIMC WINAPI ImmCreateContext(void)
314 InputContextData *new_context;
316 new_context = HeapAlloc(GetProcessHeap(),0,sizeof(InputContextData));
317 ZeroMemory(new_context,sizeof(InputContextData));
319 return (HIMC)new_context;
322 /***********************************************************************
323 * ImmDestroyContext (IMM32.@)
325 BOOL WINAPI ImmDestroyContext(HIMC hIMC)
327 InputContextData *data = (InputContextData*)hIMC;
329 TRACE("Destroying %p\n",hIMC);
331 if (hIMC)
333 if (data->dwCompStringSize)
334 HeapFree(GetProcessHeap(),0,data->CompositionString);
335 if (data->dwCompReadStringSize)
336 HeapFree(GetProcessHeap(),0,data->CompositionReadingString);
337 if (data->dwResultStringSize)
338 HeapFree(GetProcessHeap(),0,data->ResultString);
339 if (data->dwResultReadStringSize)
340 HeapFree(GetProcessHeap(),0,data->ResultReadingString);
342 if (data->textfont)
344 DeleteObject(data->textfont);
345 data->textfont = NULL;
348 HeapFree(GetProcessHeap(),0,data);
350 return TRUE;
353 /***********************************************************************
354 * ImmDisableIME (IMM32.@)
356 BOOL WINAPI ImmDisableIME(DWORD idThread)
358 FIXME("(%d): stub\n", idThread);
359 return TRUE;
362 /***********************************************************************
363 * ImmEnumRegisterWordA (IMM32.@)
365 UINT WINAPI ImmEnumRegisterWordA(
366 HKL hKL, REGISTERWORDENUMPROCA lpfnEnumProc,
367 LPCSTR lpszReading, DWORD dwStyle,
368 LPCSTR lpszRegister, LPVOID lpData)
370 FIXME("(%p, %p, %s, %d, %s, %p): stub\n",
371 hKL, lpfnEnumProc,
372 debugstr_a(lpszReading), dwStyle,
373 debugstr_a(lpszRegister), lpData
375 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
376 return 0;
379 /***********************************************************************
380 * ImmEnumRegisterWordW (IMM32.@)
382 UINT WINAPI ImmEnumRegisterWordW(
383 HKL hKL, REGISTERWORDENUMPROCW lpfnEnumProc,
384 LPCWSTR lpszReading, DWORD dwStyle,
385 LPCWSTR lpszRegister, LPVOID lpData)
387 FIXME("(%p, %p, %s, %d, %s, %p): stub\n",
388 hKL, lpfnEnumProc,
389 debugstr_w(lpszReading), dwStyle,
390 debugstr_w(lpszRegister), lpData
392 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
393 return 0;
396 /***********************************************************************
397 * ImmEscapeA (IMM32.@)
399 LRESULT WINAPI ImmEscapeA(
400 HKL hKL, HIMC hIMC,
401 UINT uEscape, LPVOID lpData)
403 FIXME("(%p, %p, %d, %p): stub\n",
404 hKL, hIMC, uEscape, lpData
406 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
407 return 0;
410 /***********************************************************************
411 * ImmEscapeW (IMM32.@)
413 LRESULT WINAPI ImmEscapeW(
414 HKL hKL, HIMC hIMC,
415 UINT uEscape, LPVOID lpData)
417 FIXME("(%p, %p, %d, %p): stub\n",
418 hKL, hIMC, uEscape, lpData
420 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
421 return 0;
424 /***********************************************************************
425 * ImmGetCandidateListA (IMM32.@)
427 DWORD WINAPI ImmGetCandidateListA(
428 HIMC hIMC, DWORD deIndex,
429 LPCANDIDATELIST lpCandList, DWORD dwBufLen)
431 FIXME("(%p, %d, %p, %d): stub\n",
432 hIMC, deIndex,
433 lpCandList, dwBufLen
435 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
436 return 0;
439 /***********************************************************************
440 * ImmGetCandidateListCountA (IMM32.@)
442 DWORD WINAPI ImmGetCandidateListCountA(
443 HIMC hIMC, LPDWORD lpdwListCount)
445 FIXME("(%p, %p): stub\n", hIMC, lpdwListCount);
446 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
447 return 0;
450 /***********************************************************************
451 * ImmGetCandidateListCountW (IMM32.@)
453 DWORD WINAPI ImmGetCandidateListCountW(
454 HIMC hIMC, LPDWORD lpdwListCount)
456 FIXME("(%p, %p): stub\n", hIMC, lpdwListCount);
457 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
458 return 0;
461 /***********************************************************************
462 * ImmGetCandidateListW (IMM32.@)
464 DWORD WINAPI ImmGetCandidateListW(
465 HIMC hIMC, DWORD deIndex,
466 LPCANDIDATELIST lpCandList, DWORD dwBufLen)
468 FIXME("(%p, %d, %p, %d): stub\n",
469 hIMC, deIndex,
470 lpCandList, dwBufLen
472 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
473 return 0;
476 /***********************************************************************
477 * ImmGetCandidateWindow (IMM32.@)
479 BOOL WINAPI ImmGetCandidateWindow(
480 HIMC hIMC, DWORD dwBufLen, LPCANDIDATEFORM lpCandidate)
482 FIXME("(%p, %d, %p): stub\n", hIMC, dwBufLen, lpCandidate);
483 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
484 return FALSE;
487 /***********************************************************************
488 * ImmGetCompositionFontA (IMM32.@)
490 BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
492 FIXME("(%p, %p): stub\n", hIMC, lplf);
493 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
494 return FALSE;
497 /***********************************************************************
498 * ImmGetCompositionFontW (IMM32.@)
500 BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
502 FIXME("(%p, %p): stub\n", hIMC, lplf);
503 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
504 return FALSE;
507 /***********************************************************************
508 * ImmGetCompositionStringA (IMM32.@)
510 LONG WINAPI ImmGetCompositionStringA(
511 HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
513 CHAR *buf;
514 LONG rc = 0;
515 InputContextData *data = (InputContextData*)hIMC;
517 TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen);
519 if (!data)
520 return FALSE;
522 if (dwIndex == GCS_RESULTSTR)
524 TRACE("GSC_RESULTSTR %p %i\n",data->ResultString,
525 data->dwResultStringSize);
527 buf = HeapAlloc( GetProcessHeap(), 0, data->dwResultStringSize * 3 );
528 rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)data->ResultString,
529 data->dwResultStringSize / sizeof(WCHAR), buf,
530 data->dwResultStringSize * 3, NULL, NULL);
531 if (dwBufLen >= rc)
532 memcpy(lpBuf,buf,rc);
534 data->bRead = TRUE;
535 HeapFree( GetProcessHeap(), 0, buf );
537 else if (dwIndex == GCS_COMPSTR)
539 TRACE("GSC_COMPSTR %p %i\n", data->CompositionString, data->dwCompStringLength);
541 buf = HeapAlloc( GetProcessHeap(), 0, data->dwCompStringLength * 3 );
542 rc = WideCharToMultiByte(CP_ACP, 0,(LPWSTR)data->CompositionString,
543 data->dwCompStringLength/ sizeof(WCHAR), buf,
544 data->dwCompStringLength* 3, NULL, NULL);
545 if (dwBufLen >= rc)
546 memcpy(lpBuf,buf,rc);
547 HeapFree( GetProcessHeap(), 0, buf );
549 else if (dwIndex == GCS_COMPATTR)
551 TRACE("GSC_COMPATTR %p %i\n", data->CompositionString, data->dwCompStringLength);
553 rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)data->CompositionString,
554 data->dwCompStringLength/ sizeof(WCHAR), NULL,
555 0, NULL, NULL);
557 if (dwBufLen >= rc)
559 int i=0;
560 for (i = 0; i < rc; i++)
561 ((LPBYTE)lpBuf)[i] = ATTR_INPUT;
564 else if (dwIndex == GCS_COMPCLAUSE)
566 TRACE("GSC_COMPCLAUSE %p %i\n", data->CompositionString, data->dwCompStringLength);
568 rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)data->CompositionString,
569 data->dwCompStringLength/ sizeof(WCHAR), NULL,
570 0, NULL, NULL);
572 if (dwBufLen >= sizeof(DWORD)*2)
574 ((LPDWORD)lpBuf)[0] = 0;
575 ((LPDWORD)lpBuf)[1] = rc;
577 rc = sizeof(DWORD)*2;
579 else if (dwIndex == GCS_RESULTCLAUSE)
581 TRACE("GSC_RESULTCLAUSE %p %i\n", data->ResultString, data->dwResultStringSize);
583 rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)data->ResultString,
584 data->dwResultStringSize/ sizeof(WCHAR), NULL,
585 0, NULL, NULL);
587 if (dwBufLen >= sizeof(DWORD)*2)
589 ((LPDWORD)lpBuf)[0] = 0;
590 ((LPDWORD)lpBuf)[1] = rc;
592 rc = sizeof(DWORD)*2;
594 else
596 FIXME("Unhandled index 0x%x\n",dwIndex);
599 return rc;
602 /***********************************************************************
603 * ImmGetCompositionStringW (IMM32.@)
605 LONG WINAPI ImmGetCompositionStringW(
606 HIMC hIMC, DWORD dwIndex,
607 LPVOID lpBuf, DWORD dwBufLen)
609 LONG rc = 0;
610 InputContextData *data = (InputContextData*)hIMC;
612 TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen);
614 if (!data)
615 return FALSE;
617 if (dwIndex == GCS_RESULTSTR)
619 data->bRead = TRUE;
621 if (dwBufLen >= data->dwResultStringSize)
622 memcpy(lpBuf,data->ResultString,data->dwResultStringSize);
624 rc = data->dwResultStringSize;
626 else if (dwIndex == GCS_RESULTREADSTR)
628 if (dwBufLen >= data->dwResultReadStringSize)
629 memcpy(lpBuf,data->ResultReadingString,
630 data->dwResultReadStringSize);
632 rc = data->dwResultReadStringSize;
634 else if (dwIndex == GCS_COMPSTR)
636 if (dwBufLen >= data->dwCompStringLength)
637 memcpy(lpBuf,data->CompositionString,data->dwCompStringLength);
639 rc = data->dwCompStringLength;
641 else if (dwIndex == GCS_COMPATTR)
643 unsigned int len = data->dwCompStringLength;
645 if (dwBufLen >= len)
647 unsigned int i=0;
648 for (i = 0; i < len; i++)
649 ((LPBYTE)lpBuf)[i] = ATTR_INPUT;
652 rc = len;
654 else if (dwIndex == GCS_COMPCLAUSE)
656 if (dwBufLen >= sizeof(DWORD)*2)
658 ((LPDWORD)lpBuf)[0] = 0;
659 ((LPDWORD)lpBuf)[1] = data->dwCompStringLength/sizeof(WCHAR);
661 rc = sizeof(DWORD)*2;
663 else if (dwIndex == GCS_COMPREADSTR)
665 if (dwBufLen >= data->dwCompReadStringSize)
666 memcpy(lpBuf,data->CompositionReadingString,
667 data->dwCompReadStringSize);
669 rc = data->dwCompReadStringSize;
671 else
673 FIXME("Unhandled index 0x%x\n",dwIndex);
676 return rc;
679 /***********************************************************************
680 * ImmGetCompositionWindow (IMM32.@)
682 BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
684 InputContextData *data = (InputContextData*)hIMC;
686 TRACE("(%p, %p)\n", hIMC, lpCompForm);
688 if (!data)
689 return FALSE;
691 memcpy(lpCompForm,&(data->CompForm),sizeof(COMPOSITIONFORM));
692 return 1;
695 /***********************************************************************
696 * ImmGetContext (IMM32.@)
699 HIMC WINAPI ImmGetContext(HWND hWnd)
701 TRACE("%p\n", hWnd);
703 if (!root_context)
704 return NULL;
706 root_context->hwnd = hWnd;
707 return (HIMC)root_context;
710 /***********************************************************************
711 * ImmGetConversionListA (IMM32.@)
713 DWORD WINAPI ImmGetConversionListA(
714 HKL hKL, HIMC hIMC,
715 LPCSTR pSrc, LPCANDIDATELIST lpDst,
716 DWORD dwBufLen, UINT uFlag)
718 FIXME("(%p, %p, %s, %p, %d, %d): stub\n",
719 hKL, hIMC, debugstr_a(pSrc), lpDst, dwBufLen, uFlag
721 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
722 return 0;
725 /***********************************************************************
726 * ImmGetConversionListW (IMM32.@)
728 DWORD WINAPI ImmGetConversionListW(
729 HKL hKL, HIMC hIMC,
730 LPCWSTR pSrc, LPCANDIDATELIST lpDst,
731 DWORD dwBufLen, UINT uFlag)
733 FIXME("(%p, %p, %s, %p, %d, %d): stub\n",
734 hKL, hIMC, debugstr_w(pSrc), lpDst, dwBufLen, uFlag
736 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
737 return 0;
740 /***********************************************************************
741 * ImmGetConversionStatus (IMM32.@)
743 BOOL WINAPI ImmGetConversionStatus(
744 HIMC hIMC, LPDWORD lpfdwConversion, LPDWORD lpfdwSentence)
746 TRACE("(%p, %p, %p): best guess\n", hIMC, lpfdwConversion, lpfdwSentence);
747 if (lpfdwConversion)
748 *lpfdwConversion = IME_CMODE_NATIVE;
749 if (lpfdwSentence)
750 *lpfdwSentence = IME_SMODE_NONE;
751 return TRUE;
754 /***********************************************************************
755 * ImmGetDefaultIMEWnd (IMM32.@)
757 HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
759 FIXME("(%p - %p %p ): semi-stub\n", hWnd,hwndDefault, root_context);
761 if (hwndDefault == NULL)
763 static const WCHAR the_name[] = {'I','M','E','\0'};
765 IMM_Register();
766 hwndDefault = CreateWindowExW( WS_EX_TOOLWINDOW, WC_IMECLASSNAME,
767 the_name, WS_POPUP, 0, 0, 1, 1, 0, 0,
768 hImeInst, 0);
770 TRACE("Default created (%p)\n",hwndDefault);
773 return (HWND)hwndDefault;
776 /***********************************************************************
777 * ImmGetDescriptionA (IMM32.@)
779 UINT WINAPI ImmGetDescriptionA(
780 HKL hKL, LPSTR lpszDescription, UINT uBufLen)
782 WCHAR *buf;
783 DWORD len;
785 TRACE("%p %p %d\n", hKL, lpszDescription, uBufLen);
787 /* find out how many characters in the unicode buffer */
788 len = ImmGetDescriptionW( hKL, NULL, 0 );
790 /* allocate a buffer of that size */
791 buf = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof (WCHAR) );
792 if( !buf )
793 return 0;
795 /* fetch the unicode buffer */
796 len = ImmGetDescriptionW( hKL, buf, len + 1 );
798 /* convert it back to ASCII */
799 len = WideCharToMultiByte( CP_ACP, 0, buf, len + 1,
800 lpszDescription, uBufLen, NULL, NULL );
802 HeapFree( GetProcessHeap(), 0, buf );
804 return len;
807 /***********************************************************************
808 * ImmGetDescriptionW (IMM32.@)
810 UINT WINAPI ImmGetDescriptionW(HKL hKL, LPWSTR lpszDescription, UINT uBufLen)
812 static const WCHAR name[] = { 'W','i','n','e',' ','X','I','M',0 };
814 FIXME("(%p, %p, %d): semi stub\n", hKL, lpszDescription, uBufLen);
816 if (!uBufLen) return lstrlenW( name );
817 lstrcpynW( lpszDescription, name, uBufLen );
818 return lstrlenW( lpszDescription );
821 /***********************************************************************
822 * ImmGetGuideLineA (IMM32.@)
824 DWORD WINAPI ImmGetGuideLineA(
825 HIMC hIMC, DWORD dwIndex, LPSTR lpBuf, DWORD dwBufLen)
827 FIXME("(%p, %d, %s, %d): stub\n",
828 hIMC, dwIndex, debugstr_a(lpBuf), dwBufLen
830 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
831 return 0;
834 /***********************************************************************
835 * ImmGetGuideLineW (IMM32.@)
837 DWORD WINAPI ImmGetGuideLineW(HIMC hIMC, DWORD dwIndex, LPWSTR lpBuf, DWORD dwBufLen)
839 FIXME("(%p, %d, %s, %d): stub\n",
840 hIMC, dwIndex, debugstr_w(lpBuf), dwBufLen
842 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
843 return 0;
846 /***********************************************************************
847 * ImmGetIMEFileNameA (IMM32.@)
849 UINT WINAPI ImmGetIMEFileNameA(
850 HKL hKL, LPSTR lpszFileName, UINT uBufLen)
852 FIXME("(%p, %p, %d): stub\n", hKL, lpszFileName, uBufLen);
853 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
854 return 0;
857 /***********************************************************************
858 * ImmGetIMEFileNameW (IMM32.@)
860 UINT WINAPI ImmGetIMEFileNameW(
861 HKL hKL, LPWSTR lpszFileName, UINT uBufLen)
863 FIXME("(%p, %p, %d): stub\n", hKL, lpszFileName, uBufLen);
864 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
865 return 0;
868 /***********************************************************************
869 * ImmGetOpenStatus (IMM32.@)
871 BOOL WINAPI ImmGetOpenStatus(HIMC hIMC)
873 InputContextData *data = (InputContextData*)hIMC;
875 if (!data)
876 return FALSE;
877 FIXME("(%p): semi-stub\n", hIMC);
879 return data->bOpen;
882 /***********************************************************************
883 * ImmGetProperty (IMM32.@)
885 DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex)
887 DWORD rc = 0;
888 TRACE("(%p, %d)\n", hKL, fdwIndex);
890 switch (fdwIndex)
892 case IGP_PROPERTY:
893 TRACE("(%s)\n", "IGP_PROPERTY");
894 rc = IME_PROP_UNICODE | IME_PROP_AT_CARET;
895 break;
896 case IGP_CONVERSION:
897 FIXME("(%s)\n", "IGP_CONVERSION");
898 rc = IME_CMODE_NATIVE;
899 break;
900 case IGP_SENTENCE:
901 FIXME("%s)\n", "IGP_SENTENCE");
902 rc = IME_SMODE_AUTOMATIC;
903 break;
904 case IGP_SETCOMPSTR:
905 TRACE("(%s)\n", "IGP_SETCOMPSTR");
906 rc = 0;
907 break;
908 case IGP_SELECT:
909 TRACE("(%s)\n", "IGP_SELECT");
910 rc = SELECT_CAP_CONVERSION | SELECT_CAP_SENTENCE;
911 break;
912 case IGP_GETIMEVERSION:
913 TRACE("(%s)\n", "IGP_GETIMEVERSION");
914 rc = IMEVER_0400;
915 break;
916 case IGP_UI:
917 TRACE("(%s)\n", "IGP_UI");
918 rc = 0;
919 break;
920 default:
921 rc = 0;
923 return rc;
926 /***********************************************************************
927 * ImmGetRegisterWordStyleA (IMM32.@)
929 UINT WINAPI ImmGetRegisterWordStyleA(
930 HKL hKL, UINT nItem, LPSTYLEBUFA lpStyleBuf)
932 FIXME("(%p, %d, %p): stub\n", hKL, nItem, lpStyleBuf);
933 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
934 return 0;
937 /***********************************************************************
938 * ImmGetRegisterWordStyleW (IMM32.@)
940 UINT WINAPI ImmGetRegisterWordStyleW(
941 HKL hKL, UINT nItem, LPSTYLEBUFW lpStyleBuf)
943 FIXME("(%p, %d, %p): stub\n", hKL, nItem, lpStyleBuf);
944 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
945 return 0;
948 /***********************************************************************
949 * ImmGetStatusWindowPos (IMM32.@)
951 BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
953 FIXME("(%p, %p): stub\n", hIMC, lpptPos);
954 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
955 return FALSE;
958 /***********************************************************************
959 * ImmGetVirtualKey (IMM32.@)
961 UINT WINAPI ImmGetVirtualKey(HWND hWnd)
963 OSVERSIONINFOA version;
964 FIXME("(%p): stub\n", hWnd);
965 GetVersionExA( &version );
966 switch(version.dwPlatformId)
968 case VER_PLATFORM_WIN32_WINDOWS:
969 return VK_PROCESSKEY;
970 case VER_PLATFORM_WIN32_NT:
971 return 0;
972 default:
973 FIXME("%d not supported\n",version.dwPlatformId);
974 return VK_PROCESSKEY;
978 /***********************************************************************
979 * ImmInstallIMEA (IMM32.@)
981 HKL WINAPI ImmInstallIMEA(
982 LPCSTR lpszIMEFileName, LPCSTR lpszLayoutText)
984 FIXME("(%s, %s): stub\n",
985 debugstr_a(lpszIMEFileName), debugstr_a(lpszLayoutText)
987 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
988 return NULL;
991 /***********************************************************************
992 * ImmInstallIMEW (IMM32.@)
994 HKL WINAPI ImmInstallIMEW(
995 LPCWSTR lpszIMEFileName, LPCWSTR lpszLayoutText)
997 FIXME("(%s, %s): stub\n",
998 debugstr_w(lpszIMEFileName), debugstr_w(lpszLayoutText)
1000 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1001 return NULL;
1004 /***********************************************************************
1005 * ImmIsIME (IMM32.@)
1007 BOOL WINAPI ImmIsIME(HKL hKL)
1009 TRACE("(%p): semi-stub\n", hKL);
1011 * FIXME: Dead key locales will return TRUE here when they should not
1012 * There is probably a more proper way to check this.
1014 return (root_context != NULL);
1017 /***********************************************************************
1018 * ImmIsUIMessageA (IMM32.@)
1020 BOOL WINAPI ImmIsUIMessageA(
1021 HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
1023 BOOL rc = FALSE;
1025 TRACE("(%p, %x, %d, %ld)\n", hWndIME, msg, wParam, lParam);
1026 if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
1027 (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP) ||
1028 (msg == WM_MSIME_SERVICE) ||
1029 (msg == WM_MSIME_RECONVERTOPTIONS) ||
1030 (msg == WM_MSIME_MOUSE) ||
1031 (msg == WM_MSIME_RECONVERTREQUEST) ||
1032 (msg == WM_MSIME_RECONVERT) ||
1033 (msg == WM_MSIME_QUERYPOSITION) ||
1034 (msg == WM_MSIME_DOCUMENTFEED))
1037 if (!hwndDefault)
1038 ImmGetDefaultIMEWnd(NULL);
1040 if (hWndIME == NULL)
1041 PostMessageA(hwndDefault, msg, wParam, lParam);
1043 rc = TRUE;
1045 return rc;
1048 /***********************************************************************
1049 * ImmIsUIMessageW (IMM32.@)
1051 BOOL WINAPI ImmIsUIMessageW(
1052 HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
1054 BOOL rc = FALSE;
1055 TRACE("(%p, %d, %d, %ld): stub\n", hWndIME, msg, wParam, lParam);
1056 if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
1057 (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP) ||
1058 (msg == WM_MSIME_SERVICE) ||
1059 (msg == WM_MSIME_RECONVERTOPTIONS) ||
1060 (msg == WM_MSIME_MOUSE) ||
1061 (msg == WM_MSIME_RECONVERTREQUEST) ||
1062 (msg == WM_MSIME_RECONVERT) ||
1063 (msg == WM_MSIME_QUERYPOSITION) ||
1064 (msg == WM_MSIME_DOCUMENTFEED))
1065 rc = TRUE;
1066 return rc;
1069 /***********************************************************************
1070 * ImmNotifyIME (IMM32.@)
1072 BOOL WINAPI ImmNotifyIME(
1073 HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
1075 BOOL rc = FALSE;
1077 TRACE("(%p, %d, %d, %d)\n",
1078 hIMC, dwAction, dwIndex, dwValue);
1080 if (!root_context)
1081 return rc;
1083 switch(dwAction)
1085 case NI_CHANGECANDIDATELIST:
1086 FIXME("%s\n","NI_CHANGECANDIDATELIST");
1087 break;
1088 case NI_CLOSECANDIDATE:
1089 FIXME("%s\n","NI_CLOSECANDIDATE");
1090 break;
1091 case NI_COMPOSITIONSTR:
1092 switch (dwIndex)
1094 case CPS_CANCEL:
1095 TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_CANCEL");
1096 if (pX11DRV_ForceXIMReset)
1097 pX11DRV_ForceXIMReset(root_context->hwnd);
1098 if (root_context->dwCompStringSize)
1100 HeapFree(GetProcessHeap(),0,
1101 root_context->CompositionString);
1102 root_context->dwCompStringSize = 0;
1103 root_context->dwCompStringLength = 0;
1104 root_context->CompositionString = NULL;
1105 ImmInternalPostIMEMessage(WM_IME_COMPOSITION, 0,
1106 GCS_COMPSTR);
1108 rc = TRUE;
1109 break;
1110 case CPS_COMPLETE:
1111 TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_COMPLETE");
1112 if (hIMC != (HIMC)FROM_IME && pX11DRV_ForceXIMReset)
1113 pX11DRV_ForceXIMReset(root_context->hwnd);
1115 if (root_context->dwResultStringSize)
1117 HeapFree(GetProcessHeap(),0,root_context->ResultString);
1118 root_context->dwResultStringSize = 0;
1119 root_context->ResultString = NULL;
1121 if (root_context->dwCompStringLength)
1123 root_context->ResultString = HeapAlloc(
1124 GetProcessHeap(), 0, root_context->dwCompStringLength);
1125 root_context->dwResultStringSize =
1126 root_context->dwCompStringLength;
1128 memcpy(root_context->ResultString,
1129 root_context->CompositionString,
1130 root_context->dwCompStringLength);
1132 HeapFree(GetProcessHeap(),0,
1133 root_context->CompositionString);
1135 root_context->dwCompStringSize = 0;
1136 root_context->dwCompStringLength = 0;
1137 root_context->CompositionString = NULL;
1138 root_context->bRead = FALSE;
1140 ImmInternalPostIMEMessage(WM_IME_COMPOSITION, 0,
1141 GCS_COMPSTR);
1143 ImmInternalPostIMEMessage(WM_IME_COMPOSITION,
1144 root_context->ResultString[0],
1145 GCS_RESULTSTR|GCS_RESULTCLAUSE);
1147 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION, 0, 0);
1148 root_context->bInComposition = FALSE;
1150 break;
1151 case CPS_CONVERT:
1152 FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_CONVERT");
1153 break;
1154 case CPS_REVERT:
1155 FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_REVERT");
1156 break;
1157 default:
1158 ERR("%s - %s (%i)\n","NI_COMPOSITIONSTR","UNKNOWN",dwIndex);
1159 break;
1161 break;
1162 case NI_IMEMENUSELECTED:
1163 FIXME("%s\n", "NI_IMEMENUSELECTED");
1164 break;
1165 case NI_OPENCANDIDATE:
1166 FIXME("%s\n", "NI_OPENCANDIDATE");
1167 break;
1168 case NI_SELECTCANDIDATESTR:
1169 FIXME("%s\n", "NI_SELECTCANDIDATESTR");
1170 break;
1171 case NI_SETCANDIDATE_PAGESIZE:
1172 FIXME("%s\n", "NI_SETCANDIDATE_PAGESIZE");
1173 break;
1174 case NI_SETCANDIDATE_PAGESTART:
1175 FIXME("%s\n", "NI_SETCANDIDATE_PAGESTART");
1176 break;
1177 default:
1178 ERR("Unknown\n");
1181 return rc;
1184 /***********************************************************************
1185 * ImmRegisterWordA (IMM32.@)
1187 BOOL WINAPI ImmRegisterWordA(
1188 HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszRegister)
1190 FIXME("(%p, %s, %d, %s): stub\n",
1191 hKL, debugstr_a(lpszReading), dwStyle, debugstr_a(lpszRegister)
1193 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1194 return FALSE;
1197 /***********************************************************************
1198 * ImmRegisterWordW (IMM32.@)
1200 BOOL WINAPI ImmRegisterWordW(
1201 HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszRegister)
1203 FIXME("(%p, %s, %d, %s): stub\n",
1204 hKL, debugstr_w(lpszReading), dwStyle, debugstr_w(lpszRegister)
1206 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1207 return FALSE;
1210 /***********************************************************************
1211 * ImmReleaseContext (IMM32.@)
1213 BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
1215 FIXME("(%p, %p): stub\n", hWnd, hIMC);
1217 return TRUE;
1220 /***********************************************************************
1221 * ImmSetCandidateWindow (IMM32.@)
1223 BOOL WINAPI ImmSetCandidateWindow(
1224 HIMC hIMC, LPCANDIDATEFORM lpCandidate)
1226 FIXME("(%p, %p): stub\n", hIMC, lpCandidate);
1227 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1228 return FALSE;
1231 /***********************************************************************
1232 * ImmSetCompositionFontA (IMM32.@)
1234 BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
1236 InputContextData *data = (InputContextData*)hIMC;
1237 TRACE("(%p, %p)\n", hIMC, lplf);
1239 if (!data)
1240 return FALSE;
1242 memcpy(&data->font,lplf,sizeof(LOGFONTA));
1243 MultiByteToWideChar(CP_ACP, 0, lplf->lfFaceName, -1, data->font.lfFaceName,
1244 LF_FACESIZE);
1246 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONFONT, 0);
1248 if (data->textfont)
1250 DeleteObject(data->textfont);
1251 data->textfont = NULL;
1254 data->textfont = CreateFontIndirectW(&data->font);
1255 return TRUE;
1258 /***********************************************************************
1259 * ImmSetCompositionFontW (IMM32.@)
1261 BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
1263 InputContextData *data = (InputContextData*)hIMC;
1264 TRACE("(%p, %p)\n", hIMC, lplf);
1266 if (!data)
1267 return FALSE;
1269 memcpy(&data->font,lplf,sizeof(LOGFONTW));
1270 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONFONT, 0);
1272 if (data->textfont)
1274 DeleteObject(data->textfont);
1275 data->textfont = NULL;
1277 data->textfont = CreateFontIndirectW(&data->font);
1278 return TRUE;
1281 /***********************************************************************
1282 * ImmSetCompositionStringA (IMM32.@)
1284 BOOL WINAPI ImmSetCompositionStringA(
1285 HIMC hIMC, DWORD dwIndex,
1286 LPCVOID lpComp, DWORD dwCompLen,
1287 LPCVOID lpRead, DWORD dwReadLen)
1289 DWORD comp_len;
1290 DWORD read_len;
1291 WCHAR *CompBuffer = NULL;
1292 WCHAR *ReadBuffer = NULL;
1293 BOOL rc;
1295 TRACE("(%p, %d, %p, %d, %p, %d): stub\n",
1296 hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
1298 comp_len = MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, NULL, 0);
1299 if (comp_len)
1301 CompBuffer = HeapAlloc(GetProcessHeap(),0,comp_len * sizeof(WCHAR));
1302 MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, CompBuffer, comp_len);
1305 read_len = MultiByteToWideChar(CP_ACP, 0, lpRead, dwReadLen, NULL, 0);
1306 if (read_len)
1308 ReadBuffer = HeapAlloc(GetProcessHeap(),0,read_len * sizeof(WCHAR));
1309 MultiByteToWideChar(CP_ACP, 0, lpRead, dwReadLen, ReadBuffer, read_len);
1312 rc = ImmSetCompositionStringW(hIMC, dwIndex, CompBuffer, comp_len,
1313 ReadBuffer, read_len);
1315 HeapFree(GetProcessHeap(), 0, CompBuffer);
1316 HeapFree(GetProcessHeap(), 0, ReadBuffer);
1318 return rc;
1321 /***********************************************************************
1322 * ImmSetCompositionStringW (IMM32.@)
1324 BOOL WINAPI ImmSetCompositionStringW(
1325 HIMC hIMC, DWORD dwIndex,
1326 LPCVOID lpComp, DWORD dwCompLen,
1327 LPCVOID lpRead, DWORD dwReadLen)
1329 DWORD flags = 0;
1330 WCHAR wParam = 0;
1332 TRACE("(%p, %d, %p, %d, %p, %d): stub\n",
1333 hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
1336 if (hIMC != (HIMC)FROM_IME)
1337 FIXME("PROBLEM: This only sets the wine level string\n");
1340 * Explanation:
1341 * this sets the composition string in the imm32.dll level
1342 * of the composition buffer. we cannot manipulate the xim level
1343 * buffer, which means that once the xim level buffer changes again
1344 * any call to this function from the application will be lost
1347 if (lpRead && dwReadLen)
1348 FIXME("Reading string unimplemented\n");
1351 * app operating this api to also receive the message from xim
1354 if (dwIndex == SCS_SETSTR)
1356 if (!root_context->bInComposition)
1358 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION, 0, 0);
1359 root_context->bInComposition = TRUE;
1362 flags = GCS_COMPSTR;
1364 if (root_context->dwCompStringLength)
1365 HeapFree(GetProcessHeap(),0,root_context->CompositionString);
1367 root_context->dwCompStringLength = dwCompLen;
1368 root_context->dwCompStringSize = dwCompLen;
1370 if (dwCompLen && lpComp)
1372 root_context->CompositionString = HeapAlloc(GetProcessHeap(), 0,
1373 dwCompLen);
1374 memcpy(root_context->CompositionString,lpComp,dwCompLen);
1376 wParam = ((const WCHAR*)lpComp)[0];
1377 flags |= GCS_COMPCLAUSE | GCS_COMPATTR;
1379 else
1380 root_context->CompositionString = NULL;
1384 UpdateDataInDefaultIMEWindow(hwndDefault);
1386 ImmInternalPostIMEMessage(WM_IME_COMPOSITION, wParam, flags);
1388 return TRUE;
1391 /***********************************************************************
1392 * ImmSetCompositionWindow (IMM32.@)
1394 BOOL WINAPI ImmSetCompositionWindow(
1395 HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
1397 BOOL reshow = FALSE;
1398 InputContextData *data = (InputContextData*)hIMC;
1400 TRACE("(%p, %p)\n", hIMC, lpCompForm);
1401 TRACE("\t%x, (%i,%i), (%i,%i - %i,%i)\n",lpCompForm->dwStyle,
1402 lpCompForm->ptCurrentPos.x, lpCompForm->ptCurrentPos.y, lpCompForm->rcArea.top,
1403 lpCompForm->rcArea.left, lpCompForm->rcArea.bottom, lpCompForm->rcArea.right);
1405 if (!data)
1406 return FALSE;
1408 memcpy(&data->CompForm,lpCompForm,sizeof(COMPOSITIONFORM));
1410 if (IsWindowVisible(hwndDefault))
1412 reshow = TRUE;
1413 ShowWindow(hwndDefault,SW_HIDE);
1416 /* FIXME: this is a partial stub */
1418 if (reshow)
1419 ShowWindow(hwndDefault,SW_SHOWNOACTIVATE);
1421 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONWINDOW, 0);
1422 return TRUE;
1425 /***********************************************************************
1426 * ImmSetConversionStatus (IMM32.@)
1428 BOOL WINAPI ImmSetConversionStatus(
1429 HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
1431 FIXME("(%p, %d, %d): stub\n",
1432 hIMC, fdwConversion, fdwSentence
1434 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1435 return FALSE;
1438 /***********************************************************************
1439 * ImmSetOpenStatus (IMM32.@)
1441 BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
1443 InputContextData *data = (InputContextData*)hIMC;
1445 TRACE("%p %d\n", hIMC, fOpen);
1447 if (hIMC == (HIMC)FROM_IME)
1450 ImmInternalSetOpenStatus(fOpen);
1452 ImmInternalSendIMENotify(IMN_SETOPENSTATUS, 0);
1453 return TRUE;
1456 /* HACK HACK HACK
1457 * Having this implementation cause Project 2003 to fail miserably
1458 * The issue is that i think something is comming out of order or
1459 * unexpetedly.
1461 * Stubbing this function will have the effect that programs will be unable
1462 * to programaticly open the IME. This should not be a large issue
1463 * as it did not properly work anyway.
1465 if (fOpen == TRUE)
1467 FIXME("IMM hack for Project 2003\n");
1468 return FALSE;
1471 if (!data)
1472 return FALSE;
1474 if (fOpen != data->bInternalState)
1476 if (fOpen == FALSE && pX11DRV_ForceXIMReset)
1477 pX11DRV_ForceXIMReset(data->hwnd);
1479 if (fOpen == FALSE)
1480 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION,0,0);
1481 else
1482 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION,0,0);
1484 ImmInternalSetOpenStatus(fOpen);
1485 ImmInternalSetOpenStatus(!fOpen);
1487 if (data->bOpen == FALSE)
1488 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION,0,0);
1489 else
1490 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION,0,0);
1492 return FALSE;
1494 return TRUE;
1497 /***********************************************************************
1498 * ImmSetStatusWindowPos (IMM32.@)
1500 BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
1502 FIXME("(%p, %p): stub\n", hIMC, lpptPos);
1503 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1504 return FALSE;
1507 /***********************************************************************
1508 * ImmSimulateHotKey (IMM32.@)
1510 BOOL WINAPI ImmSimulateHotKey(HWND hWnd, DWORD dwHotKeyID)
1512 FIXME("(%p, %d): stub\n", hWnd, dwHotKeyID);
1513 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1514 return FALSE;
1517 /***********************************************************************
1518 * ImmUnregisterWordA (IMM32.@)
1520 BOOL WINAPI ImmUnregisterWordA(
1521 HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszUnregister)
1523 FIXME("(%p, %s, %d, %s): stub\n",
1524 hKL, debugstr_a(lpszReading), dwStyle, debugstr_a(lpszUnregister)
1526 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1527 return FALSE;
1530 /***********************************************************************
1531 * ImmUnregisterWordW (IMM32.@)
1533 BOOL WINAPI ImmUnregisterWordW(
1534 HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszUnregister)
1536 FIXME("(%p, %s, %d, %s): stub\n",
1537 hKL, debugstr_w(lpszReading), dwStyle, debugstr_w(lpszUnregister)
1539 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1540 return FALSE;
1543 /***********************************************************************
1544 * ImmGetImeMenuItemsA (IMM32.@)
1546 DWORD WINAPI ImmGetImeMenuItemsA( HIMC hIMC, DWORD dwFlags, DWORD dwType,
1547 LPIMEMENUITEMINFOA lpImeParentMenu, LPIMEMENUITEMINFOA lpImeMenu,
1548 DWORD dwSize)
1550 FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC, dwFlags, dwType,
1551 lpImeParentMenu, lpImeMenu, dwSize);
1552 return 0;
1555 /***********************************************************************
1556 * ImmGetImeMenuItemsW (IMM32.@)
1558 DWORD WINAPI ImmGetImeMenuItemsW( HIMC hIMC, DWORD dwFlags, DWORD dwType,
1559 LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu,
1560 DWORD dwSize)
1562 FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC, dwFlags, dwType,
1563 lpImeParentMenu, lpImeMenu, dwSize);
1564 return 0;
1567 /*****
1568 * Internal functions to help with IME window management
1570 static void PaintDefaultIMEWnd(HWND hwnd)
1572 PAINTSTRUCT ps;
1573 RECT rect;
1574 HDC hdc = BeginPaint(hwnd,&ps);
1575 GetClientRect(hwnd,&rect);
1576 FillRect(hdc, &rect, (HBRUSH)(COLOR_WINDOW + 1));
1578 if (root_context->dwCompStringLength && root_context->CompositionString)
1580 SIZE size;
1581 POINT pt;
1582 HFONT oldfont = NULL;
1584 if (root_context->textfont)
1585 oldfont = SelectObject(hdc,root_context->textfont);
1588 GetTextExtentPoint32W(hdc, (LPWSTR)root_context->CompositionString,
1589 root_context->dwCompStringLength / sizeof(WCHAR),
1590 &size);
1591 pt.x = size.cx;
1592 pt.y = size.cy;
1593 LPtoDP(hdc,&pt,1);
1595 if (root_context->CompForm.dwStyle == CFS_POINT ||
1596 root_context->CompForm.dwStyle == CFS_FORCE_POSITION)
1598 POINT cpt = root_context->CompForm.ptCurrentPos;
1599 ClientToScreen(root_context->hwnd,&cpt);
1600 rect.left = cpt.x;
1601 rect.top = cpt.y;
1602 rect.right = rect.left + pt.x + 20;
1603 rect.bottom = rect.top + pt.y + 20;
1605 else if (root_context->CompForm.dwStyle == CFS_RECT)
1607 POINT cpt;
1608 cpt.x = root_context->CompForm.rcArea.left;
1609 cpt.y = root_context->CompForm.rcArea.top;
1610 ClientToScreen(root_context->hwnd,&cpt);
1611 rect.left = cpt.x;
1612 rect.top = cpt.y;
1613 cpt.x = root_context->CompForm.rcArea.right;
1614 cpt.y = root_context->CompForm.rcArea.bottom;
1615 ClientToScreen(root_context->hwnd,&cpt);
1616 rect.right = cpt.x;
1617 rect.bottom = cpt.y;
1619 else
1621 rect.right = rect.left + pt.x + 20;
1622 rect.bottom = rect.top + pt.y + 20;
1624 MoveWindow(hwnd, rect.left, rect.top, rect.right - rect.left ,
1625 rect.bottom - rect.top, FALSE);
1626 TextOutW(hdc, 10,10,(LPWSTR)root_context->CompositionString,
1627 root_context->dwCompStringLength / sizeof(WCHAR));
1629 if (oldfont)
1630 SelectObject(hdc,oldfont);
1632 EndPaint(hwnd,&ps);
1635 static void UpdateDataInDefaultIMEWindow(HWND hwnd)
1637 RedrawWindow(hwnd,NULL,NULL,RDW_ERASENOW|RDW_INVALIDATE);
1641 * The window proc for the default IME window
1643 static LRESULT WINAPI IME_WindowProc(HWND hwnd, UINT msg, WPARAM wParam,
1644 LPARAM lParam)
1646 LRESULT rc = 0;
1648 TRACE("Incoming Message 0x%x (0x%08x, 0x%08x)\n", msg, (UINT)wParam,
1649 (UINT)lParam);
1651 switch(msg)
1653 case WM_PAINT:
1654 PaintDefaultIMEWnd(hwnd);
1655 return FALSE;
1657 case WM_NCCREATE:
1658 return TRUE;
1660 case WM_CREATE:
1661 SetWindowTextA(hwnd,"Wine Ime Active");
1662 return TRUE;
1664 case WM_SETFOCUS:
1665 if (wParam)
1666 SetFocus((HWND)wParam);
1667 else
1668 FIXME("Received focus, should never have focus\n");
1669 break;
1670 case WM_IME_COMPOSITION:
1671 TRACE("IME message %s, 0x%x, 0x%x (%i)\n",
1672 "WM_IME_COMPOSITION", (UINT)wParam, (UINT)lParam,
1673 root_context->bRead);
1674 if (lParam & GCS_RESULTSTR)
1675 IMM_PostResult(root_context);
1676 else
1677 UpdateDataInDefaultIMEWindow(hwnd);
1678 break;
1679 case WM_IME_STARTCOMPOSITION:
1680 TRACE("IME message %s, 0x%x, 0x%x\n",
1681 "WM_IME_STARTCOMPOSITION", (UINT)wParam, (UINT)lParam);
1682 root_context->hwnd = GetFocus();
1683 ShowWindow(hwndDefault,SW_SHOWNOACTIVATE);
1684 break;
1685 case WM_IME_ENDCOMPOSITION:
1686 TRACE("IME message %s, 0x%x, 0x%x\n",
1687 "WM_IME_ENDCOMPOSITION", (UINT)wParam, (UINT)lParam);
1688 ShowWindow(hwndDefault,SW_HIDE);
1689 break;
1690 case WM_IME_SELECT:
1691 TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_SELECT",
1692 (UINT)wParam, (UINT)lParam);
1693 break;
1694 case WM_IME_CONTROL:
1695 TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_CONTROL",
1696 (UINT)wParam, (UINT)lParam);
1697 rc = 1;
1698 break;
1699 case WM_IME_NOTIFY:
1700 TRACE("!! IME NOTIFY\n");
1701 break;
1702 default:
1703 TRACE("Non-standard message 0x%x\n",msg);
1705 /* check the MSIME messages */
1706 if (msg == WM_MSIME_SERVICE)
1708 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_SERVICE",
1709 (UINT)wParam, (UINT)lParam);
1710 rc = FALSE;
1712 else if (msg == WM_MSIME_RECONVERTOPTIONS)
1714 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTOPTIONS",
1715 (UINT)wParam, (UINT)lParam);
1717 else if (msg == WM_MSIME_MOUSE)
1719 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_MOUSE",
1720 (UINT)wParam, (UINT)lParam);
1722 else if (msg == WM_MSIME_RECONVERTREQUEST)
1724 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTREQUEST",
1725 (UINT)wParam, (UINT)lParam);
1727 else if (msg == WM_MSIME_RECONVERT)
1729 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERT",
1730 (UINT)wParam, (UINT)lParam);
1732 else if (msg == WM_MSIME_QUERYPOSITION)
1734 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_QUERYPOSITION",
1735 (UINT)wParam, (UINT)lParam);
1737 else if (msg == WM_MSIME_DOCUMENTFEED)
1739 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_DOCUMENTFEED",
1740 (UINT)wParam, (UINT)lParam);
1742 /* DefWndProc if not an IME message */
1743 else if (!rc && !((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
1744 (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP)))
1745 rc = DefWindowProcW(hwnd,msg,wParam,lParam);
1747 return rc;