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

Side by Side Diff: ppapi/cpp/dev/ime_input_event_dev.h

Issue 7882004: Declarations for Pepper IME API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clarified the specification of GetSegmentAt(). Created 9 years, 3 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 PPAPI_CPP_DEV_IME_INPUT_EVENT_DEV_H_
6 #define PPAPI_CPP_DEV_IME_INPUT_EVENT_DEV_H_
7
8 #include <utility>
9
10 #include "ppapi/c/dev/ppb_ime_input_event_dev.h"
11 #include "ppapi/cpp/input_event.h"
12
13 /// @file
14 /// This file defines the API used to handle IME input events.
15
16 namespace pp {
17
18 class Var;
19
20 class IMEInputEvent_Dev : public InputEvent {
21 public:
22 /// Constructs an is_null() IME input event object.
23 IMEInputEvent_Dev();
24
25 /// Constructs an IME input event object from the provided generic input
26 /// event. If the given event is itself is_null() or is not an IME input
27 /// event, the object will be is_null().
28 ///
29 /// @param[in] event A generic input event.
30 explicit IMEInputEvent_Dev(const InputEvent& event);
31
32 /// Returns the composition text as a UTF-8 string for the given IME event.
33 ///
34 /// @return A string var representing the composition text. For non-IME
35 /// input events the return value will be an undefined var.
36 Var GetText() const;
37
38 /// Returns the number of segments in the composition text.
39 ///
40 /// @return The number of segments. For events other than COMPOSITION_UPDATE,
41 /// returns 0.
42 uint32_t GetSegmentNumber() const;
43
44 /// Returns the start and the end position of the index-th segment in the
45 /// composition text. The positions are given by byte-indices of the string
46 /// GetText(). They always satisfy 0 <= .first < .second <= (Length of
47 /// GetText()) and GetSegmentAt(index).first < GetSegmentAt(index+1).first.
48 /// When the event is not COMPOSITION_UPDATE or index >= GetSegmentNumber(),
49 /// returns (0, 0).
50 ///
51 /// @param[in] index An integer indicating a segment.
52 ///
53 /// @return A pair of integers representing the index-th segment.
54 std::pair<uint32_t, uint32_t> GetSegmentAt(uint32_t index) const;
55
56 /// Returns the index of the current target segment of composition.
57 ///
58 /// @return An integer indicating the index of the target segment. When there
59 /// is no active target segment, or the event is not COMPOSITION_UPDATE,
60 /// returns -1.
61 int32_t GetTargetSegment() const;
62
63 /// Returns the range selected by caret in the composition text.
64 ///
65 /// @return A pair of integers indicating the selection range.
66 std::pair<uint32_t, uint32_t> GetSelection() const;
67 };
68
69 } // namespace pp
70
71 #endif // PPAPI_CPP_DEV_IME_INPUT_EVENT_DEV_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698