Home | History | Annotate | Download | only in dev
      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  */
      5 
      6 /* From dev/ppb_ime_input_event_dev.idl modified Wed May 16 17:08:03 2012. */
      7 
      8 #ifndef PPAPI_C_DEV_PPB_IME_INPUT_EVENT_DEV_H_
      9 #define PPAPI_C_DEV_PPB_IME_INPUT_EVENT_DEV_H_
     10 
     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"
     19 
     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
     23 
     24 /**
     25  * @file
     26  * This file defines the <code>PPB_IMEInputEvent_Dev</code> interface.
     27  */
     28 
     29 
     30 /**
     31  * @addtogroup Interfaces
     32  * @{
     33  */
     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.
     40    *
     41    * @param[in] instance The instance for which this event occurred.
     42    *
     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.
     45    *
     46    * @param[in] time_stamp A <code>PP_TimeTicks</code> indicating the time
     47    * when the event occurred.
     48    *
     49    * @param[in] text The string returned by <code>GetText</code>.
     50    *
     51    * @param[in] segment_number The number returned by
     52    * <code>GetSegmentNumber</code>.
     53    *
     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.
     59    *
     60    * @param[in] target_segment The number returned by
     61    * <code>GetTargetSegment</code>.
     62    *
     63    * @param[in] selection_start The start index returned by
     64    * <code>GetSelection</code>.
     65    *
     66    * @param[in] selection_end The end index returned by
     67    * <code>GetSelection</code>.
     68    *
     69    * @return A <code>PP_Resource</code> containing the new IME input event.
     70    */
     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.
     82    *
     83    * @param[in] resource A <code>PP_Resource</code> corresponding to an event.
     84    *
     85    * @return <code>PP_TRUE</code> if the given resource is a valid input event.
     86    */
     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.
     91    *
     92    * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
     93    * event.
     94    *
     95    * @return A string var representing the composition text. For non-IME input
     96    * events the return value will be an undefined var.
     97    */
     98   struct PP_Var (*GetText)(PP_Resource ime_event);
     99   /**
    100    * GetSegmentNumber() returns the number of segments in the composition text.
    101    *
    102    * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
    103    * event.
    104    *
    105    * @return The number of segments. For events other than COMPOSITION_UPDATE,
    106    * returns 0.
    107    */
    108   uint32_t (*GetSegmentNumber)(PP_Resource ime_event);
    109   /**
    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.
    118    *
    119    * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
    120    * event.
    121    *
    122    * @param[in] index An integer indicating a segment.
    123    *
    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.
    126    */
    127   uint32_t (*GetSegmentOffset)(PP_Resource ime_event, uint32_t index);
    128   /**
    129    * GetTargetSegment() returns the index of the current target segment of
    130    * composition.
    131    *
    132    * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
    133    * event.
    134    *
    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.
    138    */
    139   int32_t (*GetTargetSegment)(PP_Resource ime_event);
    140   /**
    141    * GetSelection() returns the range selected by caret in the composition text.
    142    *
    143    * @param[in] ime_event A <code>PP_Resource</code> corresponding to an IME
    144    * event.
    145    *
    146    * @param[out] start The start position of the current selection.
    147    *
    148    * @param[out] end The end position of the current selection.
    149    */
    150   void (*GetSelection)(PP_Resource ime_event, uint32_t* start, uint32_t* end);
    151 };
    152 
    153 typedef struct PPB_IMEInputEvent_Dev_0_2 PPB_IMEInputEvent_Dev;
    154 
    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);
    162 };
    163 /**
    164  * @}
    165  */
    166 
    167 #endif  /* PPAPI_C_DEV_PPB_IME_INPUT_EVENT_DEV_H_ */
    168 
    169