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 UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ |
| 6 #define UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "ui/base/ime/text_input_client.h" |
| 14 #include "ui/views/ime/input_method_base.h" |
| 15 |
| 16 namespace ui { |
| 17 class InputMethod; |
| 18 } // namespace ui |
| 19 |
| 20 namespace views { |
| 21 |
| 22 class View; |
| 23 |
| 24 // A "bridge" InputMethod implementation for views top-level widgets, which just |
| 25 // sends/receives IME related events to/from a system-wide ui::InputMethod |
| 26 // object. |
| 27 class InputMethodBridge : public InputMethodBase, |
| 28 public ui::TextInputClient { |
| 29 public: |
| 30 InputMethodBridge(internal::InputMethodDelegate* delegate, |
| 31 ui::InputMethod* host); |
| 32 virtual ~InputMethodBridge(); |
| 33 |
| 34 // Overridden from InputMethod: |
| 35 virtual void Init(Widget* widget) OVERRIDE; |
| 36 virtual void OnFocus() OVERRIDE; |
| 37 virtual void OnBlur() OVERRIDE; |
| 38 virtual void DispatchKeyEvent(const KeyEvent& key) OVERRIDE; |
| 39 virtual void OnTextInputTypeChanged(View* view) OVERRIDE; |
| 40 virtual void OnCaretBoundsChanged(View* view) OVERRIDE; |
| 41 virtual void CancelComposition(View* view) OVERRIDE; |
| 42 virtual std::string GetInputLocale() OVERRIDE; |
| 43 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; |
| 44 virtual bool IsActive() OVERRIDE; |
| 45 |
| 46 // Overridden from TextInputClient: |
| 47 virtual void SetCompositionText( |
| 48 const ui::CompositionText& composition) OVERRIDE; |
| 49 virtual void ConfirmCompositionText() OVERRIDE; |
| 50 virtual void ClearCompositionText() OVERRIDE; |
| 51 virtual void InsertText(const string16& text) OVERRIDE; |
| 52 virtual void InsertChar(char16 ch, int flags) OVERRIDE; |
| 53 virtual ui::TextInputType GetTextInputType() const OVERRIDE; |
| 54 virtual gfx::Rect GetCaretBounds() OVERRIDE; |
| 55 virtual bool HasCompositionText() OVERRIDE; |
| 56 virtual bool GetTextRange(ui::Range* range) OVERRIDE; |
| 57 virtual bool GetCompositionTextRange(ui::Range* range) OVERRIDE; |
| 58 virtual bool GetSelectionRange(ui::Range* range) OVERRIDE; |
| 59 virtual bool SetSelectionRange(const ui::Range& range) OVERRIDE; |
| 60 virtual bool DeleteRange(const ui::Range& range) OVERRIDE; |
| 61 virtual bool GetTextFromRange( |
| 62 const ui::Range& range, string16* text) OVERRIDE; |
| 63 virtual void OnInputMethodChanged() OVERRIDE; |
| 64 virtual bool ChangeTextDirectionAndLayoutAlignment( |
| 65 base::i18n::TextDirection direction) OVERRIDE; |
| 66 |
| 67 // Overridden from FocusChangeListener. |
| 68 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; |
| 69 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; |
| 70 |
| 71 private: |
| 72 void UpdateViewFocusState(); |
| 73 |
| 74 ui::InputMethod* const host_; |
| 75 bool context_focused_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(InputMethodBridge); |
| 78 }; |
| 79 |
| 80 } // namespace views |
| 81 |
| 82 #endif // UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ |
OLD | NEW |