| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BRIDGE_H_ | 5 #ifndef UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ |
| 6 #define UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ | 6 #define UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "ui/base/ime/text_input_client.h" | |
| 13 #include "ui/gfx/rect.h" | |
| 14 #include "ui/views/ime/input_method_base.h" | 12 #include "ui/views/ime/input_method_base.h" |
| 15 | 13 |
| 16 namespace ui { | 14 namespace ui { |
| 17 class InputMethod; | 15 class InputMethod; |
| 18 } // namespace ui | 16 } // namespace ui |
| 19 | 17 |
| 20 namespace views { | 18 namespace views { |
| 21 | 19 |
| 22 class View; | |
| 23 | |
| 24 // A "bridge" InputMethod implementation for views top-level widgets, which just | 20 // A "bridge" InputMethod implementation for views top-level widgets, which just |
| 25 // sends/receives IME related events to/from a system-wide ui::InputMethod | 21 // sends/receives IME related events to/from a system-wide ui::InputMethod |
| 26 // object. | 22 // object. |
| 27 class InputMethodBridge : public InputMethodBase, | 23 class InputMethodBridge : public InputMethodBase { |
| 28 public ui::TextInputClient { | |
| 29 public: | 24 public: |
| 30 // |shared_input_method| indicates if |host| is shared among other top level | 25 // |shared_input_method| indicates if |host| is shared among other top level |
| 31 // widgets. | 26 // widgets. |
| 32 InputMethodBridge(internal::InputMethodDelegate* delegate, | 27 InputMethodBridge(internal::InputMethodDelegate* delegate, |
| 33 ui::InputMethod* host, | 28 ui::InputMethod* host, |
| 34 bool shared_input_method); | 29 bool shared_input_method); |
| 35 virtual ~InputMethodBridge(); | 30 virtual ~InputMethodBridge(); |
| 36 | 31 |
| 37 // Overridden from InputMethod: | 32 // Overridden from InputMethod: |
| 38 virtual void OnFocus() OVERRIDE; | |
| 39 virtual void OnBlur() OVERRIDE; | |
| 40 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event, | 33 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event, |
| 41 NativeEventResult* result) OVERRIDE; | 34 NativeEventResult* result) OVERRIDE; |
| 42 virtual void DispatchKeyEvent(const ui::KeyEvent& key) OVERRIDE; | 35 virtual void DispatchKeyEvent(const ui::KeyEvent& key) OVERRIDE; |
| 43 virtual void OnTextInputTypeChanged(View* view) OVERRIDE; | 36 virtual void OnTextInputTypeChanged(View* view) OVERRIDE; |
| 44 virtual void OnCaretBoundsChanged(View* view) OVERRIDE; | 37 virtual void OnCaretBoundsChanged(View* view) OVERRIDE; |
| 45 virtual void CancelComposition(View* view) OVERRIDE; | 38 virtual void CancelComposition(View* view) OVERRIDE; |
| 46 virtual void OnInputLocaleChanged() OVERRIDE; | 39 virtual void OnInputLocaleChanged() OVERRIDE; |
| 47 virtual std::string GetInputLocale() OVERRIDE; | 40 virtual std::string GetInputLocale() OVERRIDE; |
| 48 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; | 41 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; |
| 49 virtual bool IsActive() OVERRIDE; | 42 virtual bool IsActive() OVERRIDE; |
| 50 virtual bool IsCandidatePopupOpen() const OVERRIDE; | 43 virtual bool IsCandidatePopupOpen() const OVERRIDE; |
| 51 | 44 |
| 52 // Overridden from TextInputClient: | |
| 53 virtual void SetCompositionText( | |
| 54 const ui::CompositionText& composition) OVERRIDE; | |
| 55 virtual void ConfirmCompositionText() OVERRIDE; | |
| 56 virtual void ClearCompositionText() OVERRIDE; | |
| 57 virtual void InsertText(const string16& text) OVERRIDE; | |
| 58 virtual void InsertChar(char16 ch, int flags) OVERRIDE; | |
| 59 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE; | |
| 60 virtual ui::TextInputType GetTextInputType() const OVERRIDE; | |
| 61 virtual ui::TextInputMode GetTextInputMode() const OVERRIDE; | |
| 62 virtual bool CanComposeInline() const OVERRIDE; | |
| 63 virtual gfx::Rect GetCaretBounds() OVERRIDE; | |
| 64 virtual bool GetCompositionCharacterBounds(uint32 index, | |
| 65 gfx::Rect* rect) OVERRIDE; | |
| 66 virtual bool HasCompositionText() OVERRIDE; | |
| 67 virtual bool GetTextRange(ui::Range* range) OVERRIDE; | |
| 68 virtual bool GetCompositionTextRange(ui::Range* range) OVERRIDE; | |
| 69 virtual bool GetSelectionRange(ui::Range* range) OVERRIDE; | |
| 70 virtual bool SetSelectionRange(const ui::Range& range) OVERRIDE; | |
| 71 virtual bool DeleteRange(const ui::Range& range) OVERRIDE; | |
| 72 virtual bool GetTextFromRange( | |
| 73 const ui::Range& range, string16* text) OVERRIDE; | |
| 74 virtual void OnInputMethodChanged() OVERRIDE; | |
| 75 virtual bool ChangeTextDirectionAndLayoutAlignment( | |
| 76 base::i18n::TextDirection direction) OVERRIDE; | |
| 77 virtual void ExtendSelectionAndDelete(size_t before, size_t after) OVERRIDE; | |
| 78 virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE; | |
| 79 | |
| 80 // Overridden from FocusChangeListener. | 45 // Overridden from FocusChangeListener. |
| 81 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; | 46 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; |
| 82 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; | 47 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; |
| 83 | 48 |
| 84 ui::InputMethod* GetHostInputMethod() const; | 49 ui::InputMethod* GetHostInputMethod() const; |
| 85 | 50 |
| 86 private: | 51 private: |
| 87 void UpdateViewFocusState(); | 52 void UpdateViewFocusState(); |
| 88 | 53 |
| 89 ui::InputMethod* const host_; | 54 ui::InputMethod* const host_; |
| 90 | 55 |
| 91 const bool shared_input_method_; | 56 const bool shared_input_method_; |
| 92 | 57 |
| 93 bool context_focused_; | 58 bool context_focused_; |
| 94 | 59 |
| 95 DISALLOW_COPY_AND_ASSIGN(InputMethodBridge); | 60 DISALLOW_COPY_AND_ASSIGN(InputMethodBridge); |
| 96 }; | 61 }; |
| 97 | 62 |
| 98 } // namespace views | 63 } // namespace views |
| 99 | 64 |
| 100 #endif // UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ | 65 #endif // UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ |
| OLD | NEW |