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

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: Rebase. Created 9 years, 8 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_text.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 class View;
25
26 // An interface implemented by a View that needs text input support.
27 class TextInputClient {
28 public:
29 virtual ~TextInputClient() {}
30
31 // Input method result -------------------------------------------------------
32
33 // Sets composition text and attributes. If there is composition text already,
34 // it’ll be replaced by the new one. Otherwise, current selection will be
35 // replaced. If there is no selection, the composition text will be inserted
36 // at the insertion point.
37 virtual void SetCompositionText(const ui::CompositionText& composition) = 0;
38
39 // Converts current composition text into final content.
40 virtual void ConfirmCompositionText() = 0;
41
42 // Removes current composition text.
43 virtual void ClearCompositionText() = 0;
44
45 // Inserts a given text at the insertion point. Current composition text or
46 // selection will be removed. This method should never be called when the
47 // current text input type is TEXT_INPUT_TYPE_NONE.
48 virtual void InsertText(const string16& text) = 0;
49
50 // Inserts a single char at the insertion point. Unlike above InsertText()
51 // method, this method has an extra |flags| parameter indicating the modifier
52 // key states when the character is generated. This method should only be
53 // called when a key press is not handled by the input method but still
54 // generates a character (eg. by the keyboard driver). In another word, the
55 // preceding key press event should not be a VKEY_PROCESSKEY.
56 // This method will be called whenever a char is generated by the keyboard,
57 // even if the current text input type is TEXT_INPUT_TYPE_NONE.
58 virtual void InsertChar(char16 ch, int flags) = 0;
59
60 // Input context information -------------------------------------------------
61
62 // Returns current text input type. It could be changed and even becomes
63 // TEXT_INPUT_TYPE_NONE at runtime.
64 virtual ui::TextInputType GetTextInputType() = 0;
65
66 // Returns current caret (insertion point) bounds relative to the View’s
67 // coordinates. If there is selection, then the selection bounds will be
68 // returned.
69 virtual gfx::Rect GetCaretBounds() = 0;
70
71 // Returns true if there is composition text.
72 virtual bool HasCompositionText() = 0;
73
74 // Document content operations ----------------------------------------------
75
76 // Retrieves the UTF-16 based character range containing all text in the View.
77 // Returns false if the information cannot be retrieved right now.
78 virtual bool GetTextRange(ui::Range* range) = 0;
79
80 // Retrieves the UTF-16 based character range of current composition text.
81 // Returns false if the information cannot be retrieved right now.
82 virtual bool GetCompositionTextRange(ui::Range* range) = 0;
83
84 // Retrieves the UTF-16 based character range of current selection.
85 // Returns false if the information cannot be retrieved right now.
86 virtual bool GetSelectionRange(ui::Range* range) = 0;
87
88 // Selects the given UTF-16 based character range. Current composition text
89 // will be confirmed before selecting the range.
90 // Returns false if the operation is not supported.
91 virtual bool SetSelectionRange(const ui::Range& range) = 0;
92
93 // Deletes contents in the given UTF-16 based character range. Current
94 // composition text will be confirmed before deleting the range.
95 // The input caret will be moved to the place where the range gets deleted.
96 // Returns false if the oepration is not supported.
97 virtual bool DeleteRange(const ui::Range& range) = 0;
98
99 // Retrieves the text content in a given UTF-16 based character range.
100 // The result will be send back to the input method by calling the given
101 // callback, which may happen asynchronously.
102 // Returns false if the operation is not supported.
103 virtual bool GetTextFromRange(
104 const ui::Range& range,
105 const base::Callback<void(const string16&)>& callback) = 0;
106
107 // Miscellaneous ------------------------------------------------------------
108
109 // Called whenever current keyboard layout or input method is changed,
110 // especially the change of input locale and text direction.
111 virtual void OnInputMethodChanged() = 0;
112
113 // Called whenever the user requests to change the text direction and layout
114 // alignment of the current text box. It’s for supporting ctrl-shift on
115 // Windows.
116 // Returns false if the operation is not supported.
117 virtual bool ChangeTextDirectionAndLayoutAlignment(
118 base::i18n::TextDirection direction) = 0;
119
120 // Gets the View object who owns this TextInputClient instance.
121 virtual View* GetView() = 0;
122 };
123
124 } // namespace views
125
126 #endif // VIEWS_IME_TEXT_INPUT_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698