1 #ifndef DALI_TOOLKIT_TEXT_EDITOR_H
2 #define DALI_TOOLKIT_TEXT_EDITOR_H
5 * Copyright (c) 2019 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 multi-line editable text editor.
43 * | %Signal Name | Method | |
44 * |----------------------|--------------------------------|--------------------|
45 * | textChanged | @ref TextChangedSignal() | @SINCE_1_1.37 |
46 * | inputStyleChanged | @ref InputStyleChangedSignal() | @SINCE_1_2_2 |
49 class DALI_TOOLKIT_API TextEditor : public Control
54 * @brief Enumeration for the start and end property ranges for this control.
59 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
60 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
64 * @brief Enumeration for the instance of properties belonging to the TextEditor class.
70 * @brief Enumeration for the instance of properties belonging to the TextEditor 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 color.
91 * @details Name "textColor", type Property::VECTOR4.
97 * @brief The requested font family.
98 * @details Name "fontFamily", type Property::STRING.
104 * @brief The requested font style.
105 * @details Name "fontStyle", type Property::STRING or Property::MAP.
111 * @brief The size of font in points.
112 * @details Name "pointSize", type Property::FLOAT.
113 * Conversion from Pixel size to Point size : Point size = Pixel size * 72 / DPI.
119 * @brief The text horizontal alignment.
120 * @details Name "horizontalAlignment", type Property::STRING or type HorizontalAlignment::Type (Property::INTEGER)
121 * Values "BEGIN" "CENTER" "END".
122 * @note Return type is Property::STRING
125 HORIZONTAL_ALIGNMENT,
128 * @brief Vertical scrolling will occur if the cursor is this close to the control border.
129 * @details Name "scrollThreshold", type Property::FLOAT.
135 * @brief The scroll speed in pixels per second.
136 * @details Name "scrollSpeed", type Property::FLOAT.
142 * @brief The color to apply to the primary cursor.
143 * @details Name "primaryCursorColor", type Property::VECTOR4.
146 PRIMARY_CURSOR_COLOR,
149 * @brief The color to apply to the secondary cursor.
150 * @details Name "secondaryCursorColor", type Property::VECTOR4.
153 SECONDARY_CURSOR_COLOR,
156 * @brief Whether the cursor should blink or not.
157 * @details Name "enableCursorBlink", type Property::BOOLEAN.
163 * @brief The time interval in seconds between cursor on/off states.
164 * @details Name "cursorBlinkInterval", type Property::FLOAT.
167 CURSOR_BLINK_INTERVAL,
170 * @brief The cursor will stop blinking after this number of seconds (if non-zero).
171 * @details Name "cursorBlinkDuration", type Property::FLOAT.
174 CURSOR_BLINK_DURATION,
177 * @brief The cursor width.
178 * @details Name "cursorWidth", type Property::INTEGER.
184 * @brief The image to display for the grab handle.
185 * @details Name "grabHandleImage", type Property::STRING.
191 * @brief The image to display when the grab handle is pressed.
192 * @details Name "grabHandlePressedImage", type Property::STRING.
195 GRAB_HANDLE_PRESSED_IMAGE,
198 * @brief The image to display for the left selection handle.
199 * @details Name "selectionHandleImageLeft", type Property::MAP.
202 SELECTION_HANDLE_IMAGE_LEFT,
205 * @brief The image to display for the right selection handle.
206 * @details Name "selectionHandleImageRight", type Property::MAP.
209 SELECTION_HANDLE_IMAGE_RIGHT,
212 * @brief The image to display when the left selection handle is pressed.
213 * @details Name "selectionHandlePressedImageLeft", type Property::MAP.
216 SELECTION_HANDLE_PRESSED_IMAGE_LEFT,
219 * @brief The image to display when the right selection handle is pressed.
220 * @details Name "selectionHandlePressedImageRight", type Property::MAP.
223 SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,
226 * @brief The image to display for the left selection handle marker.
227 * @details Name "selectionHandleMarkerImageLeft", type Property::MAP.
230 SELECTION_HANDLE_MARKER_IMAGE_LEFT,
233 * @brief The image to display for the right selection handle marker.
234 * @details Name "selectionHandleMarkerImageRight", type Property::MAP.
237 SELECTION_HANDLE_MARKER_IMAGE_RIGHT,
240 * @brief The color of the selection highlight.
241 * @details Name "selectionHighlightColor", type Property::VECTOR4.
244 SELECTION_HIGHLIGHT_COLOR,
247 * @brief The decorations (handles etc) will positioned within this area on-screen.
248 * @details Name "decorationBoundingBox", type Property::RECTANGLE.
251 DECORATION_BOUNDING_BOX,
254 * @brief Whether the mark-up processing is enabled.
255 * @details Name "enableMarkup", type Property::BOOLEAN.
261 * @brief The color of the new input text.
262 * @details Name "inputColor", type Property::VECTOR4.
268 * @brief The font's family of the new input text.
269 * @details Name "inputFontFamily", type Property::STRING.
275 * @brief The font's style of the new input text.
276 * @details Name "inputFontStyle", type Property::MAP.
282 * @brief The font's size of the new input text in points.
283 * @details Name "inputPointSize", type Property::FLOAT.
289 * @brief The default extra space between lines in points.
290 * @details Name "lineSpacing", type Property::FLOAT.
296 * @brief The extra space between lines in points.
297 * @details Name "inputLineSpacing", type Property::FLOAT.
299 * @note This affects the whole paragraph where the new input text is inserted.
304 * @copydoc Dali::Toolkit::TextLabel::Property::UNDERLINE
309 * @brief The underline parameters of the new input text.
310 * @details Name "inputUnderline", type Property::MAP.
316 * @copydoc Dali::Toolkit::TextLabel::Property::SHADOW
321 * @brief The shadow parameters of the new input text.
322 * @details Name "inputShadow", type Property::MAP.
328 * @brief The default emboss parameters.
329 * @details Name "emboss", type Property::MAP.
335 * @brief The emboss parameters of the new input text.
336 * @details Name "inputEmboss", type Property::MAP.
342 * @copydoc Dali::Toolkit::TextLabel::Property::OUTLINE
347 * @brief The outline parameters of the new input text.
348 * @details Name "inputOutline", type Property::MAP.
354 * @brief Enable or disable the smooth scroll animation.
355 * @details Name "smoothScroll", type Property::BOOLEAN.
361 * @brief Sets the duration of smooth scroll animation.
362 * @details Name "smoothScrollDuration", type Property::FLOAT.
365 SMOOTH_SCROLL_DURATION,
368 * @brief Enable or disable the scroll bar.
369 * @details Name "enableScrollBar", type Property::BOOLEAN.
375 * @brief Sets the duration of scroll bar to show.
376 * @details Name "scrollBarShowDuration", type Property::FLOAT.
379 SCROLL_BAR_SHOW_DURATION,
382 * @brief Sets the duration of scroll bar to fade out.
383 * @details Name "scrollBarFadeDuration", type Property::FLOAT.
386 SCROLL_BAR_FADE_DURATION,
389 * @brief The size of font in pixels.
390 * @details Name "pixelSize", type Property::FLOAT.
391 * Conversion from Point size to Pixel size:
392 * Pixel size = Point size * DPI / 72
398 * @brief The line count of text.
399 * @details Name "lineCount", type Property::INTEGER.
401 * @note This property is read-only.
406 * @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
407 * @details Name "enableSelection", type Property::BOOLEAN.
413 * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
414 * @details Name "placeholder", type Property::MAP.
417 * Property::Map propertyMap;
418 * propertyMap["placeholderText"] = "Setting Placeholder Text";
419 * propertyMap["placeholderTextFocused"] = "Setting Placeholder Text Focused";
420 * propertyMap["placeholderColor"] = Color::RED;
421 * propertyMap["placeholderFontFamily"] = "Arial";
422 * propertyMap["placeholderPointSize"] = 12.0f;
424 * Property::Map fontStyleMap;
425 * fontStyleMap.Insert( "weight", "bold" );
426 * fontStyleMap.Insert( "width", "condensed" );
427 * fontStyleMap.Insert( "slant", "italic" );
428 * propertyMap["placeholderFontStyle"] = fontStyleMap;
430 * editor.SetProperty( TextEditor::Property::PLACEHOLDER, propertyMap );
438 * @brief Line wrap mode when text lines are greater than the layout width.
439 * @details Name "lineWrapMode", type Text::LineWrap::Mode (Text::Property::INTEGER) or Property::STRING.
441 * @note Default is Text::LineWrap::WORD.
442 * @note Return type is Text::LineWrap::Mode (Text::Property::INTEGER).
443 * @see Text::LineWrap
450 * @brief Mask used by the signal InputStyleChangedSignal(). Notifies which parameters of the input style have changed.
457 * @brief Enumeration for mask used by the signal InputStyleChangedSignal().
462 NONE = 0x0000, ///< @SINCE_1_2_2
463 COLOR = 0x0001, ///< @SINCE_1_2_2
464 FONT_FAMILY = 0x0002, ///< @SINCE_1_2_2
465 POINT_SIZE = 0x0004, ///< @SINCE_1_2_2
466 FONT_STYLE = 0x0008, ///< @SINCE_1_2_2
467 LINE_SPACING = 0x0010, ///< @SINCE_1_2_2
468 UNDERLINE = 0x0020, ///< @SINCE_1_2_2
469 SHADOW = 0x0040, ///< @SINCE_1_2_2
470 EMBOSS = 0x0080, ///< @SINCE_1_2_2
471 OUTLINE = 0x0100 ///< @SINCE_1_2_2
476 * @brief Enumerations for the type of scrolling.
478 * @see ScrollStateChangedSignal()
483 * @brief Enumerations for the type of scrolling.
485 * @see ScrollStateChangedSignal()
489 STARTED, ///< Scrolling has started. @SINCE_1_2.60
490 FINISHED ///< Scrolling has finished. @SINCE_1_2.60
497 * @brief Text changed signal type.
500 typedef Signal<void ( TextEditor ) > TextChangedSignalType;
503 * @brief Input Style changed signal type.
506 typedef Signal<void ( TextEditor, InputStyle::Mask ) > InputStyleChangedSignalType;
509 * @brief Scroll state changed signal type.
512 typedef Signal< void ( TextEditor, Scroll::Type ) > ScrollStateChangedSignalType;
515 * @brief Creates the TextEditor control.
518 * @return A handle to the TextEditor control
520 static TextEditor New();
523 * @brief Creates an empty handle.
530 * @brief Copy constructor.
533 * @param[in] handle The handle to copy from
535 TextEditor( const TextEditor& handle );
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 );
549 * This is non-virtual since derived Handle types must not contain data or virtual methods.
555 * @brief Downcasts a handle to TextEditor.
557 * If the BaseHandle points is a TextEditor, the downcast returns a valid handle.
558 * If not, the returned handle is left empty.
561 * @param[in] handle Handle to an object
562 * @return Handle to a TextEditor or an empty handle
564 static TextEditor DownCast( BaseHandle handle );
569 * @brief This signal is emitted when the text changes.
571 * A callback of the following type may be connected:
573 * void YourCallbackName( TextEditor textEditor );
577 * @return The signal to connect to
579 TextChangedSignalType& TextChangedSignal();
582 * @brief This signal is emitted when the input style is updated as a consequence of a change in the cursor position.
583 * i.e. The signal is not emitted when the input style is updated through the property system.
585 * A callback of the following type may be connected. The @p mask parameter notifies which parts of the style have changed.
587 * void YourCallbackName( TextEditor textEditor, TextEditor::InputStyle::Mask mask );
591 * @return The signal to connect to
593 InputStyleChangedSignalType& InputStyleChangedSignal();
596 * @brief This signal is emitted when TextEditor scrolling is started or finished.
598 * A callback of the following type may be connected:
600 * void YourCallbackName( Scroll::Type type );
602 * type: Whether the scrolling is started or finished.
605 * @return The signal to connect to
607 ScrollStateChangedSignalType& ScrollStateChangedSignal();
609 public: // Not intended for application developers
613 * @brief Creates a handle using the Toolkit::Internal implementation.
616 * @param[in] implementation The Control implementation
618 DALI_INTERNAL TextEditor( Internal::TextEditor& implementation );
621 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
624 * @param[in] internal A pointer to the internal CustomActor
626 explicit DALI_INTERNAL TextEditor( Dali::Internal::CustomActor* internal );
633 } // namespace Toolkit
637 #endif // DALI_TOOLKIT_TEXT_EDITOR_H