1 #ifndef DALI_TOOLKIT_TEXT_EDITOR_H
2 #define DALI_TOOLKIT_TEXT_EDITOR_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.
22 #include <dali-toolkit/public-api/controls/control.h>
28 namespace Internal DALI_INTERNAL
33 * @addtogroup dali_toolkit_controls_text_controls
38 * @brief A control which provides a multi-line editable text editor.
41 * | %Signal Name | Method | |
42 * |----------------------|--------------------------------|--------------------|
43 * | textChanged | @ref TextChangedSignal() | @SINCE_1_1.37 |
44 * | inputStyleChanged | @ref InputStyleChangedSignal() | @SINCE_1_2_2 |
47 class DALI_TOOLKIT_API TextEditor : public Control
51 * @brief Enumeration for the start and end property ranges for this control.
56 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
57 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
61 * @brief Enumeration for the instance of properties belonging to the TextEditor class.
67 * @brief Enumeration for the instance of properties belonging to the TextEditor class.
73 * @brief The text to display in UTF-8 format.
74 * @details Name "text", type Property::STRING.
77 TEXT = PROPERTY_START_INDEX,
80 * @brief The text color.
81 * @details Name "textColor", type Property::VECTOR4.
87 * @brief The requested font family.
88 * @details Name "fontFamily", type Property::STRING.
94 * @brief The requested font style.
95 * @details Name "fontStyle", type Property::STRING or Property::MAP.
101 * @brief The size of font in points.
102 * @details Name "pointSize", type Property::FLOAT.
103 * Conversion from Pixel size to Point size : Point size = Pixel size * 72 / DPI.
109 * @brief The text horizontal alignment.
110 * @details Name "horizontalAlignment", type Property::STRING or type HorizontalAlignment::Type (Property::INTEGER)
111 * Values "BEGIN" "CENTER" "END".
112 * @note Return type is Property::STRING
115 HORIZONTAL_ALIGNMENT,
118 * @brief Vertical scrolling will occur if the cursor is this close to the control border.
119 * @details Name "scrollThreshold", type Property::FLOAT.
125 * @brief The scroll speed in pixels per second.
126 * @details Name "scrollSpeed", type Property::FLOAT.
132 * @brief The color to apply to the primary cursor.
133 * @details Name "primaryCursorColor", type Property::VECTOR4.
136 PRIMARY_CURSOR_COLOR,
139 * @brief The color to apply to the secondary cursor.
140 * @details Name "secondaryCursorColor", type Property::VECTOR4.
143 SECONDARY_CURSOR_COLOR,
146 * @brief Whether the cursor should blink or not.
147 * @details Name "enableCursorBlink", type Property::BOOLEAN.
153 * @brief The time interval in seconds between cursor on/off states.
154 * @details Name "cursorBlinkInterval", type Property::FLOAT.
157 CURSOR_BLINK_INTERVAL,
160 * @brief The cursor will stop blinking after this number of seconds (if non-zero).
161 * @details Name "cursorBlinkDuration", type Property::FLOAT.
164 CURSOR_BLINK_DURATION,
167 * @brief The cursor width.
168 * @details Name "cursorWidth", type Property::INTEGER.
174 * @brief The image to display for the grab handle.
175 * @details Name "grabHandleImage", type Property::STRING.
181 * @brief The image to display when the grab handle is pressed.
182 * @details Name "grabHandlePressedImage", type Property::STRING.
185 GRAB_HANDLE_PRESSED_IMAGE,
188 * @brief The image to display for the left selection handle.
189 * @details Name "selectionHandleImageLeft", type Property::MAP.
192 SELECTION_HANDLE_IMAGE_LEFT,
195 * @brief The image to display for the right selection handle.
196 * @details Name "selectionHandleImageRight", type Property::MAP.
199 SELECTION_HANDLE_IMAGE_RIGHT,
202 * @brief The image to display when the left selection handle is pressed.
203 * @details Name "selectionHandlePressedImageLeft", type Property::MAP.
206 SELECTION_HANDLE_PRESSED_IMAGE_LEFT,
209 * @brief The image to display when the right selection handle is pressed.
210 * @details Name "selectionHandlePressedImageRight", type Property::MAP.
213 SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,
216 * @brief The image to display for the left selection handle marker.
217 * @details Name "selectionHandleMarkerImageLeft", type Property::MAP.
220 SELECTION_HANDLE_MARKER_IMAGE_LEFT,
223 * @brief The image to display for the right selection handle marker.
224 * @details Name "selectionHandleMarkerImageRight", type Property::MAP.
227 SELECTION_HANDLE_MARKER_IMAGE_RIGHT,
230 * @brief The color of the selection highlight.
231 * @details Name "selectionHighlightColor", type Property::VECTOR4.
234 SELECTION_HIGHLIGHT_COLOR,
237 * @brief The decorations (handles etc) will positioned within this area on-screen.
238 * @details Name "decorationBoundingBox", type Property::RECTANGLE.
241 DECORATION_BOUNDING_BOX,
244 * @brief Whether the mark-up processing is enabled.
245 * @details Name "enableMarkup", type Property::BOOLEAN.
251 * @brief The color of the new input text.
252 * @details Name "inputColor", type Property::VECTOR4.
258 * @brief The font's family of the new input text.
259 * @details Name "inputFontFamily", type Property::STRING.
265 * @brief The font's style of the new input text.
266 * @details Name "inputFontStyle", type Property::MAP.
272 * @brief The font's size of the new input text in points.
273 * @details Name "inputPointSize", type Property::FLOAT.
279 * @brief The default extra space between lines in points.
280 * @details Name "lineSpacing", type Property::FLOAT.
286 * @brief The extra space between lines in points.
287 * @details Name "inputLineSpacing", type Property::FLOAT.
289 * @note This affects the whole paragraph where the new input text is inserted.
294 * @copydoc Dali::Toolkit::TextLabel::Property::UNDERLINE
299 * @brief The underline parameters of the new input text.
300 * @details Name "inputUnderline", type Property::MAP.
306 * @copydoc Dali::Toolkit::TextLabel::Property::SHADOW
311 * @brief The shadow parameters of the new input text.
312 * @details Name "inputShadow", type Property::MAP.
318 * @brief The default emboss parameters.
319 * @details Name "emboss", type Property::MAP.
325 * @brief The emboss parameters of the new input text.
326 * @details Name "inputEmboss", type Property::MAP.
332 * @copydoc Dali::Toolkit::TextLabel::Property::OUTLINE
337 * @brief The outline parameters of the new input text.
338 * @details Name "inputOutline", type Property::MAP.
344 * @brief Enable or disable the smooth scroll animation.
345 * @details Name "smoothScroll", type Property::BOOLEAN.
351 * @brief Sets the duration of smooth scroll animation.
352 * @details Name "smoothScrollDuration", type Property::FLOAT.
355 SMOOTH_SCROLL_DURATION,
358 * @brief Enable or disable the scroll bar.
359 * @details Name "enableScrollBar", type Property::BOOLEAN.
365 * @brief Sets the duration of scroll bar to show.
366 * @details Name "scrollBarShowDuration", type Property::FLOAT.
369 SCROLL_BAR_SHOW_DURATION,
372 * @brief Sets the duration of scroll bar to fade out.
373 * @details Name "scrollBarFadeDuration", type Property::FLOAT.
376 SCROLL_BAR_FADE_DURATION,
379 * @brief The size of font in pixels.
380 * @details Name "pixelSize", type Property::FLOAT.
381 * Conversion from Point size to Pixel size:
382 * Pixel size = Point size * DPI / 72
388 * @brief The line count of text.
389 * @details Name "lineCount", type Property::INTEGER.
391 * @note This property is read-only.
396 * @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
397 * @details Name "enableSelection", type Property::BOOLEAN.
403 * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
404 * @details Name "placeholder", type Property::MAP.
407 * Property::Map propertyMap;
408 * propertyMap["placeholderText"] = "Setting Placeholder Text";
409 * propertyMap["placeholderTextFocused"] = "Setting Placeholder Text Focused";
410 * propertyMap["placeholderColor"] = Color::RED;
411 * propertyMap["placeholderFontFamily"] = "Arial";
412 * propertyMap["placeholderPointSize"] = 12.0f;
414 * Property::Map fontStyleMap;
415 * fontStyleMap.Insert( "weight", "bold" );
416 * fontStyleMap.Insert( "width", "condensed" );
417 * fontStyleMap.Insert( "slant", "italic" );
418 * propertyMap["placeholderFontStyle"] = fontStyleMap;
420 * editor.SetProperty( TextEditor::Property::PLACEHOLDER, propertyMap );
428 * @brief Line wrap mode when text lines are greater than the layout width.
429 * @details Name "lineWrapMode", type Text::LineWrap::Mode (Text::Property::INTEGER) or Property::STRING.
431 * @note Default is Text::LineWrap::WORD.
432 * @note Return type is Text::LineWrap::Mode (Text::Property::INTEGER).
433 * @see Text::LineWrap
440 * @brief Mask used by the signal InputStyleChangedSignal(). Notifies which parameters of the input style have changed.
447 * @brief Enumeration for mask used by the signal InputStyleChangedSignal().
452 NONE = 0x0000, ///< @SINCE_1_2_2
453 COLOR = 0x0001, ///< @SINCE_1_2_2
454 FONT_FAMILY = 0x0002, ///< @SINCE_1_2_2
455 POINT_SIZE = 0x0004, ///< @SINCE_1_2_2
456 FONT_STYLE = 0x0008, ///< @SINCE_1_2_2
457 LINE_SPACING = 0x0010, ///< @SINCE_1_2_2
458 UNDERLINE = 0x0020, ///< @SINCE_1_2_2
459 SHADOW = 0x0040, ///< @SINCE_1_2_2
460 EMBOSS = 0x0080, ///< @SINCE_1_2_2
461 OUTLINE = 0x0100, ///< @SINCE_1_2_2
462 STRIKETHROUGH = 0x0200,
467 * @brief Enumerations for the type of scrolling.
469 * @see ScrollStateChangedSignal()
474 * @brief Enumerations for the type of scrolling.
476 * @see ScrollStateChangedSignal()
480 STARTED, ///< Scrolling has started. @SINCE_1_2.60
481 FINISHED ///< Scrolling has finished. @SINCE_1_2.60
488 * @brief Text changed signal type.
491 typedef Signal<void(TextEditor)> TextChangedSignalType;
494 * @brief Input Style changed signal type.
497 typedef Signal<void(TextEditor, InputStyle::Mask)> InputStyleChangedSignalType;
500 * @brief Scroll state changed signal type.
503 typedef Signal<void(TextEditor, Scroll::Type)> ScrollStateChangedSignalType;
506 * @brief Creates the TextEditor control.
509 * @return A handle to the TextEditor control
515 * @brief Creates an empty handle.
522 * @brief Copy constructor.
525 * @param[in] handle The handle to copy from
527 TextEditor(const TextEditor& handle);
530 * @brief Move constructor
533 * @param[in] rhs A reference to the moved handle
535 TextEditor(TextEditor&& rhs);
538 * @brief Assignment operator.
541 * @param[in] handle The handle to copy from
542 * @return A reference to this
544 TextEditor& operator=(const TextEditor& handle);
547 * @brief Move assignment
550 * @param[in] rhs A reference to the moved handle
551 * @return A reference to this
553 TextEditor& operator=(TextEditor&& rhs);
558 * This is non-virtual since derived Handle types must not contain data or virtual methods.
564 * @brief Downcasts a handle to TextEditor.
566 * If the BaseHandle points is a TextEditor, the downcast returns a valid handle.
567 * If not, the returned handle is left empty.
570 * @param[in] handle Handle to an object
571 * @return Handle to a TextEditor or an empty handle
574 DownCast(BaseHandle handle);
579 * @brief This signal is emitted when the text changes.
581 * A callback of the following type may be connected:
583 * void YourCallbackName( TextEditor textEditor );
587 * @return The signal to connect to
589 TextChangedSignalType&
593 * @brief This signal is emitted when the input style is updated as a consequence of a change in the cursor position.
594 * i.e. The signal is not emitted when the input style is updated through the property system.
596 * A callback of the following type may be connected. The @p mask parameter notifies which parts of the style have changed.
598 * void YourCallbackName( TextEditor textEditor, TextEditor::InputStyle::Mask mask );
602 * @return The signal to connect to
604 InputStyleChangedSignalType&
605 InputStyleChangedSignal();
608 * @brief This signal is emitted when TextEditor scrolling is started or finished.
610 * A callback of the following type may be connected:
612 * void YourCallbackName( Scroll::Type type );
614 * type: Whether the scrolling is started or finished.
617 * @return The signal to connect to
619 ScrollStateChangedSignalType&
620 ScrollStateChangedSignal();
622 public: // Not intended for application developers
625 * @brief Creates a handle using the Toolkit::Internal implementation.
628 * @param[in] implementation The Control implementation
631 TextEditor(Internal::TextEditor& implementation);
634 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
637 * @param[in] internal A pointer to the internal CustomActor
639 explicit DALI_INTERNAL
640 TextEditor(Dali::Internal::CustomActor* internal);
647 } // namespace Toolkit
651 #endif // DALI_TOOLKIT_TEXT_EDITOR_H