Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: views/ime/text_input_client.h

Issue 6688049: New InputMethod api for Views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 VIEWS_IME_TEXT_INPUT_CLIENT_H_
6 #define VIEWS_IME_TEXT_INPUT_CLIENT_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/string16.h"
14 #include "ui/base/ime/composition.h"
15 #include "ui/base/ime/text_input_type.h"
16 #include "ui/base/range/range.h"
17
18 namespace gfx {
19 class Rect;
20 }
21
22 namespace views {
23
24 // An interface implemented by a View that needs text input support.
25 class TextInputClient {
26 public:
27 virtual ~TextInputClient() {}
28
29 // Input method result -------------------------------------------------------
30
31 // Sets composition text and attributes. If there is composition text already,
32 // it’ll be replaced by the new one. Otherwise, current selection will be
33 // replaced. If there is no selection, the composition text will be inserted
34 // at the insertion point.
35 virtual void SetComposition(const ui::Composition& composition) = 0;
36
37 // Converts current composition text into final content.
38 virtual void ConfirmComposition() = 0;
39
40 // Removes current composition text.
41 virtual void ClearComposition() = 0;
42
43 // Inserts a given text at the insertion point. Current composition text or
44 // selection will be removed. This method should never be called when the
45 // current text input type is TEXT_INPUT_TYPE_NONE.
46 virtual void InsertText(const string16& text) = 0;
47
48 // Inserts a single char at the insertion point. Unlike above InsertText()
49 // method, this method has an extra |flags| parameter indicating the modifier
50 // key states when the character is generated. This method should only be
51 // called when a key press is not handled by the input method but still
52 // generates a character (eg. by the keyboard driver). In another word, the
53 // preceding key press event should not be a VKEY_PROCESSKEY.
54 // This method will be called whenever a char is generated by the keyboard,
55 // even if the current text input type is TEXT_INPUT_TYPE_NONE.
56 virtual void InsertChar(char16 ch, int flags) = 0;
57
58 // Input context information -------------------------------------------------
59
60 // Returns current text input type. It could be changed and even becomes
61 // TEXT_INPUT_TYPE_NONE at runtime.
62 virtual ui::TextInputType GetTextInputType() = 0;
63
64 // Returns current caret (insertion point) bounds relative to the View’s
65 // coordinates. If there is selection, then the selection bounds will be
66 // returned.
67 virtual gfx::Rect GetCaretBounds() = 0;
68
69 // Returns true if there is composition text.
70 virtual bool HasComposition() = 0;
71
72
73 // Document content operations ----------------------------------------------
74
75 // Retrieves the UTF-16 based character range containing all text in the View.
76 // Returns false if the information cannot be retrieved right now.
77 virtual bool GetTextRange(ui::Range* range) = 0;
78
79 // Retrieves the UTF-16 based character range of current composition text.
80 // Returns false if the information cannot be retrieved right now.
81 virtual bool GetCompositionRange(ui::Range* range) = 0;
82
83 // Retrieves the UTF-16 based character range of current selection.
84 // Returns false if the information cannot be retrieved right now.
85 virtual bool GetSelectionRange(ui::Range* range) = 0;
86
87 // Selects the given UTF-16 based character range. Current composition text
88 // will be confirmed before selecting the range.
89 // Returns false if the operation is not supported.
90 virtual bool SetSelectionRange(const ui::Range& range) = 0;
91
92 // Deletes contents in the given UTF-16 based character range. Current
93 // composition text will be confirmed before deleting the range.
94 // The input caret will be moved to the place where the range gets deleted.
95 // Returns false if the oepration is not supported.
96 virtual bool DeleteRange(const ui::Range& range) = 0;
97
98 // Retrieves the text content in a given UTF-16 based character range.
99 // The result will be send back to the input method by calling the given
100 // callback, which may happen asynchronously.
101 // Returns false if the operation is not supported.
102 virtual bool GetTextFromRange(
103 const ui::Range& range,
104 const base::Callback<void(string16)>& callback) = 0;
105
106 // Miscellaneous ------------------------------------------------------------
107
108 // Called whenever current keyboard layout or input method is changed,
109 // especially the change of input locale and text direction.
110 virtual void OnInputMethodChanged() = 0;
111
112 // Called whenever the user requests to change the text direction and layout
113 // alignment of the current text box. It’s for supporting ctrl-shift on
114 // Windows.
115 // Returns false if the operation is not supported.
116 virtual bool ChangeTextDirectionAndLayoutAlignment(
117 base::i18n::TextDirection direction) = 0;
118 };
119
120 } // namespace views
121
122 #endif // VIEWS_IME_TEXT_INPUT_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698