1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_BASE_IME_INPUT_METHOD_IMM32_H_ 6 #define UI_BASE_IME_INPUT_METHOD_IMM32_H_ 7 8 #include <windows.h> 9 10 #include <string> 11 12 #include "base/basictypes.h" 13 #include "base/compiler_specific.h" 14 #include "ui/base/ime/input_method_win.h" 15 16 namespace ui { 17 18 // An InputMethod implementation based on Windows IMM32 API. 19 class UI_EXPORT InputMethodIMM32 : public InputMethodWin { 20 public: 21 InputMethodIMM32(internal::InputMethodDelegate* delegate, 22 HWND toplevel_window_handle); 23 24 // Overridden from InputMethod: 25 virtual void OnFocus() OVERRIDE; 26 virtual void OnBlur() OVERRIDE; 27 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event, 28 NativeEventResult* result) OVERRIDE; 29 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE; 30 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE; 31 virtual void CancelComposition(const TextInputClient* client) OVERRIDE; 32 virtual bool IsCandidatePopupOpen() const OVERRIDE; 33 34 protected: 35 // Overridden from InputMethodBase: 36 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, 37 TextInputClient* focused) OVERRIDE; 38 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, 39 TextInputClient* focused) OVERRIDE; 40 41 private: 42 LRESULT OnImeSetContext(HWND window_handle, 43 UINT message, 44 WPARAM wparam, 45 LPARAM lparam, 46 BOOL* handled); 47 LRESULT OnImeStartComposition(HWND window_handle, 48 UINT message, 49 WPARAM wparam, 50 LPARAM lparam, 51 BOOL* handled); 52 LRESULT OnImeComposition(HWND window_handle, 53 UINT message, 54 WPARAM wparam, 55 LPARAM lparam, 56 BOOL* handled); 57 LRESULT OnImeEndComposition(HWND window_handle, 58 UINT message, 59 WPARAM wparam, 60 LPARAM lparam, 61 BOOL* handled); 62 LRESULT OnImeNotify(UINT message, 63 WPARAM wparam, 64 LPARAM lparam, 65 BOOL* handled); 66 67 // Asks the client to confirm current composition text. 68 void ConfirmCompositionText(); 69 70 // Enables or disables the IME according to the current text input type. 71 void UpdateIMEState(); 72 73 bool enabled_; 74 75 // True if we know for sure that a candidate window is open. 76 bool is_candidate_popup_open_; 77 78 // Window handle where composition is on-going. NULL when there is no 79 // composition. 80 HWND composing_window_handle_; 81 82 DISALLOW_COPY_AND_ASSIGN(InputMethodIMM32); 83 }; 84 85 } // namespace ui 86 87 #endif // UI_BASE_IME_INPUT_METHOD_IMM32_H_ 88