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