]> git.sesse.net Git - casparcg/blob - dependencies64/cef/windows/tests/cefclient/browser/osr_ime_handler_win.h
ed43ad20800665da15abf63a4a3b60f4188b0228
[casparcg] / dependencies64 / cef / windows / tests / cefclient / browser / osr_ime_handler_win.h
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.
4
5 #ifndef CEF_TESTS_CEFCLIENT_BROWSER_OSR_IME_HANDLER_WIN_H_
6 #define CEF_TESTS_CEFCLIENT_BROWSER_OSR_IME_HANDLER_WIN_H_
7 #pragma once
8
9 #include <windows.h>
10 #include <vector>
11
12 #include "include/internal/cef_types_wrappers.h"
13
14 namespace client {
15
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 {
19  public:
20   explicit OsrImeHandlerWin(HWND hwnd);
21   virtual ~OsrImeHandlerWin();
22
23   // Retrieves whether or not there is an ongoing composition.
24   bool is_composing() const { return is_composing_; }
25
26   // Retrieves the input language from Windows and update it.
27   void SetInputLanguage();
28
29   // Creates the IME caret windows if required.
30   void CreateImeWindow();
31
32   // Destroys the IME caret windows.
33   void DestroyImeWindow();
34
35   // Cleans up the all resources attached to the given IMM32Manager object, and
36   // reset its composition status.
37   void CleanupComposition();
38
39   // Resets the composition status and cancels the ongoing composition.
40   void ResetComposition();
41
42   // Retrieves a composition result of the ongoing composition if it exists.
43   bool GetResult(LPARAM lparam, CefString& result);
44
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);
51
52   // Enables the IME attached to the given window.
53   virtual void EnableIME();
54
55   // Disables the IME attached to the given window.
56   virtual void DisableIME();
57
58   // Cancels an ongoing composition of the IME.
59   virtual void CancelIME();
60
61   // Updates the IME caret position of the given window.
62   void UpdateCaretPosition(int index);
63
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);
69
70   // Updates the position of the IME windows.
71   void MoveImeWindow();
72
73  private:
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);
79
80   // Retrieves a string from the IMM.
81   bool GetString(HIMC imm_context, WPARAM lparam, int type, CefString& result);
82
83   // Represents whether or not there is an ongoing composition.
84   bool is_composing_;
85
86   // The current composition character range and its bounds.
87   std::vector<CefRect> composition_bounds_;
88
89   // This value represents whether or not the current input context has IMEs.
90   bool ime_status_;
91
92   // The current input Language ID retrieved from Windows -
93   // used for processing language-specific operations in IME.
94   LANGID input_language_id_;
95
96   // Represents whether or not the current input context has created a system
97   // caret to set the position of its IME candidate window.
98   bool system_caret_;
99
100   // The rectangle of the input caret retrieved from a renderer process.
101   CefRect ime_rect_;
102
103   // The current cursor index in composition string.
104   int cursor_index_;
105
106   // The composition range in the string. This may be used to determine the
107   // offset in composition bounds.
108   CefRange composition_range_;
109
110   // Hwnd associated with this instance.
111   HWND hwnd_;
112 };
113
114 }  // namespace client
115
116 #endif  // CEF_TESTS_CEFCLIENT_BROWSER_OSR_IME_HANDLER_WIN_H_