| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 VIEWS_IME_INPUT_METHOD_WIN_H_ | |
| 6 #define VIEWS_IME_INPUT_METHOD_WIN_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <windows.h> | |
| 10 | |
| 11 #include <string> | |
| 12 | |
| 13 #include "base/basictypes.h" | |
| 14 #include "base/compiler_specific.h" | |
| 15 #include "ui/base/win/ime_input.h" | |
| 16 #include "views/ime/input_method_base.h" | |
| 17 #include "views/view.h" | |
| 18 #include "views/widget/widget.h" | |
| 19 | |
| 20 namespace views { | |
| 21 | |
| 22 // An InputMethod implementation based on Windows IMM32 API. | |
| 23 class InputMethodWin : public InputMethodBase { | |
| 24 public: | |
| 25 explicit InputMethodWin(internal::InputMethodDelegate* delegate); | |
| 26 virtual ~InputMethodWin(); | |
| 27 | |
| 28 // Overridden from InputMethod: | |
| 29 virtual void Init(Widget* widget) OVERRIDE; | |
| 30 virtual void OnFocus() OVERRIDE; | |
| 31 virtual void OnBlur() OVERRIDE; | |
| 32 virtual void DispatchKeyEvent(const KeyEvent& key) OVERRIDE; | |
| 33 virtual void OnTextInputTypeChanged(View* view) OVERRIDE; | |
| 34 virtual void OnCaretBoundsChanged(View* view) OVERRIDE; | |
| 35 virtual void CancelComposition(View* view) OVERRIDE; | |
| 36 virtual std::string GetInputLocale() OVERRIDE; | |
| 37 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; | |
| 38 virtual bool IsActive() OVERRIDE; | |
| 39 | |
| 40 // Handles IME messages. | |
| 41 LRESULT OnImeMessages(UINT message, WPARAM wparam, LPARAM lparam, | |
| 42 BOOL* handled); | |
| 43 | |
| 44 // Message handlers. The native widget is responsible for forwarding following | |
| 45 // messages to the input method. | |
| 46 void OnInputLangChange(DWORD character_set, HKL input_language_id); | |
| 47 | |
| 48 private: | |
| 49 LRESULT OnImeSetContext( | |
| 50 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled); | |
| 51 LRESULT OnImeStartComposition( | |
| 52 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled); | |
| 53 LRESULT OnImeComposition( | |
| 54 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled); | |
| 55 LRESULT OnImeEndComposition( | |
| 56 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled); | |
| 57 LRESULT OnImeRequest( | |
| 58 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled); | |
| 59 // For both WM_CHAR and WM_SYSCHAR | |
| 60 LRESULT OnChar( | |
| 61 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled); | |
| 62 // For both WM_DEADCHAR and WM_SYSDEADCHAR | |
| 63 LRESULT OnDeadChar( | |
| 64 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled); | |
| 65 | |
| 66 LRESULT OnDocumentFeed(RECONVERTSTRING *reconv); | |
| 67 LRESULT OnReconvertString(RECONVERTSTRING *reconv); | |
| 68 | |
| 69 // Overridden from InputMethodBase. | |
| 70 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; | |
| 71 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; | |
| 72 | |
| 73 // A helper function to return the Widget's native window. | |
| 74 HWND hwnd() const { return widget()->GetNativeView(); } | |
| 75 | |
| 76 // Asks the client to confirm current composition text. | |
| 77 void ConfirmCompositionText(); | |
| 78 | |
| 79 // Enables or disables the IME according to the current text input type. | |
| 80 void UpdateIMEState(); | |
| 81 | |
| 82 // Indicates if the current input locale has an IME. | |
| 83 bool active_; | |
| 84 | |
| 85 // Name of the current input locale. | |
| 86 std::string locale_; | |
| 87 | |
| 88 // The current input text direction. | |
| 89 base::i18n::TextDirection direction_; | |
| 90 | |
| 91 // The new text direction and layout alignment requested by the user by | |
| 92 // pressing ctrl-shift. It'll be sent to the text input client when the key | |
| 93 // is released. | |
| 94 base::i18n::TextDirection pending_requested_direction_; | |
| 95 | |
| 96 // Windows IMM32 wrapper. | |
| 97 // (See "ui/base/win/ime_input.h" for its details.) | |
| 98 ui::ImeInput ime_input_; | |
| 99 | |
| 100 DISALLOW_COPY_AND_ASSIGN(InputMethodWin); | |
| 101 }; | |
| 102 | |
| 103 } // namespace views | |
| 104 | |
| 105 #endif // VIEWS_IME_INPUT_METHOD_WIN_H_ | |
| OLD | NEW |