diff options
author | michi_cc <michi_cc@openttd.org> | 2013-08-05 20:37:18 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2013-08-05 20:37:18 +0000 |
commit | cbdfd31a3c4607501d3869af87695b524b51a911 (patch) | |
tree | e866db6eb4995d11e52b41733c436240e0cea61d /src | |
parent | da09fd3077c288317aaa897b4665c30150358321 (diff) | |
download | openttd-cbdfd31a3c4607501d3869af87695b524b51a911.tar.xz |
(svn r25682) -Change: [Win32] Position the IME candidate window at the caret position.
Diffstat (limited to 'src')
-rw-r--r-- | src/video/win32_v.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index f7394ba99..a6ca85c97 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -523,6 +523,40 @@ static void SetCompositionPos(HWND hwnd) 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. */ static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam) { @@ -560,6 +594,7 @@ static void CancelIMEComposition(HWND hwnd) #else static void SetCompositionPos(HWND hwnd) {} +static void SetCandidatePos(HWND hwnd) {} static void CancelIMEComposition(HWND hwnd) {} #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: return HandleIMEComposition(hwnd, wParam, lParam); + case WM_IME_NOTIFY: + if (wParam == IMN_OPENCANDIDATE) SetCandidatePos(hwnd); + break; + #if !defined(UNICODE) case WM_IME_CHAR: if (GB(wParam, 8, 8) != 0) { @@ -1252,4 +1291,5 @@ void VideoDriver_Win32::EditBoxLostFocus() { CancelIMEComposition(_wnd.main_wnd); SetCompositionPos(_wnd.main_wnd); + SetCandidatePos(_wnd.main_wnd); } |