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 VIEWS_IME_INPUT_METHOD_H_ | 5 #ifndef VIEWS_IME_INPUT_METHOD_H_ |
6 #define VIEWS_IME_INPUT_METHOD_H_ | 6 #define VIEWS_IME_INPUT_METHOD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
13 #include "ui/base/ime/text_input_type.h" | 14 #include "ui/base/ime/text_input_type.h" |
14 | 15 |
15 namespace views { | 16 namespace views { |
16 | 17 |
17 namespace internal { | 18 namespace internal { |
18 class InputMethodDelegate; | 19 class InputMethodDelegate; |
19 } // namespace internal | 20 } // namespace internal |
20 | 21 |
21 class KeyEvent; | 22 class KeyEvent; |
22 class TextInputClient; | 23 class TextInputClient; |
23 class View; | 24 class View; |
24 class Widget; | 25 class Widget; |
25 | 26 |
| 27 class TextInputTypeChangedListener { |
| 28 public: |
| 29 virtual void TextInputTypeChanged(View* view, ui::TextInputType type) = 0; |
| 30 |
| 31 protected: |
| 32 virtual ~TextInputTypeChangedListener() {} |
| 33 }; |
| 34 |
26 // An interface implemented by an object that encapsulates a native input method | 35 // An interface implemented by an object that encapsulates a native input method |
27 // service provided by the underlying operation system. | 36 // service provided by the underlying operation system. |
28 // Because on most systems, the system input method service is bound to | 37 // Because on most systems, the system input method service is bound to |
29 // individual native window. On Windows, its HWND, on Linux/Gtk, its GdkWindow. | 38 // individual native window. On Windows, its HWND, on Linux/Gtk, its GdkWindow. |
30 // And in Views control system, only the top-level NativeWidget has a native | 39 // And in Views control system, only the top-level NativeWidget has a native |
31 // window that can get keyboard focus. So this API is designed to be bound to | 40 // window that can get keyboard focus. So this API is designed to be bound to |
32 // the top-level NativeWidget. | 41 // the top-level NativeWidget. |
33 class InputMethod { | 42 class InputMethod { |
34 public: | 43 public: |
35 virtual ~InputMethod() {} | 44 virtual ~InputMethod() {} |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 103 |
95 // Gets the focused text input client. Returns NULL if the Widget is not | 104 // Gets the focused text input client. Returns NULL if the Widget is not |
96 // focused, or there is no focused View or the focused View doesn't support | 105 // focused, or there is no focused View or the focused View doesn't support |
97 // text input. | 106 // text input. |
98 virtual TextInputClient* GetTextInputClient() const = 0; | 107 virtual TextInputClient* GetTextInputClient() const = 0; |
99 | 108 |
100 // Gets the text input type of the focused text input client. Returns | 109 // Gets the text input type of the focused text input client. Returns |
101 // ui::TEXT_INPUT_TYPE_NONE if there is no focused text input client. | 110 // ui::TEXT_INPUT_TYPE_NONE if there is no focused text input client. |
102 virtual ui::TextInputType GetTextInputType() const = 0; | 111 virtual ui::TextInputType GetTextInputType() const = 0; |
103 | 112 |
| 113 // Adds/Removes text input type changed listener |
| 114 void AddTextInputTypeChangedListener(TextInputTypeChangedListener* listener); |
| 115 |
| 116 void RemoveTextInputTypeChangedListener( |
| 117 TextInputTypeChangedListener* listener); |
| 118 |
| 119 protected: |
| 120 // Notifies all listeners that the text input type is changed. |
| 121 void TextInputTypeChanged(View* view); |
| 122 |
| 123 private: |
| 124 // The list of registered TextInputTypeChanged listeners. |
| 125 typedef std::vector<TextInputTypeChangedListener*> |
| 126 TextInputTypeChangedListenerList; |
| 127 TextInputTypeChangedListenerList text_input_type_changed_listeners_; |
| 128 |
104 // TODO(suzhe): Support mouse/touch event. | 129 // TODO(suzhe): Support mouse/touch event. |
105 }; | 130 }; |
106 | 131 |
107 } // namespace views | 132 } // namespace views |
108 | 133 |
109 #endif // VIEWS_IME_INPUT_METHOD_H_ | 134 #endif // VIEWS_IME_INPUT_METHOD_H_ |
OLD | NEW |