1 // Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
2 // 2013 The Chromium Authors. All rights reserved. Use of this source code is
3 // governed by a BSD-style license that can be found in the LICENSE file.
5 #ifndef CEF_TESTS_CEFCLIENT_BROWSER_OSR_IME_HANDLER_WIN_H_
6 #define CEF_TESTS_CEFCLIENT_BROWSER_OSR_IME_HANDLER_WIN_H_
12 #include "include/internal/cef_types_wrappers.h"
16 // Handles IME for the native parent window that hosts an off-screen browser.
17 // This object is only accessed on the CEF UI thread.
18 class OsrImeHandlerWin {
20 explicit OsrImeHandlerWin(HWND hwnd);
21 virtual ~OsrImeHandlerWin();
23 // Retrieves whether or not there is an ongoing composition.
24 bool is_composing() const { return is_composing_; }
26 // Retrieves the input language from Windows and update it.
27 void SetInputLanguage();
29 // Creates the IME caret windows if required.
30 void CreateImeWindow();
32 // Destroys the IME caret windows.
33 void DestroyImeWindow();
35 // Cleans up the all resources attached to the given IMM32Manager object, and
36 // reset its composition status.
37 void CleanupComposition();
39 // Resets the composition status and cancels the ongoing composition.
40 void ResetComposition();
42 // Retrieves a composition result of the ongoing composition if it exists.
43 bool GetResult(LPARAM lparam, CefString& result);
45 // Retrieves the current composition status of the ongoing composition.
46 // Includes composition text, underline information and selection range in the
47 // composition text. IMM32 does not support char selection.
48 bool GetComposition(LPARAM lparam, CefString &composition_text,
49 std::vector<CefCompositionUnderline> &underlines,
50 int& composition_start);
52 // Enables the IME attached to the given window.
53 virtual void EnableIME();
55 // Disables the IME attached to the given window.
56 virtual void DisableIME();
58 // Cancels an ongoing composition of the IME.
59 virtual void CancelIME();
61 // Updates the IME caret position of the given window.
62 void UpdateCaretPosition(int index);
64 // Updates the composition range. |selected_range| is the range of characters
65 // that have been selected. |character_bounds| is the bounds of each character
66 // in view device coordinates.
67 void ChangeCompositionRange(const CefRange& selection_range,
68 const std::vector<CefRect>& character_bounds);
70 // Updates the position of the IME windows.
74 // Retrieves the composition information.
75 void GetCompositionInfo(HIMC imm_context, LPARAM lparam,
76 CefString &composition_text,
77 std::vector<CefCompositionUnderline>& underlines,
78 int& composition_start);
80 // Retrieves a string from the IMM.
81 bool GetString(HIMC imm_context, WPARAM lparam, int type, CefString& result);
83 // Represents whether or not there is an ongoing composition.
86 // The current composition character range and its bounds.
87 std::vector<CefRect> composition_bounds_;
89 // This value represents whether or not the current input context has IMEs.
92 // The current input Language ID retrieved from Windows -
93 // used for processing language-specific operations in IME.
94 LANGID input_language_id_;
96 // Represents whether or not the current input context has created a system
97 // caret to set the position of its IME candidate window.
100 // The rectangle of the input caret retrieved from a renderer process.
103 // The current cursor index in composition string.
106 // The composition range in the string. This may be used to determine the
107 // offset in composition bounds.
108 CefRange composition_range_;
110 // Hwnd associated with this instance.
114 } // namespace client
116 #endif // CEF_TESTS_CEFCLIENT_BROWSER_OSR_IME_HANDLER_WIN_H_