1 #ifndef __DALI_TOOLKIT_TEXT_EDITOR_H__
2 #define __DALI_TOOLKIT_TEXT_EDITOR_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 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_IMPORT_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.
121 * Values "BEGIN" "CENTER" "END".
124 HORIZONTAL_ALIGNMENT,
127 * @brief Vertical scrolling will occur if the cursor is this close to the control border.
128 * @details Name "scrollThreshold", type Property::FLOAT.
134 * @brief The scroll speed in pixels per second.
135 * @details Name "scrollSpeed", type Property::FLOAT.
141 * @brief The color to apply to the primary cursor.
142 * @details Name "primaryCursorColor", type Property::VECTOR4.
145 PRIMARY_CURSOR_COLOR,
148 * @brief The color to apply to the secondary cursor.
149 * @details Name "secondaryCursorColor", type Property::VECTOR4.
152 SECONDARY_CURSOR_COLOR,
155 * @brief Whether the cursor should blink or not.
156 * @details Name "enableCursorBlink", type Property::BOOLEAN.
162 * @brief The time interval in seconds between cursor on/off states.
163 * @details Name "cursorBlinkInterval", type Property::FLOAT.
166 CURSOR_BLINK_INTERVAL,
169 * @brief The cursor will stop blinking after this number of seconds (if non-zero).
170 * @details Name "cursorBlinkDuration", type Property::FLOAT.
173 CURSOR_BLINK_DURATION,
176 * @brief The cursor width.
177 * @details Name "cursorWidth", type Property::INTEGER.
183 * @brief The image to display for the grab handle.
184 * @details Name "grabHandleImage", type Property::STRING.
190 * @brief The image to display when the grab handle is pressed.
191 * @details Name "grabHandlePressedImage", type Property::STRING.
194 GRAB_HANDLE_PRESSED_IMAGE,
197 * @brief The image to display for the left selection handle.
198 * @details Name "selectionHandleImageLeft", type Property::MAP.
201 SELECTION_HANDLE_IMAGE_LEFT,
204 * @brief The image to display for the right selection handle.
205 * @details Name "selectionHandleImageRight", type Property::MAP.
208 SELECTION_HANDLE_IMAGE_RIGHT,
211 * @brief The image to display when the left selection handle is pressed.
212 * @details Name "selectionHandlePressedImageLeft", type Property::MAP.
215 SELECTION_HANDLE_PRESSED_IMAGE_LEFT,
218 * @brief The image to display when the right selection handle is pressed.
219 * @details Name "selectionHandlePressedImageRight", type Property::MAP.
222 SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,
225 * @brief The image to display for the left selection handle marker.
226 * @details Name "selectionHandleMarkerImageLeft", type Property::MAP.
229 SELECTION_HANDLE_MARKER_IMAGE_LEFT,
232 * @brief The image to display for the right selection handle marker.
233 * @details Name "selectionHandleMarkerImageRight", type Property::MAP.
236 SELECTION_HANDLE_MARKER_IMAGE_RIGHT,
239 * @brief The color of the selection highlight.
240 * @details Name "selectionHighlightColor", type Property::VECTOR4.
243 SELECTION_HIGHLIGHT_COLOR,
246 * @brief The decorations (handles etc) will positioned within this area on-screen.
247 * @details Name "decorationBoundingBox", type Property::RECTANGLE.
250 DECORATION_BOUNDING_BOX,
253 * @brief Whether the mark-up processing is enabled.
254 * @details Name "enableMarkup", type Property::BOOLEAN.
260 * @brief The color of the new input text.
261 * @details Name "inputColor", type Property::VECTOR4.
267 * @brief The font's family of the new input text.
268 * @details Name "inputFontFamily", type Property::STRING.
274 * @brief The font's style of the new input text.
275 * @details Name "inputFontStyle", type Property::MAP.
281 * @brief The font's size of the new input text in points.
282 * @details Name "inputPointSize", type Property::FLOAT.
288 * @brief The default extra space between lines in points.
289 * @details Name "lineSpacing", type Property::FLOAT.
295 * @brief The extra space between lines in points.
296 * @details Name "inputLineSpacing", type Property::FLOAT.
298 * @note This affects the whole paragraph where the new input text is inserted.
303 * @brief The default underline parameters.
304 * @details Name "underline", type Property::MAP.
310 * @brief The underline parameters of the new input text.
311 * @details Name "inputUnderline", type Property::MAP.
317 * @brief The default shadow parameters.
318 * @details Name "shadow", type Property::MAP.
324 * @brief The shadow parameters of the new input text.
325 * @details Name "inputShadow", type Property::MAP.
331 * @brief The default emboss parameters.
332 * @details Name "emboss", type Property::MAP.
338 * @brief The emboss parameters of the new input text.
339 * @details Name "inputEmboss", type Property::MAP.
345 * @brief The default outline parameters.
346 * @details Name "outline", type Property::MAP.
352 * @brief The outline parameters of the new input text.
353 * @details Name "inputOutline", type Property::MAP.
359 * @brief Enable or disable the smooth scroll animation.
360 * @details Name "smoothScroll", type Property::BOOLEAN.
366 * @brief Sets the duration of smooth scroll animation.
367 * @details Name "smoothScrollDuration", type Property::FLOAT.
370 SMOOTH_SCROLL_DURATION,
373 * @brief Enable or disable the scroll bar.
374 * @details Name "enableScrollBar", type Property::BOOLEAN.
380 * @brief Sets the duration of scroll bar to show.
381 * @details Name "scrollBarShowDuration", type Property::FLOAT.
384 SCROLL_BAR_SHOW_DURATION,
387 * @brief Sets the duration of scroll bar to fade out.
388 * @details Name "scrollBarFadeDuration", type Property::FLOAT.
391 SCROLL_BAR_FADE_DURATION,
394 * @brief The size of font in pixels.
395 * @details Name "pixelSize", type Property::FLOAT.
396 * Conversion from Point size to Pixel size:
397 * Pixel size = Point size * DPI / 72
403 * @brief The line count of text.
404 * @details Name "lineCount", type Property::INTEGER.
406 * @note This property is read-only.
411 * @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
412 * @details Name "enableSelection", type Property::BOOLEAN.
418 * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
419 * @details Name "placeholder", type Property::MAP.
422 * Property::Map propertyMap;
423 * propertyMap["placeholderText"] = "Setting Placeholder Text";
424 * propertyMap["placeholderTextFocused"] = "Setting Placeholder Text Focused";
425 * propertyMap["placeholderColor"] = Color::RED;
426 * propertyMap["placeholderFontFamily"] = "Arial";
427 * propertyMap["placeholderPointSize"] = 12.0f;
429 * Property::Map fontStyleMap;
430 * fontStyleMap.Insert( "weight", "bold" );
431 * fontStyleMap.Insert( "width", "condensed" );
432 * fontStyleMap.Insert( "slant", "italic" );
433 * propertyMap["placeholderFontStyle"] = fontStyleMap;
435 * editor.SetProperty( TextEditor::Property::PLACEHOLDER, propertyMap );
443 * @brief line wrap mode when the text lines over layout width.
444 * @details Name "lineWrapMode", type Property::STRING.
452 * @brief Mask used by the signal InputStyleChangedSignal(). Notifies which parameters of the input style have changed.
459 * @brief Enumeration for mask used by the signal InputStyleChangedSignal().
464 NONE = 0x0000, ///< @SINCE_1_2_2
465 COLOR = 0x0001, ///< @SINCE_1_2_2
466 FONT_FAMILY = 0x0002, ///< @SINCE_1_2_2
467 POINT_SIZE = 0x0004, ///< @SINCE_1_2_2
468 FONT_STYLE = 0x0008, ///< @SINCE_1_2_2
469 LINE_SPACING = 0x0010, ///< @SINCE_1_2_2
470 UNDERLINE = 0x0020, ///< @SINCE_1_2_2
471 SHADOW = 0x0040, ///< @SINCE_1_2_2
472 EMBOSS = 0x0080, ///< @SINCE_1_2_2
473 OUTLINE = 0x0100 ///< @SINCE_1_2_2
478 * @brief Enumerations for the type of scrolling.
480 * @see ScrollStateChangedSignal()
485 * @brief Enumerations for the type of scrolling.
487 * @see ScrollStateChangedSignal()
491 STARTED, ///< Scrolling has started. @SINCE_1_2.60
492 FINISHED ///< Scrolling has finished. @SINCE_1_2.60
499 * @brief Text changed signal type.
502 typedef Signal<void ( TextEditor ) > TextChangedSignalType;
505 * @brief Input Style changed signal type.
508 typedef Signal<void ( TextEditor, InputStyle::Mask ) > InputStyleChangedSignalType;
511 * @brief Scroll state changed signal type.
514 typedef Signal< void ( TextEditor, Scroll::Type ) > ScrollStateChangedSignalType;
517 * @brief Creates the TextEditor control.
520 * @return A handle to the TextEditor control
522 static TextEditor New();
525 * @brief Creates an empty handle.
532 * @brief Copy constructor.
535 * @param[in] handle The handle to copy from
537 TextEditor( const TextEditor& handle );
540 * @brief Assignment operator.
543 * @param[in] handle The handle to copy from
544 * @return A reference to this
546 TextEditor& operator=( const TextEditor& handle );
551 * This is non-virtual since derived Handle types must not contain data or virtual methods.
557 * @brief Downcasts a handle to TextEditor.
559 * If the BaseHandle points is a TextEditor, the downcast returns a valid handle.
560 * If not, the returned handle is left empty.
563 * @param[in] handle Handle to an object
564 * @return Handle to a TextEditor or an empty handle
566 static TextEditor DownCast( BaseHandle handle );
571 * @brief This signal is emitted when the text changes.
573 * A callback of the following type may be connected:
575 * void YourCallbackName( TextEditor textEditor );
579 * @return The signal to connect to
581 TextChangedSignalType& TextChangedSignal();
584 * @brief This signal is emitted when the input style is updated as a consequence of a change in the cursor position.
585 * i.e. The signal is not emitted when the input style is updated through the property system.
587 * A callback of the following type may be connected. The @p mask parameter notifies which parts of the style have changed.
589 * void YourCallbackName( TextEditor textEditor, TextEditor::InputStyle::Mask mask );
593 * @return The signal to connect to
595 InputStyleChangedSignalType& InputStyleChangedSignal();
598 * @brief This signal is emitted when TextEditor scrolling is started or finished.
600 * A callback of the following type may be connected:
602 * void YourCallbackName( Scroll::Type type );
604 * type: Whether the scrolling is started or finished.
607 * @return The signal to connect to
609 ScrollStateChangedSignalType& ScrollStateChangedSignal();
611 public: // Not intended for application developers
615 * @brief Creates a handle using the Toolkit::Internal implementation.
618 * @param[in] implementation The Control implementation
620 DALI_INTERNAL TextEditor( Internal::TextEditor& implementation );
623 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
626 * @param[in] internal A pointer to the internal CustomActor
628 explicit DALI_INTERNAL TextEditor( Dali::Internal::CustomActor* internal );
635 } // namespace Toolkit
639 #endif // __DALI_TOOLKIT_TEXT_EDITOR_H__