Merge "Add a callback for navigation policy in web engine." into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / atspi-interfaces / text.h
1 #ifndef DALI_ADAPTOR_ATSPI_TEXT_H
2 #define DALI_ADAPTOR_ATSPI_TEXT_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 // EXTERNAL INCLUDES
21 #include <string>
22
23 // INTERNAL INCLUDES
24 #include <dali/devel-api/adaptor-framework/accessibility.h>
25 #include <dali/devel-api/atspi-interfaces/accessible.h>
26
27 namespace Dali::Accessibility
28 {
29 /**
30  * @brief Interface representing objects which can store immutable texts.
31  *
32  * @see Dali::Accessibility::EditableText
33  */
34 class DALI_ADAPTOR_API Text : public virtual Accessible
35 {
36 public:
37   /**
38    * @brief Gets stored text in given range.
39    *
40    * @param[in] startOffset The index of first character
41    * @param[in] endOffset The index of first character after the last one expected
42    *
43    * @return The substring of stored text
44    */
45   virtual std::string GetText(std::size_t startOffset, std::size_t endOffset) const = 0;
46
47   /**
48    * @brief Gets number of all stored characters.
49    *
50    * @return The number of characters
51    * @remarks This method is `CharacterCount` in DBus method.
52    */
53   virtual std::size_t GetCharacterCount() const = 0;
54
55   /**
56    * @brief Gets the cursor offset.
57    *
58    * @return Value of cursor offset
59    * @remarks This method is `CaretOffset` in DBus method.
60    */
61   virtual std::size_t GetCursorOffset() const = 0;
62
63   /**
64    * @brief Sets the cursor offset.
65    *
66    * @param[in] offset Cursor offset
67    *
68    * @return True if successful
69    * @remarks This method is `SetCaretOffset` in DBus method.
70    */
71   virtual bool SetCursorOffset(std::size_t offset) = 0;
72
73   /**
74    * @brief Gets substring of stored text truncated in concrete gradation.
75    *
76    * @param[in] offset The position in stored text
77    * @param[in] boundary The enumeration describing text gradation
78    *
79    * @return Range structure containing acquired text and offsets in original string
80    *
81    * @see Dali::Accessibility::Range
82    */
83   virtual Range GetTextAtOffset(std::size_t offset, TextBoundary boundary) const = 0;
84
85   /**
86    * @brief Gets selected text.
87    *
88    * @param[in] selectionIndex The selection index
89    * @note Currently only one selection (i.e. with index = 0) is supported
90    *
91    * @return Range structure containing acquired text and offsets in original string
92    *
93    * @remarks This method is `GetSelection` in DBus method.
94    * @see Dali::Accessibility::Range
95    */
96   virtual Range GetRangeOfSelection(std::size_t selectionIndex) const = 0;
97
98   /**
99    * @brief Removes the whole selection.
100    *
101    * @param[in] selectionIndex The selection index
102    * @note Currently only one selection (i.e. with index = 0) is supported
103    *
104    * @return bool on success, false otherwise
105    */
106   virtual bool RemoveSelection(std::size_t selectionIndex) = 0;
107
108   /**
109    * @brief Sets selected text.
110    *
111    * @param[in] selectionIndex The selection index
112    * @param[in] startOffset The index of first character
113    * @param[in] endOffset The index of first character after the last one expected
114    *
115    * @note Currently only one selection (i.e. with index = 0) is supported
116    *
117    * @return true on success, false otherwise
118    * @remarks This method is `SetSelection` in DBus method.
119    */
120   virtual bool SetRangeOfSelection(std::size_t selectionIndex, std::size_t startOffset, std::size_t endOffset) = 0;
121 };
122
123 } // namespace Dali::Accessibility
124
125 #endif // DALI_ADAPTOR_ATSPI_TEXT_H