1 #ifndef __DALI_TOOLKIT_TEXT_FIELD_H__
2 #define __DALI_TOOLKIT_TEXT_FIELD_H__
5 * Copyright (c) 2017 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.
22 #include <dali-toolkit/public-api/controls/control.h>
30 namespace Internal DALI_INTERNAL
35 * @addtogroup dali_toolkit_controls_text_controls
40 * @brief A control which provides a single-line editable text field.
43 * | %Signal Name | Method | |
44 * |----------------------|--------------------------------|--------------------|
45 * | textChanged | @ref TextChangedSignal() | @SINCE_1_0.0 |
46 * | maxLengthReached | @ref MaxLengthReachedSignal() | @SINCE_1_0.0 |
47 * | inputStyleChanged | @ref InputStyleChangedSignal() | @SINCE_1_2_2 |
49 class DALI_IMPORT_API TextField : public Control
54 * @brief The start and end property ranges for this control.
59 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
60 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices @SINCE_1_0.0
64 * @brief Enumeration for the instance of properties belonging to the TextField class.
70 * @brief Enumeration for the instance of properties belonging to the TextField class.
76 * @brief The type or rendering e.g. bitmap-based.
77 * @details Name "renderingBackend", type Property::INTEGER.
80 RENDERING_BACKEND = PROPERTY_START_INDEX,
83 * @brief The text to display in UTF-8 format.
84 * @details Name "text", type Property::STRING.
90 * @brief The text to display when the TextField is empty and inactive.
91 * @details Name "placeholderText", type Property::STRING.
97 * @brief The text to display when the TextField is empty with key-input focus.
98 * @details Name "placeholderTextFocused", type Property::STRING.
101 PLACEHOLDER_TEXT_FOCUSED,
104 * @brief The requested font family.
105 * @details Name "fontFamily", type Property::STRING.
111 * @brief The requested font style
112 * @details Name "fontStyle", type Property::STRING or Property::MAP.
118 * @brief The size of font in points.
119 * @details Name "pointSize", type Property::FLOAT.
120 * (Conversion from Pixel size to Point size : Point size = Pixel size * 72 / DPI).
126 * @brief The maximum number of characters that can be inserted.
127 * @details Name "maxLength", type Property::INTEGER.
133 * @brief Specifies how the text is truncated when it does not fit.
134 * @details Name "exceedPolicy", type Property::INTEGER.
140 * @brief The line horizontal alignment.
141 * @details Name "horizontalAlignment", type Property::STRING.
142 * Values "BEGIN", "CENTER", "END".
145 HORIZONTAL_ALIGNMENT,
148 * @brief The line vertical alignment.
149 * @details Name "verticalAlignment", type Property::STRING.
150 * Values "TOP", "CENTER", "BOTTOM".
156 * @brief The text color.
157 * @details Name "textColor", type Property::VECTOR4.
163 * @brief The placeholder-text color.
164 * @details Name "placeholderTextColor", type Property::VECTOR4.
167 PLACEHOLDER_TEXT_COLOR,
170 * @DEPRECATED_1_1.37 Use SHADOW instead.
171 * @brief The drop shadow offset 0 indicates no shadow.
172 * @details Name "shadowOffset", type Property::VECTOR2.
178 * @DEPRECATED_1_1.37 Use SHADOW instead.
179 * @brief The color of a drop shadow.
180 * @details Name "shadowColor", type Property::VECTOR4.
186 * @brief The color to apply to the primary cursor.
187 * @details Name "primaryCursorColor", type Property::VECTOR4.
190 PRIMARY_CURSOR_COLOR,
193 * @brief The color to apply to the secondary cursor.
194 * @details Name "secondaryCursorColor", type Property::VECTOR4.
197 SECONDARY_CURSOR_COLOR,
200 * @brief Whether the cursor should blink or not.
201 * @details Name "enableCursorBlink", type Property::BOOLEAN.
207 * @brief The time interval in seconds between cursor on/off states.
208 * @details Name "cursorBlinkInterval", type Property::FLOAT.
211 CURSOR_BLINK_INTERVAL,
214 * @brief The cursor will stop blinking after this number of seconds (if non-zero)
215 * @details Name "cursorBlinkDuration", type Property::FLOAT.
218 CURSOR_BLINK_DURATION,
221 * @brief The cursor width.
222 * @details Name "cursorWidth", type Property::INTEGER.
228 * @brief The image to display for the grab handle.
229 * @details Name "grabHandleImage", type Property::STRING.
235 * @brief The image to display when the grab handle is pressed
236 * @details Name "grabHandlePressedImage", type Property::STRING.
239 GRAB_HANDLE_PRESSED_IMAGE,
242 * @brief Horizontal scrolling will occur if the cursor is this close to the control border.
243 * @details Name "scrollThreshold", type Property::FLOAT.
249 * @brief The scroll speed in pixels per second.
250 * @details Name "scrollSpeed", type Property::FLOAT.
256 * @brief The image to display for the left selection handle.
257 * @details Name "selectionHandleImageLeft", type Property::MAP.
260 SELECTION_HANDLE_IMAGE_LEFT,
263 * @brief The image to display for the right selection handle.
264 * @details Name "selectionHandleImageRight", type Property::MAP.
267 SELECTION_HANDLE_IMAGE_RIGHT,
270 * @brief The image to display when the left selection handle is pressed.
271 * @details Name "selectionHandlePressedImageLeft", type Property::MAP.
274 SELECTION_HANDLE_PRESSED_IMAGE_LEFT,
277 * @brief The image to display when the right selection handle is pressed.
278 * @details Name "selectionHandlePressedImageRight", type Property::MAP.
281 SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,
284 * @brief The image to display for the left selection handle marker.
285 * @details Name "selectionHandleMarkerImageLeft", type Property::MAP.
288 SELECTION_HANDLE_MARKER_IMAGE_LEFT,
291 * @brief The image to display for the right selection handle marker.
292 * @details Name "selectionHandleMarkerImageRight", type Property::MAP.
295 SELECTION_HANDLE_MARKER_IMAGE_RIGHT,
298 * @brief The color of the selection highlight.
299 * @details Name "selectionHighlightColor", type Property::VECTOR4.
302 SELECTION_HIGHLIGHT_COLOR,
305 * @brief The decorations (handles etc) will positioned within this area on-screen.
306 * @details Name "decorationBoundingBox", type Property::RECTANGLE.
309 DECORATION_BOUNDING_BOX,
312 * @brief The settings to relating to the System's Input Method, Key and Value.
313 * @details Name "inputMethodSettings", type Property::MAP.
316 INPUT_METHOD_SETTINGS,
319 * @brief The color of the new input text.
320 * @details Name "inputColor", type Property::VECTOR4.
326 * @brief Whether the mark-up processing is enabled.
327 * @details Name "enableMarkup", type Property::BOOLEAN.
333 * @brief The font's family of the new input text.
334 * @details Name "inputFontFamily", type Property::STRING.
340 * @brief The font's style of the new input text.
341 * @details Name "inputFontStyle", type Property::MAP.
347 * @brief The font's size of the new input text in points.
348 * @details Name "inputPointSize", type Property::FLOAT.
354 * @brief The default underline parameters.
355 * @details Name "underline", type Property::MAP.
361 * @brief The underline parameters of the new input text.
362 * @details Name "inputUnderline", type Property::MAP.
368 * @brief The default shadow parameters.
369 * @details Name "shadow", type Property::MAP.
375 * @brief The shadow parameters of the new input text.
376 * @details Name "inputShadow", type Property::MAP.
382 * @brief The default emboss parameters.
383 * @details Name "emboss", type Property::MAP.
389 * @brief The emboss parameters of the new input text.
390 * @details Name "inputEmboss", type Property::MAP.
396 * @brief The default outline parameters.
397 * @details Name "outline", type Property::MAP.
403 * @brief The outline parameters of the new input text.
404 * @details Name "inputOutline", type Property::MAP.
410 * @brief Hides the input characters and instead shows a default character for password or pin entry.
411 * @details Name "hiddenInputSettings", type Property::MAP.
414 * @see HiddenInput::Property
416 HIDDEN_INPUT_SETTINGS,
419 * @brief The size of font in pixels.
420 * @details Name "pixelSize", type Property::FLOAT.
421 * Conversion from Point size to Pixel size:
422 * Pixel size = Point size * DPI / 72
428 * @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
429 * @details Name "enableSelection", type Property::BOOLEAN.
435 * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
436 * @details Name "placeholder", type Property::MAP.
439 * Property::Map propertyMap;
440 * propertyMap["placeholderText"] = "Setting Placeholder Text";
441 * propertyMap["placeholderTextFocused"] = "Setting Placeholder Text Focused";
442 * propertyMap["placeholderColor"] = Color::RED;
443 * propertyMap["placeholderFontFamily"] = "Arial";
444 * propertyMap["placeholderPointSize"] = 12.0f;
445 * propertyMap["placeholderEllipsis"] = true;
447 * Property::Map fontStyleMap;
448 * fontStyleMap.Insert( "weight", "bold" );
449 * fontStyleMap.Insert( "width", "condensed" );
450 * fontStyleMap.Insert( "slant", "italic" );
451 * propertyMap["placeholderFontStyle"] = fontStyleMap;
453 * field.SetProperty( TextField::Property::PLACEHOLDER, propertyMap );
460 * @brief Whether we should show the ellipsis if it is required.
461 * @details Name "ellipsis", type Property::BOOLEAN.
463 * @note PLACEHOLDER map is used to add ellipsis to placeholder text.
470 * @brief Enumeration for specifying how the text is truncated when it does not fit.
472 * The default value is \e EXCEED_POLICY_CLIP.
477 EXCEED_POLICY_ORIGINAL, ///< The text will be display at original size, and may exceed the TextField boundary. @SINCE_1_0.0
478 EXCEED_POLICY_CLIP ///< The end of text will be clipped to fit within the TextField. @SINCE_1_0.0
482 * @brief Mask used by the signal InputStyleChangedSignal(). Notifies which parameters of the input style have changed.
489 * @brief Mask used by the signal InputStyleChangedSignal().
495 NONE = 0x0000, ///< @SINCE_1_2_2
496 COLOR = 0x0001, ///< @SINCE_1_2_2
497 FONT_FAMILY = 0x0002, ///< @SINCE_1_2_2
498 POINT_SIZE = 0x0004, ///< @SINCE_1_2_2
499 FONT_STYLE = 0x0008, ///< @SINCE_1_2_2
500 UNDERLINE = 0x0010, ///< @SINCE_1_2_2
501 SHADOW = 0x0020, ///< @SINCE_1_2_2
502 EMBOSS = 0x0040, ///< @SINCE_1_2_2
503 OUTLINE = 0x0080 ///< @SINCE_1_2_2
510 * @brief Text changed signal type.
513 typedef Signal<void ( TextField ) > TextChangedSignalType;
516 * @brief Max Characters Exceed signal type.
519 typedef Signal<void ( TextField ) > MaxLengthReachedSignalType;
522 * @brief Input Style changed signal type.
525 typedef Signal<void ( TextField, InputStyle::Mask ) > InputStyleChangedSignalType;
528 * @brief Creates the TextField control.
530 * @return A handle to the TextField control
532 static TextField New();
535 * @brief Creates an empty handle.
541 * @brief Copy constructor.
544 * @param[in] handle The handle to copy from
546 TextField( const TextField& handle );
549 * @brief Assignment operator.
552 * @param[in] handle The handle to copy from
553 * @return A reference to this
555 TextField& operator=( const TextField& handle );
560 * This is non-virtual since derived Handle types must not contain data or virtual methods.
566 * @brief Downcasts a handle to TextField.
568 * If the BaseHandle points is a TextField, the downcast returns a valid handle.
569 * If not, the returned handle is left empty.
572 * @param[in] handle Handle to an object
573 * @return Handle to a TextField or an empty handle
575 static TextField DownCast( BaseHandle handle );
580 * @brief This signal is emitted when the text changes.
582 * A callback of the following type may be connected:
584 * void YourCallbackName( TextField textField );
587 * @return The signal to connect to.
589 TextChangedSignalType& TextChangedSignal();
592 * @brief This signal is emitted when inserted text exceeds the maximum character limit.
594 * A callback of the following type may be connected:
596 * void YourCallbackName( TextField textField );
599 * @return The signal to connect to
601 MaxLengthReachedSignalType& MaxLengthReachedSignal();
604 * @brief This signal is emitted when the input style is updated as a consequence of a change in the cursor position.
605 * i.e. The signal is not emitted when the input style is updated through the property system.
607 * A callback of the following type may be connected. The @p mask parameter notifies which parts of the style have changed.
609 * void YourCallbackName( TextField textField, TextField::InputStyle::Mask mask );
613 * @return The signal to connect to
615 InputStyleChangedSignalType& InputStyleChangedSignal();
617 public: // Not intended for application developers
620 * @brief Creates a handle using the Toolkit::Internal implementation.
623 * @param[in] implementation The Control implementation
625 DALI_INTERNAL TextField( Internal::TextField& implementation );
628 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
631 * @param[in] internal A pointer to the internal CustomActor
633 explicit DALI_INTERNAL TextField( Dali::Internal::CustomActor* internal );
639 } // namespace Toolkit
643 #endif // __DALI_TOOLKIT_TEXT_FIELD_H__