| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_VIEWS_IME_INPUT_METHOD_WIN_H_ | 5 #ifndef UI_VIEWS_IME_INPUT_METHOD_WIN_H_ |
| 6 #define UI_VIEWS_IME_INPUT_METHOD_WIN_H_ | 6 #define UI_VIEWS_IME_INPUT_METHOD_WIN_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "ui/base/win/ime_input.h" | 14 #include "ui/base/win/ime_input.h" |
| 15 #include "ui/views/ime/input_method_base.h" | 15 #include "ui/views/ime/input_method_base.h" |
| 16 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 | 18 |
| 19 namespace views { | 19 namespace views { |
| 20 | 20 |
| 21 // An InputMethod implementation based on Windows IMM32 API. | 21 // An InputMethod implementation based on Windows IMM32 API. |
| 22 class InputMethodWin : public InputMethodBase { | 22 class InputMethodWin : public InputMethodBase { |
| 23 public: | 23 public: |
| 24 explicit InputMethodWin(internal::InputMethodDelegate* delegate); | 24 InputMethodWin(internal::InputMethodDelegate* delegate, HWND hwnd); |
| 25 virtual ~InputMethodWin(); | 25 virtual ~InputMethodWin(); |
| 26 | 26 |
| 27 // Overridden from InputMethod: | 27 // Overridden from InputMethod: |
| 28 virtual void Init(Widget* widget) OVERRIDE; | 28 virtual void Init(Widget* widget) OVERRIDE; |
| 29 virtual void OnFocus() OVERRIDE; | 29 virtual void OnFocus() OVERRIDE; |
| 30 virtual void OnBlur() OVERRIDE; | 30 virtual void OnBlur() OVERRIDE; |
| 31 virtual void DispatchKeyEvent(const ui::KeyEvent& key) OVERRIDE; | 31 virtual void DispatchKeyEvent(const ui::KeyEvent& key) OVERRIDE; |
| 32 virtual void OnTextInputTypeChanged(View* view) OVERRIDE; | 32 virtual void OnTextInputTypeChanged(View* view) OVERRIDE; |
| 33 virtual void OnCaretBoundsChanged(View* view) OVERRIDE; | 33 virtual void OnCaretBoundsChanged(View* view) OVERRIDE; |
| 34 virtual void CancelComposition(View* view) OVERRIDE; | 34 virtual void CancelComposition(View* view) OVERRIDE; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 62 LRESULT OnDeadChar( | 62 LRESULT OnDeadChar( |
| 63 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled); | 63 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled); |
| 64 | 64 |
| 65 LRESULT OnDocumentFeed(RECONVERTSTRING *reconv); | 65 LRESULT OnDocumentFeed(RECONVERTSTRING *reconv); |
| 66 LRESULT OnReconvertString(RECONVERTSTRING *reconv); | 66 LRESULT OnReconvertString(RECONVERTSTRING *reconv); |
| 67 | 67 |
| 68 // Overridden from InputMethodBase. | 68 // Overridden from InputMethodBase. |
| 69 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; | 69 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; |
| 70 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; | 70 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; |
| 71 | 71 |
| 72 // A helper function to return the Widget's native window. | |
| 73 HWND hwnd() const { return widget()->GetNativeView(); } | |
| 74 | |
| 75 // Asks the client to confirm current composition text. | 72 // Asks the client to confirm current composition text. |
| 76 void ConfirmCompositionText(); | 73 void ConfirmCompositionText(); |
| 77 | 74 |
| 78 // Enables or disables the IME according to the current text input type. | 75 // Enables or disables the IME according to the current text input type. |
| 79 void UpdateIMEState(); | 76 void UpdateIMEState(); |
| 80 | 77 |
| 78 // The HWND this InputMethod is bound to. |
| 79 HWND hwnd_; |
| 80 |
| 81 // Indicates if the current input locale has an IME. | 81 // Indicates if the current input locale has an IME. |
| 82 bool active_; | 82 bool active_; |
| 83 | 83 |
| 84 // Name of the current input locale. | 84 // Name of the current input locale. |
| 85 std::string locale_; | 85 std::string locale_; |
| 86 | 86 |
| 87 // The current input text direction. | 87 // The current input text direction. |
| 88 base::i18n::TextDirection direction_; | 88 base::i18n::TextDirection direction_; |
| 89 | 89 |
| 90 // The new text direction and layout alignment requested by the user by | 90 // The new text direction and layout alignment requested by the user by |
| 91 // pressing ctrl-shift. It'll be sent to the text input client when the key | 91 // pressing ctrl-shift. It'll be sent to the text input client when the key |
| 92 // is released. | 92 // is released. |
| 93 base::i18n::TextDirection pending_requested_direction_; | 93 base::i18n::TextDirection pending_requested_direction_; |
| 94 | 94 |
| 95 // Windows IMM32 wrapper. | 95 // Windows IMM32 wrapper. |
| 96 // (See "ui/base/win/ime_input.h" for its details.) | 96 // (See "ui/base/win/ime_input.h" for its details.) |
| 97 ui::ImeInput ime_input_; | 97 ui::ImeInput ime_input_; |
| 98 | 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(InputMethodWin); | 99 DISALLOW_COPY_AND_ASSIGN(InputMethodWin); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 } // namespace views | 102 } // namespace views |
| 103 | 103 |
| 104 #endif // UI_VIEWS_IME_INPUT_METHOD_WIN_H_ | 104 #endif // UI_VIEWS_IME_INPUT_METHOD_WIN_H_ |
| OLD | NEW |