OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_BASE_IME_WIN_IMM32_MANAGER_H | 5 #ifndef UI_BASE_IME_WIN_IMM32_MANAGER_H |
6 #define UI_BASE_IME_WIN_IMM32_MANAGER_H | 6 #define UI_BASE_IME_WIN_IMM32_MANAGER_H |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 // only for inputting East-Asian language texts, but also the ones from | 70 // only for inputting East-Asian language texts, but also the ones from |
71 // tablets (on Windows XP Tablet PC Edition and Windows Vista), voice | 71 // tablets (on Windows XP Tablet PC Edition and Windows Vista), voice |
72 // recognizers (e.g. ViaVoice and Microsoft Office), etc. | 72 // recognizers (e.g. ViaVoice and Microsoft Office), etc. |
73 // We can disable TSF and CUAS in Windows XP Tablet PC Edition. On the other | 73 // We can disable TSF and CUAS in Windows XP Tablet PC Edition. On the other |
74 // hand, we can NEVER disable either TSF or CUAS in Windows Vista, i.e. | 74 // hand, we can NEVER disable either TSF or CUAS in Windows Vista, i.e. |
75 // THIS CLASS IS NOT ONLY USED ON THE INPUT CONTEXTS OF EAST-ASIAN | 75 // THIS CLASS IS NOT ONLY USED ON THE INPUT CONTEXTS OF EAST-ASIAN |
76 // LANGUAGES BUT ALSO USED ON THE INPUT CONTEXTS OF ALL LANGUAGES. | 76 // LANGUAGES BUT ALSO USED ON THE INPUT CONTEXTS OF ALL LANGUAGES. |
77 class UI_EXPORT IMM32Manager { | 77 class UI_EXPORT IMM32Manager { |
78 public: | 78 public: |
79 IMM32Manager(); | 79 IMM32Manager(); |
80 ~IMM32Manager(); | 80 virtual ~IMM32Manager(); |
81 | 81 |
82 // Retrieves whether or not there is an ongoing composition. | 82 // Retrieves whether or not there is an ongoing composition. |
83 bool is_composing() const { return is_composing_; } | 83 virtual bool is_composing() const { return is_composing_; } |
jochen (gone - plz use gerrit)
2013/08/07 02:25:23
i think it's enough to make the methods virtual wh
yoichio
2013/08/07 03:33:55
Done.
| |
84 | 84 |
85 // Retrieves the input language from Windows and update it. | 85 // Retrieves the input language from Windows and update it. |
86 // Return values | 86 // Return values |
87 // * true | 87 // * true |
88 // The given input language has IMEs. | 88 // The given input language has IMEs. |
89 // * false | 89 // * false |
90 // The given input language does not have IMEs. | 90 // The given input language does not have IMEs. |
91 bool SetInputLanguage(); | 91 virtual bool SetInputLanguage(); |
92 | 92 |
93 // Creates the IME windows, and allocate required resources for them. | 93 // Creates the IME windows, and allocate required resources for them. |
94 // Parameters | 94 // Parameters |
95 // * window_handle [in] (HWND) | 95 // * window_handle [in] (HWND) |
96 // Represents the window handle of the caller. | 96 // Represents the window handle of the caller. |
97 void CreateImeWindow(HWND window_handle); | 97 virtual void CreateImeWindow(HWND window_handle); |
98 | 98 |
99 // Updates the style of the IME windows. | 99 // Updates the style of the IME windows. |
100 // Parameters | 100 // Parameters |
101 // * window_handle [in] (HWND) | 101 // * window_handle [in] (HWND) |
102 // Represents the window handle of the caller. | 102 // Represents the window handle of the caller. |
103 // * message [in] (UINT) | 103 // * message [in] (UINT) |
104 // * wparam [in] (WPARAM) | 104 // * wparam [in] (WPARAM) |
105 // * lparam [in] (LPARAM) | 105 // * lparam [in] (LPARAM) |
106 // Represent the windows message of the caller. | 106 // Represent the windows message of the caller. |
107 // These parameters are used for verifying if this function is called | 107 // These parameters are used for verifying if this function is called |
108 // in a handler function for WM_IME_SETCONTEXT messages because this | 108 // in a handler function for WM_IME_SETCONTEXT messages because this |
109 // function uses ::DefWindowProc() to update the style. | 109 // function uses ::DefWindowProc() to update the style. |
110 // A caller just has to pass the input parameters for the handler | 110 // A caller just has to pass the input parameters for the handler |
111 // function without modifications. | 111 // function without modifications. |
112 // * handled [out] (BOOL*) | 112 // * handled [out] (BOOL*) |
113 // Returns ::DefWindowProc() is really called in this function. | 113 // Returns ::DefWindowProc() is really called in this function. |
114 // PLEASE DO NOT CALL ::DefWindowProc() IF THIS VALUE IS TRUE! | 114 // PLEASE DO NOT CALL ::DefWindowProc() IF THIS VALUE IS TRUE! |
115 // All the window styles set in this function are over-written when | 115 // All the window styles set in this function are over-written when |
116 // calling ::DefWindowProc() after returning this function. | 116 // calling ::DefWindowProc() after returning this function. |
117 // Returns the value returned by DefWindowProc. | 117 // Returns the value returned by DefWindowProc. |
118 LRESULT SetImeWindowStyle(HWND window_handle, UINT message, | 118 virtual LRESULT SetImeWindowStyle(HWND window_handle, UINT message, |
119 WPARAM wparam, LPARAM lparam, BOOL* handled); | 119 WPARAM wparam, LPARAM lparam, |
120 BOOL* handled); | |
120 | 121 |
121 // Destroys the IME windows and all the resources attached to them. | 122 // Destroys the IME windows and all the resources attached to them. |
122 // Parameters | 123 // Parameters |
123 // * window_handle [in] (HWND) | 124 // * window_handle [in] (HWND) |
124 // Represents the window handle of the caller. | 125 // Represents the window handle of the caller. |
125 void DestroyImeWindow(HWND window_handle); | 126 virtual void DestroyImeWindow(HWND window_handle); |
126 | 127 |
127 // Updates the position of the IME windows. | 128 // Updates the position of the IME windows. |
128 // Parameters | 129 // Parameters |
129 // * window_handle [in] (HWND) | 130 // * window_handle [in] (HWND) |
130 // Represents the window handle of the caller. | 131 // Represents the window handle of the caller. |
131 void UpdateImeWindow(HWND window_handle); | 132 virtual void UpdateImeWindow(HWND window_handle); |
132 | 133 |
133 // Cleans up the all resources attached to the given IMM32Manager object, and | 134 // Cleans up the all resources attached to the given IMM32Manager object, and |
134 // reset its composition status. | 135 // reset its composition status. |
135 // Parameters | 136 // Parameters |
136 // * window_handle [in] (HWND) | 137 // * window_handle [in] (HWND) |
137 // Represents the window handle of the caller. | 138 // Represents the window handle of the caller. |
138 void CleanupComposition(HWND window_handle); | 139 virtual void CleanupComposition(HWND window_handle); |
139 | 140 |
140 // Resets the composition status. | 141 // Resets the composition status. |
141 // Cancel the ongoing composition if it exists. | 142 // Cancel the ongoing composition if it exists. |
142 // NOTE(hbono): This method does not release the allocated resources. | 143 // NOTE(hbono): This method does not release the allocated resources. |
143 // Parameters | 144 // Parameters |
144 // * window_handle [in] (HWND) | 145 // * window_handle [in] (HWND) |
145 // Represents the window handle of the caller. | 146 // Represents the window handle of the caller. |
146 void ResetComposition(HWND window_handle); | 147 virtual void ResetComposition(HWND window_handle); |
147 | 148 |
148 // Retrieves a composition result of the ongoing composition if it exists. | 149 // Retrieves a composition result of the ongoing composition if it exists. |
149 // Parameters | 150 // Parameters |
150 // * window_handle [in] (HWND) | 151 // * window_handle [in] (HWND) |
151 // Represents the window handle of the caller. | 152 // Represents the window handle of the caller. |
152 // * lparam [in] (LPARAM) | 153 // * lparam [in] (LPARAM) |
153 // Specifies the updated members of the ongoing composition, and must be | 154 // Specifies the updated members of the ongoing composition, and must be |
154 // the same parameter of a WM_IME_COMPOSITION message handler. | 155 // the same parameter of a WM_IME_COMPOSITION message handler. |
155 // This parameter is used for checking if the ongoing composition has | 156 // This parameter is used for checking if the ongoing composition has |
156 // its result string, | 157 // its result string, |
157 // * result [out] (string16) | 158 // * result [out] (string16) |
158 // Represents the object contains the composition result. | 159 // Represents the object contains the composition result. |
159 // Return values | 160 // Return values |
160 // * true | 161 // * true |
161 // The ongoing composition has a composition result. | 162 // The ongoing composition has a composition result. |
162 // * false | 163 // * false |
163 // The ongoing composition does not have composition results. | 164 // The ongoing composition does not have composition results. |
164 // Remarks | 165 // Remarks |
165 // This function is designed for being called from WM_IME_COMPOSITION | 166 // This function is designed for being called from WM_IME_COMPOSITION |
166 // message handlers. | 167 // message handlers. |
167 bool GetResult(HWND window_handle, LPARAM lparam, string16* result); | 168 virtual bool GetResult(HWND window_handle, LPARAM lparam, string16* result); |
168 | 169 |
169 // Retrieves the current composition status of the ongoing composition. | 170 // Retrieves the current composition status of the ongoing composition. |
170 // Parameters | 171 // Parameters |
171 // * window_handle [in] (HWND) | 172 // * window_handle [in] (HWND) |
172 // Represents the window handle of the caller. | 173 // Represents the window handle of the caller. |
173 // * lparam [in] (LPARAM) | 174 // * lparam [in] (LPARAM) |
174 // Specifies the updated members of the ongoing composition, and must be | 175 // Specifies the updated members of the ongoing composition, and must be |
175 // the same parameter of a WM_IME_COMPOSITION message handler. | 176 // the same parameter of a WM_IME_COMPOSITION message handler. |
176 // This parameter is used for checking if the ongoing composition has | 177 // This parameter is used for checking if the ongoing composition has |
177 // its result string, | 178 // its result string, |
178 // * composition [out] (Composition) | 179 // * composition [out] (Composition) |
179 // Represents the struct contains the composition status. | 180 // Represents the struct contains the composition status. |
180 // Return values | 181 // Return values |
181 // * true | 182 // * true |
182 // The status of the ongoing composition is updated. | 183 // The status of the ongoing composition is updated. |
183 // * false | 184 // * false |
184 // The status of the ongoing composition is not updated. | 185 // The status of the ongoing composition is not updated. |
185 // Remarks | 186 // Remarks |
186 // This function is designed for being called from WM_IME_COMPOSITION | 187 // This function is designed for being called from WM_IME_COMPOSITION |
187 // message handlers. | 188 // message handlers. |
188 bool GetComposition(HWND window_handle, LPARAM lparam, | 189 virtual bool GetComposition(HWND window_handle, LPARAM lparam, |
189 CompositionText* composition); | 190 CompositionText* composition); |
190 | 191 |
191 // Enables the IME attached to the given window, i.e. allows user-input | 192 // Enables the IME attached to the given window, i.e. allows user-input |
192 // events to be dispatched to the IME. | 193 // events to be dispatched to the IME. |
193 // Parameters | 194 // Parameters |
194 // * window_handle [in] (HWND) | 195 // * window_handle [in] (HWND) |
195 // Represents the window handle of the caller. | 196 // Represents the window handle of the caller. |
196 // * complete [in] (bool) | 197 // * complete [in] (bool) |
197 // Represents whether or not to complete the ongoing composition. | 198 // Represents whether or not to complete the ongoing composition. |
198 // + true | 199 // + true |
199 // After finishing the ongoing composition and close its IME windows, | 200 // After finishing the ongoing composition and close its IME windows, |
200 // start another composition and display its IME windows to the given | 201 // start another composition and display its IME windows to the given |
201 // position. | 202 // position. |
202 // + false | 203 // + false |
203 // Just move the IME windows of the ongoing composition to the given | 204 // Just move the IME windows of the ongoing composition to the given |
204 // position without finishing it. | 205 // position without finishing it. |
205 void EnableIME(HWND window_handle); | 206 virtual void EnableIME(HWND window_handle); |
206 | 207 |
207 // Disables the IME attached to the given window, i.e. prohibits any | 208 // Disables the IME attached to the given window, i.e. prohibits any |
208 // user-input events from being dispatched to the IME. | 209 // user-input events from being dispatched to the IME. |
209 // In Chrome, this function is used when: | 210 // In Chrome, this function is used when: |
210 // * a renreder process sets its input focus to a password input. | 211 // * a renreder process sets its input focus to a password input. |
211 // Parameters | 212 // Parameters |
212 // * window_handle [in] (HWND) | 213 // * window_handle [in] (HWND) |
213 // Represents the window handle of the caller. | 214 // Represents the window handle of the caller. |
214 void DisableIME(HWND window_handle); | 215 virtual void DisableIME(HWND window_handle); |
215 | 216 |
216 // Cancels an ongoing composition of the IME attached to the given window. | 217 // Cancels an ongoing composition of the IME attached to the given window. |
217 // Parameters | 218 // Parameters |
218 // * window_handle [in] (HWND) | 219 // * window_handle [in] (HWND) |
219 // Represents the window handle of the caller. | 220 // Represents the window handle of the caller. |
220 void CancelIME(HWND window_handle); | 221 virtual void CancelIME(HWND window_handle); |
221 | 222 |
222 // Updates the caret position of the given window. | 223 // Updates the caret position of the given window. |
223 // Parameters | 224 // Parameters |
224 // * window_handle [in] (HWND) | 225 // * window_handle [in] (HWND) |
225 // Represents the window handle of the caller. | 226 // Represents the window handle of the caller. |
226 // * caret_rect [in] (const gfx::Rect&) | 227 // * caret_rect [in] (const gfx::Rect&) |
227 // Represent the rectangle of the input caret. | 228 // Represent the rectangle of the input caret. |
228 // This rectangle is used for controlling the positions of IME windows. | 229 // This rectangle is used for controlling the positions of IME windows. |
229 void UpdateCaretRect(HWND window_handle, const gfx::Rect& caret_rect); | 230 virtual void UpdateCaretRect(HWND window_handle, const gfx::Rect& caret_rect); |
230 | 231 |
231 // Updates the setting whether we want IME to render composition text. | 232 // Updates the setting whether we want IME to render composition text. |
232 void SetUseCompositionWindow(bool use_composition_window); | 233 virtual void SetUseCompositionWindow(bool use_composition_window); |
233 | 234 |
234 // Returns the current input language id. | 235 // Returns the current input language id. |
235 LANGID input_language_id() const { return input_language_id_; } | 236 virtual LANGID input_language_id() const { return input_language_id_; } |
236 | 237 |
237 // Returns BCP-47 tag name of the current input language. | 238 // Returns BCP-47 tag name of the current input language. |
238 std::string GetInputLanguageName() const; | 239 virtual std::string GetInputLanguageName() const; |
239 | 240 |
240 // Returns the text direction of the current input language. | 241 // Returns the text direction of the current input language. |
241 base::i18n::TextDirection GetTextDirection() const; | 242 virtual base::i18n::TextDirection GetTextDirection() const; |
242 | 243 |
243 // Sets conversion status corresponding to |input_mode|. | 244 // Sets conversion status corresponding to |input_mode|. |
244 void SetTextInputMode(HWND window_handle, TextInputMode input_mode); | 245 virtual void SetTextInputMode(HWND window_handle, TextInputMode input_mode); |
245 | 246 |
246 // Helper functions ---------------------------------------------------------- | 247 // Helper functions ---------------------------------------------------------- |
247 | 248 |
248 // Checks if there is any RTL keyboard layout installed in the system. | 249 // Checks if there is any RTL keyboard layout installed in the system. |
249 static bool IsRTLKeyboardLayoutInstalled(); | 250 static bool IsRTLKeyboardLayoutInstalled(); |
250 | 251 |
251 // Checks if the user pressed both Ctrl and right or left Shift keys to | 252 // Checks if the user pressed both Ctrl and right or left Shift keys to |
252 // requrest to change the text direction and layout alignment explicitly. | 253 // requrest to change the text direction and layout alignment explicitly. |
253 // Returns true if only a Ctrl key and a Shift key are down. The desired text | 254 // Returns true if only a Ctrl key and a Shift key are down. The desired text |
254 // direction will be stored in |*direction|. | 255 // direction will be stored in |*direction|. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 | 322 |
322 // Indicates whether or not we want IME to render composition text. | 323 // Indicates whether or not we want IME to render composition text. |
323 bool use_composition_window_; | 324 bool use_composition_window_; |
324 | 325 |
325 DISALLOW_COPY_AND_ASSIGN(IMM32Manager); | 326 DISALLOW_COPY_AND_ASSIGN(IMM32Manager); |
326 }; | 327 }; |
327 | 328 |
328 } // namespace ui | 329 } // namespace ui |
329 | 330 |
330 #endif // UI_BASE_IME_WIN_IMM32_MANAGER_H | 331 #endif // UI_BASE_IME_WIN_IMM32_MANAGER_H |
OLD | NEW |