Delete unused downloads page asset.
[chromium-blink-merge.git] / ppapi / c / dev / ppb_ime_input_event_dev.h
blob590a1d96e189bf4555b3615acd4c96ce80a59cbe
1 /* Copyright (c) 2012 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 */
6 /* From dev/ppb_ime_input_event_dev.idl modified Wed May 16 17:08:03 2012. */
8 #ifndef PPAPI_C_DEV_PPB_IME_INPUT_EVENT_DEV_H_
9 #define PPAPI_C_DEV_PPB_IME_INPUT_EVENT_DEV_H_
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_macros.h"
14 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/c/pp_stdint.h"
16 #include "ppapi/c/pp_time.h"
17 #include "ppapi/c/pp_var.h"
18 #include "ppapi/c/ppb_input_event.h"
20 #define PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_1 "PPB_IMEInputEvent(Dev);0.1"
21 #define PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_2 "PPB_IMEInputEvent(Dev);0.2"
22 #define PPB_IME_INPUT_EVENT_DEV_INTERFACE PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_2
24 /**
25 * @file
26 * This file defines the <code>PPB_IMEInputEvent_Dev</code> interface.
30 /**
31 * @addtogroup Interfaces
32 * @{
34 struct PPB_IMEInputEvent_Dev_0_2 {
35 /**
36 * Create() creates an IME input event with the given parameters. Normally
37 * you will get an IME event passed through the <code>HandleInputEvent</code>
38 * and will not need to create them, but some applications may want to create
39 * their own for internal use.
41 * @param[in] instance The instance for which this event occurred.
43 * @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of
44 * input event. The type must be one of the IME event types.
46 * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
47 * when the event occurred.
49 * @param[in] text The string returned by <code>GetText</code>.
51 * @param[in] segment_number The number returned by
52 * <code>GetSegmentNumber</code>.
54 * @param[in] segment_offsets The array of numbers returned by
55 * <code>GetSegmentOffset</code>. If <code>segment_number</code> is zero,
56 * the number of elements of the array should be zero. If
57 * <code>segment_number</code> is non-zero, the length of the array must be
58 * <code>segment_number</code> + 1.
60 * @param[in] target_segment The number returned by
61 * <code>GetTargetSegment</code>.
63 * @param[in] selection_start The start index returned by
64 * <code>GetSelection</code>.
66 * @param[in] selection_end The end index returned by
67 * <code>GetSelection</code>.
69 * @return A <code>PP_Resource</code> containing the new IME input event.
71 PP_Resource (*Create)(PP_Instance instance,
72 PP_InputEvent_Type type,
73 PP_TimeTicks time_stamp,
74 struct PP_Var text,
75 uint32_t segment_number,
76 const uint32_t segment_offsets[],
77 int32_t target_segment,
78 uint32_t selection_start,
79 uint32_t selection_end);
80 /**
81 * IsIMEInputEvent() determines if a resource is an IME event.
83 * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
85 * @return <code>PP_TRUE</code> if the given resource is a valid input event.
87 PP_Bool (*IsIMEInputEvent)(PP_Resource resource);
88 /**
89 * GetText() returns the composition text as a UTF-8 string for the given IME
90 * event.
92 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
93 * event.
95 * @return A string var representing the composition text. For non-IME input
96 * events the return value will be an undefined var.
98 struct PP_Var (*GetText)(PP_Resource ime_event);
99 /**
100 * GetSegmentNumber() returns the number of segments in the composition text.
102 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
103 * event.
105 * @return The number of segments. For events other than COMPOSITION_UPDATE,
106 * returns 0.
108 uint32_t (*GetSegmentNumber)(PP_Resource ime_event);
110 * GetSegmentOffset() returns the position of the index-th segmentation point
111 * in the composition text. The position is given by a byte-offset (not a
112 * character-offset) of the string returned by GetText(). It always satisfies
113 * 0=GetSegmentOffset(0) < ... < GetSegmentOffset(i) < GetSegmentOffset(i+1)
114 * < ... < GetSegmentOffset(GetSegmentNumber())=(byte-length of GetText()).
115 * Note that [GetSegmentOffset(i), GetSegmentOffset(i+1)) represents the range
116 * of the i-th segment, and hence GetSegmentNumber() can be a valid argument
117 * to this function instead of an off-by-1 error.
119 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
120 * event.
122 * @param[in] index An integer indicating a segment.
124 * @return The byte-offset of the segmentation point. If the event is not
125 * COMPOSITION_UPDATE or index is out of range, returns 0.
127 uint32_t (*GetSegmentOffset)(PP_Resource ime_event, uint32_t index);
129 * GetTargetSegment() returns the index of the current target segment of
130 * composition.
132 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
133 * event.
135 * @return An integer indicating the index of the target segment. When there
136 * is no active target segment, or the event is not COMPOSITION_UPDATE,
137 * returns -1.
139 int32_t (*GetTargetSegment)(PP_Resource ime_event);
141 * GetSelection() returns the range selected by caret in the composition text.
143 * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
144 * event.
146 * @param[out] start The start position of the current selection.
148 * @param[out] end The end position of the current selection.
150 void (*GetSelection)(PP_Resource ime_event, uint32_t* start, uint32_t* end);
153 typedef struct PPB_IMEInputEvent_Dev_0_2 PPB_IMEInputEvent_Dev;
155 struct PPB_IMEInputEvent_Dev_0_1 {
156 PP_Bool (*IsIMEInputEvent)(PP_Resource resource);
157 struct PP_Var (*GetText)(PP_Resource ime_event);
158 uint32_t (*GetSegmentNumber)(PP_Resource ime_event);
159 uint32_t (*GetSegmentOffset)(PP_Resource ime_event, uint32_t index);
160 int32_t (*GetTargetSegment)(PP_Resource ime_event);
161 void (*GetSelection)(PP_Resource ime_event, uint32_t* start, uint32_t* end);
164 * @}
167 #endif /* PPAPI_C_DEV_PPB_IME_INPUT_EVENT_DEV_H_ */