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,
79 GET_GLYPH_METRICS = 0x0040,
81 UPDATE_LAYOUT_SIZE = 0x0100,
85 UPDATE_DIRECTION = 0x1000,
86 ALL_OPERATIONS = 0xFFFF
90 * @brief Used to distinguish between regular key events and InputMethodContext events
99 * @brief Used to specify whether to update the input style.
101 enum UpdateInputStyleType
104 DONT_UPDATE_INPUT_STYLE
108 * @brief Used to specify what has been updated after the Relayout() method has been called.
112 NONE_UPDATED = 0x0, ///< Nothing has been updated.
113 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
114 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
118 * @brief Different placeholder-text can be shown when the control is active/inactive.
122 PLACEHOLDER_TYPE_ACTIVE,
123 PLACEHOLDER_TYPE_INACTIVE,
127 * @brief Enumeration for Font Size Type.
131 POINT_SIZE, // The size of font in points.
132 PIXEL_SIZE // The size of font in pixels.
139 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
140 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
141 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
153 TEXT_FIT_FONT_SIZE_TYPE
157 public: // Constructor.
160 * @brief Create a new instance of a Controller.
162 * @return A pointer to a new Controller.
164 static ControllerPtr New();
167 * @brief Create a new instance of a Controller.
169 * @param[in] controlInterface The control's interface.
171 * @return A pointer to a new Controller.
173 static ControllerPtr New( ControlInterface* controlInterface );
176 * @brief Create a new instance of a Controller.
178 * @param[in] controlInterface The control's interface.
179 * @param[in] editableControlInterface The editable control's interface.
181 * @return A pointer to a new Controller.
183 static ControllerPtr New( ControlInterface* controlInterface,
184 EditableControlInterface* editableControlInterface );
186 public: // Configure the text controller.
189 * @brief Called to enable text input.
191 * @note Selectable or editable controls should call this once after Controller::New().
192 * @param[in] decorator Used to create cursor, selection handle decorations etc.
193 * @param[in] inputMethodContext Used to manager ime.
195 void EnableTextInput( DecoratorPtr decorator, InputMethodContext& inputMethodContext );
198 * @brief Used to switch between bitmap & vector based glyphs
200 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
202 void SetGlyphType( TextAbstraction::GlyphType glyphType );
205 * @brief Enables/disables the mark-up processor.
207 * By default is disabled.
209 * @param[in] enable Whether to enable the mark-up processor.
211 void SetMarkupProcessorEnabled( bool enable );
214 * @brief Retrieves whether the mark-up processor is enabled.
216 * By default is disabled.
218 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
220 bool IsMarkupProcessorEnabled() const;
223 * @brief Enables/disables the auto text scrolling
225 * By default is disabled.
227 * @param[in] enable Whether to enable the auto scrolling
229 void SetAutoScrollEnabled( bool enable );
232 * @brief Retrieves whether auto text scrolling is enabled.
234 * By default is disabled.
236 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
238 bool IsAutoScrollEnabled() const;
241 * @brief Get direction of the text from the first line of text,
242 * @return bool rtl (right to left) is true
244 CharacterDirection GetAutoScrollDirection() const;
247 * @brief Get the alignment offset of the first line of text.
249 * @return The alignment offset.
251 float GetAutoScrollLineAlignment() const;
254 * @brief Enables the horizontal scrolling.
256 * @param[in] enable Whether to enable the horizontal scrolling.
258 void SetHorizontalScrollEnabled( bool enable );
261 * @brief Retrieves whether the horizontal scrolling is enabled.
263 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
265 bool IsHorizontalScrollEnabled() const;
268 * @brief Enables the vertical scrolling.
270 * @param[in] enable Whether to enable the vertical scrolling.
272 void SetVerticalScrollEnabled( bool enable );
275 * @brief Retrieves whether the verticall scrolling is enabled.
277 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
279 bool IsVerticalScrollEnabled() const;
282 * @brief Enables the smooth handle panning.
284 * @param[in] enable Whether to enable the smooth handle panning.
286 void SetSmoothHandlePanEnabled( bool enable );
289 * @brief Retrieves whether the smooth handle panning is enabled.
291 * @return @e true if the smooth handle panning is enabled.
293 bool IsSmoothHandlePanEnabled() const;
296 * @brief Sets the maximum number of characters that can be inserted into the TextModel
298 * @param[in] maxCharacters maximum number of characters to be accepted
300 void SetMaximumNumberOfCharacters( Length maxCharacters );
303 * @brief Sets the maximum number of characters that can be inserted into the TextModel
305 * @param[in] maxCharacters maximum number of characters to be accepted
307 int GetMaximumNumberOfCharacters();
310 * @brief Called to enable/disable cursor blink.
312 * @note Only editable controls should calls this.
313 * @param[in] enabled Whether the cursor should blink or not.
315 void SetEnableCursorBlink( bool enable );
318 * @brief Query whether cursor blink is enabled.
320 * @return Whether the cursor should blink or not.
322 bool GetEnableCursorBlink() const;
325 * @brief Whether to enable the multi-line layout.
327 * @param[in] enable \e true enables the multi-line (by default)
329 void SetMultiLineEnabled( bool enable );
332 * @return Whether the multi-line layout is enabled.
334 bool IsMultiLineEnabled() const;
337 * @brief Sets the text's horizontal alignment.
339 * @param[in] alignment The horizontal alignment.
341 void SetHorizontalAlignment( HorizontalAlignment::Type alignment );
344 * @copydoc ModelInterface::GetHorizontalAlignment()
346 HorizontalAlignment::Type GetHorizontalAlignment() const;
349 * @brief Sets the text's vertical alignment.
351 * @param[in] alignment The vertical alignment.
353 void SetVerticalAlignment( VerticalAlignment::Type alignment );
356 * @copydoc ModelInterface::GetVerticalAlignment()
358 VerticalAlignment::Type GetVerticalAlignment() const;
361 * @brief Sets the text's wrap mode
362 * @param[in] text wrap mode The unit of wrapping
364 void SetLineWrapMode( Text::LineWrap::Mode textWarpMode );
367 * @brief Retrieve text wrap mode previously set.
368 * @return text wrap mode
370 Text::LineWrap::Mode GetLineWrapMode() const;
373 * @brief Enable or disable the text elide.
375 * @param[in] enabled Whether to enable the text elide.
377 void SetTextElideEnabled( bool enabled );
380 * @copydoc ModelInterface::IsTextElideEnabled()
382 bool IsTextElideEnabled() const;
385 * @brief Enable or disable the text fit.
387 * @param[in] enabled Whether to enable the text fit.
389 void SetTextFitEnabled(bool enabled);
392 * @brief Whether the text fit is enabled or not.
394 * @return True if the text fit is enabled
396 bool IsTextFitEnabled() const;
399 * @brief Sets minimum size valid for text fit.
401 * @param[in] minimum size value.
402 * @param[in] type The font size type is point size or pixel size
404 void SetTextFitMinSize( float pointSize, FontSizeType type );
407 * @brief Retrieves the minimum point size valid for text fit.
409 * @return The minimum point size valid for text fit
411 float GetTextFitMinSize() const;
414 * @brief Sets maximum size valid for text fit.
416 * @param[in] maximum size value.
417 * @param[in] type The font size type is point size or pixel size
419 void SetTextFitMaxSize( float pointSize, FontSizeType type );
422 * @brief Retrieves the maximum point size valid for text fit.
424 * @return The maximum point size valid for text fit
426 float GetTextFitMaxSize() const;
429 * @brief Sets step size for font increase valid for text fit.
431 * @param[in] step size value.
432 * @param[in] type The font size type is point size or pixel size
434 void SetTextFitStepSize( float step, FontSizeType type );
437 * @brief Retrieves the step point size valid for text fit.
439 * @return The step point size valid for text fit
441 float GetTextFitStepSize() const;
444 * @brief Sets content size valid for text fit.
446 * @param[in] Content size value.
448 void SetTextFitContentSize(Vector2 size);
451 * @brief Retrieves the content size valid for text fit.
453 * @return The content size valid for text fit
455 Vector2 GetTextFitContentSize() const;
458 * @brief Enable or disable the placeholder text elide.
459 * @param enabled Whether to enable the placeholder text elide.
461 void SetPlaceholderTextElideEnabled( bool enabled );
464 * @brief Whether the placeholder text elide property is enabled.
465 * @return True if the placeholder text elide property is enabled, false otherwise.
467 bool IsPlaceholderTextElideEnabled() const;
470 * @brief Enable or disable the text selection.
471 * @param[in] enabled Whether to enable the text selection.
473 void SetSelectionEnabled( bool enabled );
476 * @brief Whether the text selection is enabled or not.
477 * @return True if the text selection is enabled
479 bool IsSelectionEnabled() const;
482 * @brief Enable or disable the text selection using Shift key.
483 * @param enabled Whether to enable the text selection using Shift key
485 void SetShiftSelectionEnabled( bool enabled );
488 * @brief Whether the text selection using Shift key is enabled or not.
489 * @return True if the text selection using Shift key is enabled
491 bool IsShiftSelectionEnabled() const;
494 * @brief Enable or disable the grab handles for text selection.
496 * @param[in] enabled Whether to enable the grab handles
498 void SetGrabHandleEnabled( bool enabled );
501 * @brief Returns whether the grab handles are enabled.
503 * @return True if the grab handles are enabled
505 bool IsGrabHandleEnabled() const;
508 * @brief Enable or disable the grab handles for text selection.
510 * @param[in] enabled Whether to enable the grab handles
512 void SetGrabHandlePopupEnabled( bool enabled );
515 * @brief Returns whether the grab handles are enabled.
517 * @return True if the grab handles are enabled
519 bool IsGrabHandlePopupEnabled() const;
522 * @brief Sets input type to password
524 * @note The string is displayed hidden character
526 * @param[in] passwordInput True if password input is enabled.
528 void SetInputModePassword( bool passwordInput );
531 * @brief Returns whether the input mode type is set as password.
533 * @return True if input mode type is password
535 bool IsInputModePassword();
538 * @brief Sets the action when there is a double tap event on top of a text area with no text.
540 * @param[in] action The action to do.
542 void SetNoTextDoubleTapAction( NoTextTap::Action action );
545 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
547 * @return The action to do.
549 NoTextTap::Action GetNoTextDoubleTapAction() const;
552 * @briefSets the action when there is a long press event on top of a text area with no text.
554 * @param[in] action The action to do.
556 void SetNoTextLongPressAction( NoTextTap::Action action );
559 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
561 * @return The action to do.
563 NoTextTap::Action GetNoTextLongPressAction() const;
566 * @brief Query if Underline settings were provided by string or map
567 * @return bool true if set by string
569 bool IsUnderlineSetByString();
572 * Set method underline setting were set by
573 * @param[in] bool, true if set by string
575 void UnderlineSetByString( bool setByString );
578 * @brief Query if shadow settings were provided by string or map
579 * @return bool true if set by string
581 bool IsShadowSetByString();
584 * Set method shadow setting were set by
585 * @param[in] bool, true if set by string
587 void ShadowSetByString( bool setByString );
590 * @brief Query if outline settings were provided by string or map
591 * @return bool true if set by string
593 bool IsOutlineSetByString();
596 * Set method outline setting were set by
597 * @param[in] bool, true if set by string
599 void OutlineSetByString( bool setByString );
602 * @brief Query if font style settings were provided by string or map
603 * @return bool true if set by string
605 bool IsFontStyleSetByString();
608 * Set method font style setting were set by
609 * @param[in] bool, true if set by string
611 void FontStyleSetByString( bool setByString );
616 * @brief Replaces any text previously set.
618 * @note This will be converted into UTF-32 when stored in the text model.
619 * @param[in] text A string of UTF-8 characters.
621 void SetText( const std::string& text );
624 * @brief Retrieve any text previously set.
626 * @param[out] text A string of UTF-8 characters.
628 void GetText( std::string& text ) const;
631 * @brief Replaces any placeholder text previously set.
633 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
634 * @param[in] text A string of UTF-8 characters.
636 void SetPlaceholderText( PlaceholderType type, const std::string& text );
639 * @brief Retrieve any placeholder text previously set.
641 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
642 * @param[out] A string of UTF-8 characters.
644 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
647 * @ brief Update the text after a font change
648 * @param[in] newDefaultFont The new font to change to
650 void UpdateAfterFontChange( const std::string& newDefaultFont );
652 public: // Default style & Input style
655 * @brief Set the default font family.
657 * @param[in] defaultFontFamily The default font family.
659 void SetDefaultFontFamily( const std::string& defaultFontFamily );
662 * @brief Retrieve the default font family.
664 * @return The default font family.
666 const std::string& GetDefaultFontFamily() const;
669 * @brief Sets the placeholder text font family.
670 * @param[in] placeholderTextFontFamily The placeholder text font family.
672 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
675 * @brief Retrieves the placeholder text font family.
677 * @return The placeholder text font family
679 const std::string& GetPlaceholderFontFamily() const;
682 * @brief Sets the default font weight.
684 * @param[in] weight The font weight.
686 void SetDefaultFontWeight( FontWeight weight );
689 * @brief Whether the font's weight has been defined.
691 bool IsDefaultFontWeightDefined() const;
694 * @brief Retrieves the default font weight.
696 * @return The default font weight.
698 FontWeight GetDefaultFontWeight() const;
701 * @brief Sets the placeholder text font weight.
703 * @param[in] weight The font weight
705 void SetPlaceholderTextFontWeight( FontWeight weight );
708 * @brief Whether the font's weight has been defined.
710 * @return True if the placeholder text font weight is defined
712 bool IsPlaceholderTextFontWeightDefined() const;
715 * @brief Retrieves the placeholder text font weight.
717 * @return The placeholder text font weight
719 FontWeight GetPlaceholderTextFontWeight() const;
722 * @brief Sets the default font width.
724 * @param[in] width The font width.
726 void SetDefaultFontWidth( FontWidth width );
729 * @brief Whether the font's width has been defined.
731 bool IsDefaultFontWidthDefined() const;
734 * @brief Retrieves the default font width.
736 * @return The default font width.
738 FontWidth GetDefaultFontWidth() const;
741 * @brief Sets the placeholder text font width.
743 * @param[in] width The font width
745 void SetPlaceholderTextFontWidth( FontWidth width );
748 * @brief Whether the font's width has been defined.
750 * @return True if the placeholder text font width is defined
752 bool IsPlaceholderTextFontWidthDefined() const;
755 * @brief Retrieves the placeholder text font width.
757 * @return The placeholder text font width
759 FontWidth GetPlaceholderTextFontWidth() const;
762 * @brief Sets the default font slant.
764 * @param[in] slant The font slant.
766 void SetDefaultFontSlant( FontSlant slant );
769 * @brief Whether the font's slant has been defined.
771 bool IsDefaultFontSlantDefined() const;
774 * @brief Retrieves the default font slant.
776 * @return The default font slant.
778 FontSlant GetDefaultFontSlant() const;
781 * @brief Sets the placeholder text font slant.
783 * @param[in] slant The font slant
785 void SetPlaceholderTextFontSlant( FontSlant slant );
788 * @brief Whether the font's slant has been defined.
790 * @return True if the placeholder text font slant is defined
792 bool IsPlaceholderTextFontSlantDefined() const;
795 * @brief Retrieves the placeholder text font slant.
797 * @return The placeholder text font slant
799 FontSlant GetPlaceholderTextFontSlant() const;
802 * @brief Set the default font size.
804 * @param[in] fontSize The default font size
805 * @param[in] type The font size type is point size or pixel size
807 void SetDefaultFontSize( float fontSize, FontSizeType type );
810 * @brief Retrieve the default point size.
812 * @param[in] type The font size type
813 * @return The default point size.
815 float GetDefaultFontSize( FontSizeType type ) const;
818 * @brief Sets the Placeholder text font size.
819 * @param[in] fontSize The placeholder text font size
820 * @param[in] type The font size type is point size or pixel size
822 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
825 * @brief Retrieves the Placeholder text font size.
826 * @param[in] type The font size type
827 * @return The placeholder font size
829 float GetPlaceholderTextFontSize( FontSizeType type ) const;
832 * @brief Sets the text's default color.
834 * @param color The default color.
836 void SetDefaultColor( const Vector4& color );
839 * @brief Retrieves the text's default color.
841 * @return The default color.
843 const Vector4& GetDefaultColor() const;
846 * @brief Set the text color
848 * @param textColor The text color
850 void SetPlaceholderTextColor( const Vector4& textColor );
853 * @brief Retrieve the text color
855 * @return The text color
857 const Vector4& GetPlaceholderTextColor() const;
860 * @brief Set the shadow offset.
862 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
864 void SetShadowOffset( const Vector2& shadowOffset );
867 * @brief Retrieve the shadow offset.
869 * @return The shadow offset.
871 const Vector2& GetShadowOffset() const;
874 * @brief Set the shadow color.
876 * @param[in] shadowColor The shadow color.
878 void SetShadowColor( const Vector4& shadowColor );
881 * @brief Retrieve the shadow color.
883 * @return The shadow color.
885 const Vector4& GetShadowColor() const;
888 * @brief Set the shadow blur radius.
890 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
892 void SetShadowBlurRadius( const float& shadowBlurRadius );
895 * @brief Retrieve the shadow blur radius.
897 * @return The shadow blur radius.
899 const float& GetShadowBlurRadius() const;
902 * @brief Set the underline color.
904 * @param[in] color color of underline.
906 void SetUnderlineColor( const Vector4& color );
909 * @brief Retrieve the underline color.
911 * @return The underline color.
913 const Vector4& GetUnderlineColor() const;
916 * @brief Set the underline enabled flag.
918 * @param[in] enabled The underline enabled flag.
920 void SetUnderlineEnabled( bool enabled );
923 * @brief Returns whether the text is underlined or not.
925 * @return The underline state.
927 bool IsUnderlineEnabled() const;
930 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
932 * @param[in] height The height in pixels of the underline
934 void SetUnderlineHeight( float height );
937 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
939 * @return The height of the underline, or 0 if height is not overrided.
941 float GetUnderlineHeight() const;
944 * @brief Set the outline color.
946 * @param[in] color color of outline.
948 void SetOutlineColor( const Vector4& color );
951 * @brief Retrieve the outline color.
953 * @return The outline color.
955 const Vector4& GetOutlineColor() const;
958 * @brief Set the outline width
960 * @param[in] width The width in pixels of the outline, 0 indicates no outline
962 void SetOutlineWidth( uint16_t width );
965 * @brief Retrieves the width of an outline
967 * @return The width of the outline.
969 uint16_t GetOutlineWidth() const;
972 * @brief Set the background color.
974 * @param[in] color color of background.
976 void SetBackgroundColor( const Vector4& color );
979 * @brief Retrieve the background color.
981 * @return The background color.
983 const Vector4& GetBackgroundColor() const;
986 * @brief Set the background enabled flag.
988 * @param[in] enabled The background enabled flag.
990 void SetBackgroundEnabled( bool enabled );
993 * @brief Returns whether to enable text background or not.
995 * @return Whether text background is enabled.
997 bool IsBackgroundEnabled() const;
1000 * @brief Sets the emboss's properties string.
1002 * @note The string is stored to be recovered.
1004 * @param[in] embossProperties The emboss's properties string.
1006 void SetDefaultEmbossProperties( const std::string& embossProperties );
1009 * @brief Retrieves the emboss's properties string.
1011 * @return The emboss's properties string.
1013 const std::string& GetDefaultEmbossProperties() const;
1016 * @brief Sets the outline's properties string.
1018 * @note The string is stored to be recovered.
1020 * @param[in] outlineProperties The outline's properties string.
1022 void SetDefaultOutlineProperties( const std::string& outlineProperties );
1025 * @brief Retrieves the outline's properties string.
1027 * @return The outline's properties string.
1029 const std::string& GetDefaultOutlineProperties() const;
1032 * @brief Sets the default line spacing.
1034 * @param[in] lineSpacing The line spacing.
1036 * @return True if lineSpacing has been updated, false otherwise
1038 bool SetDefaultLineSpacing( float lineSpacing );
1041 * @brief Retrieves the default line spacing.
1043 * @return The line spacing.
1045 float GetDefaultLineSpacing() const;
1048 * @brief Sets the input text's color.
1050 * @param[in] color The input text's color.
1052 void SetInputColor( const Vector4& color );
1055 * @brief Retrieves the input text's color.
1057 * @return The input text's color.
1059 const Vector4& GetInputColor() const;
1062 * @brief Sets the input text's font family name.
1064 * @param[in] fontFamily The text's font family name.
1066 void SetInputFontFamily( const std::string& fontFamily );
1069 * @brief Retrieves the input text's font family name.
1071 * @return The input text's font family name.
1073 const std::string& GetInputFontFamily() const;
1076 * @brief Sets the input font's weight.
1078 * @param[in] weight The input font's weight.
1080 void SetInputFontWeight( FontWeight weight );
1083 * @return Whether the font's weight has been defined.
1085 bool IsInputFontWeightDefined() const;
1088 * @brief Retrieves the input font's weight.
1090 * @return The input font's weight.
1092 FontWeight GetInputFontWeight() const;
1095 * @brief Sets the input font's width.
1097 * @param[in] width The input font's width.
1099 void SetInputFontWidth( FontWidth width );
1102 * @return Whether the font's width has been defined.
1104 bool IsInputFontWidthDefined() const;
1107 * @brief Retrieves the input font's width.
1109 * @return The input font's width.
1111 FontWidth GetInputFontWidth() const;
1114 * @brief Sets the input font's slant.
1116 * @param[in] slant The input font's slant.
1118 void SetInputFontSlant( FontSlant slant );
1121 * @return Whether the font's slant has been defined.
1123 bool IsInputFontSlantDefined() const;
1126 * @brief Retrieves the input font's slant.
1128 * @return The input font's slant.
1130 FontSlant GetInputFontSlant() const;
1133 * @brief Sets the input font's point size.
1135 * @param[in] size The input font's point size.
1137 void SetInputFontPointSize( float size );
1140 * @brief Retrieves the input font's point size.
1142 * @return The input font's point size.
1144 float GetInputFontPointSize() const;
1147 * @brief Sets the input line spacing.
1149 * @param[in] lineSpacing The line spacing.
1151 void SetInputLineSpacing( float lineSpacing );
1154 * @brief Retrieves the input line spacing.
1156 * @return The line spacing.
1158 float GetInputLineSpacing() const;
1161 * @brief Sets the input shadow's properties string.
1163 * @note The string is stored to be recovered.
1165 * @param[in] shadowProperties The shadow's properties string.
1167 void SetInputShadowProperties( const std::string& shadowProperties );
1170 * @brief Retrieves the input shadow's properties string.
1172 * @return The shadow's properties string.
1174 const std::string& GetInputShadowProperties() const;
1177 * @brief Sets the input underline's properties string.
1179 * @note The string is stored to be recovered.
1181 * @param[in] underlineProperties The underline's properties string.
1183 void SetInputUnderlineProperties( const std::string& underlineProperties );
1186 * @brief Retrieves the input underline's properties string.
1188 * @return The underline's properties string.
1190 const std::string& GetInputUnderlineProperties() const;
1193 * @brief Sets the input emboss's properties string.
1195 * @note The string is stored to be recovered.
1197 * @param[in] embossProperties The emboss's properties string.
1199 void SetInputEmbossProperties( const std::string& embossProperties );
1202 * @brief Retrieves the input emboss's properties string.
1204 * @return The emboss's properties string.
1206 const std::string& GetInputEmbossProperties() const;
1209 * @brief Sets input the outline's properties string.
1211 * @note The string is stored to be recovered.
1213 * @param[in] outlineProperties The outline's properties string.
1215 void SetInputOutlineProperties( const std::string& outlineProperties );
1218 * @brief Retrieves the input outline's properties string.
1220 * @return The outline's properties string.
1222 const std::string& GetInputOutlineProperties() const;
1225 * @brief Set the control's interface.
1227 * @param[in] controlInterface The control's interface.
1229 void SetControlInterface( ControlInterface* controlInterface );
1231 public: // Queries & retrieves.
1234 * @brief Return the layout engine.
1236 * @return A reference to the layout engine.
1238 Layout::Engine& GetLayoutEngine();
1241 * @brief Return a view of the text.
1243 * @return A reference to the view.
1248 * @copydoc Control::GetNaturalSize()
1250 Vector3 GetNaturalSize();
1253 * @copydoc Control::GetHeightForWidth()
1255 float GetHeightForWidth( float width );
1258 * @brief Calculates the point size for text for given layout()
1260 void FitPointSizeforLayout( Size layoutSize );
1263 * @brief Checks if the point size fits within the layout size.
1265 * @return Whether the point size fits within the layout size.
1267 bool CheckForTextFit( float pointSize, Size& layoutSize );
1270 * @brief Retrieves the text's number of lines for a given width.
1271 * @param[in] width The width of the text's area.
1272 * @ return The number of lines.
1274 int GetLineCount( float width );
1277 * @brief Retrieves the text's model.
1279 * @return A pointer to the text's model.
1281 const ModelInterface* const GetTextModel() const;
1284 * @brief Used to get scrolled distance by user input
1286 * @return Distance from last scroll offset to new scroll offset
1288 float GetScrollAmountByUserInput();
1291 * @brief Get latest scroll amount, control size and layout size
1293 * This method is used to get information of control's scroll
1294 * @param[out] scrollPosition The current scrolled position
1295 * @param[out] controlHeight The size of a UI control
1296 * @param[out] layoutHeight The size of a bounding box to layout text within.
1298 * @return Whether the text scroll position is changed or not after last update.
1300 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1303 * @brief Used to set the hidden input option
1305 void SetHiddenInputOption( const Property::Map& options );
1308 * @brief Used to get the hidden input option
1310 void GetHiddenInputOption( Property::Map& options );
1313 * @brief Sets the Placeholder Properties.
1315 * @param[in] map The placeholder property map
1317 void SetPlaceholderProperty( const Property::Map& map );
1320 * @brief Retrieves the Placeholder Property map.
1322 * @param[out] map The property map
1324 void GetPlaceholderProperty( Property::Map& map );
1327 * @brief Checks text direction.
1328 * @return The text direction.
1330 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1333 * @brief Retrieves vertical line alignment
1334 * @return The vertical line alignment
1336 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1339 * @brief Sets vertical line alignment
1340 * @param[in] alignment The vertical line alignment for the text
1342 void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
1345 * @brief Retrieves ignoreSpaceAfterText value from model
1346 * @return The value of ignoreSpaceAfterText
1348 bool IsIgnoreSpacesAfterText() const;
1351 * @brief Sets ignoreSpaceAfterText value to model
1352 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1354 void SetIgnoreSpacesAfterText( bool ignore );
1357 * @brief Retrieves matchSystemLanguageDirection value from model
1358 * @return The value of matchSystemLanguageDirection
1360 bool IsMatchSystemLanguageDirection() const;
1363 * @brief Sets matchSystemLanguageDirection value to model
1364 * @param[in] match The value of matchSystemLanguageDirection for the text
1366 void SetMatchSystemLanguageDirection( bool match );
1369 * @brief Sets layoutDirection value
1370 * @param[in] layoutDirection The value of system language direction
1372 void SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection );
1375 * @brief Retrieves if showing real text or not.
1376 * @return The value of showing real text.
1378 bool IsShowingRealText() const;
1380 public: // Relayout.
1383 * @brief Triggers a relayout which updates View (if necessary).
1385 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1386 * @param[in] size A the size of a bounding box to layout text within.
1387 * @param[in] layoutDirection The direction of the system language.
1389 * @return Whether the text model or decorations were updated.
1391 UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT );
1394 * @brief Request a relayout using the ControlInterface.
1396 void RequestRelayout();
1398 public: // Input style change signals.
1401 * @return Whether the queue of input style changed signals is empty.
1403 bool IsInputStyleChangedSignalsQueueEmpty();
1406 * @brief Process all pending input style changed signals.
1408 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1409 * text controls. Text controls may send signals to state the input style has changed.
1411 void ProcessInputStyleChangedSignals();
1413 public: // Text-input Event Queuing.
1416 * @brief Called by editable UI controls when keyboard focus is gained.
1418 void KeyboardFocusGainEvent();
1421 * @brief Called by editable UI controls when focus is lost.
1423 void KeyboardFocusLostEvent();
1426 * @brief Called by editable UI controls when key events are received.
1428 * @param[in] event The key event.
1429 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1431 bool KeyEvent( const Dali::KeyEvent& event );
1434 * @brief Called by editable UI controls when a tap gesture occurs.
1435 * @param[in] tapCount The number of taps.
1436 * @param[in] x The x position relative to the top-left of the parent control.
1437 * @param[in] y The y position relative to the top-left of the parent control.
1439 void TapEvent( unsigned int tapCount, float x, float y );
1442 * @brief Called by editable UI controls when a pan gesture occurs.
1444 * @param[in] state The state of the gesture.
1445 * @param[in] displacement This distance panned since the last pan gesture.
1447 void PanEvent( Gesture::State state, const Vector2& displacement );
1450 * @brief Called by editable UI controls when a long press gesture occurs.
1452 * @param[in] state The state of the gesture.
1453 * @param[in] x The x position relative to the top-left of the parent control.
1454 * @param[in] y The y position relative to the top-left of the parent control.
1456 void LongPressEvent( Gesture::State state, float x, float y );
1459 * @brief Creates a selection event.
1461 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1463 * @param[in] x The x position relative to the top-left of the parent control.
1464 * @param[in] y The y position relative to the top-left of the parent control.
1465 * @param[in] selectAll Whether the whole text is selected.
1467 void SelectEvent( float x, float y, bool selectAll );
1470 * @brief Event received from input method context
1472 * @param[in] inputMethodContext The input method context.
1473 * @param[in] inputMethodContextEvent The event received.
1474 * @return A data struture indicating if update is needed, cursor position and current text.
1476 InputMethodContext::CallbackData OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent );
1479 * @brief Event from Clipboard notifying an Item has been selected for pasting
1481 void PasteClipboardItemEvent();
1484 * @brief Return true when text control should clear key input focus when escape key is pressed.
1486 * @return Whether text control should clear key input focus or not when escape key is pressed.
1488 bool ShouldClearFocusOnEscape() const;
1491 * @brief Create an actor that renders the text background color
1493 * @return the created actor or an empty handle if no background color needs to be rendered.
1495 Actor CreateBackgroundActor();
1497 protected: // Inherit from Text::Decorator::ControllerInterface.
1500 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1502 virtual void GetTargetSize( Vector2& targetSize );
1505 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1507 virtual void AddDecoration( Actor& actor, bool needsClipping );
1510 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1512 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1514 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1517 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1519 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1521 protected: // Inherit from HiddenText.
1524 * @brief Invoked from HiddenText when showing time of the last character was expired
1526 virtual void DisplayTimeExpired();
1531 * @brief Called by editable UI controls when key events are received.
1533 * @param[in] text The text to insert.
1534 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1536 void InsertText( const std::string& text, InsertType type );
1539 * @brief Paste given string into Text model
1540 * @param[in] stringToPaste this string will be inserted into the text model
1542 void PasteText( const std::string& stringToPaste );
1545 * @brief Remove a given number of characters
1547 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1548 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1549 * style when pre-edit text is removed.
1551 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1552 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1553 * @param[in] type Whether to update the input style.
1554 * @return True if the remove was successful.
1556 bool RemoveText( int cursorOffset,
1557 int numberOfCharacters,
1558 UpdateInputStyleType type );
1561 * @brief Checks if text is selected and if so removes it.
1562 * @return true if text was removed
1564 bool RemoveSelectedText();
1566 private: // Relayout.
1569 * @brief Lays-out the text.
1571 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1573 * @param[in] size A the size of a bounding box to layout text within.
1574 * @param[in] operations The layout operations which need to be done.
1575 * @param[out] layoutSize The size of the laid-out text.
1577 bool DoRelayout( const Size& size,
1578 OperationsMask operations,
1582 * @brief Calulates the vertical offset to align the text inside the bounding box.
1584 * @param[in] size The size of the bounding box.
1586 void CalculateVerticalOffset( const Size& size );
1591 * @brief Process queued events which modify the model.
1593 void ProcessModifyEvents();
1596 * @brief Used to process an event queued from SetText()
1598 void TextReplacedEvent();
1601 * @brief Used to process an event queued from key events etc.
1603 void TextInsertedEvent();
1606 * @brief Used to process an event queued from backspace key etc.
1608 void TextDeletedEvent();
1611 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1613 * @param[in] keyCode The keycode for the key pressed
1614 * @return True if a character was deleted.
1616 bool DeleteEvent( int keyCode );
1618 private: // Helpers.
1621 * @brief Used to remove the text included the placeholder text.
1626 * @brief Helper to show the place holder text..
1628 void ShowPlaceholderText();
1631 * @brief Helper to clear font-specific data (only).
1633 void ClearFontData();
1636 * @brief Helper to clear text's style data.
1638 void ClearStyleData();
1641 * @brief Used to reset the cursor position after setting a new text.
1643 * @param[in] cursorIndex Where to place the cursor.
1645 void ResetCursorPosition( CharacterIndex cursorIndex );
1648 * @brief Used to reset the scroll position after setting a new text.
1650 void ResetScrollPosition();
1652 private: // Private contructors & copy operator.
1655 * @brief Private constructor.
1660 * @brief Private constructor.
1662 Controller( ControlInterface* controlInterface );
1665 * @brief Private constructor.
1667 Controller( ControlInterface* controlInterface,
1668 EditableControlInterface* editableControlInterface );
1671 Controller( const Controller& handle );
1674 Controller& operator=( const Controller& handle );
1676 protected: // Destructor.
1679 * @brief A reference counted object may only be deleted by calling Unreference().
1681 virtual ~Controller();
1685 struct Impl; ///< Made public for testing purposes
1694 } // namespace Toolkit
1698 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H