| 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" |
| 12 #include "ui/views/ime/input_method_base.h" | 14 #include "ui/views/ime/input_method_base.h" |
| 13 | 15 |
| 14 namespace ui { | 16 namespace ui { |
| 15 class InputMethod; | 17 class InputMethod; |
| 16 } // namespace ui | 18 } // namespace ui |
| 17 | 19 |
| 18 namespace views { | 20 namespace views { |
| 19 | 21 |
| 22 class View; |
| 23 |
| 20 // A "bridge" InputMethod implementation for views top-level widgets, which just | 24 // A "bridge" InputMethod implementation for views top-level widgets, which just |
| 21 // sends/receives IME related events to/from a system-wide ui::InputMethod | 25 // sends/receives IME related events to/from a system-wide ui::InputMethod |
| 22 // object. | 26 // object. |
| 23 class InputMethodBridge : public InputMethodBase { | 27 class InputMethodBridge : public InputMethodBase, |
| 28 public ui::TextInputClient { |
| 24 public: | 29 public: |
| 25 // |shared_input_method| indicates if |host| is shared among other top level | 30 // |shared_input_method| indicates if |host| is shared among other top level |
| 26 // widgets. | 31 // widgets. |
| 27 InputMethodBridge(internal::InputMethodDelegate* delegate, | 32 InputMethodBridge(internal::InputMethodDelegate* delegate, |
| 28 ui::InputMethod* host, | 33 ui::InputMethod* host, |
| 29 bool shared_input_method); | 34 bool shared_input_method); |
| 30 virtual ~InputMethodBridge(); | 35 virtual ~InputMethodBridge(); |
| 31 | 36 |
| 32 // Overridden from InputMethod: | 37 // Overridden from InputMethod: |
| 38 virtual void OnFocus() OVERRIDE; |
| 39 virtual void OnBlur() OVERRIDE; |
| 33 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event, | 40 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event, |
| 34 NativeEventResult* result) OVERRIDE; | 41 NativeEventResult* result) OVERRIDE; |
| 35 virtual void DispatchKeyEvent(const ui::KeyEvent& key) OVERRIDE; | 42 virtual void DispatchKeyEvent(const ui::KeyEvent& key) OVERRIDE; |
| 36 virtual void OnTextInputTypeChanged(View* view) OVERRIDE; | 43 virtual void OnTextInputTypeChanged(View* view) OVERRIDE; |
| 37 virtual void OnCaretBoundsChanged(View* view) OVERRIDE; | 44 virtual void OnCaretBoundsChanged(View* view) OVERRIDE; |
| 38 virtual void CancelComposition(View* view) OVERRIDE; | 45 virtual void CancelComposition(View* view) OVERRIDE; |
| 39 virtual void OnInputLocaleChanged() OVERRIDE; | 46 virtual void OnInputLocaleChanged() OVERRIDE; |
| 40 virtual std::string GetInputLocale() OVERRIDE; | 47 virtual std::string GetInputLocale() OVERRIDE; |
| 41 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; | 48 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; |
| 42 virtual bool IsActive() OVERRIDE; | 49 virtual bool IsActive() OVERRIDE; |
| 43 virtual bool IsCandidatePopupOpen() const OVERRIDE; | 50 virtual bool IsCandidatePopupOpen() const OVERRIDE; |
| 44 | 51 |
| 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 |
| 45 // Overridden from FocusChangeListener. | 80 // Overridden from FocusChangeListener. |
| 46 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; | 81 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; |
| 47 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; | 82 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; |
| 48 | 83 |
| 49 ui::InputMethod* GetHostInputMethod() const; | 84 ui::InputMethod* GetHostInputMethod() const; |
| 50 | 85 |
| 51 private: | 86 private: |
| 52 void UpdateViewFocusState(); | 87 void UpdateViewFocusState(); |
| 53 | 88 |
| 54 ui::InputMethod* const host_; | 89 ui::InputMethod* const host_; |
| 55 | 90 |
| 56 const bool shared_input_method_; | 91 const bool shared_input_method_; |
| 57 | 92 |
| 58 bool context_focused_; | 93 bool context_focused_; |
| 59 | 94 |
| 60 DISALLOW_COPY_AND_ASSIGN(InputMethodBridge); | 95 DISALLOW_COPY_AND_ASSIGN(InputMethodBridge); |
| 61 }; | 96 }; |
| 62 | 97 |
| 63 } // namespace views | 98 } // namespace views |
| 64 | 99 |
| 65 #endif // UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ | 100 #endif // UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ |
| OLD | NEW |