Home | History | Annotate | Download | only in cpp
      1 // Copyright 2013 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_TEXT_INPUT_CONTROLLER_H_
      6 #define PPAPI_CPP_TEXT_INPUT_CONTROLLER_H_
      7 
      8 #include <string>
      9 
     10 #include "ppapi/c/ppb_text_input_controller.h"
     11 #include "ppapi/cpp/instance_handle.h"
     12 #include "ppapi/cpp/var.h"
     13 
     14 /// @file
     15 /// This file defines the APIs for text input handling.
     16 
     17 namespace pp {
     18 
     19 class Rect;
     20 class Instance;
     21 
     22 /// This class can be used for giving hints to the browser about the text input
     23 /// status of plugins.
     24 class TextInputController {
     25  public:
     26   /// A constructor for creating a <code>TextInputController</code>.
     27   ///
     28   /// @param[in] instance The instance with which this resource will be
     29   /// associated.
     30   explicit TextInputController(const InstanceHandle& instance);
     31 
     32   /// Destructor.
     33   ~TextInputController();
     34 
     35   /// SetTextInputType() informs the browser about the current text input mode
     36   /// of the plugin.
     37   ///
     38   /// @param[in] type The type of text input type.
     39   void SetTextInputType(PP_TextInput_Type type);
     40 
     41   /// UpdateCaretPosition() informs the browser about the coordinates of the
     42   /// text input caret area.
     43   ///
     44   /// @param[in] caret A rectangle indicating the caret area.
     45   void UpdateCaretPosition(const Rect& caret);
     46 
     47   /// CancelCompositionText() informs the browser that the current composition
     48   /// text is cancelled by the plugin.
     49   void CancelCompositionText();
     50 
     51   /// UpdateSurroundingText() informs the browser about the current text
     52   /// selection and surrounding text.
     53   ///
     54   /// @param[in] text A UTF-8 sting indicating string buffer of current input
     55   /// context.
     56   ///
     57   /// @param[in] caret A integer indicating the byte index of caret location in
     58   /// <code>text</code>.
     59   ///
     60   /// @param[in] caret A integer indicating the byte index of anchor location in
     61   /// <code>text</code>. If there is no selection, this value should be equal to
     62   /// <code>caret</code>.
     63   void UpdateSurroundingText(const Var& text,
     64                              uint32_t caret,
     65                              uint32_t anchor);
     66 
     67  private:
     68   InstanceHandle instance_;
     69 };
     70 
     71 }  // namespace pp
     72 
     73 #endif  // PPAPI_CPP_TEXT_INPUT_CONTROLLER_H_
     74