mirror of https://github.com/OpenTTD/OpenTTD
(svn r25682) -Change: [Win32] Position the IME candidate window at the caret position.
parent
da09fd3077
commit
cbdfd31a3c
|
@ -523,6 +523,40 @@ static void SetCompositionPos(HWND hwnd)
|
||||||
ImmReleaseContext(hwnd, hIMC);
|
ImmReleaseContext(hwnd, hIMC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set the position of the candidate window. */
|
||||||
|
static void SetCandidatePos(HWND hwnd)
|
||||||
|
{
|
||||||
|
HIMC hIMC = ImmGetContext(hwnd);
|
||||||
|
if (hIMC != NULL) {
|
||||||
|
CANDIDATEFORM cf;
|
||||||
|
cf.dwIndex = 0;
|
||||||
|
cf.dwStyle = CFS_EXCLUDE;
|
||||||
|
|
||||||
|
if (EditBoxInGlobalFocus()) {
|
||||||
|
Point pt = _focused_window->GetCaretPosition();
|
||||||
|
cf.ptCurrentPos.x = _focused_window->left + pt.x;
|
||||||
|
cf.ptCurrentPos.y = _focused_window->top + pt.y;
|
||||||
|
if (_focused_window->window_class == WC_CONSOLE) {
|
||||||
|
cf.rcArea.left = _focused_window->left;
|
||||||
|
cf.rcArea.top = _focused_window->top;
|
||||||
|
cf.rcArea.right = _focused_window->left + _focused_window->width;
|
||||||
|
cf.rcArea.bottom = _focused_window->top + _focused_window->height;
|
||||||
|
} else {
|
||||||
|
cf.rcArea.left = _focused_window->left + _focused_window->nested_focus->pos_x;
|
||||||
|
cf.rcArea.top = _focused_window->top + _focused_window->nested_focus->pos_y;
|
||||||
|
cf.rcArea.right = cf.rcArea.left + _focused_window->nested_focus->current_x;
|
||||||
|
cf.rcArea.bottom = cf.rcArea.top + _focused_window->nested_focus->current_y;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cf.ptCurrentPos.x = 0;
|
||||||
|
cf.ptCurrentPos.y = 0;
|
||||||
|
SetRectEmpty(&cf.rcArea);
|
||||||
|
}
|
||||||
|
ImmSetCandidateWindow(hIMC, &cf);
|
||||||
|
}
|
||||||
|
ImmReleaseContext(hwnd, hIMC);
|
||||||
|
}
|
||||||
|
|
||||||
/** Handle WM_IME_COMPOSITION messages. */
|
/** Handle WM_IME_COMPOSITION messages. */
|
||||||
static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -560,6 +594,7 @@ static void CancelIMEComposition(HWND hwnd)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static void SetCompositionPos(HWND hwnd) {}
|
static void SetCompositionPos(HWND hwnd) {}
|
||||||
|
static void SetCandidatePos(HWND hwnd) {}
|
||||||
static void CancelIMEComposition(HWND hwnd) {}
|
static void CancelIMEComposition(HWND hwnd) {}
|
||||||
|
|
||||||
#endif /* !defined(WINCE) || _WIN32_WCE >= 0x400 */
|
#endif /* !defined(WINCE) || _WIN32_WCE >= 0x400 */
|
||||||
|
@ -707,6 +742,10 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
case WM_IME_COMPOSITION:
|
case WM_IME_COMPOSITION:
|
||||||
return HandleIMEComposition(hwnd, wParam, lParam);
|
return HandleIMEComposition(hwnd, wParam, lParam);
|
||||||
|
|
||||||
|
case WM_IME_NOTIFY:
|
||||||
|
if (wParam == IMN_OPENCANDIDATE) SetCandidatePos(hwnd);
|
||||||
|
break;
|
||||||
|
|
||||||
#if !defined(UNICODE)
|
#if !defined(UNICODE)
|
||||||
case WM_IME_CHAR:
|
case WM_IME_CHAR:
|
||||||
if (GB(wParam, 8, 8) != 0) {
|
if (GB(wParam, 8, 8) != 0) {
|
||||||
|
@ -1252,4 +1291,5 @@ void VideoDriver_Win32::EditBoxLostFocus()
|
||||||
{
|
{
|
||||||
CancelIMEComposition(_wnd.main_wnd);
|
CancelIMEComposition(_wnd.main_wnd);
|
||||||
SetCompositionPos(_wnd.main_wnd);
|
SetCompositionPos(_wnd.main_wnd);
|
||||||
|
SetCandidatePos(_wnd.main_wnd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue