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_BASE_H_ | 5 #ifndef UI_VIEWS_IME_INPUT_METHOD_BASE_H_ |
6 #define UI_VIEWS_IME_INPUT_METHOD_BASE_H_ | 6 #define UI_VIEWS_IME_INPUT_METHOD_BASE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ui/views/focus/focus_manager.h" | 10 #include "ui/views/focus/focus_manager.h" |
11 #include "ui/views/ime/input_method.h" | 11 #include "ui/views/ime/input_method.h" |
12 #include "ui/views/ime/input_method_delegate.h" | 12 #include "ui/views/ime/input_method_delegate.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 class Rect; | 15 class Rect; |
16 } | 16 } |
17 | 17 |
18 namespace ui { | 18 namespace ui { |
| 19 class KeyEvent; |
19 class TextInputClient; | 20 class TextInputClient; |
20 } | 21 } |
21 | 22 |
22 namespace views { | 23 namespace views { |
23 | 24 |
24 class View; | 25 class View; |
25 | 26 |
26 // A helper class providing functionalities shared among InputMethod | 27 // A helper class providing functionalities shared among InputMethod |
27 // implementations. | 28 // implementations. |
28 class VIEWS_EXPORT InputMethodBase : NON_EXPORTED_BASE(public InputMethod), | 29 class VIEWS_EXPORT InputMethodBase : NON_EXPORTED_BASE(public InputMethod), |
29 public FocusChangeListener { | 30 public FocusChangeListener { |
30 public: | 31 public: |
31 InputMethodBase(); | 32 InputMethodBase(); |
32 virtual ~InputMethodBase(); | 33 virtual ~InputMethodBase(); |
33 | 34 |
34 // Overriden from InputMethod. | 35 // Overridden from InputMethod. |
35 virtual void set_delegate(internal::InputMethodDelegate* delegate) OVERRIDE; | 36 virtual void set_delegate(internal::InputMethodDelegate* delegate) OVERRIDE; |
36 | 37 |
37 // If a derived class overrides this method, it should call parent's | 38 // If a derived class overrides this method, it should call parent's |
38 // implementation first. | 39 // implementation first. |
39 virtual void Init(Widget* widget) OVERRIDE; | 40 virtual void Init(Widget* widget) OVERRIDE; |
40 | 41 |
41 // If a derived class overrides this method, it should call parent's | 42 // If a derived class overrides this method, it should call parent's |
42 // implementation first, to make sure |widget_focused_| flag can be updated | 43 // implementation first, to make sure |widget_focused_| flag can be updated |
43 // correctly. | 44 // correctly. |
44 virtual void OnFocus() OVERRIDE; | 45 virtual void OnFocus() OVERRIDE; |
(...skipping 30 matching lines...) Expand all Loading... |
75 // ui::TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text | 76 // ui::TEXT_INPUT_TYPE_NONE. Also returns true if there is no focused text |
76 // input client. | 77 // input client. |
77 bool IsTextInputTypeNone() const; | 78 bool IsTextInputTypeNone() const; |
78 | 79 |
79 // Convenience method to call the focused text input client's | 80 // Convenience method to call the focused text input client's |
80 // OnInputMethodChanged() method. It'll only take effect if the current text | 81 // OnInputMethodChanged() method. It'll only take effect if the current text |
81 // input type is not ui::TEXT_INPUT_TYPE_NONE. | 82 // input type is not ui::TEXT_INPUT_TYPE_NONE. |
82 void OnInputMethodChanged() const; | 83 void OnInputMethodChanged() const; |
83 | 84 |
84 // Convenience method to call delegate_->DispatchKeyEventPostIME(). | 85 // Convenience method to call delegate_->DispatchKeyEventPostIME(). |
85 void DispatchKeyEventPostIME(const KeyEvent& key) const; | 86 void DispatchKeyEventPostIME(const ui::KeyEvent& key) const; |
86 | 87 |
87 // Gets the current text input client's caret bounds in Widget's coordinates. | 88 // Gets the current text input client's caret bounds in Widget's coordinates. |
88 // Returns false if the current text input client doesn't support text input. | 89 // Returns false if the current text input client doesn't support text input. |
89 bool GetCaretBoundsInWidget(gfx::Rect* rect) const; | 90 bool GetCaretBoundsInWidget(gfx::Rect* rect) const; |
90 | 91 |
91 private: | 92 private: |
92 internal::InputMethodDelegate* delegate_; | 93 internal::InputMethodDelegate* delegate_; |
93 Widget* widget_; | 94 Widget* widget_; |
94 | 95 |
95 // Indicates if the top-level widget is focused or not. | 96 // Indicates if the top-level widget is focused or not. |
96 bool widget_focused_; | 97 bool widget_focused_; |
97 | 98 |
98 DISALLOW_COPY_AND_ASSIGN(InputMethodBase); | 99 DISALLOW_COPY_AND_ASSIGN(InputMethodBase); |
99 }; | 100 }; |
100 | 101 |
101 } // namespace views | 102 } // namespace views |
102 | 103 |
103 #endif // UI_VIEWS_IME_INPUT_METHOD_BASE_H_ | 104 #endif // UI_VIEWS_IME_INPUT_METHOD_BASE_H_ |
OLD | NEW |