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;
51 * @brief Text selection operations .
60 typedef IntrusivePtr<Controller> ControllerPtr;
63 * @brief A Text Controller is used by UI Controls which display text.
65 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
66 * It provides a view of the text that can be used by rendering back-ends.
68 * For selectable/editable UI controls, the controller handles input events from the UI control
69 * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
71 * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
73 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
75 public: // Enumerated types.
78 * @brief Text related operations to be done in the relayout process.
82 NO_OPERATION = 0x0000,
83 CONVERT_TO_UTF32 = 0x0001,
85 VALIDATE_FONTS = 0x0004,
86 GET_LINE_BREAKS = 0x0008,
89 GET_GLYPH_METRICS = 0x0040,
91 UPDATE_LAYOUT_SIZE = 0x0100,
95 UPDATE_DIRECTION = 0x1000,
96 ALL_OPERATIONS = 0xFFFF
100 * @brief Used to distinguish between regular key events and InputMethodContext events
109 * @brief Used to specify whether to update the input style.
111 enum UpdateInputStyleType
114 DONT_UPDATE_INPUT_STYLE
118 * @brief Used to specify what has been updated after the Relayout() method has been called.
122 NONE_UPDATED = 0x0, ///< Nothing has been updated.
123 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
124 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
128 * @brief Different placeholder-text can be shown when the control is active/inactive.
132 PLACEHOLDER_TYPE_ACTIVE,
133 PLACEHOLDER_TYPE_INACTIVE,
137 * @brief Enumeration for Font Size Type.
141 POINT_SIZE, // The size of font in points.
142 PIXEL_SIZE // The size of font in pixels.
149 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
150 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
151 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
163 TEXT_FIT_FONT_SIZE_TYPE
167 public: // Constructor.
170 * @brief Create a new instance of a Controller.
172 * @return A pointer to a new Controller.
174 static ControllerPtr New();
177 * @brief Create a new instance of a Controller.
179 * @param[in] controlInterface The control's interface.
181 * @return A pointer to a new Controller.
183 static ControllerPtr New( ControlInterface* controlInterface );
186 * @brief Create a new instance of a Controller.
188 * @param[in] controlInterface The control's interface.
189 * @param[in] editableControlInterface The editable control's interface.
191 * @return A pointer to a new Controller.
193 static ControllerPtr New( ControlInterface* controlInterface,
194 EditableControlInterface* editableControlInterface );
196 public: // Configure the text controller.
199 * @brief Called to enable text input.
201 * @note Selectable or editable controls should call this once after Controller::New().
202 * @param[in] decorator Used to create cursor, selection handle decorations etc.
203 * @param[in] inputMethodContext Used to manager ime.
205 void EnableTextInput( DecoratorPtr decorator, InputMethodContext& inputMethodContext );
208 * @brief Used to switch between bitmap & vector based glyphs
210 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
212 void SetGlyphType( TextAbstraction::GlyphType glyphType );
215 * @brief Enables/disables the mark-up processor.
217 * By default is disabled.
219 * @param[in] enable Whether to enable the mark-up processor.
221 void SetMarkupProcessorEnabled( bool enable );
224 * @brief Retrieves whether the mark-up processor is enabled.
226 * By default is disabled.
228 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
230 bool IsMarkupProcessorEnabled() const;
233 * @brief Enables/disables the auto text scrolling
235 * By default is disabled.
237 * @param[in] enable Whether to enable the auto scrolling
239 void SetAutoScrollEnabled( bool enable );
242 * @brief Retrieves whether auto text scrolling is enabled.
244 * By default is disabled.
246 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
248 bool IsAutoScrollEnabled() const;
251 * @brief Get direction of the text from the first line of text,
252 * @return bool rtl (right to left) is true
254 CharacterDirection GetAutoScrollDirection() const;
257 * @brief Get the alignment offset of the first line of text.
259 * @return The alignment offset.
261 float GetAutoScrollLineAlignment() const;
264 * @brief Enables the horizontal scrolling.
266 * @param[in] enable Whether to enable the horizontal scrolling.
268 void SetHorizontalScrollEnabled( bool enable );
271 * @brief Retrieves whether the horizontal scrolling is enabled.
273 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
275 bool IsHorizontalScrollEnabled() const;
278 * @brief Enables the vertical scrolling.
280 * @param[in] enable Whether to enable the vertical scrolling.
282 void SetVerticalScrollEnabled( bool enable );
285 * @brief Retrieves whether the verticall scrolling is enabled.
287 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
289 bool IsVerticalScrollEnabled() const;
292 * @brief Enables the smooth handle panning.
294 * @param[in] enable Whether to enable the smooth handle panning.
296 void SetSmoothHandlePanEnabled( bool enable );
299 * @brief Retrieves whether the smooth handle panning is enabled.
301 * @return @e true if the smooth handle panning is enabled.
303 bool IsSmoothHandlePanEnabled() const;
306 * @brief Sets the maximum number of characters that can be inserted into the TextModel
308 * @param[in] maxCharacters maximum number of characters to be accepted
310 void SetMaximumNumberOfCharacters( Length maxCharacters );
313 * @brief Sets the maximum number of characters that can be inserted into the TextModel
315 * @param[in] maxCharacters maximum number of characters to be accepted
317 int GetMaximumNumberOfCharacters();
320 * @brief Called to enable/disable cursor blink.
322 * @note Only editable controls should calls this.
323 * @param[in] enabled Whether the cursor should blink or not.
325 void SetEnableCursorBlink( bool enable );
328 * @brief Query whether cursor blink is enabled.
330 * @return Whether the cursor should blink or not.
332 bool GetEnableCursorBlink() const;
335 * @brief Whether to enable the multi-line layout.
337 * @param[in] enable \e true enables the multi-line (by default)
339 void SetMultiLineEnabled( bool enable );
342 * @return Whether the multi-line layout is enabled.
344 bool IsMultiLineEnabled() const;
347 * @brief Sets the text's horizontal alignment.
349 * @param[in] alignment The horizontal alignment.
351 void SetHorizontalAlignment( HorizontalAlignment::Type alignment );
354 * @copydoc ModelInterface::GetHorizontalAlignment()
356 HorizontalAlignment::Type GetHorizontalAlignment() const;
359 * @brief Sets the text's vertical alignment.
361 * @param[in] alignment The vertical alignment.
363 void SetVerticalAlignment( VerticalAlignment::Type alignment );
366 * @copydoc ModelInterface::GetVerticalAlignment()
368 VerticalAlignment::Type GetVerticalAlignment() const;
371 * @brief Sets the text's wrap mode
372 * @param[in] text wrap mode The unit of wrapping
374 void SetLineWrapMode( Text::LineWrap::Mode textWarpMode );
377 * @brief Retrieve text wrap mode previously set.
378 * @return text wrap mode
380 Text::LineWrap::Mode GetLineWrapMode() const;
383 * @brief Enable or disable the text elide.
385 * @param[in] enabled Whether to enable the text elide.
387 void SetTextElideEnabled( bool enabled );
390 * @copydoc ModelInterface::IsTextElideEnabled()
392 bool IsTextElideEnabled() const;
395 * @brief Enable or disable the text fit.
397 * @param[in] enabled Whether to enable the text fit.
399 void SetTextFitEnabled(bool enabled);
402 * @brief Whether the text fit is enabled or not.
404 * @return True if the text fit is enabled
406 bool IsTextFitEnabled() const;
409 * @brief Sets minimum size valid for text fit.
411 * @param[in] minimum size value.
412 * @param[in] type The font size type is point size or pixel size
414 void SetTextFitMinSize( float pointSize, FontSizeType type );
417 * @brief Retrieves the minimum point size valid for text fit.
419 * @return The minimum point size valid for text fit
421 float GetTextFitMinSize() const;
424 * @brief Sets maximum size valid for text fit.
426 * @param[in] maximum size value.
427 * @param[in] type The font size type is point size or pixel size
429 void SetTextFitMaxSize( float pointSize, FontSizeType type );
432 * @brief Retrieves the maximum point size valid for text fit.
434 * @return The maximum point size valid for text fit
436 float GetTextFitMaxSize() const;
439 * @brief Sets step size for font increase valid for text fit.
441 * @param[in] step size value.
442 * @param[in] type The font size type is point size or pixel size
444 void SetTextFitStepSize( float step, FontSizeType type );
447 * @brief Retrieves the step point size valid for text fit.
449 * @return The step point size valid for text fit
451 float GetTextFitStepSize() const;
454 * @brief Sets content size valid for text fit.
456 * @param[in] Content size value.
458 void SetTextFitContentSize(Vector2 size);
461 * @brief Retrieves the content size valid for text fit.
463 * @return The content size valid for text fit
465 Vector2 GetTextFitContentSize() const;
468 * @brief Enable or disable the placeholder text elide.
469 * @param enabled Whether to enable the placeholder text elide.
471 void SetPlaceholderTextElideEnabled( bool enabled );
474 * @brief Whether the placeholder text elide property is enabled.
475 * @return True if the placeholder text elide property is enabled, false otherwise.
477 bool IsPlaceholderTextElideEnabled() const;
480 * @brief Enable or disable the text selection.
481 * @param[in] enabled Whether to enable the text selection.
483 void SetSelectionEnabled( bool enabled );
486 * @brief Whether the text selection is enabled or not.
487 * @return True if the text selection is enabled
489 bool IsSelectionEnabled() const;
492 * @brief Enable or disable the text selection using Shift key.
493 * @param enabled Whether to enable the text selection using Shift key
495 void SetShiftSelectionEnabled( bool enabled );
498 * @brief Whether the text selection using Shift key is enabled or not.
499 * @return True if the text selection using Shift key is enabled
501 bool IsShiftSelectionEnabled() const;
504 * @brief Enable or disable the grab handles for text selection.
506 * @param[in] enabled Whether to enable the grab handles
508 void SetGrabHandleEnabled( bool enabled );
511 * @brief Returns whether the grab handles are enabled.
513 * @return True if the grab handles are enabled
515 bool IsGrabHandleEnabled() const;
518 * @brief Enable or disable the grab handles for text selection.
520 * @param[in] enabled Whether to enable the grab handles
522 void SetGrabHandlePopupEnabled( bool enabled );
525 * @brief Returns whether the grab handles are enabled.
527 * @return True if the grab handles are enabled
529 bool IsGrabHandlePopupEnabled() const;
532 * @brief Sets input type to password
534 * @note The string is displayed hidden character
536 * @param[in] passwordInput True if password input is enabled.
538 void SetInputModePassword( bool passwordInput );
541 * @brief Returns whether the input mode type is set as password.
543 * @return True if input mode type is password
545 bool IsInputModePassword();
548 * @brief Sets the action when there is a double tap event on top of a text area with no text.
550 * @param[in] action The action to do.
552 void SetNoTextDoubleTapAction( NoTextTap::Action action );
555 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
557 * @return The action to do.
559 NoTextTap::Action GetNoTextDoubleTapAction() const;
562 * @briefSets the action when there is a long press event on top of a text area with no text.
564 * @param[in] action The action to do.
566 void SetNoTextLongPressAction( NoTextTap::Action action );
569 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
571 * @return The action to do.
573 NoTextTap::Action GetNoTextLongPressAction() const;
576 * @brief Query if Underline settings were provided by string or map
577 * @return bool true if set by string
579 bool IsUnderlineSetByString();
582 * Set method underline setting were set by
583 * @param[in] bool, true if set by string
585 void UnderlineSetByString( bool setByString );
588 * @brief Query if shadow settings were provided by string or map
589 * @return bool true if set by string
591 bool IsShadowSetByString();
594 * Set method shadow setting were set by
595 * @param[in] bool, true if set by string
597 void ShadowSetByString( bool setByString );
600 * @brief Query if outline settings were provided by string or map
601 * @return bool true if set by string
603 bool IsOutlineSetByString();
606 * Set method outline setting were set by
607 * @param[in] bool, true if set by string
609 void OutlineSetByString( bool setByString );
612 * @brief Query if font style settings were provided by string or map
613 * @return bool true if set by string
615 bool IsFontStyleSetByString();
618 * Set method font style setting were set by
619 * @param[in] bool, true if set by string
621 void FontStyleSetByString( bool setByString );
626 * @brief Replaces any text previously set.
628 * @note This will be converted into UTF-32 when stored in the text model.
629 * @param[in] text A string of UTF-8 characters.
631 void SetText( const std::string& text );
634 * @brief Retrieve any text previously set.
636 * @param[out] text A string of UTF-8 characters.
638 void GetText( std::string& text ) const;
641 * @brief Replaces any placeholder text previously set.
643 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
644 * @param[in] text A string of UTF-8 characters.
646 void SetPlaceholderText( PlaceholderType type, const std::string& text );
649 * @brief Retrieve any placeholder text previously set.
651 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
652 * @param[out] A string of UTF-8 characters.
654 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
657 * @ brief Update the text after a font change
658 * @param[in] newDefaultFont The new font to change to
660 void UpdateAfterFontChange( const std::string& newDefaultFont );
662 public: // Default style & Input style
665 * @brief Set the default font family.
667 * @param[in] defaultFontFamily The default font family.
669 void SetDefaultFontFamily( const std::string& defaultFontFamily );
672 * @brief Retrieve the default font family.
674 * @return The default font family.
676 const std::string& GetDefaultFontFamily() const;
679 * @brief Sets the placeholder text font family.
680 * @param[in] placeholderTextFontFamily The placeholder text font family.
682 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
685 * @brief Retrieves the placeholder text font family.
687 * @return The placeholder text font family
689 const std::string& GetPlaceholderFontFamily() const;
692 * @brief Sets the default font weight.
694 * @param[in] weight The font weight.
696 void SetDefaultFontWeight( FontWeight weight );
699 * @brief Whether the font's weight has been defined.
701 bool IsDefaultFontWeightDefined() const;
704 * @brief Retrieves the default font weight.
706 * @return The default font weight.
708 FontWeight GetDefaultFontWeight() const;
711 * @brief Sets the placeholder text font weight.
713 * @param[in] weight The font weight
715 void SetPlaceholderTextFontWeight( FontWeight weight );
718 * @brief Whether the font's weight has been defined.
720 * @return True if the placeholder text font weight is defined
722 bool IsPlaceholderTextFontWeightDefined() const;
725 * @brief Retrieves the placeholder text font weight.
727 * @return The placeholder text font weight
729 FontWeight GetPlaceholderTextFontWeight() const;
732 * @brief Sets the default font width.
734 * @param[in] width The font width.
736 void SetDefaultFontWidth( FontWidth width );
739 * @brief Whether the font's width has been defined.
741 bool IsDefaultFontWidthDefined() const;
744 * @brief Retrieves the default font width.
746 * @return The default font width.
748 FontWidth GetDefaultFontWidth() const;
751 * @brief Sets the placeholder text font width.
753 * @param[in] width The font width
755 void SetPlaceholderTextFontWidth( FontWidth width );
758 * @brief Whether the font's width has been defined.
760 * @return True if the placeholder text font width is defined
762 bool IsPlaceholderTextFontWidthDefined() const;
765 * @brief Retrieves the placeholder text font width.
767 * @return The placeholder text font width
769 FontWidth GetPlaceholderTextFontWidth() const;
772 * @brief Sets the default font slant.
774 * @param[in] slant The font slant.
776 void SetDefaultFontSlant( FontSlant slant );
779 * @brief Whether the font's slant has been defined.
781 bool IsDefaultFontSlantDefined() const;
784 * @brief Retrieves the default font slant.
786 * @return The default font slant.
788 FontSlant GetDefaultFontSlant() const;
791 * @brief Sets the placeholder text font slant.
793 * @param[in] slant The font slant
795 void SetPlaceholderTextFontSlant( FontSlant slant );
798 * @brief Whether the font's slant has been defined.
800 * @return True if the placeholder text font slant is defined
802 bool IsPlaceholderTextFontSlantDefined() const;
805 * @brief Retrieves the placeholder text font slant.
807 * @return The placeholder text font slant
809 FontSlant GetPlaceholderTextFontSlant() const;
812 * @brief Set the default font size.
814 * @param[in] fontSize The default font size
815 * @param[in] type The font size type is point size or pixel size
817 void SetDefaultFontSize( float fontSize, FontSizeType type );
820 * @brief Retrieve the default point size.
822 * @param[in] type The font size type
823 * @return The default point size.
825 float GetDefaultFontSize( FontSizeType type ) const;
828 * @brief Sets the Placeholder text font size.
829 * @param[in] fontSize The placeholder text font size
830 * @param[in] type The font size type is point size or pixel size
832 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
835 * @brief Retrieves the Placeholder text font size.
836 * @param[in] type The font size type
837 * @return The placeholder font size
839 float GetPlaceholderTextFontSize( FontSizeType type ) const;
842 * @brief Sets the text's default color.
844 * @param color The default color.
846 void SetDefaultColor( const Vector4& color );
849 * @brief Retrieves the text's default color.
851 * @return The default color.
853 const Vector4& GetDefaultColor() const;
856 * @brief Set the text color
858 * @param textColor The text color
860 void SetPlaceholderTextColor( const Vector4& textColor );
863 * @brief Retrieve the text color
865 * @return The text color
867 const Vector4& GetPlaceholderTextColor() const;
870 * @brief Set the shadow offset.
872 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
874 void SetShadowOffset( const Vector2& shadowOffset );
877 * @brief Retrieve the shadow offset.
879 * @return The shadow offset.
881 const Vector2& GetShadowOffset() const;
884 * @brief Set the shadow color.
886 * @param[in] shadowColor The shadow color.
888 void SetShadowColor( const Vector4& shadowColor );
891 * @brief Retrieve the shadow color.
893 * @return The shadow color.
895 const Vector4& GetShadowColor() const;
898 * @brief Set the shadow blur radius.
900 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
902 void SetShadowBlurRadius( const float& shadowBlurRadius );
905 * @brief Retrieve the shadow blur radius.
907 * @return The shadow blur radius.
909 const float& GetShadowBlurRadius() const;
912 * @brief Set the underline color.
914 * @param[in] color color of underline.
916 void SetUnderlineColor( const Vector4& color );
919 * @brief Retrieve the underline color.
921 * @return The underline color.
923 const Vector4& GetUnderlineColor() const;
926 * @brief Set the underline enabled flag.
928 * @param[in] enabled The underline enabled flag.
930 void SetUnderlineEnabled( bool enabled );
933 * @brief Returns whether the text is underlined or not.
935 * @return The underline state.
937 bool IsUnderlineEnabled() const;
940 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
942 * @param[in] height The height in pixels of the underline
944 void SetUnderlineHeight( float height );
947 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
949 * @return The height of the underline, or 0 if height is not overrided.
951 float GetUnderlineHeight() const;
954 * @brief Set the outline color.
956 * @param[in] color color of outline.
958 void SetOutlineColor( const Vector4& color );
961 * @brief Retrieve the outline color.
963 * @return The outline color.
965 const Vector4& GetOutlineColor() const;
968 * @brief Set the outline width
970 * @param[in] width The width in pixels of the outline, 0 indicates no outline
972 void SetOutlineWidth( uint16_t width );
975 * @brief Retrieves the width of an outline
977 * @return The width of the outline.
979 uint16_t GetOutlineWidth() const;
982 * @brief Set the background color.
984 * @param[in] color color of background.
986 void SetBackgroundColor( const Vector4& color );
989 * @brief Retrieve the background color.
991 * @return The background color.
993 const Vector4& GetBackgroundColor() const;
996 * @brief Set the background enabled flag.
998 * @param[in] enabled The background enabled flag.
1000 void SetBackgroundEnabled( bool enabled );
1003 * @brief Returns whether to enable text background or not.
1005 * @return Whether text background is enabled.
1007 bool IsBackgroundEnabled() const;
1010 * @brief Sets the emboss's properties string.
1012 * @note The string is stored to be recovered.
1014 * @param[in] embossProperties The emboss's properties string.
1016 void SetDefaultEmbossProperties( const std::string& embossProperties );
1019 * @brief Retrieves the emboss's properties string.
1021 * @return The emboss's properties string.
1023 const std::string& GetDefaultEmbossProperties() const;
1026 * @brief Sets the outline's properties string.
1028 * @note The string is stored to be recovered.
1030 * @param[in] outlineProperties The outline's properties string.
1032 void SetDefaultOutlineProperties( const std::string& outlineProperties );
1035 * @brief Retrieves the outline's properties string.
1037 * @return The outline's properties string.
1039 const std::string& GetDefaultOutlineProperties() const;
1042 * @brief Sets the default line spacing.
1044 * @param[in] lineSpacing The line spacing.
1046 * @return True if lineSpacing has been updated, false otherwise
1048 bool SetDefaultLineSpacing( float lineSpacing );
1051 * @brief Retrieves the default line spacing.
1053 * @return The line spacing.
1055 float GetDefaultLineSpacing() const;
1058 * @brief Sets the default line size.
1060 * @param[in] lineSize The line size.
1062 * @return True if lineSize has been updated, false otherwise
1064 bool SetDefaultLineSize( float lineSize );
1067 * @brief Retrieves the default line size.
1069 * @return The line size.
1071 float GetDefaultLineSize() const;
1074 * @brief Sets the input text's color.
1076 * @param[in] color The input text's color.
1078 void SetInputColor( const Vector4& color );
1081 * @brief Retrieves the input text's color.
1083 * @return The input text's color.
1085 const Vector4& GetInputColor() const;
1088 * @brief Sets the input text's font family name.
1090 * @param[in] fontFamily The text's font family name.
1092 void SetInputFontFamily( const std::string& fontFamily );
1095 * @brief Retrieves the input text's font family name.
1097 * @return The input text's font family name.
1099 const std::string& GetInputFontFamily() const;
1102 * @brief Sets the input font's weight.
1104 * @param[in] weight The input font's weight.
1106 void SetInputFontWeight( FontWeight weight );
1109 * @return Whether the font's weight has been defined.
1111 bool IsInputFontWeightDefined() const;
1114 * @brief Retrieves the input font's weight.
1116 * @return The input font's weight.
1118 FontWeight GetInputFontWeight() const;
1121 * @brief Sets the input font's width.
1123 * @param[in] width The input font's width.
1125 void SetInputFontWidth( FontWidth width );
1128 * @return Whether the font's width has been defined.
1130 bool IsInputFontWidthDefined() const;
1133 * @brief Retrieves the input font's width.
1135 * @return The input font's width.
1137 FontWidth GetInputFontWidth() const;
1140 * @brief Sets the input font's slant.
1142 * @param[in] slant The input font's slant.
1144 void SetInputFontSlant( FontSlant slant );
1147 * @return Whether the font's slant has been defined.
1149 bool IsInputFontSlantDefined() const;
1152 * @brief Retrieves the input font's slant.
1154 * @return The input font's slant.
1156 FontSlant GetInputFontSlant() const;
1159 * @brief Sets the input font's point size.
1161 * @param[in] size The input font's point size.
1163 void SetInputFontPointSize( float size );
1166 * @brief Retrieves the input font's point size.
1168 * @return The input font's point size.
1170 float GetInputFontPointSize() const;
1173 * @brief Sets the input line spacing.
1175 * @param[in] lineSpacing The line spacing.
1177 void SetInputLineSpacing( float lineSpacing );
1180 * @brief Retrieves the input line spacing.
1182 * @return The line spacing.
1184 float GetInputLineSpacing() const;
1187 * @brief Sets the input shadow's properties string.
1189 * @note The string is stored to be recovered.
1191 * @param[in] shadowProperties The shadow's properties string.
1193 void SetInputShadowProperties( const std::string& shadowProperties );
1196 * @brief Retrieves the input shadow's properties string.
1198 * @return The shadow's properties string.
1200 const std::string& GetInputShadowProperties() const;
1203 * @brief Sets the input underline's properties string.
1205 * @note The string is stored to be recovered.
1207 * @param[in] underlineProperties The underline's properties string.
1209 void SetInputUnderlineProperties( const std::string& underlineProperties );
1212 * @brief Retrieves the input underline's properties string.
1214 * @return The underline's properties string.
1216 const std::string& GetInputUnderlineProperties() const;
1219 * @brief Sets the input emboss's properties string.
1221 * @note The string is stored to be recovered.
1223 * @param[in] embossProperties The emboss's properties string.
1225 void SetInputEmbossProperties( const std::string& embossProperties );
1228 * @brief Retrieves the input emboss's properties string.
1230 * @return The emboss's properties string.
1232 const std::string& GetInputEmbossProperties() const;
1235 * @brief Sets input the outline's properties string.
1237 * @note The string is stored to be recovered.
1239 * @param[in] outlineProperties The outline's properties string.
1241 void SetInputOutlineProperties( const std::string& outlineProperties );
1244 * @brief Retrieves the input outline's properties string.
1246 * @return The outline's properties string.
1248 const std::string& GetInputOutlineProperties() const;
1251 * @brief Set the control's interface.
1253 * @param[in] controlInterface The control's interface.
1255 void SetControlInterface( ControlInterface* controlInterface );
1257 public: // Queries & retrieves.
1260 * @brief Return the layout engine.
1262 * @return A reference to the layout engine.
1264 Layout::Engine& GetLayoutEngine();
1267 * @brief Return a view of the text.
1269 * @return A reference to the view.
1274 * @copydoc Control::GetNaturalSize()
1276 Vector3 GetNaturalSize();
1279 * @copydoc Control::GetHeightForWidth()
1281 float GetHeightForWidth( float width );
1284 * @brief Calculates the point size for text for given layout()
1286 void FitPointSizeforLayout( Size layoutSize );
1289 * @brief Checks if the point size fits within the layout size.
1291 * @return Whether the point size fits within the layout size.
1293 bool CheckForTextFit( float pointSize, Size& layoutSize );
1296 * @brief Retrieves the text's number of lines for a given width.
1297 * @param[in] width The width of the text's area.
1298 * @ return The number of lines.
1300 int GetLineCount( float width );
1303 * @brief Retrieves the text's model.
1305 * @return A pointer to the text's model.
1307 const ModelInterface* const GetTextModel() const;
1310 * @brief Used to get scrolled distance by user input
1312 * @return Distance from last scroll offset to new scroll offset
1314 float GetScrollAmountByUserInput();
1317 * @brief Get latest scroll amount, control size and layout size
1319 * This method is used to get information of control's scroll
1320 * @param[out] scrollPosition The current scrolled position
1321 * @param[out] controlHeight The size of a UI control
1322 * @param[out] layoutHeight The size of a bounding box to layout text within.
1324 * @return Whether the text scroll position is changed or not after last update.
1326 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1329 * @brief Used to set the hidden input option
1331 void SetHiddenInputOption( const Property::Map& options );
1334 * @brief Used to get the hidden input option
1336 void GetHiddenInputOption( Property::Map& options );
1339 * @brief Sets the Placeholder Properties.
1341 * @param[in] map The placeholder property map
1343 void SetPlaceholderProperty( const Property::Map& map );
1346 * @brief Retrieves the Placeholder Property map.
1348 * @param[out] map The property map
1350 void GetPlaceholderProperty( Property::Map& map );
1353 * @brief Checks text direction.
1354 * @return The text direction.
1356 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1359 * @brief Retrieves vertical line alignment
1360 * @return The vertical line alignment
1362 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1365 * @brief Sets vertical line alignment
1366 * @param[in] alignment The vertical line alignment for the text
1368 void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
1371 * @brief Retrieves ignoreSpaceAfterText value from model
1372 * @return The value of ignoreSpaceAfterText
1374 bool IsIgnoreSpacesAfterText() const;
1377 * @brief Sets ignoreSpaceAfterText value to model
1378 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1380 void SetIgnoreSpacesAfterText( bool ignore );
1383 * @brief Retrieves matchSystemLanguageDirection value from model
1384 * @return The value of matchSystemLanguageDirection
1386 bool IsMatchSystemLanguageDirection() const;
1389 * @brief Sets matchSystemLanguageDirection value to model
1390 * @param[in] match The value of matchSystemLanguageDirection for the text
1392 void SetMatchSystemLanguageDirection( bool match );
1395 * @brief Sets layoutDirection value
1396 * @param[in] layoutDirection The value of system language direction
1398 void SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection );
1401 * @brief Retrieves if showing real text or not.
1402 * @return The value of showing real text.
1404 bool IsShowingRealText() const;
1406 public: // Relayout.
1409 * @brief Triggers a relayout which updates View (if necessary).
1411 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1412 * @param[in] size A the size of a bounding box to layout text within.
1413 * @param[in] layoutDirection The direction of the system language.
1415 * @return Whether the text model or decorations were updated.
1417 UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT );
1420 * @brief Request a relayout using the ControlInterface.
1422 void RequestRelayout();
1424 public: // Input style change signals.
1427 * @return Whether the queue of input style changed signals is empty.
1429 bool IsInputStyleChangedSignalsQueueEmpty();
1432 * @brief Process all pending input style changed signals.
1434 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1435 * text controls. Text controls may send signals to state the input style has changed.
1437 void ProcessInputStyleChangedSignals();
1439 public: // Text-input Event Queuing.
1442 * @brief Called by editable UI controls when keyboard focus is gained.
1444 void KeyboardFocusGainEvent();
1447 * @brief Called by editable UI controls when focus is lost.
1449 void KeyboardFocusLostEvent();
1452 * @brief Called by editable UI controls when key events are received.
1454 * @param[in] event The key event.
1455 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1457 bool KeyEvent( const Dali::KeyEvent& event );
1460 * @brief Called by editable UI controls when a tap gesture occurs.
1461 * @param[in] tapCount The number of taps.
1462 * @param[in] x The x position relative to the top-left of the parent control.
1463 * @param[in] y The y position relative to the top-left of the parent control.
1465 void TapEvent( unsigned int tapCount, float x, float y );
1468 * @brief Called by editable UI controls when a pan gesture occurs.
1470 * @param[in] state The state of the gesture.
1471 * @param[in] displacement This distance panned since the last pan gesture.
1473 void PanEvent( GestureState state, const Vector2& displacement );
1476 * @brief Called by editable UI controls when a long press gesture occurs.
1478 * @param[in] state The state of the gesture.
1479 * @param[in] x The x position relative to the top-left of the parent control.
1480 * @param[in] y The y position relative to the top-left of the parent control.
1482 void LongPressEvent( GestureState state, float x, float y );
1485 * @brief Creates a selection event.
1487 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1489 * @param[in] x The x position relative to the top-left of the parent control.
1490 * @param[in] y The y position relative to the top-left of the parent control.
1491 * @param[in] selection type like the whole text is selected or unselected.
1493 void SelectEvent( float x, float y, SelectionType selection );
1496 * @brief Event received from input method context
1498 * @param[in] inputMethodContext The input method context.
1499 * @param[in] inputMethodContextEvent The event received.
1500 * @return A data struture indicating if update is needed, cursor position and current text.
1502 InputMethodContext::CallbackData OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent );
1505 * @brief Event from Clipboard notifying an Item has been selected for pasting
1507 void PasteClipboardItemEvent();
1510 * @brief Return true when text control should clear key input focus when escape key is pressed.
1512 * @return Whether text control should clear key input focus or not when escape key is pressed.
1514 bool ShouldClearFocusOnEscape() const;
1517 * @brief Create an actor that renders the text background color
1519 * @return the created actor or an empty handle if no background color needs to be rendered.
1521 Actor CreateBackgroundActor();
1524 * @brief Retrive Selected text.
1526 * @return The seleced text.
1528 std::string GetSelectedText();
1530 protected: // Inherit from Text::Decorator::ControllerInterface.
1533 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1535 void GetTargetSize( Vector2& targetSize ) override;
1538 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1540 void AddDecoration( Actor& actor, bool needsClipping ) override;
1543 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1545 void DecorationEvent( HandleType handle, HandleState state, float x, float y ) override;
1547 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1550 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1552 void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button ) override;
1554 protected: // Inherit from HiddenText.
1557 * @brief Invoked from HiddenText when showing time of the last character was expired
1559 void DisplayTimeExpired() override;
1564 * @brief Called by editable UI controls when key events are received.
1566 * @param[in] text The text to insert.
1567 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1569 void InsertText( const std::string& text, InsertType type );
1572 * @brief Paste given string into Text model
1573 * @param[in] stringToPaste this string will be inserted into the text model
1575 void PasteText( const std::string& stringToPaste );
1578 * @brief Remove a given number of characters
1580 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1581 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1582 * style when pre-edit text is removed.
1584 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1585 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1586 * @param[in] type Whether to update the input style.
1587 * @return True if the remove was successful.
1589 bool RemoveText( int cursorOffset,
1590 int numberOfCharacters,
1591 UpdateInputStyleType type );
1594 * @brief Checks if text is selected and if so removes it.
1595 * @return true if text was removed
1597 bool RemoveSelectedText();
1599 private: // Relayout.
1602 * @brief Lays-out the text.
1604 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1606 * @param[in] size A the size of a bounding box to layout text within.
1607 * @param[in] operations The layout operations which need to be done.
1608 * @param[out] layoutSize The size of the laid-out text.
1610 bool DoRelayout( const Size& size,
1611 OperationsMask operations,
1615 * @brief Calulates the vertical offset to align the text inside the bounding box.
1617 * @param[in] size The size of the bounding box.
1619 void CalculateVerticalOffset( const Size& size );
1624 * @brief Process queued events which modify the model.
1626 void ProcessModifyEvents();
1629 * @brief Used to process an event queued from SetText()
1631 void TextReplacedEvent();
1634 * @brief Used to process an event queued from key events etc.
1636 void TextInsertedEvent();
1639 * @brief Used to process an event queued from backspace key etc.
1641 void TextDeletedEvent();
1644 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1646 * @param[in] keyCode The keycode for the key pressed
1647 * @return True if a character was deleted.
1649 bool DeleteEvent( int keyCode );
1651 private: // Helpers.
1654 * @brief Used to remove the text included the placeholder text.
1659 * @brief Helper to show the place holder text..
1661 void ShowPlaceholderText();
1664 * @brief Helper to clear font-specific data (only).
1666 void ClearFontData();
1669 * @brief Helper to clear text's style data.
1671 void ClearStyleData();
1674 * @brief Used to reset the cursor position after setting a new text.
1676 * @param[in] cursorIndex Where to place the cursor.
1678 void ResetCursorPosition( CharacterIndex cursorIndex );
1681 * @brief Used to reset the scroll position after setting a new text.
1683 void ResetScrollPosition();
1685 private: // Private contructors & copy operator.
1688 * @brief Private constructor.
1693 * @brief Private constructor.
1695 Controller( ControlInterface* controlInterface );
1698 * @brief Private constructor.
1700 Controller( ControlInterface* controlInterface,
1701 EditableControlInterface* editableControlInterface );
1704 Controller( const Controller& handle );
1707 Controller& operator=( const Controller& handle );
1709 protected: // Destructor.
1712 * @brief A reference counted object may only be deleted by calling Unreference().
1714 virtual ~Controller();
1718 struct Impl; ///< Made public for testing purposes
1727 } // namespace Toolkit
1731 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H