1 #ifndef DALI_TOOLKIT_TEXT_FIELD_DEVEL_H
2 #define DALI_TOOLKIT_TEXT_FIELD_DEVEL_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali/devel-api/adaptor-framework/input-method-context.h>
24 #include <dali-toolkit/public-api/controls/text-controls/input-filter-properties.h>
25 #include <dali-toolkit/public-api/controls/text-controls/text-field.h>
31 namespace DevelTextField
37 TEXT = Dali::Toolkit::TextField::Property::TEXT,
38 PLACEHOLDER_TEXT = Dali::Toolkit::TextField::Property::PLACEHOLDER_TEXT,
39 PLACEHOLDER_TEXT_FOCUSED = Dali::Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED,
40 FONT_FAMILY = Dali::Toolkit::TextField::Property::FONT_FAMILY,
41 FONT_STYLE = Dali::Toolkit::TextField::Property::FONT_STYLE,
42 POINT_SIZE = Dali::Toolkit::TextField::Property::POINT_SIZE,
43 MAX_LENGTH = Dali::Toolkit::TextField::Property::MAX_LENGTH,
44 EXCEED_POLICY = Dali::Toolkit::TextField::Property::EXCEED_POLICY,
45 HORIZONTAL_ALIGNMENT = Dali::Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT,
46 VERTICAL_ALIGNMENT = Dali::Toolkit::TextField::Property::VERTICAL_ALIGNMENT,
47 TEXT_COLOR = Dali::Toolkit::TextField::Property::TEXT_COLOR,
48 PLACEHOLDER_TEXT_COLOR = Dali::Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR,
49 PRIMARY_CURSOR_COLOR = Dali::Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR,
50 SECONDARY_CURSOR_COLOR = Dali::Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR,
51 ENABLE_CURSOR_BLINK = Dali::Toolkit::TextField::Property::ENABLE_CURSOR_BLINK,
52 CURSOR_BLINK_INTERVAL = Dali::Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL,
53 CURSOR_BLINK_DURATION = Dali::Toolkit::TextField::Property::CURSOR_BLINK_DURATION,
54 CURSOR_WIDTH = Dali::Toolkit::TextField::Property::CURSOR_WIDTH,
55 GRAB_HANDLE_IMAGE = Dali::Toolkit::TextField::Property::GRAB_HANDLE_IMAGE,
56 GRAB_HANDLE_PRESSED_IMAGE = Dali::Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE,
57 SCROLL_THRESHOLD = Dali::Toolkit::TextField::Property::SCROLL_THRESHOLD,
58 SCROLL_SPEED = Dali::Toolkit::TextField::Property::SCROLL_SPEED,
59 SELECTION_HANDLE_IMAGE_LEFT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT,
60 SELECTION_HANDLE_IMAGE_RIGHT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT,
61 SELECTION_HANDLE_PRESSED_IMAGE_LEFT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT,
62 SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,
63 SELECTION_HANDLE_MARKER_IMAGE_LEFT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT,
64 SELECTION_HANDLE_MARKER_IMAGE_RIGHT = Dali::Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT,
65 SELECTION_HIGHLIGHT_COLOR = Dali::Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR,
66 DECORATION_BOUNDING_BOX = Dali::Toolkit::TextField::Property::DECORATION_BOUNDING_BOX,
67 INPUT_METHOD_SETTINGS = Dali::Toolkit::TextField::Property::INPUT_METHOD_SETTINGS,
68 INPUT_COLOR = Dali::Toolkit::TextField::Property::INPUT_COLOR,
69 ENABLE_MARKUP = Dali::Toolkit::TextField::Property::ENABLE_MARKUP,
70 INPUT_FONT_FAMILY = Dali::Toolkit::TextField::Property::INPUT_FONT_FAMILY,
71 INPUT_FONT_STYLE = Dali::Toolkit::TextField::Property::INPUT_FONT_STYLE,
72 INPUT_POINT_SIZE = Dali::Toolkit::TextField::Property::INPUT_POINT_SIZE,
73 UNDERLINE = Dali::Toolkit::TextField::Property::UNDERLINE,
74 INPUT_UNDERLINE = Dali::Toolkit::TextField::Property::INPUT_UNDERLINE,
75 SHADOW = Dali::Toolkit::TextField::Property::SHADOW,
76 INPUT_SHADOW = Dali::Toolkit::TextField::Property::INPUT_SHADOW,
77 EMBOSS = Dali::Toolkit::TextField::Property::EMBOSS,
78 INPUT_EMBOSS = Dali::Toolkit::TextField::Property::INPUT_EMBOSS,
79 OUTLINE = Dali::Toolkit::TextField::Property::OUTLINE,
80 INPUT_OUTLINE = Dali::Toolkit::TextField::Property::INPUT_OUTLINE,
81 HIDDEN_INPUT_SETTINGS = Dali::Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS,
82 PIXEL_SIZE = Dali::Toolkit::TextField::Property::PIXEL_SIZE,
83 ENABLE_SELECTION = Dali::Toolkit::TextField::Property::ENABLE_SELECTION,
84 PLACEHOLDER = Dali::Toolkit::TextField::Property::PLACEHOLDER,
85 ELLIPSIS = Dali::Toolkit::TextField::Property::ELLIPSIS,
88 * @brief Enables Text selection using Shift key.
89 * @details Name "enableShiftSelection", type Property::BOOLEAN.
91 ENABLE_SHIFT_SELECTION = ELLIPSIS + 1,
94 * @brief Enables the grab handles for text selection.
95 * @details Name "enableGrabHandle", type Property::BOOLEAN.
96 * @note The default value is true, which means the grab handles are enabled by default.
98 ENABLE_GRAB_HANDLE = ELLIPSIS + 2,
101 * @brief Modifies the default text alignment to match the direction of the system language.
102 * @details Name "matchSystemLanguageDirection", type (Property::BOOLEAN), Read/Write
103 * @note The default value is false
105 MATCH_SYSTEM_LANGUAGE_DIRECTION = ELLIPSIS + 3,
108 * @brief Enables the grab handle popup for text selection.
109 * @details Name "enableGrabHandlePopup", type Property::BOOLEAN.
110 * @note The default value is true, which means the grab handle popup is enabled by default.
112 ENABLE_GRAB_HANDLE_POPUP = ELLIPSIS + 4,
115 * @brief The default text background parameters.
116 * @details Name "textBackground", type Property::VECTOR4.
117 * @note Use "textBackground" as property name to avoid conflict with Control's "background" property.
118 * @note The default value is Color::TRANSPARENT.
120 BACKGROUND = ELLIPSIS + 5,
123 * @brief The selected text in UTF-8 format.
124 * @details Name "selectedText", type Property::STRING.
125 * @note This property is read-only.
127 SELECTED_TEXT = ELLIPSIS + 6,
130 * @brief The type or rendering e.g. bitmap-based.
131 * @details Name "renderingBackend", type Property::INTEGER.
133 RENDERING_BACKEND = ELLIPSIS + 7,
136 * @brief The selected text start position.
137 * @details Name "selectedTextStart", type Property::INTEGER.
142 * @brief The selected text range end position.
143 * @details Name "selectedTextEnd", type Property::INTEGER.
148 * @brief The Editable state of control.
149 * @details Name "enableEditing", type Property::BOOLEAN.
154 * @brief The font size scale.
155 * @details name "fontSizeScale", type Property::FLOAT.
156 * @note The default value is 1.0 which does nothing.
157 * The given font size scale value is used for multiplying the specified font size before querying fonts.
159 * e.g. The rendering results of both cases are same.
160 * - fontSize: 15pt, fontSizeScale: 1.0
161 * - fontSize: 10pt, fontSizeScale: 1.5
166 * @brief The position for primary cursor.
167 * @details Name "primaryCursorPosition", type Property::INTEGER.
169 PRIMARY_CURSOR_POSITION,
172 * @brief The color of the grab color.
173 * @details Name "grabHandleColor", type Property::VECTOR4.
178 * @brief The input filter
179 * @details Name "inputFilter", type Property::MAP.
181 * The inputFilter map contains the following keys:
183 * | %Property Name | Type | Required | Description |
184 * |----------------------|----------|----------|---------------------------------------------------------------------------------------------------------------------|
185 * | accepted | STRING | No | A regular expression in the set of characters to be accepted by the inputFilter (the default value is empty string) |
186 * | rejected | STRING | No | A regular expression in the set of characters to be rejected by the inputFilter (the default value is empty string) |
189 * The character set must follow the regular expression rules.
190 * Behaviour can not be guaranteed for incorrect grammars.
191 * Refer the link below for detailed rules.
192 * The functions in std::regex library use the ECMAScript grammar:
193 * http://cplusplus.com/reference/regex/ECMAScript/
195 * You can use enums instead of "accepted" and "rejected" strings.
196 * @see Dali::Toolkit::InputFilter::Property::Type
200 * Property::Map filter;
201 * filter[InputFilter::Property::ACCEPTED] = "[\\d]"; // accept whole digits
202 * filter[InputFilter::Property::REJECTED] = "[0-5]"; // reject 0, 1, 2, 3, 4, 5
204 * field.SetProperty(DevelTextField::Property::INPUT_FILTER, filter); // acceptable inputs are 6, 7, 8, 9
210 } // namespace Property
213 * @brief Return the input method context of TextField.
215 * @param[in] textField The instance of TextField.
216 * @return InputMethodContext instance.
218 DALI_TOOLKIT_API InputMethodContext GetInputMethodContext(TextField textField);
221 * @brief Anchor clicked signal type.
224 * - const char* : href of clicked anchor.
225 * - uint32_t : length of href.
227 using AnchorClickedSignalType = Signal<void(TextField, const char*, uint32_t)>;
230 * @brief This signal is emitted when the anchor is clicked.
232 * A callback of the following type may be connected:
234 * void YourCallbackName(TextField textField, const char* href, uint32_t hrefLength);
236 * @param[in] textField The instance of TextField.
237 * @return The signal to connect to.
239 DALI_TOOLKIT_API AnchorClickedSignalType& AnchorClickedSignal(TextField textField);
242 * @brief Input filtered signal type.
244 using InputFilteredSignalType = Signal<void(TextField, Toolkit::InputFilter::Property::Type)>;
247 * @brief This signal is emitted when the character to be inserted is filtered by the input filter.
249 * A callback of the following type may be connected:
251 * void YourCallbackName(TextField textField, Toolkit::InputFilter::Property::Type type);
253 * DevelTextField::InputFilteredSignal(textField).Connect(this, &OnInputFiltered);
255 * void OnInputFiltered(TextField textField, InputFilter::Property::Type type)
257 * if (type == InputFilter::Property::ACCEPTED)
259 * // If the input has been filtered with an accepted filter, the type is ACCEPTED.
261 * else if (type == InputFilter::Property::REJECTED)
263 * // If the input has been filtered with an rejected filter, the type is REJECTED.
267 * @param[in] textField The instance of TextField.
268 * @return The signal to connect to.
270 DALI_TOOLKIT_API InputFilteredSignalType& InputFilteredSignal(TextField textField);
273 * @brief Select the whole text of TextField.
275 * @param[in] textField The instance of TextField.
277 DALI_TOOLKIT_API void SelectWholeText(TextField textField);
280 * @brief Unselect the whole text of TextField.
282 * @param[in] textField The instance of TextField.
284 DALI_TOOLKIT_API void SelectNone(TextField textField);
286 } // namespace DevelTextField
288 } // namespace Toolkit
292 #endif // DALI_TOOLKIT_TEXT_FIELD_DEVEL_H