DALi Version 2.1.5
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-editable-control-interface.h
1 #ifndef DALI_TOOLKIT_TEXT_EDITABLE_CONTROL_INTERFACE_H
2 #define DALI_TOOLKIT_TEXT_EDITABLE_CONTROL_INTERFACE_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
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/text/input-style.h>
23 #include <dali-toolkit/public-api/controls/text-controls/input-filter-properties.h>
24
25 namespace Dali
26 {
27 class Actor;
28
29 namespace Toolkit
30 {
31 namespace Text
32 {
33 /**
34  * @brief An interface that the Text::Controller uses to notify about text changes and add decoration to the text control.
35  */
36 class EditableControlInterface
37 {
38 public:
39   /**
40    * @brief Virtual destructor.
41    */
42   virtual ~EditableControlInterface()
43   {
44   }
45
46   /**
47    * @brief Called to signal that text has been inserted.
48    */
49   virtual void TextInserted(unsigned int position, unsigned int length, const std::string& content) = 0;
50
51   /**
52    * @brief Called to signal that text has been deleted.
53    */
54   virtual void TextDeleted(unsigned int position, unsigned int length, const std::string& content) = 0;
55
56   /**
57    * @brief Called to signal that caret (cursor position) has been moved.
58    */
59   virtual void CursorPositionChanged(unsigned int oldPosition, unsigned int newPosition) = 0;
60
61   /**
62    * @brief Called to signal that text has been inserted or deleted.
63    *
64    * @param[in] immediate If true, it immediately emits the signal, if false, only emits once the signal when OnRelayout() is called next time.
65    */
66   virtual void TextChanged(bool immediate) = 0;
67
68   /**
69    * @brief Called when the number of characters to be inserted exceeds the maximum limit
70    */
71   virtual void MaxLengthReached() = 0;
72
73   /**
74    * @brief Called to signal that input style has been changed.
75    *
76    * @param[in] inputStyleMask Mask with the bits of the input style that has changed.
77    */
78   virtual void InputStyleChanged(InputStyle::Mask inputStyleMask) = 0;
79
80   /**
81    * @brief Called when the character to be inserted is filtered by the input filter.
82    *
83    * @param[in] type The filter type is ACCEPTED or REJECTED.
84    */
85   virtual void InputFiltered(Toolkit::InputFilter::Property::Type type) = 0;
86
87   /**
88    * @brief Add a decoration.
89    *
90    * @param[in] decoration The actor displaying a decoration.
91    * @param[in] needsClipping Whether the actor needs clipping.
92    */
93   virtual void AddDecoration(Actor& actor, bool needsClipping) = 0;
94
95   /**
96    * @brief Gets the color of the control.
97    *
98    * @param[out] The color of the control.
99    */
100   virtual void GetControlBackgroundColor(Vector4& color) const = 0;
101
102   /**
103    * @brief Editable status (on/off).
104    *
105    * @return true if it can be edit, else false.
106    */
107   virtual bool IsEditable() const = 0;
108
109   /**
110    * @brief Change the editable status (on/off) .
111    *
112    * @param[in] editable The editable status.
113    */
114   virtual void SetEditable(bool editable) = 0;
115
116   /**
117    * @brief Called to copy the selected text.
118    * @return The copied text.
119    */
120   virtual string CopyText() = 0;
121
122   /**
123    * @brief Called to cut the selected text.
124    * @return The cut text.
125    */
126   virtual string CutText() = 0;
127
128   /**
129    * @brief Called to paste the most recent clipboard text item into the control.
130    */
131   virtual void PasteText() = 0;
132 };
133
134 } // namespace Text
135
136 } // namespace Toolkit
137
138 } // namespace Dali
139
140 #endif // DALI_TOOLKIT_TEXT_EDITABLE_CONTROL_INTERFACE_H