1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
5 * Copyright (c) 2018 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/devel-api/adaptor-framework/input-method-context.h>
23 #include <dali/public-api/events/gesture.h>
26 #include <dali-toolkit/public-api/text/text-enumerations.h>
27 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
28 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
29 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
30 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
31 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
32 #include <dali-toolkit/internal/text/hidden-text.h>
33 #include <dali-toolkit/internal/text/text-model-interface.h>
45 class ControlInterface;
46 class EditableControlInterface;
48 class RenderingController;
50 typedef IntrusivePtr<Controller> ControllerPtr;
53 * @brief A Text Controller is used by UI Controls which display text.
55 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
56 * It provides a view of the text that can be used by rendering back-ends.
58 * For selectable/editable UI controls, the controller handles input events from the UI control
59 * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
61 * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
63 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
65 public: // Enumerated types.
68 * @brief Text related operations to be done in the relayout process.
72 NO_OPERATION = 0x0000,
73 CONVERT_TO_UTF32 = 0x0001,
75 VALIDATE_FONTS = 0x0004,
76 GET_LINE_BREAKS = 0x0008,
77 GET_WORD_BREAKS = 0x0010,
80 GET_GLYPH_METRICS = 0x0080,
82 UPDATE_LAYOUT_SIZE = 0x0200,
86 UPDATE_DIRECTION = 0x2000,
87 ALL_OPERATIONS = 0xFFFF
91 * @brief Used to distinguish between regular key events and InputMethodContext events
100 * @brief Used to specify whether to update the input style.
102 enum UpdateInputStyleType
105 DONT_UPDATE_INPUT_STYLE
109 * @brief Used to specify what has been updated after the Relayout() method has been called.
113 NONE_UPDATED = 0x0, ///< Nothing has been updated.
114 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
115 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
119 * @brief Different placeholder-text can be shown when the control is active/inactive.
123 PLACEHOLDER_TYPE_ACTIVE,
124 PLACEHOLDER_TYPE_INACTIVE,
128 * @brief Enumeration for Font Size Type.
132 POINT_SIZE, // The size of font in points.
133 PIXEL_SIZE // The size of font in pixels.
140 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
141 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
142 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
154 TEXT_FIT_FONT_SIZE_TYPE
158 public: // Constructor.
161 * @brief Create a new instance of a Controller.
163 * @return A pointer to a new Controller.
165 static ControllerPtr New();
168 * @brief Create a new instance of a Controller.
170 * @param[in] controlInterface The control's interface.
172 * @return A pointer to a new Controller.
174 static ControllerPtr New( ControlInterface* controlInterface );
177 * @brief Create a new instance of a Controller.
179 * @param[in] controlInterface The control's interface.
180 * @param[in] editableControlInterface The editable control's interface.
182 * @return A pointer to a new Controller.
184 static ControllerPtr New( ControlInterface* controlInterface,
185 EditableControlInterface* editableControlInterface );
187 public: // Configure the text controller.
190 * @brief Called to enable text input.
192 * @note Selectable or editable controls should call this once after Controller::New().
193 * @param[in] decorator Used to create cursor, selection handle decorations etc.
194 * @param[in] inputMethodContext Used to manager ime.
196 void EnableTextInput( DecoratorPtr decorator, InputMethodContext& inputMethodContext );
199 * @brief Used to switch between bitmap & vector based glyphs
201 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
203 void SetGlyphType( TextAbstraction::GlyphType glyphType );
206 * @brief Enables/disables the mark-up processor.
208 * By default is disabled.
210 * @param[in] enable Whether to enable the mark-up processor.
212 void SetMarkupProcessorEnabled( bool enable );
215 * @brief Retrieves whether the mark-up processor is enabled.
217 * By default is disabled.
219 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
221 bool IsMarkupProcessorEnabled() const;
224 * @brief Enables/disables the auto text scrolling
226 * By default is disabled.
228 * @param[in] enable Whether to enable the auto scrolling
230 void SetAutoScrollEnabled( bool enable );
233 * @brief Retrieves whether auto text scrolling is enabled.
235 * By default is disabled.
237 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
239 bool IsAutoScrollEnabled() const;
242 * @brief Get direction of the text from the first line of text,
243 * @return bool rtl (right to left) is true
245 CharacterDirection GetAutoScrollDirection() const;
248 * @brief Get the alignment offset of the first line of text.
250 * @return The alignment offset.
252 float GetAutoScrollLineAlignment() const;
255 * @brief Enables the horizontal scrolling.
257 * @param[in] enable Whether to enable the horizontal scrolling.
259 void SetHorizontalScrollEnabled( bool enable );
262 * @brief Retrieves whether the horizontal scrolling is enabled.
264 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
266 bool IsHorizontalScrollEnabled() const;
269 * @brief Enables the vertical scrolling.
271 * @param[in] enable Whether to enable the vertical scrolling.
273 void SetVerticalScrollEnabled( bool enable );
276 * @brief Retrieves whether the verticall scrolling is enabled.
278 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
280 bool IsVerticalScrollEnabled() const;
283 * @brief Enables the smooth handle panning.
285 * @param[in] enable Whether to enable the smooth handle panning.
287 void SetSmoothHandlePanEnabled( bool enable );
290 * @brief Retrieves whether the smooth handle panning is enabled.
292 * @return @e true if the smooth handle panning is enabled.
294 bool IsSmoothHandlePanEnabled() const;
297 * @brief Sets the maximum number of characters that can be inserted into the TextModel
299 * @param[in] maxCharacters maximum number of characters to be accepted
301 void SetMaximumNumberOfCharacters( Length maxCharacters );
304 * @brief Sets the maximum number of characters that can be inserted into the TextModel
306 * @param[in] maxCharacters maximum number of characters to be accepted
308 int GetMaximumNumberOfCharacters();
311 * @brief Called to enable/disable cursor blink.
313 * @note Only editable controls should calls this.
314 * @param[in] enabled Whether the cursor should blink or not.
316 void SetEnableCursorBlink( bool enable );
319 * @brief Query whether cursor blink is enabled.
321 * @return Whether the cursor should blink or not.
323 bool GetEnableCursorBlink() const;
326 * @brief Whether to enable the multi-line layout.
328 * @param[in] enable \e true enables the multi-line (by default)
330 void SetMultiLineEnabled( bool enable );
333 * @return Whether the multi-line layout is enabled.
335 bool IsMultiLineEnabled() const;
338 * @brief Sets the text's horizontal alignment.
340 * @param[in] alignment The horizontal alignment.
342 void SetHorizontalAlignment( HorizontalAlignment::Type alignment );
345 * @copydoc ModelInterface::GetHorizontalAlignment()
347 HorizontalAlignment::Type GetHorizontalAlignment() const;
350 * @brief Sets the text's vertical alignment.
352 * @param[in] alignment The vertical alignment.
354 void SetVerticalAlignment( VerticalAlignment::Type alignment );
357 * @copydoc ModelInterface::GetVerticalAlignment()
359 VerticalAlignment::Type GetVerticalAlignment() const;
362 * @brief Sets the text's wrap mode
363 * @param[in] text wrap mode The unit of wrapping
365 void SetLineWrapMode( Text::LineWrap::Mode textWarpMode );
368 * @brief Retrieve text wrap mode previously set.
369 * @return text wrap mode
371 Text::LineWrap::Mode GetLineWrapMode() const;
374 * @brief Enable or disable the text elide.
376 * @param[in] enabled Whether to enable the text elide.
378 void SetTextElideEnabled( bool enabled );
381 * @copydoc ModelInterface::IsTextElideEnabled()
383 bool IsTextElideEnabled() const;
386 * @brief Enable or disable the text fit.
388 * @param[in] enabled Whether to enable the text fit.
390 void SetTextFitEnabled(bool enabled);
393 * @brief Whether the text fit is enabled or not.
395 * @return True if the text fit is enabled
397 bool IsTextFitEnabled() const;
400 * @brief Sets minimum size valid for text fit.
402 * @param[in] minimum size value.
403 * @param[in] type The font size type is point size or pixel size
405 void SetTextFitMinSize( float pointSize, FontSizeType type );
408 * @brief Retrieves the minimum point size valid for text fit.
410 * @return The minimum point size valid for text fit
412 float GetTextFitMinSize() const;
415 * @brief Sets maximum size valid for text fit.
417 * @param[in] maximum size value.
418 * @param[in] type The font size type is point size or pixel size
420 void SetTextFitMaxSize( float pointSize, FontSizeType type );
423 * @brief Retrieves the maximum point size valid for text fit.
425 * @return The maximum point size valid for text fit
427 float GetTextFitMaxSize() const;
430 * @brief Sets step size for font increase valid for text fit.
432 * @param[in] step size value.
433 * @param[in] type The font size type is point size or pixel size
435 void SetTextFitStepSize( float step, FontSizeType type );
438 * @brief Retrieves the step point size valid for text fit.
440 * @return The step point size valid for text fit
442 float GetTextFitStepSize() const;
445 * @brief Sets content size valid for text fit.
447 * @param[in] Content size value.
449 void SetTextFitContentSize(Vector2 size);
452 * @brief Retrieves the content size valid for text fit.
454 * @return The content size valid for text fit
456 Vector2 GetTextFitContentSize() const;
459 * @brief Enable or disable the placeholder text elide.
460 * @param enabled Whether to enable the placeholder text elide.
462 void SetPlaceholderTextElideEnabled( bool enabled );
465 * @brief Whether the placeholder text elide property is enabled.
466 * @return True if the placeholder text elide property is enabled, false otherwise.
468 bool IsPlaceholderTextElideEnabled() const;
471 * @brief Enable or disable the text selection.
472 * @param[in] enabled Whether to enable the text selection.
474 void SetSelectionEnabled( bool enabled );
477 * @brief Whether the text selection is enabled or not.
478 * @return True if the text selection is enabled
480 bool IsSelectionEnabled() const;
483 * @brief Enable or disable the text selection using Shift key.
484 * @param enabled Whether to enable the text selection using Shift key
486 void SetShiftSelectionEnabled( bool enabled );
489 * @brief Whether the text selection using Shift key is enabled or not.
490 * @return True if the text selection using Shift key is enabled
492 bool IsShiftSelectionEnabled() const;
495 * @brief Enable or disable the grab handles for text selection.
497 * @param[in] enabled Whether to enable the grab handles
499 void SetGrabHandleEnabled( bool enabled );
502 * @brief Returns whether the grab handles are enabled.
504 * @return True if the grab handles are enabled
506 bool IsGrabHandleEnabled() const;
509 * @brief Enable or disable the grab handles for text selection.
511 * @param[in] enabled Whether to enable the grab handles
513 void SetGrabHandlePopupEnabled( bool enabled );
516 * @brief Returns whether the grab handles are enabled.
518 * @return True if the grab handles are enabled
520 bool IsGrabHandlePopupEnabled() const;
523 * @brief Sets input type to password
525 * @note The string is displayed hidden character
527 * @param[in] passwordInput True if password input is enabled.
529 void SetInputModePassword( bool passwordInput );
532 * @brief Returns whether the input mode type is set as password.
534 * @return True if input mode type is password
536 bool IsInputModePassword();
539 * @brief Sets the action when there is a double tap event on top of a text area with no text.
541 * @param[in] action The action to do.
543 void SetNoTextDoubleTapAction( NoTextTap::Action action );
546 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
548 * @return The action to do.
550 NoTextTap::Action GetNoTextDoubleTapAction() const;
553 * @briefSets the action when there is a long press event on top of a text area with no text.
555 * @param[in] action The action to do.
557 void SetNoTextLongPressAction( NoTextTap::Action action );
560 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
562 * @return The action to do.
564 NoTextTap::Action GetNoTextLongPressAction() const;
567 * @brief Query if Underline settings were provided by string or map
568 * @return bool true if set by string
570 bool IsUnderlineSetByString();
573 * Set method underline setting were set by
574 * @param[in] bool, true if set by string
576 void UnderlineSetByString( bool setByString );
579 * @brief Query if shadow settings were provided by string or map
580 * @return bool true if set by string
582 bool IsShadowSetByString();
585 * Set method shadow setting were set by
586 * @param[in] bool, true if set by string
588 void ShadowSetByString( bool setByString );
591 * @brief Query if outline settings were provided by string or map
592 * @return bool true if set by string
594 bool IsOutlineSetByString();
597 * Set method outline setting were set by
598 * @param[in] bool, true if set by string
600 void OutlineSetByString( bool setByString );
603 * @brief Query if font style settings were provided by string or map
604 * @return bool true if set by string
606 bool IsFontStyleSetByString();
609 * Set method font style setting were set by
610 * @param[in] bool, true if set by string
612 void FontStyleSetByString( bool setByString );
617 * @brief Replaces any text previously set.
619 * @note This will be converted into UTF-32 when stored in the text model.
620 * @param[in] text A string of UTF-8 characters.
622 void SetText( const std::string& text );
625 * @brief Retrieve any text previously set.
627 * @param[out] text A string of UTF-8 characters.
629 void GetText( std::string& text ) const;
632 * @brief Replaces any placeholder text previously set.
634 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
635 * @param[in] text A string of UTF-8 characters.
637 void SetPlaceholderText( PlaceholderType type, const std::string& text );
640 * @brief Retrieve any placeholder text previously set.
642 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
643 * @param[out] A string of UTF-8 characters.
645 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
648 * @ brief Update the text after a font change
649 * @param[in] newDefaultFont The new font to change to
651 void UpdateAfterFontChange( const std::string& newDefaultFont );
654 * @brief The method acquires currently selected text
655 * @param selectedText variable to place selected text in
657 void RetrieveSelection( std::string& selectedText ) const;
660 * @brief The method sets selection in given range
661 * @param start index of first character
662 * @param end index of first character after selection
664 void SetSelection( int start, int end );
667 * @brief This method retrieve indexes of current selection
669 * @return a pair, where first element is left index of selection and second is the right one
671 std::pair< int, int > GetSelectionIndexes() const;
674 * Place string in system clipboard
675 * @param source std::string
677 void CopyStringToClipboard( const std::string& source );
680 * Place currently selected text in system clipboard
681 * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard
683 void SendSelectionToClipboard( bool deleteAfterSending );
685 public: // Default style & Input style
688 * @brief Set the default font family.
690 * @param[in] defaultFontFamily The default font family.
692 void SetDefaultFontFamily( const std::string& defaultFontFamily );
695 * @brief Retrieve the default font family.
697 * @return The default font family.
699 const std::string& GetDefaultFontFamily() const;
702 * @brief Sets the placeholder text font family.
703 * @param[in] placeholderTextFontFamily The placeholder text font family.
705 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
708 * @brief Retrieves the placeholder text font family.
710 * @return The placeholder text font family
712 const std::string& GetPlaceholderFontFamily() const;
715 * @brief Sets the default font weight.
717 * @param[in] weight The font weight.
719 void SetDefaultFontWeight( FontWeight weight );
722 * @brief Whether the font's weight has been defined.
724 bool IsDefaultFontWeightDefined() const;
727 * @brief Retrieves the default font weight.
729 * @return The default font weight.
731 FontWeight GetDefaultFontWeight() const;
734 * @brief Sets the placeholder text font weight.
736 * @param[in] weight The font weight
738 void SetPlaceholderTextFontWeight( FontWeight weight );
741 * @brief Whether the font's weight has been defined.
743 * @return True if the placeholder text font weight is defined
745 bool IsPlaceholderTextFontWeightDefined() const;
748 * @brief Retrieves the placeholder text font weight.
750 * @return The placeholder text font weight
752 FontWeight GetPlaceholderTextFontWeight() const;
755 * @brief Sets the default font width.
757 * @param[in] width The font width.
759 void SetDefaultFontWidth( FontWidth width );
762 * @brief Whether the font's width has been defined.
764 bool IsDefaultFontWidthDefined() const;
767 * @brief Retrieves the default font width.
769 * @return The default font width.
771 FontWidth GetDefaultFontWidth() const;
774 * @brief Sets the placeholder text font width.
776 * @param[in] width The font width
778 void SetPlaceholderTextFontWidth( FontWidth width );
781 * @brief Whether the font's width has been defined.
783 * @return True if the placeholder text font width is defined
785 bool IsPlaceholderTextFontWidthDefined() const;
788 * @brief Retrieves the placeholder text font width.
790 * @return The placeholder text font width
792 FontWidth GetPlaceholderTextFontWidth() const;
795 * @brief Sets the default font slant.
797 * @param[in] slant The font slant.
799 void SetDefaultFontSlant( FontSlant slant );
802 * @brief Whether the font's slant has been defined.
804 bool IsDefaultFontSlantDefined() const;
807 * @brief Retrieves the default font slant.
809 * @return The default font slant.
811 FontSlant GetDefaultFontSlant() const;
814 * @brief Sets the placeholder text font slant.
816 * @param[in] slant The font slant
818 void SetPlaceholderTextFontSlant( FontSlant slant );
821 * @brief Whether the font's slant has been defined.
823 * @return True if the placeholder text font slant is defined
825 bool IsPlaceholderTextFontSlantDefined() const;
828 * @brief Retrieves the placeholder text font slant.
830 * @return The placeholder text font slant
832 FontSlant GetPlaceholderTextFontSlant() const;
835 * @brief Set the default font size.
837 * @param[in] fontSize The default font size
838 * @param[in] type The font size type is point size or pixel size
840 void SetDefaultFontSize( float fontSize, FontSizeType type );
843 * @brief Retrieve the default point size.
845 * @param[in] type The font size type
846 * @return The default point size.
848 float GetDefaultFontSize( FontSizeType type ) const;
851 * @brief Sets the Placeholder text font size.
852 * @param[in] fontSize The placeholder text font size
853 * @param[in] type The font size type is point size or pixel size
855 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
858 * @brief Retrieves the Placeholder text font size.
859 * @param[in] type The font size type
860 * @return The placeholder font size
862 float GetPlaceholderTextFontSize( FontSizeType type ) const;
865 * @brief Sets the text's default color.
867 * @param color The default color.
869 void SetDefaultColor( const Vector4& color );
872 * @brief Retrieves the text's default color.
874 * @return The default color.
876 const Vector4& GetDefaultColor() const;
879 * @brief Set the text color
881 * @param textColor The text color
883 void SetPlaceholderTextColor( const Vector4& textColor );
886 * @brief Retrieve the text color
888 * @return The text color
890 const Vector4& GetPlaceholderTextColor() const;
893 * @brief Set the shadow offset.
895 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
897 void SetShadowOffset( const Vector2& shadowOffset );
900 * @brief Retrieve the shadow offset.
902 * @return The shadow offset.
904 const Vector2& GetShadowOffset() const;
907 * @brief Set the shadow color.
909 * @param[in] shadowColor The shadow color.
911 void SetShadowColor( const Vector4& shadowColor );
914 * @brief Retrieve the shadow color.
916 * @return The shadow color.
918 const Vector4& GetShadowColor() const;
921 * @brief Set the shadow blur radius.
923 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
925 void SetShadowBlurRadius( const float& shadowBlurRadius );
928 * @brief Retrieve the shadow blur radius.
930 * @return The shadow blur radius.
932 const float& GetShadowBlurRadius() const;
935 * @brief Set the underline color.
937 * @param[in] color color of underline.
939 void SetUnderlineColor( const Vector4& color );
942 * @brief Retrieve the underline color.
944 * @return The underline color.
946 const Vector4& GetUnderlineColor() const;
949 * @brief Set the underline enabled flag.
951 * @param[in] enabled The underline enabled flag.
953 void SetUnderlineEnabled( bool enabled );
956 * @brief Returns whether the text is underlined or not.
958 * @return The underline state.
960 bool IsUnderlineEnabled() const;
963 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
965 * @param[in] height The height in pixels of the underline
967 void SetUnderlineHeight( float height );
970 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
972 * @return The height of the underline, or 0 if height is not overrided.
974 float GetUnderlineHeight() const;
977 * @brief Set the outline color.
979 * @param[in] color color of outline.
981 void SetOutlineColor( const Vector4& color );
984 * @brief Retrieve the outline color.
986 * @return The outline color.
988 const Vector4& GetOutlineColor() const;
991 * @brief Set the outline width
993 * @param[in] width The width in pixels of the outline, 0 indicates no outline
995 void SetOutlineWidth( uint16_t width );
998 * @brief Retrieves the width of an outline
1000 * @return The width of the outline.
1002 uint16_t GetOutlineWidth() const;
1005 * @brief Set the background color.
1007 * @param[in] color color of background.
1009 void SetBackgroundColor( const Vector4& color );
1012 * @brief Retrieve the background color.
1014 * @return The background color.
1016 const Vector4& GetBackgroundColor() const;
1019 * @brief Set the background enabled flag.
1021 * @param[in] enabled The background enabled flag.
1023 void SetBackgroundEnabled( bool enabled );
1026 * @brief Returns whether to enable text background or not.
1028 * @return Whether text background is enabled.
1030 bool IsBackgroundEnabled() const;
1033 * @brief Sets the emboss's properties string.
1035 * @note The string is stored to be recovered.
1037 * @param[in] embossProperties The emboss's properties string.
1039 void SetDefaultEmbossProperties( const std::string& embossProperties );
1042 * @brief Retrieves the emboss's properties string.
1044 * @return The emboss's properties string.
1046 const std::string& GetDefaultEmbossProperties() const;
1049 * @brief Sets the outline's properties string.
1051 * @note The string is stored to be recovered.
1053 * @param[in] outlineProperties The outline's properties string.
1055 void SetDefaultOutlineProperties( const std::string& outlineProperties );
1058 * @brief Retrieves the outline's properties string.
1060 * @return The outline's properties string.
1062 const std::string& GetDefaultOutlineProperties() const;
1065 * @brief Sets the default line spacing.
1067 * @param[in] lineSpacing The line spacing.
1069 * @return True if lineSpacing has been updated, false otherwise
1071 bool SetDefaultLineSpacing( float lineSpacing );
1074 * @brief Retrieves the default line spacing.
1076 * @return The line spacing.
1078 float GetDefaultLineSpacing() const;
1081 * @brief Sets the input text's color.
1083 * @param[in] color The input text's color.
1085 void SetInputColor( const Vector4& color );
1088 * @brief Retrieves the input text's color.
1090 * @return The input text's color.
1092 const Vector4& GetInputColor() const;
1095 * @brief Sets the input text's font family name.
1097 * @param[in] fontFamily The text's font family name.
1099 void SetInputFontFamily( const std::string& fontFamily );
1102 * @brief Retrieves the input text's font family name.
1104 * @return The input text's font family name.
1106 const std::string& GetInputFontFamily() const;
1109 * @brief Sets the input font's weight.
1111 * @param[in] weight The input font's weight.
1113 void SetInputFontWeight( FontWeight weight );
1116 * @return Whether the font's weight has been defined.
1118 bool IsInputFontWeightDefined() const;
1121 * @brief Retrieves the input font's weight.
1123 * @return The input font's weight.
1125 FontWeight GetInputFontWeight() const;
1128 * @brief Sets the input font's width.
1130 * @param[in] width The input font's width.
1132 void SetInputFontWidth( FontWidth width );
1135 * @return Whether the font's width has been defined.
1137 bool IsInputFontWidthDefined() const;
1140 * @brief Retrieves the input font's width.
1142 * @return The input font's width.
1144 FontWidth GetInputFontWidth() const;
1147 * @brief Sets the input font's slant.
1149 * @param[in] slant The input font's slant.
1151 void SetInputFontSlant( FontSlant slant );
1154 * @return Whether the font's slant has been defined.
1156 bool IsInputFontSlantDefined() const;
1159 * @brief Retrieves the input font's slant.
1161 * @return The input font's slant.
1163 FontSlant GetInputFontSlant() const;
1166 * @brief Sets the input font's point size.
1168 * @param[in] size The input font's point size.
1170 void SetInputFontPointSize( float size );
1173 * @brief Retrieves the input font's point size.
1175 * @return The input font's point size.
1177 float GetInputFontPointSize() const;
1180 * @brief Sets the input line spacing.
1182 * @param[in] lineSpacing The line spacing.
1184 void SetInputLineSpacing( float lineSpacing );
1187 * @brief Retrieves the input line spacing.
1189 * @return The line spacing.
1191 float GetInputLineSpacing() const;
1194 * @brief Sets the input shadow's properties string.
1196 * @note The string is stored to be recovered.
1198 * @param[in] shadowProperties The shadow's properties string.
1200 void SetInputShadowProperties( const std::string& shadowProperties );
1203 * @brief Retrieves the input shadow's properties string.
1205 * @return The shadow's properties string.
1207 const std::string& GetInputShadowProperties() const;
1210 * @brief Sets the input underline's properties string.
1212 * @note The string is stored to be recovered.
1214 * @param[in] underlineProperties The underline's properties string.
1216 void SetInputUnderlineProperties( const std::string& underlineProperties );
1219 * @brief Retrieves the input underline's properties string.
1221 * @return The underline's properties string.
1223 const std::string& GetInputUnderlineProperties() const;
1226 * @brief Sets the input emboss's properties string.
1228 * @note The string is stored to be recovered.
1230 * @param[in] embossProperties The emboss's properties string.
1232 void SetInputEmbossProperties( const std::string& embossProperties );
1235 * @brief Retrieves the input emboss's properties string.
1237 * @return The emboss's properties string.
1239 const std::string& GetInputEmbossProperties() const;
1242 * @brief Sets input the outline's properties string.
1244 * @note The string is stored to be recovered.
1246 * @param[in] outlineProperties The outline's properties string.
1248 void SetInputOutlineProperties( const std::string& outlineProperties );
1251 * @brief Retrieves the input outline's properties string.
1253 * @return The outline's properties string.
1255 const std::string& GetInputOutlineProperties() const;
1258 * @brief Set the control's interface.
1260 * @param[in] controlInterface The control's interface.
1262 void SetControlInterface( ControlInterface* controlInterface );
1264 public: // Queries & retrieves.
1267 * @brief Return the layout engine.
1269 * @return A reference to the layout engine.
1271 Layout::Engine& GetLayoutEngine();
1274 * @brief Return a view of the text.
1276 * @return A reference to the view.
1281 * @copydoc Control::GetNaturalSize()
1283 Vector3 GetNaturalSize();
1286 * @copydoc Control::GetHeightForWidth()
1288 float GetHeightForWidth( float width );
1291 * @brief Calculates the point size for text for given layout()
1293 void FitPointSizeforLayout( Size layoutSize );
1296 * @brief Checks if the point size fits within the layout size.
1298 * @return Whether the point size fits within the layout size.
1300 bool CheckForTextFit( float pointSize, Size& layoutSize );
1303 * @brief Retrieves the text's number of lines for a given width.
1304 * @param[in] width The width of the text's area.
1305 * @ return The number of lines.
1307 int GetLineCount( float width );
1310 * @brief Retrieves the text's model.
1312 * @return A pointer to the text's model.
1314 const ModelInterface* const GetTextModel() const;
1317 * @brief Used to get scrolled distance by user input
1319 * @return Distance from last scroll offset to new scroll offset
1321 float GetScrollAmountByUserInput();
1324 * @brief Get latest scroll amount, control size and layout size
1326 * This method is used to get information of control's scroll
1327 * @param[out] scrollPosition The current scrolled position
1328 * @param[out] controlHeight The size of a UI control
1329 * @param[out] layoutHeight The size of a bounding box to layout text within.
1331 * @return Whether the text scroll position is changed or not after last update.
1333 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1336 * @brief Used to set the hidden input option
1338 void SetHiddenInputOption( const Property::Map& options );
1341 * @brief Used to get the hidden input option
1343 void GetHiddenInputOption( Property::Map& options );
1346 * @brief Sets the Placeholder Properties.
1348 * @param[in] map The placeholder property map
1350 void SetPlaceholderProperty( const Property::Map& map );
1353 * @brief Retrieves the Placeholder Property map.
1355 * @param[out] map The property map
1357 void GetPlaceholderProperty( Property::Map& map );
1360 * @brief Checks text direction.
1361 * @return The text direction.
1363 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1366 * @brief Retrieves vertical line alignment
1367 * @return The vertical line alignment
1369 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1372 * @brief Sets vertical line alignment
1373 * @param[in] alignment The vertical line alignment for the text
1375 void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
1378 * @brief Retrieves ignoreSpaceAfterText value from model
1379 * @return The value of ignoreSpaceAfterText
1381 bool IsIgnoreSpacesAfterText() const;
1384 * @brief Sets ignoreSpaceAfterText value to model
1385 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1387 void SetIgnoreSpacesAfterText( bool ignore );
1390 * @brief Retrieves matchSystemLanguageDirection value from model
1391 * @return The value of matchSystemLanguageDirection
1393 bool IsMatchSystemLanguageDirection() const;
1396 * @brief Sets matchSystemLanguageDirection value to model
1397 * @param[in] match The value of matchSystemLanguageDirection for the text
1399 void SetMatchSystemLanguageDirection( bool match );
1402 * @brief Sets layoutDirection value
1403 * @param[in] layoutDirection The value of system language direction
1405 void SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection );
1408 * @brief Retrieves if showing real text or not.
1409 * @return The value of showing real text.
1411 bool IsShowingRealText() const;
1413 public: // Relayout.
1416 * @brief Triggers a relayout which updates View (if necessary).
1418 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1419 * @param[in] size A the size of a bounding box to layout text within.
1420 * @param[in] layoutDirection The direction of the system language.
1422 * @return Whether the text model or decorations were updated.
1424 UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT );
1427 * @brief Request a relayout using the ControlInterface.
1429 void RequestRelayout();
1431 public: // Input style change signals.
1434 * @return Whether the queue of input style changed signals is empty.
1436 bool IsInputStyleChangedSignalsQueueEmpty();
1439 * @brief Process all pending input style changed signals.
1441 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1442 * text controls. Text controls may send signals to state the input style has changed.
1444 void ProcessInputStyleChangedSignals();
1446 public: // Text-input Event Queuing.
1449 * @brief Called by editable UI controls when keyboard focus is gained.
1451 void KeyboardFocusGainEvent();
1454 * @brief Called by editable UI controls when focus is lost.
1456 void KeyboardFocusLostEvent();
1459 * @brief Called by editable UI controls when key events are received.
1461 * @param[in] event The key event.
1462 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1464 bool KeyEvent( const Dali::KeyEvent& event );
1467 * @brief Called by editable UI controls when a tap gesture occurs.
1468 * @param[in] tapCount The number of taps.
1469 * @param[in] x The x position relative to the top-left of the parent control.
1470 * @param[in] y The y position relative to the top-left of the parent control.
1472 void TapEvent( unsigned int tapCount, float x, float y );
1475 * @brief Called by editable UI controls when a pan gesture occurs.
1477 * @param[in] state The state of the gesture.
1478 * @param[in] displacement This distance panned since the last pan gesture.
1480 void PanEvent( Gesture::State state, const Vector2& displacement );
1483 * @brief Called by editable UI controls when a long press gesture occurs.
1485 * @param[in] state The state of the gesture.
1486 * @param[in] x The x position relative to the top-left of the parent control.
1487 * @param[in] y The y position relative to the top-left of the parent control.
1489 void LongPressEvent( Gesture::State state, float x, float y );
1492 * @brief Creates a selection event.
1494 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1496 * @param[in] x The x position relative to the top-left of the parent control.
1497 * @param[in] y The y position relative to the top-left of the parent control.
1498 * @param[in] selectAll Whether the whole text is selected.
1500 void SelectEvent( float x, float y, bool selectAll );
1503 * @brief Event received from input method context
1505 * @param[in] inputMethodContext The input method context.
1506 * @param[in] inputMethodContextEvent The event received.
1507 * @return A data struture indicating if update is needed, cursor position and current text.
1509 InputMethodContext::CallbackData OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent );
1512 * @brief Event from Clipboard notifying an Item has been selected for pasting
1514 void PasteClipboardItemEvent();
1517 * @brief Return true when text control should clear key input focus when escape key is pressed.
1519 * @return Whether text control should clear key input focus or not when escape key is pressed.
1521 bool ShouldClearFocusOnEscape() const;
1524 * @brief Used to reset the cursor position after setting a new text.
1526 * @param[in] cursorIndex Where to place the cursor.
1528 void ResetCursorPosition( CharacterIndex cursorIndex );
1531 * @brief The method acquires current position of cursor
1532 * @return unsigned value with cursor position
1534 CharacterIndex GetCursorPosition();
1536 protected: // Inherit from Text::Decorator::ControllerInterface.
1539 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1541 virtual void GetTargetSize( Vector2& targetSize );
1544 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1546 virtual void AddDecoration( Actor& actor, bool needsClipping );
1549 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1551 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1553 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1556 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1558 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1560 protected: // Inherit from HiddenText.
1563 * @brief Invoked from HiddenText when showing time of the last character was expired
1565 virtual void DisplayTimeExpired();
1570 * @brief Called by editable UI controls when key events are received.
1572 * @param[in] text The text to insert.
1573 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1575 void InsertText( const std::string& text, InsertType type );
1578 * @brief Paste given string into Text model
1579 * @param[in] stringToPaste this string will be inserted into the text model
1581 void PasteText( const std::string& stringToPaste );
1584 * @brief Remove a given number of characters
1586 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1587 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1588 * style when pre-edit text is removed.
1590 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1591 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1592 * @param[in] type Whether to update the input style.
1593 * @return True if the remove was successful.
1595 bool RemoveText( int cursorOffset,
1596 int numberOfCharacters,
1597 UpdateInputStyleType type );
1600 * @brief Checks if text is selected and if so removes it.
1601 * @return true if text was removed
1603 bool RemoveSelectedText();
1605 private: // Relayout.
1608 * @brief Lays-out the text.
1610 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1612 * @param[in] size A the size of a bounding box to layout text within.
1613 * @param[in] operations The layout operations which need to be done.
1614 * @param[out] layoutSize The size of the laid-out text.
1616 bool DoRelayout( const Size& size,
1617 OperationsMask operations,
1621 * @brief Calulates the vertical offset to align the text inside the bounding box.
1623 * @param[in] size The size of the bounding box.
1625 void CalculateVerticalOffset( const Size& size );
1630 * @brief Process queued events which modify the model.
1632 void ProcessModifyEvents();
1635 * @brief Used to process an event queued from SetText()
1637 void TextReplacedEvent();
1640 * @brief Used to process an event queued from key events etc.
1642 void TextInsertedEvent();
1645 * @brief Used to process an event queued from backspace key etc.
1647 void TextDeletedEvent();
1650 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1652 * @param[in] keyCode The keycode for the key pressed
1653 * @return True if a character was deleted.
1655 bool DeleteEvent( int keyCode );
1657 private: // Helpers.
1660 * @brief Used to remove the text included the placeholder text.
1665 * @brief Helper to show the place holder text..
1667 void ShowPlaceholderText();
1670 * @brief Helper to clear font-specific data (only).
1672 void ClearFontData();
1675 * @brief Helper to clear text's style data.
1677 void ClearStyleData();
1680 * @brief Used to reset the scroll position after setting a new text.
1682 void ResetScrollPosition();
1684 private: // Private contructors & copy operator.
1687 * @brief Private constructor.
1692 * @brief Private constructor.
1694 Controller( ControlInterface* controlInterface );
1697 * @brief Private constructor.
1699 Controller( ControlInterface* controlInterface,
1700 EditableControlInterface* editableControlInterface );
1703 Controller( const Controller& handle );
1706 Controller& operator=( const Controller& handle );
1708 protected: // Destructor.
1711 * @brief A reference counted object may only be deleted by calling Unreference().
1713 virtual ~Controller();
1717 struct Impl; ///< Made public for testing purposes
1726 } // namespace Toolkit
1730 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H