1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/devel-api/adaptor-framework/imf-manager.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/internal/text/decorator/text-decorator.h>
29 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
30 #include <dali-toolkit/internal/text/hidden-text.h>
31 #include <dali-toolkit/internal/text/text-model-interface.h>
43 class ControlInterface;
44 class EditableControlInterface;
46 class RenderingController;
48 typedef IntrusivePtr<Controller> ControllerPtr;
51 * @brief A Text Controller is used by UI Controls which display text.
53 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
54 * It provides a view of the text that can be used by rendering back-ends.
56 * For selectable/editable UI controls, the controller handles input events from the UI control
57 * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
59 * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
61 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
63 public: // Enumerated types.
66 * @brief Text related operations to be done in the relayout process.
70 NO_OPERATION = 0x0000,
71 CONVERT_TO_UTF32 = 0x0001,
73 VALIDATE_FONTS = 0x0004,
74 GET_LINE_BREAKS = 0x0008,
75 GET_WORD_BREAKS = 0x0010,
78 GET_GLYPH_METRICS = 0x0080,
80 UPDATE_LAYOUT_SIZE = 0x0200,
84 UPDATE_DIRECTION = 0x2000,
85 ALL_OPERATIONS = 0xFFFF
89 * @brief Used to distinguish between regular key events and IMF events
98 * @brief Used to specify whether to update the input style.
100 enum UpdateInputStyleType
103 DONT_UPDATE_INPUT_STYLE
107 * @brief Used to specify what has been updated after the Relayout() method has been called.
111 NONE_UPDATED = 0x0, ///< Nothing has been updated.
112 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
113 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
117 * @brief Different placeholder-text can be shown when the control is active/inactive.
121 PLACEHOLDER_TYPE_ACTIVE,
122 PLACEHOLDER_TYPE_INACTIVE,
126 * @brief Enumeration for Font Size Type.
130 POINT_SIZE, // The size of font in points.
131 PIXEL_SIZE // The size of font in pixels.
138 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
139 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
140 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
144 public: // Constructor.
147 * @brief Create a new instance of a Controller.
149 * @return A pointer to a new Controller.
151 static ControllerPtr New();
154 * @brief Create a new instance of a Controller.
156 * @param[in] controlInterface The control's interface.
158 * @return A pointer to a new Controller.
160 static ControllerPtr New( ControlInterface* controlInterface );
163 * @brief Create a new instance of a Controller.
165 * @param[in] controlInterface The control's interface.
166 * @param[in] editableControlInterface The editable control's interface.
168 * @return A pointer to a new Controller.
170 static ControllerPtr New( ControlInterface* controlInterface,
171 EditableControlInterface* editableControlInterface );
173 public: // Configure the text controller.
176 * @brief Called to enable text input.
178 * @note Selectable or editable controls should call this once after Controller::New().
179 * @param[in] decorator Used to create cursor, selection handle decorations etc.
181 void EnableTextInput( DecoratorPtr decorator );
184 * @brief Used to switch between bitmap & vector based glyphs
186 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
188 void SetGlyphType( TextAbstraction::GlyphType glyphType );
191 * @brief Enables/disables the mark-up processor.
193 * By default is disabled.
195 * @param[in] enable Whether to enable the mark-up processor.
197 void SetMarkupProcessorEnabled( bool enable );
200 * @brief Retrieves whether the mark-up processor is enabled.
202 * By default is disabled.
204 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
206 bool IsMarkupProcessorEnabled() const;
209 * @brief Enables/disables the auto text scrolling
211 * By default is disabled.
213 * @param[in] enable Whether to enable the auto scrolling
215 void SetAutoScrollEnabled( bool enable );
218 * @brief Retrieves whether auto text scrolling is enabled.
220 * By default is disabled.
222 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
224 bool IsAutoScrollEnabled() const;
227 * @brief Get direction of the text from the first line of text,
228 * @return bool rtl (right to left) is true
230 CharacterDirection GetAutoScrollDirection() const;
233 * @brief Get the alignment offset of the first line of text.
235 * @return The alignment offset.
237 float GetAutoScrollLineAlignment() const;
240 * @brief Enables the horizontal scrolling.
242 * @param[in] enable Whether to enable the horizontal scrolling.
244 void SetHorizontalScrollEnabled( bool enable );
247 * @brief Retrieves whether the horizontal scrolling is enabled.
249 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
251 bool IsHorizontalScrollEnabled() const;
254 * @brief Enables the vertical scrolling.
256 * @param[in] enable Whether to enable the vertical scrolling.
258 void SetVerticalScrollEnabled( bool enable );
261 * @brief Retrieves whether the verticall scrolling is enabled.
263 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
265 bool IsVerticalScrollEnabled() const;
268 * @brief Enables the smooth handle panning.
270 * @param[in] enable Whether to enable the smooth handle panning.
272 void SetSmoothHandlePanEnabled( bool enable );
275 * @brief Retrieves whether the smooth handle panning is enabled.
277 * @return @e true if the smooth handle panning is enabled.
279 bool IsSmoothHandlePanEnabled() const;
282 * @brief Sets the maximum number of characters that can be inserted into the TextModel
284 * @param[in] maxCharacters maximum number of characters to be accepted
286 void SetMaximumNumberOfCharacters( Length maxCharacters );
289 * @brief Sets the maximum number of characters that can be inserted into the TextModel
291 * @param[in] maxCharacters maximum number of characters to be accepted
293 int GetMaximumNumberOfCharacters();
296 * @brief Called to enable/disable cursor blink.
298 * @note Only editable controls should calls this.
299 * @param[in] enabled Whether the cursor should blink or not.
301 void SetEnableCursorBlink( bool enable );
304 * @brief Query whether cursor blink is enabled.
306 * @return Whether the cursor should blink or not.
308 bool GetEnableCursorBlink() const;
311 * @brief Whether to enable the multi-line layout.
313 * @param[in] enable \e true enables the multi-line (by default)
315 void SetMultiLineEnabled( bool enable );
318 * @return Whether the multi-line layout is enabled.
320 bool IsMultiLineEnabled() const;
323 * @brief Sets the text's horizontal alignment.
325 * @param[in] alignment The horizontal alignment.
327 void SetHorizontalAlignment( HorizontalAlignment::Type alignment );
330 * @copydoc ModelInterface::GetHorizontalAlignment()
332 HorizontalAlignment::Type GetHorizontalAlignment() const;
335 * @brief Sets the text's vertical alignment.
337 * @param[in] alignment The vertical alignment.
339 void SetVerticalAlignment( VerticalAlignment::Type alignment );
342 * @copydoc ModelInterface::GetVerticalAlignment()
344 VerticalAlignment::Type GetVerticalAlignment() const;
347 * @brief Sets the text's wrap mode
348 * @param[in] text wrap mode The unit of wrapping
350 void SetLineWrapMode( Text::LineWrap::Mode textWarpMode );
353 * @brief Retrieve text wrap mode previously set.
354 * @return text wrap mode
356 Text::LineWrap::Mode GetLineWrapMode() const;
359 * @brief Enable or disable the text elide.
361 * @param[in] enabled Whether to enable the text elide.
363 void SetTextElideEnabled( bool enabled );
366 * @copydoc ModelInterface::IsTextElideEnabled()
368 bool IsTextElideEnabled() const;
371 * @brief Enable or disable the placeholder text elide.
372 * @param enabled Whether to enable the placeholder text elide.
374 void SetPlaceholderTextElideEnabled( bool enabled );
377 * @brief Whether the placeholder text elide property is enabled.
378 * @return True if the placeholder text elide property is enabled, false otherwise.
380 bool IsPlaceholderTextElideEnabled() const;
383 * @brief Enable or disable the text selection.
384 * @param[in] enabled Whether to enable the text selection.
386 void SetSelectionEnabled( bool enabled );
389 * @brief Whether the text selection is enabled or not.
390 * @return True if the text selection is enabled
392 bool IsSelectionEnabled() const;
395 * @brief Sets input type to password
397 * @note The string is displayed hidden character
399 * @param[in] passwordInput True if password input is enabled.
401 void SetInputModePassword( bool passwordInput );
404 * @brief Returns whether the input mode type is set as password.
406 * @return True if input mode type is password
408 bool IsInputModePassword();
411 * @brief Sets the action when there is a double tap event on top of a text area with no text.
413 * @param[in] action The action to do.
415 void SetNoTextDoubleTapAction( NoTextTap::Action action );
418 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
420 * @return The action to do.
422 NoTextTap::Action GetNoTextDoubleTapAction() const;
425 * @briefSets the action when there is a long press event on top of a text area with no text.
427 * @param[in] action The action to do.
429 void SetNoTextLongPressAction( NoTextTap::Action action );
432 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
434 * @return The action to do.
436 NoTextTap::Action GetNoTextLongPressAction() const;
439 * @brief Query if Underline settings were provided by string or map
440 * @return bool true if set by string
442 bool IsUnderlineSetByString();
445 * Set method underline setting were set by
446 * @param[in] bool, true if set by string
448 void UnderlineSetByString( bool setByString );
451 * @brief Query if shadow settings were provided by string or map
452 * @return bool true if set by string
454 bool IsShadowSetByString();
457 * Set method shadow setting were set by
458 * @param[in] bool, true if set by string
460 void ShadowSetByString( bool setByString );
463 * @brief Query if outline settings were provided by string or map
464 * @return bool true if set by string
466 bool IsOutlineSetByString();
469 * Set method outline setting were set by
470 * @param[in] bool, true if set by string
472 void OutlineSetByString( bool setByString );
475 * @brief Query if font style settings were provided by string or map
476 * @return bool true if set by string
478 bool IsFontStyleSetByString();
481 * Set method font style setting were set by
482 * @param[in] bool, true if set by string
484 void FontStyleSetByString( bool setByString );
489 * @brief Replaces any text previously set.
491 * @note This will be converted into UTF-32 when stored in the text model.
492 * @param[in] text A string of UTF-8 characters.
494 void SetText( const std::string& text );
497 * @brief Retrieve any text previously set.
499 * @param[out] text A string of UTF-8 characters.
501 void GetText( std::string& text ) const;
504 * @brief Replaces any placeholder text previously set.
506 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
507 * @param[in] text A string of UTF-8 characters.
509 void SetPlaceholderText( PlaceholderType type, const std::string& text );
512 * @brief Retrieve any placeholder text previously set.
514 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
515 * @param[out] A string of UTF-8 characters.
517 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
520 * @ brief Update the text after a font change
521 * @param[in] newDefaultFont The new font to change to
523 void UpdateAfterFontChange( const std::string& newDefaultFont );
525 public: // Default style & Input style
528 * @brief Set the default font family.
530 * @param[in] defaultFontFamily The default font family.
532 void SetDefaultFontFamily( const std::string& defaultFontFamily );
535 * @brief Retrieve the default font family.
537 * @return The default font family.
539 const std::string& GetDefaultFontFamily() const;
542 * @brief Sets the placeholder text font family.
543 * @param[in] placeholderTextFontFamily The placeholder text font family.
545 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
548 * @brief Retrieves the placeholder text font family.
550 * @return The placeholder text font family
552 const std::string& GetPlaceholderFontFamily() const;
555 * @brief Sets the default font weight.
557 * @param[in] weight The font weight.
559 void SetDefaultFontWeight( FontWeight weight );
562 * @brief Whether the font's weight has been defined.
564 bool IsDefaultFontWeightDefined() const;
567 * @brief Retrieves the default font weight.
569 * @return The default font weight.
571 FontWeight GetDefaultFontWeight() const;
574 * @brief Sets the placeholder text font weight.
576 * @param[in] weight The font weight
578 void SetPlaceholderTextFontWeight( FontWeight weight );
581 * @brief Whether the font's weight has been defined.
583 * @return True if the placeholder text font weight is defined
585 bool IsPlaceholderTextFontWeightDefined() const;
588 * @brief Retrieves the placeholder text font weight.
590 * @return The placeholder text font weight
592 FontWeight GetPlaceholderTextFontWeight() const;
595 * @brief Sets the default font width.
597 * @param[in] width The font width.
599 void SetDefaultFontWidth( FontWidth width );
602 * @brief Whether the font's width has been defined.
604 bool IsDefaultFontWidthDefined() const;
607 * @brief Retrieves the default font width.
609 * @return The default font width.
611 FontWidth GetDefaultFontWidth() const;
614 * @brief Sets the placeholder text font width.
616 * @param[in] width The font width
618 void SetPlaceholderTextFontWidth( FontWidth width );
621 * @brief Whether the font's width has been defined.
623 * @return True if the placeholder text font width is defined
625 bool IsPlaceholderTextFontWidthDefined() const;
628 * @brief Retrieves the placeholder text font width.
630 * @return The placeholder text font width
632 FontWidth GetPlaceholderTextFontWidth() const;
635 * @brief Sets the default font slant.
637 * @param[in] slant The font slant.
639 void SetDefaultFontSlant( FontSlant slant );
642 * @brief Whether the font's slant has been defined.
644 bool IsDefaultFontSlantDefined() const;
647 * @brief Retrieves the default font slant.
649 * @return The default font slant.
651 FontSlant GetDefaultFontSlant() const;
654 * @brief Sets the placeholder text font slant.
656 * @param[in] slant The font slant
658 void SetPlaceholderTextFontSlant( FontSlant slant );
661 * @brief Whether the font's slant has been defined.
663 * @return True if the placeholder text font slant is defined
665 bool IsPlaceholderTextFontSlantDefined() const;
668 * @brief Retrieves the placeholder text font slant.
670 * @return The placeholder text font slant
672 FontSlant GetPlaceholderTextFontSlant() const;
675 * @brief Set the default font size.
677 * @param[in] fontSize The default font size
678 * @param[in] type The font size type is point size or pixel size
680 void SetDefaultFontSize( float fontSize, FontSizeType type );
683 * @brief Retrieve the default point size.
685 * @param[in] type The font size type
686 * @return The default point size.
688 float GetDefaultFontSize( FontSizeType type ) const;
691 * @brief Sets the Placeholder text font size.
692 * @param[in] fontSize The placeholder text font size
693 * @param[in] type The font size type is point size or pixel size
695 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
698 * @brief Retrieves the Placeholder text font size.
699 * @param[in] type The font size type
700 * @return The placeholder font size
702 float GetPlaceholderTextFontSize( FontSizeType type ) const;
705 * @brief Sets the text's default color.
707 * @param color The default color.
709 void SetDefaultColor( const Vector4& color );
712 * @brief Retrieves the text's default color.
714 * @return The default color.
716 const Vector4& GetDefaultColor() const;
719 * @brief Set the text color
721 * @param textColor The text color
723 void SetPlaceholderTextColor( const Vector4& textColor );
726 * @brief Retrieve the text color
728 * @return The text color
730 const Vector4& GetPlaceholderTextColor() const;
733 * @brief Set the shadow offset.
735 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
737 void SetShadowOffset( const Vector2& shadowOffset );
740 * @brief Retrieve the shadow offset.
742 * @return The shadow offset.
744 const Vector2& GetShadowOffset() const;
747 * @brief Set the shadow color.
749 * @param[in] shadowColor The shadow color.
751 void SetShadowColor( const Vector4& shadowColor );
754 * @brief Retrieve the shadow color.
756 * @return The shadow color.
758 const Vector4& GetShadowColor() const;
761 * @brief Set the shadow blur radius.
763 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
765 void SetShadowBlurRadius( const float& shadowBlurRadius );
768 * @brief Retrieve the shadow blur radius.
770 * @return The shadow blur radius.
772 const float& GetShadowBlurRadius() const;
775 * @brief Set the underline color.
777 * @param[in] color color of underline.
779 void SetUnderlineColor( const Vector4& color );
782 * @brief Retrieve the underline color.
784 * @return The underline color.
786 const Vector4& GetUnderlineColor() const;
789 * @brief Set the underline enabled flag.
791 * @param[in] enabled The underline enabled flag.
793 void SetUnderlineEnabled( bool enabled );
796 * @brief Returns whether the text is underlined or not.
798 * @return The underline state.
800 bool IsUnderlineEnabled() const;
803 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
805 * @param[in] height The height in pixels of the underline
807 void SetUnderlineHeight( float height );
810 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
812 * @return The height of the underline, or 0 if height is not overrided.
814 float GetUnderlineHeight() const;
817 * @brief Set the outline color.
819 * @param[in] color color of outline.
821 void SetOutlineColor( const Vector4& color );
824 * @brief Retrieve the outline color.
826 * @return The outline color.
828 const Vector4& GetOutlineColor() const;
831 * @brief Set the outline width
833 * @param[in] width The width in pixels of the outline, 0 indicates no outline
835 void SetOutlineWidth( float width );
838 * @brief Retrieves the width of an outline
840 * @return The width of the outline.
842 float GetOutlineWidth() const;
845 * @brief Sets the emboss's properties string.
847 * @note The string is stored to be recovered.
849 * @param[in] embossProperties The emboss's properties string.
851 void SetDefaultEmbossProperties( const std::string& embossProperties );
854 * @brief Retrieves the emboss's properties string.
856 * @return The emboss's properties string.
858 const std::string& GetDefaultEmbossProperties() const;
861 * @brief Sets the outline's properties string.
863 * @note The string is stored to be recovered.
865 * @param[in] outlineProperties The outline's properties string.
867 void SetDefaultOutlineProperties( const std::string& outlineProperties );
870 * @brief Retrieves the outline's properties string.
872 * @return The outline's properties string.
874 const std::string& GetDefaultOutlineProperties() const;
877 * @brief Sets the default line spacing.
879 * @param[in] lineSpacing The line spacing.
881 void SetDefaultLineSpacing( float lineSpacing );
884 * @brief Retrieves the default line spacing.
886 * @return The line spacing.
888 float GetDefaultLineSpacing() const;
891 * @brief Sets the input text's color.
893 * @param[in] color The input text's color.
895 void SetInputColor( const Vector4& color );
898 * @brief Retrieves the input text's color.
900 * @return The input text's color.
902 const Vector4& GetInputColor() const;
905 * @brief Sets the input text's font family name.
907 * @param[in] fontFamily The text's font family name.
909 void SetInputFontFamily( const std::string& fontFamily );
912 * @brief Retrieves the input text's font family name.
914 * @return The input text's font family name.
916 const std::string& GetInputFontFamily() const;
919 * @brief Sets the input font's weight.
921 * @param[in] weight The input font's weight.
923 void SetInputFontWeight( FontWeight weight );
926 * @return Whether the font's weight has been defined.
928 bool IsInputFontWeightDefined() const;
931 * @brief Retrieves the input font's weight.
933 * @return The input font's weight.
935 FontWeight GetInputFontWeight() const;
938 * @brief Sets the input font's width.
940 * @param[in] width The input font's width.
942 void SetInputFontWidth( FontWidth width );
945 * @return Whether the font's width has been defined.
947 bool IsInputFontWidthDefined() const;
950 * @brief Retrieves the input font's width.
952 * @return The input font's width.
954 FontWidth GetInputFontWidth() const;
957 * @brief Sets the input font's slant.
959 * @param[in] slant The input font's slant.
961 void SetInputFontSlant( FontSlant slant );
964 * @return Whether the font's slant has been defined.
966 bool IsInputFontSlantDefined() const;
969 * @brief Retrieves the input font's slant.
971 * @return The input font's slant.
973 FontSlant GetInputFontSlant() const;
976 * @brief Sets the input font's point size.
978 * @param[in] size The input font's point size.
980 void SetInputFontPointSize( float size );
983 * @brief Retrieves the input font's point size.
985 * @return The input font's point size.
987 float GetInputFontPointSize() const;
990 * @brief Sets the input line spacing.
992 * @param[in] lineSpacing The line spacing.
994 void SetInputLineSpacing( float lineSpacing );
997 * @brief Retrieves the input line spacing.
999 * @return The line spacing.
1001 float GetInputLineSpacing() const;
1004 * @brief Sets the input shadow's properties string.
1006 * @note The string is stored to be recovered.
1008 * @param[in] shadowProperties The shadow's properties string.
1010 void SetInputShadowProperties( const std::string& shadowProperties );
1013 * @brief Retrieves the input shadow's properties string.
1015 * @return The shadow's properties string.
1017 const std::string& GetInputShadowProperties() const;
1020 * @brief Sets the input underline's properties string.
1022 * @note The string is stored to be recovered.
1024 * @param[in] underlineProperties The underline's properties string.
1026 void SetInputUnderlineProperties( const std::string& underlineProperties );
1029 * @brief Retrieves the input underline's properties string.
1031 * @return The underline's properties string.
1033 const std::string& GetInputUnderlineProperties() const;
1036 * @brief Sets the input emboss's properties string.
1038 * @note The string is stored to be recovered.
1040 * @param[in] embossProperties The emboss's properties string.
1042 void SetInputEmbossProperties( const std::string& embossProperties );
1045 * @brief Retrieves the input emboss's properties string.
1047 * @return The emboss's properties string.
1049 const std::string& GetInputEmbossProperties() const;
1052 * @brief Sets input the outline's properties string.
1054 * @note The string is stored to be recovered.
1056 * @param[in] outlineProperties The outline's properties string.
1058 void SetInputOutlineProperties( const std::string& outlineProperties );
1061 * @brief Retrieves the input outline's properties string.
1063 * @return The outline's properties string.
1065 const std::string& GetInputOutlineProperties() const;
1068 * @brief Set the control's interface.
1070 * @param[in] controlInterface The control's interface.
1072 void SetControlInterface( ControlInterface* controlInterface );
1074 public: // Queries & retrieves.
1077 * @brief Return the layout engine.
1079 * @return A reference to the layout engine.
1081 Layout::Engine& GetLayoutEngine();
1084 * @brief Return a view of the text.
1086 * @return A reference to the view.
1091 * @copydoc Control::GetNaturalSize()
1093 Vector3 GetNaturalSize();
1096 * @copydoc Control::GetHeightForWidth()
1098 float GetHeightForWidth( float width );
1101 * @brief Retrieves the text's number of lines for a given width.
1102 * @param[in] width The width of the text's area.
1103 * @ return The number of lines.
1105 int GetLineCount( float width );
1108 * @brief Retrieves the text's model.
1110 * @return A pointer to the text's model.
1112 const ModelInterface* const GetTextModel() const;
1115 * @brief Used to get scrolled distance by user input
1117 * @return Distance from last scroll offset to new scroll offset
1119 float GetScrollAmountByUserInput();
1122 * @brief Get latest scroll amount, control size and layout size
1124 * This method is used to get information of control's scroll
1125 * @param[out] scrollPosition The current scrolled position
1126 * @param[out] controlHeight The size of a UI control
1127 * @param[out] layoutHeight The size of a bounding box to layout text within.
1129 * @return Whether the text scroll position is changed or not after last update.
1131 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1134 * @brief Used to set the hidden input option
1136 void SetHiddenInputOption( const Property::Map& options );
1139 * @brief Used to get the hidden input option
1141 void GetHiddenInputOption( Property::Map& options );
1144 * @brief Sets the Placeholder Properties.
1146 * @param[in] map The placeholder property map
1148 void SetPlaceholderProperty( const Property::Map& map );
1151 * @brief Retrieves the Placeholder Property map.
1153 * @param[out] map The property map
1155 void GetPlaceholderProperty( Property::Map& map );
1157 public: // Relayout.
1160 * @brief Triggers a relayout which updates View (if necessary).
1162 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1163 * @param[in] size A the size of a bounding box to layout text within.
1165 * @return Whether the text model or decorations were updated.
1167 UpdateTextType Relayout( const Size& size );
1170 * @brief Request a relayout using the ControlInterface.
1172 void RequestRelayout();
1174 public: // Input style change signals.
1177 * @return Whether the queue of input style changed signals is empty.
1179 bool IsInputStyleChangedSignalsQueueEmpty();
1182 * @brief Process all pending input style changed signals.
1184 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1185 * text controls. Text controls may send signals to state the input style has changed.
1187 void ProcessInputStyleChangedSignals();
1189 public: // Text-input Event Queuing.
1192 * @brief Called by editable UI controls when keyboard focus is gained.
1194 void KeyboardFocusGainEvent();
1197 * @brief Called by editable UI controls when focus is lost.
1199 void KeyboardFocusLostEvent();
1202 * @brief Called by editable UI controls when key events are received.
1204 * @param[in] event The key event.
1205 * @param[in] type Used to distinguish between regular key events and IMF events.
1207 bool KeyEvent( const Dali::KeyEvent& event );
1210 * @brief Called by editable UI controls when a tap gesture occurs.
1211 * @param[in] tapCount The number of taps.
1212 * @param[in] x The x position relative to the top-left of the parent control.
1213 * @param[in] y The y position relative to the top-left of the parent control.
1215 void TapEvent( unsigned int tapCount, float x, float y );
1218 * @brief Called by editable UI controls when a pan gesture occurs.
1220 * @param[in] state The state of the gesture.
1221 * @param[in] displacement This distance panned since the last pan gesture.
1223 void PanEvent( Gesture::State state, const Vector2& displacement );
1226 * @brief Called by editable UI controls when a long press gesture occurs.
1228 * @param[in] state The state of the gesture.
1229 * @param[in] x The x position relative to the top-left of the parent control.
1230 * @param[in] y The y position relative to the top-left of the parent control.
1232 void LongPressEvent( Gesture::State state, float x, float y );
1235 * @brief Event received from IMF manager
1237 * @param[in] imfManager The IMF manager.
1238 * @param[in] imfEvent The event received.
1239 * @return A data struture indicating if update is needed, cursor position and current text.
1241 ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
1244 * @brief Event from Clipboard notifying an Item has been selected for pasting
1246 void PasteClipboardItemEvent();
1249 * @brief Return true when text control should clear key input focus when escape key is pressed.
1251 * @return Whether text control should clear key input focus or not when escape key is pressed.
1253 bool ShouldClearFocusOnEscape() const;
1255 protected: // Inherit from Text::Decorator::ControllerInterface.
1258 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1260 virtual void GetTargetSize( Vector2& targetSize );
1263 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1265 virtual void AddDecoration( Actor& actor, bool needsClipping );
1268 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1270 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1272 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1275 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1277 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1279 protected: // Inherit from HiddenText.
1282 * @brief Invoked from HiddenText when showing time of the last character was expired
1284 virtual void DisplayTimeExpired();
1289 * @brief Called by editable UI controls when key events are received.
1291 * @param[in] text The text to insert.
1292 * @param[in] type Used to distinguish between regular key events and IMF events.
1294 void InsertText( const std::string& text, InsertType type );
1297 * @brief Paste given string into Text model
1298 * @param[in] stringToPaste this string will be inserted into the text model
1300 void PasteText( const std::string& stringToPaste );
1303 * @brief Remove a given number of characters
1305 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1306 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1307 * style when pre-edit text is removed.
1309 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1310 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1311 * @param[in] type Whether to update the input style.
1312 * @return True if the remove was successful.
1314 bool RemoveText( int cursorOffset,
1315 int numberOfCharacters,
1316 UpdateInputStyleType type );
1319 * @brief Checks if text is selected and if so removes it.
1320 * @return true if text was removed
1322 bool RemoveSelectedText();
1324 private: // Relayout.
1327 * @brief Lays-out the text.
1329 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1331 * @param[in] size A the size of a bounding box to layout text within.
1332 * @param[in] operations The layout operations which need to be done.
1333 * @param[out] layoutSize The size of the laid-out text.
1335 bool DoRelayout( const Size& size,
1336 OperationsMask operations,
1340 * @brief Calulates the vertical offset to align the text inside the bounding box.
1342 * @param[in] size The size of the bounding box.
1344 void CalculateVerticalOffset( const Size& size );
1349 * @brief Process queued events which modify the model.
1351 void ProcessModifyEvents();
1354 * @brief Used to process an event queued from SetText()
1356 void TextReplacedEvent();
1359 * @brief Used to process an event queued from key events etc.
1361 void TextInsertedEvent();
1364 * @brief Used to process an event queued from backspace key etc.
1366 void TextDeletedEvent();
1369 * @brief Creates a selection event.
1371 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1373 * @param[in] x The x position relative to the top-left of the parent control.
1374 * @param[in] y The y position relative to the top-left of the parent control.
1375 * @param[in] selectAll Whether the whole text is selected.
1377 void SelectEvent( float x, float y, bool selectAll );
1380 * @brief Helper to KeyEvent() to handle the backspace case.
1382 * @return True if a character was deleted.
1384 bool BackspaceKeyEvent();
1386 private: // Helpers.
1389 * @brief Used to remove the text included the placeholder text.
1394 * @brief Helper to show the place holder text..
1396 void ShowPlaceholderText();
1399 * @brief Helper to clear font-specific data (only).
1401 void ClearFontData();
1404 * @brief Helper to clear text's style data.
1406 void ClearStyleData();
1409 * @brief Used to reset the cursor position after setting a new text.
1411 * @param[in] cursorIndex Where to place the cursor.
1413 void ResetCursorPosition( CharacterIndex cursorIndex );
1416 * @brief Used to reset the scroll position after setting a new text.
1418 void ResetScrollPosition();
1420 private: // Private contructors & copy operator.
1423 * @brief Private constructor.
1428 * @brief Private constructor.
1430 Controller( ControlInterface* controlInterface );
1433 * @brief Private constructor.
1435 Controller( ControlInterface* controlInterface,
1436 EditableControlInterface* editableControlInterface );
1439 Controller( const Controller& handle );
1442 Controller& operator=( const Controller& handle );
1444 protected: // Destructor.
1447 * @brief A reference counted object may only be deleted by calling Unreference().
1449 virtual ~Controller();
1459 } // namespace Toolkit
1463 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H