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_TEXT_INPUT_CLIENT_H_ | 5 #ifndef VIEWS_IME_TEXT_INPUT_CLIENT_H_ |
6 #define VIEWS_IME_TEXT_INPUT_CLIENT_H_ | 6 #define VIEWS_IME_TEXT_INPUT_CLIENT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | |
13 #include "base/string16.h" | 12 #include "base/string16.h" |
14 #include "ui/base/ime/composition_text.h" | 13 #include "ui/base/ime/composition_text.h" |
15 #include "ui/base/ime/text_input_type.h" | 14 #include "ui/base/ime/text_input_type.h" |
16 #include "ui/base/range/range.h" | 15 #include "ui/base/range/range.h" |
17 #include "views/views_export.h" | 16 #include "views/views_export.h" |
18 | 17 |
19 namespace gfx { | 18 namespace gfx { |
20 class Rect; | 19 class Rect; |
21 } | 20 } |
22 | 21 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // Returns current caret (insertion point) bounds relative to the View’s | 66 // Returns current caret (insertion point) bounds relative to the View’s |
68 // coordinates. If there is selection, then the selection bounds will be | 67 // coordinates. If there is selection, then the selection bounds will be |
69 // returned. | 68 // returned. |
70 virtual gfx::Rect GetCaretBounds() = 0; | 69 virtual gfx::Rect GetCaretBounds() = 0; |
71 | 70 |
72 // Returns true if there is composition text. | 71 // Returns true if there is composition text. |
73 virtual bool HasCompositionText() = 0; | 72 virtual bool HasCompositionText() = 0; |
74 | 73 |
75 // Document content operations ---------------------------------------------- | 74 // Document content operations ---------------------------------------------- |
76 | 75 |
77 // Retrieves the UTF-16 based character range containing all text in the View. | 76 // Retrieves the UTF-16 based character range containing accessabled text in |
| 77 // the View. It must cover the composition and selection range. |
78 // Returns false if the information cannot be retrieved right now. | 78 // Returns false if the information cannot be retrieved right now. |
79 virtual bool GetTextRange(ui::Range* range) = 0; | 79 virtual bool GetTextRange(ui::Range* range) = 0; |
80 | 80 |
81 // Retrieves the UTF-16 based character range of current composition text. | 81 // Retrieves the UTF-16 based character range of current composition text. |
82 // Returns false if the information cannot be retrieved right now. | 82 // Returns false if the information cannot be retrieved right now. |
83 virtual bool GetCompositionTextRange(ui::Range* range) = 0; | 83 virtual bool GetCompositionTextRange(ui::Range* range) = 0; |
84 | 84 |
85 // Retrieves the UTF-16 based character range of current selection. | 85 // Retrieves the UTF-16 based character range of current selection. |
86 // Returns false if the information cannot be retrieved right now. | 86 // Returns false if the information cannot be retrieved right now. |
87 virtual bool GetSelectionRange(ui::Range* range) = 0; | 87 virtual bool GetSelectionRange(ui::Range* range) = 0; |
88 | 88 |
89 // Selects the given UTF-16 based character range. Current composition text | 89 // Selects the given UTF-16 based character range. Current composition text |
90 // will be confirmed before selecting the range. | 90 // will be confirmed before selecting the range. |
91 // Returns false if the operation is not supported. | 91 // Returns false if the operation is not supported. |
92 virtual bool SetSelectionRange(const ui::Range& range) = 0; | 92 virtual bool SetSelectionRange(const ui::Range& range) = 0; |
93 | 93 |
94 // Deletes contents in the given UTF-16 based character range. Current | 94 // Deletes contents in the given UTF-16 based character range. Current |
95 // composition text will be confirmed before deleting the range. | 95 // composition text will be confirmed before deleting the range. |
96 // The input caret will be moved to the place where the range gets deleted. | 96 // The input caret will be moved to the place where the range gets deleted. |
97 // Returns false if the oepration is not supported. | 97 // Returns false if the oepration is not supported. |
98 virtual bool DeleteRange(const ui::Range& range) = 0; | 98 virtual bool DeleteRange(const ui::Range& range) = 0; |
99 | 99 |
100 // Retrieves the text content in a given UTF-16 based character range. | 100 // Retrieves the text content in a given UTF-16 based character range. |
101 // The result will be send back to the input method by calling the given | 101 // If the given range is out of the text range, it returns the intersection |
102 // callback, which may happen asynchronously. | 102 // of given range and text range. The result will be written in text and |
| 103 // actual_range. |
| 104 // Also see |GetTextRange()|. |
103 // Returns false if the operation is not supported. | 105 // Returns false if the operation is not supported. |
104 virtual bool GetTextFromRange( | 106 virtual bool GetTextFromRange( |
105 const ui::Range& range, | 107 const ui::Range& range, |
106 const base::Callback<void(const string16&)>& callback) = 0; | 108 string16* text, |
| 109 ui::Range* actual_range) = 0; |
107 | 110 |
108 // Miscellaneous ------------------------------------------------------------ | 111 // Miscellaneous ------------------------------------------------------------ |
109 | 112 |
110 // Called whenever current keyboard layout or input method is changed, | 113 // Called whenever current keyboard layout or input method is changed, |
111 // especially the change of input locale and text direction. | 114 // especially the change of input locale and text direction. |
112 virtual void OnInputMethodChanged() = 0; | 115 virtual void OnInputMethodChanged() = 0; |
113 | 116 |
114 // Called whenever the user requests to change the text direction and layout | 117 // Called whenever the user requests to change the text direction and layout |
115 // alignment of the current text box. It’s for supporting ctrl-shift on | 118 // alignment of the current text box. It’s for supporting ctrl-shift on |
116 // Windows. | 119 // Windows. |
117 // Returns false if the operation is not supported. | 120 // Returns false if the operation is not supported. |
118 virtual bool ChangeTextDirectionAndLayoutAlignment( | 121 virtual bool ChangeTextDirectionAndLayoutAlignment( |
119 base::i18n::TextDirection direction) = 0; | 122 base::i18n::TextDirection direction) = 0; |
120 | 123 |
121 // Gets the View object who owns this TextInputClient instance. | 124 // Gets the View object who owns this TextInputClient instance. |
122 virtual View* GetOwnerViewOfTextInputClient() = 0; | 125 virtual View* GetOwnerViewOfTextInputClient() = 0; |
123 }; | 126 }; |
124 | 127 |
125 } // namespace views | 128 } // namespace views |
126 | 129 |
127 #endif // VIEWS_IME_TEXT_INPUT_CLIENT_H_ | 130 #endif // VIEWS_IME_TEXT_INPUT_CLIENT_H_ |
OLD | NEW |