Aric Stewart : riched20: Make richedit control IME aware.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jun 28 08:08:06 CDT 2007
Module: wine
Branch: master
Commit: c03125a1be04d4a2c9f047d92a32b4eb6869ae68
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c03125a1be04d4a2c9f047d92a32b4eb6869ae68
Author: Aric Stewart <aric at codeweavers.com>
Date: Wed Jun 27 07:57:51 2007 -0500
riched20: Make richedit control IME aware.
---
dlls/riched20/Makefile.in | 2 +-
dlls/riched20/editor.c | 59 +++++++++++++++++++++++++++++++++++++++++++++
dlls/riched20/editstr.h | 2 +
3 files changed, 62 insertions(+), 1 deletions(-)
diff --git a/dlls/riched20/Makefile.in b/dlls/riched20/Makefile.in
index 87feccd..6b974e5 100644
--- a/dlls/riched20/Makefile.in
+++ b/dlls/riched20/Makefile.in
@@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = riched20.dll
IMPORTLIB = libriched20.$(IMPLIBEXT)
-IMPORTS = ole32 user32 gdi32 kernel32
+IMPORTS = ole32 imm32 user32 gdi32 kernel32
EXTRALIBS = -luuid
C_SRCS = \
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index b83fb41..4cdb54a 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -227,6 +227,7 @@
#define NO_SHLWAPI_STREAM
#include "shlwapi.h"
#include "rtf.h"
+#include "imm.h"
#define STACK_SIZE_DEFAULT 100
#define STACK_SIZE_MAX 1000
@@ -2515,6 +2516,64 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
ME_RewrapRepaint(editor);
return DefWindowProcW(hWnd, msg, wParam, lParam);
}
+ /* IME messages to make richedit controls IME aware */
+ case WM_IME_SETCONTEXT:
+ case WM_IME_CONTROL:
+ case WM_IME_SELECT:
+ case WM_IME_COMPOSITIONFULL:
+ return 0;
+ case WM_IME_STARTCOMPOSITION:
+ {
+ editor->imeStartIndex=ME_GetCursorOfs(editor,0);
+ ME_DeleteSelection(editor);
+ ME_CommitUndo(editor);
+ ME_UpdateRepaint(editor);
+ return 0;
+ }
+ case WM_IME_COMPOSITION:
+ {
+ HIMC hIMC;
+
+ ME_Style *style = ME_GetInsertStyle(editor, 0);
+ hIMC = ImmGetContext(hWnd);
+ ME_DeleteSelection(editor);
+ ME_CommitUndo(editor);
+ ME_SaveTempStyle(editor);
+ if (lParam & GCS_RESULTSTR)
+ {
+ LPWSTR lpCompStr = NULL;
+ DWORD dwBufLen;
+
+ dwBufLen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
+ lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR));
+ ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpCompStr, dwBufLen);
+ lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
+ ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
+ }
+ else if (lParam & GCS_COMPSTR)
+ {
+ LPWSTR lpCompStr = NULL;
+ DWORD dwBufLen;
+
+ dwBufLen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
+ lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR));
+ ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, dwBufLen);
+ lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
+
+ ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
+ ME_SetSelection(editor,editor->imeStartIndex,
+ editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
+ }
+ ME_ReleaseStyle(style);
+ ME_UpdateRepaint(editor);
+ return 0;
+ }
+ case WM_IME_ENDCOMPOSITION:
+ {
+ ME_DeleteSelection(editor);
+ editor->imeStartIndex=-1;
+ return 0;
+ }
case EM_GETOLEINTERFACE:
{
LPVOID *ppvObj = (LPVOID*) lParam;
diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h
index ee5dfe3..7bb91d5 100644
--- a/dlls/riched20/editstr.h
+++ b/dlls/riched20/editstr.h
@@ -322,6 +322,8 @@ typedef struct tagME_TextEditor
BOOL AutoURLDetect_bEnable;
WCHAR cPasswordMask;
BOOL bHaveFocus;
+ /*for IME */
+ int imeStartIndex;
} ME_TextEditor;
typedef struct tagME_Context
More information about the wine-cvs
mailing list