mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 19:33:37 +00:00
user32/edit: Delegate composition string rendering to the IME UI.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53860
This commit is contained in:
parent
40fddc6233
commit
851c57d475
|
@ -128,9 +128,8 @@ typedef struct
|
|||
/*
|
||||
* IME Data
|
||||
*/
|
||||
UINT composition_len; /* length of composition, 0 == no composition */
|
||||
int composition_start; /* the character position for the composition */
|
||||
UINT ime_status; /* IME status flag */
|
||||
UINT ime_status; /* IME status flag */
|
||||
|
||||
/*
|
||||
* Uniscribe Data
|
||||
*/
|
||||
|
@ -2149,9 +2148,6 @@ static INT EDIT_PaintText(EDITSTATE *es, HDC dc, INT x, INT y, INT line, INT col
|
|||
{
|
||||
COLORREF BkColor;
|
||||
COLORREF TextColor;
|
||||
LOGFONTW underline_font;
|
||||
HFONT hUnderline = 0;
|
||||
HFONT old_font = 0;
|
||||
INT ret;
|
||||
INT li;
|
||||
INT BkMode;
|
||||
|
@ -2163,20 +2159,9 @@ static INT EDIT_PaintText(EDITSTATE *es, HDC dc, INT x, INT y, INT line, INT col
|
|||
BkColor = GetBkColor(dc);
|
||||
TextColor = GetTextColor(dc);
|
||||
if (rev) {
|
||||
if (es->composition_len == 0)
|
||||
{
|
||||
SetBkColor(dc, GetSysColor(COLOR_HIGHLIGHT));
|
||||
SetTextColor(dc, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
||||
SetBkMode( dc, OPAQUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
HFONT current = GetCurrentObject(dc,OBJ_FONT);
|
||||
GetObjectW(current,sizeof(LOGFONTW),&underline_font);
|
||||
underline_font.lfUnderline = TRUE;
|
||||
hUnderline = CreateFontIndirectW(&underline_font);
|
||||
old_font = SelectObject(dc,hUnderline);
|
||||
}
|
||||
SetBkColor(dc, GetSysColor(COLOR_HIGHLIGHT));
|
||||
SetTextColor(dc, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
||||
SetBkMode(dc, OPAQUE);
|
||||
}
|
||||
li = EDIT_EM_LineIndex(es, line);
|
||||
if (es->style & ES_MULTILINE) {
|
||||
|
@ -2188,19 +2173,9 @@ static INT EDIT_PaintText(EDITSTATE *es, HDC dc, INT x, INT y, INT line, INT col
|
|||
ret = size.cx;
|
||||
}
|
||||
if (rev) {
|
||||
if (es->composition_len == 0)
|
||||
{
|
||||
SetBkColor(dc, BkColor);
|
||||
SetTextColor(dc, TextColor);
|
||||
SetBkMode( dc, BkMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (old_font)
|
||||
SelectObject(dc,old_font);
|
||||
if (hUnderline)
|
||||
DeleteObject(hUnderline);
|
||||
}
|
||||
SetBkColor(dc, BkColor);
|
||||
SetTextColor(dc, TextColor);
|
||||
SetBkMode(dc, BkMode);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -4362,75 +4337,6 @@ static LRESULT EDIT_EM_GetThumb(EDITSTATE *es)
|
|||
* The Following code is to handle inline editing from IMEs
|
||||
*/
|
||||
|
||||
static void EDIT_GetCompositionStr(HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
|
||||
{
|
||||
LONG buflen;
|
||||
LPWSTR lpCompStr;
|
||||
LPSTR lpCompStrAttr = NULL;
|
||||
DWORD dwBufLenAttr;
|
||||
|
||||
buflen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
|
||||
|
||||
if (buflen < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lpCompStr = HeapAlloc(GetProcessHeap(),0,buflen);
|
||||
if (!lpCompStr)
|
||||
{
|
||||
ERR("Unable to allocate IME CompositionString\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (buflen)
|
||||
ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, buflen);
|
||||
|
||||
if (CompFlag & GCS_COMPATTR)
|
||||
{
|
||||
/*
|
||||
* We do not use the attributes yet. it would tell us what characters
|
||||
* are in transition and which are converted or decided upon
|
||||
*/
|
||||
dwBufLenAttr = ImmGetCompositionStringW(hIMC, GCS_COMPATTR, NULL, 0);
|
||||
if (dwBufLenAttr)
|
||||
{
|
||||
dwBufLenAttr ++;
|
||||
lpCompStrAttr = HeapAlloc(GetProcessHeap(),0,dwBufLenAttr+1);
|
||||
if (!lpCompStrAttr)
|
||||
{
|
||||
ERR("Unable to allocate IME Attribute String\n");
|
||||
HeapFree(GetProcessHeap(),0,lpCompStr);
|
||||
return;
|
||||
}
|
||||
ImmGetCompositionStringW(hIMC,GCS_COMPATTR, lpCompStrAttr,
|
||||
dwBufLenAttr);
|
||||
lpCompStrAttr[dwBufLenAttr] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* check for change in composition start */
|
||||
if (es->selection_end < es->composition_start)
|
||||
es->composition_start = es->selection_end;
|
||||
|
||||
/* replace existing selection string */
|
||||
es->selection_start = es->composition_start;
|
||||
|
||||
if (es->composition_len > 0)
|
||||
es->selection_end = es->composition_start + es->composition_len;
|
||||
else
|
||||
es->selection_end = es->selection_start;
|
||||
|
||||
EDIT_EM_ReplaceSel(es, FALSE, lpCompStr, buflen / sizeof(WCHAR), TRUE, TRUE);
|
||||
es->composition_len = abs(es->composition_start - es->selection_end);
|
||||
|
||||
es->selection_start = es->composition_start;
|
||||
es->selection_end = es->selection_start + es->composition_len;
|
||||
|
||||
HeapFree(GetProcessHeap(),0,lpCompStrAttr);
|
||||
HeapFree(GetProcessHeap(),0,lpCompStr);
|
||||
}
|
||||
|
||||
static void EDIT_GetResultStr(HIMC hIMC, EDITSTATE *es)
|
||||
{
|
||||
LONG buflen;
|
||||
|
@ -4450,48 +4356,22 @@ static void EDIT_GetResultStr(HIMC hIMC, EDITSTATE *es)
|
|||
}
|
||||
|
||||
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpResultStr, buflen);
|
||||
|
||||
/* check for change in composition start */
|
||||
if (es->selection_end < es->composition_start)
|
||||
es->composition_start = es->selection_end;
|
||||
|
||||
es->selection_start = es->composition_start;
|
||||
es->selection_end = es->composition_start + es->composition_len;
|
||||
EDIT_EM_ReplaceSel(es, TRUE, lpResultStr, buflen / sizeof(WCHAR), TRUE, TRUE);
|
||||
es->composition_start = es->selection_end;
|
||||
es->composition_len = 0;
|
||||
|
||||
HeapFree(GetProcessHeap(),0,lpResultStr);
|
||||
}
|
||||
|
||||
static void EDIT_ImeComposition(HWND hwnd, LPARAM CompFlag, EDITSTATE *es)
|
||||
{
|
||||
HIMC hIMC;
|
||||
int cursor;
|
||||
|
||||
if (es->composition_len == 0 && es->selection_start != es->selection_end)
|
||||
{
|
||||
EDIT_EM_ReplaceSel(es, TRUE, NULL, 0, TRUE, TRUE);
|
||||
es->composition_start = es->selection_end;
|
||||
}
|
||||
|
||||
hIMC = ImmGetContext(hwnd);
|
||||
if (!hIMC)
|
||||
return;
|
||||
|
||||
if (CompFlag & GCS_RESULTSTR)
|
||||
{
|
||||
EDIT_GetResultStr(hIMC, es);
|
||||
cursor = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CompFlag & GCS_COMPSTR)
|
||||
EDIT_GetCompositionStr(hIMC, CompFlag, es);
|
||||
cursor = ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, 0, 0);
|
||||
}
|
||||
|
||||
ImmReleaseContext(hwnd, hIMC);
|
||||
EDIT_SetCaretPos(es, es->selection_start + cursor, es->flags & EF_AFTER_WRAP);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5230,32 +5110,11 @@ LRESULT EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, B
|
|||
EDIT_UpdateImmCompositionFont(es);
|
||||
break;
|
||||
|
||||
case WM_IME_STARTCOMPOSITION:
|
||||
es->composition_start = es->selection_end;
|
||||
es->composition_len = 0;
|
||||
break;
|
||||
|
||||
case WM_IME_COMPOSITION:
|
||||
if (lParam & GCS_RESULTSTR && !(es->ime_status & EIMES_GETCOMPSTRATONCE))
|
||||
{
|
||||
DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
|
||||
break;
|
||||
}
|
||||
|
||||
EDIT_ImeComposition(hwnd, lParam, es);
|
||||
break;
|
||||
|
||||
case WM_IME_ENDCOMPOSITION:
|
||||
if (es->composition_len > 0)
|
||||
{
|
||||
EDIT_EM_ReplaceSel(es, TRUE, NULL, 0, TRUE, TRUE);
|
||||
es->selection_end = es->selection_start;
|
||||
es->composition_len= 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_IME_COMPOSITIONFULL:
|
||||
break;
|
||||
EDIT_EM_ReplaceSel(es, TRUE, NULL, 0, TRUE, TRUE);
|
||||
if ((lParam & GCS_RESULTSTR) && (es->ime_status & EIMES_GETCOMPSTRATONCE))
|
||||
EDIT_ImeComposition(hwnd, lParam, es);
|
||||
return DefWindowProcW(hwnd, msg, wParam, lParam);
|
||||
|
||||
case WM_IME_SELECT:
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue