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 underline color.
763 * @param[in] color color of underline.
765 void SetUnderlineColor( const Vector4& color );
768 * @brief Retrieve the underline color.
770 * @return The underline color.
772 const Vector4& GetUnderlineColor() const;
775 * @brief Set the underline enabled flag.
777 * @param[in] enabled The underline enabled flag.
779 void SetUnderlineEnabled( bool enabled );
782 * @brief Returns whether the text is underlined or not.
784 * @return The underline state.
786 bool IsUnderlineEnabled() const;
789 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
791 * @param[in] height The height in pixels of the underline
793 void SetUnderlineHeight( float height );
796 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
798 * @return The height of the underline, or 0 if height is not overrided.
800 float GetUnderlineHeight() const;
803 * @brief Set the outline color.
805 * @param[in] color color of outline.
807 void SetOutlineColor( const Vector4& color );
810 * @brief Retrieve the outline color.
812 * @return The outline color.
814 const Vector4& GetOutlineColor() const;
817 * @brief Set the outline width
819 * @param[in] width The width in pixels of the outline, 0 indicates no outline
821 void SetOutlineWidth( float width );
824 * @brief Retrieves the width of an outline
826 * @return The width of the outline.
828 float GetOutlineWidth() const;
831 * @brief Sets the emboss's properties string.
833 * @note The string is stored to be recovered.
835 * @param[in] embossProperties The emboss's properties string.
837 void SetDefaultEmbossProperties( const std::string& embossProperties );
840 * @brief Retrieves the emboss's properties string.
842 * @return The emboss's properties string.
844 const std::string& GetDefaultEmbossProperties() const;
847 * @brief Sets the outline's properties string.
849 * @note The string is stored to be recovered.
851 * @param[in] outlineProperties The outline's properties string.
853 void SetDefaultOutlineProperties( const std::string& outlineProperties );
856 * @brief Retrieves the outline's properties string.
858 * @return The outline's properties string.
860 const std::string& GetDefaultOutlineProperties() const;
863 * @brief Sets the default line spacing.
865 * @param[in] lineSpacing The line spacing.
867 void SetDefaultLineSpacing( float lineSpacing );
870 * @brief Retrieves the default line spacing.
872 * @return The line spacing.
874 float GetDefaultLineSpacing() const;
877 * @brief Sets the input text's color.
879 * @param[in] color The input text's color.
881 void SetInputColor( const Vector4& color );
884 * @brief Retrieves the input text's color.
886 * @return The input text's color.
888 const Vector4& GetInputColor() const;
891 * @brief Sets the input text's font family name.
893 * @param[in] fontFamily The text's font family name.
895 void SetInputFontFamily( const std::string& fontFamily );
898 * @brief Retrieves the input text's font family name.
900 * @return The input text's font family name.
902 const std::string& GetInputFontFamily() const;
905 * @brief Sets the input font's weight.
907 * @param[in] weight The input font's weight.
909 void SetInputFontWeight( FontWeight weight );
912 * @return Whether the font's weight has been defined.
914 bool IsInputFontWeightDefined() const;
917 * @brief Retrieves the input font's weight.
919 * @return The input font's weight.
921 FontWeight GetInputFontWeight() const;
924 * @brief Sets the input font's width.
926 * @param[in] width The input font's width.
928 void SetInputFontWidth( FontWidth width );
931 * @return Whether the font's width has been defined.
933 bool IsInputFontWidthDefined() const;
936 * @brief Retrieves the input font's width.
938 * @return The input font's width.
940 FontWidth GetInputFontWidth() const;
943 * @brief Sets the input font's slant.
945 * @param[in] slant The input font's slant.
947 void SetInputFontSlant( FontSlant slant );
950 * @return Whether the font's slant has been defined.
952 bool IsInputFontSlantDefined() const;
955 * @brief Retrieves the input font's slant.
957 * @return The input font's slant.
959 FontSlant GetInputFontSlant() const;
962 * @brief Sets the input font's point size.
964 * @param[in] size The input font's point size.
966 void SetInputFontPointSize( float size );
969 * @brief Retrieves the input font's point size.
971 * @return The input font's point size.
973 float GetInputFontPointSize() const;
976 * @brief Sets the input line spacing.
978 * @param[in] lineSpacing The line spacing.
980 void SetInputLineSpacing( float lineSpacing );
983 * @brief Retrieves the input line spacing.
985 * @return The line spacing.
987 float GetInputLineSpacing() const;
990 * @brief Sets the input shadow's properties string.
992 * @note The string is stored to be recovered.
994 * @param[in] shadowProperties The shadow's properties string.
996 void SetInputShadowProperties( const std::string& shadowProperties );
999 * @brief Retrieves the input shadow's properties string.
1001 * @return The shadow's properties string.
1003 const std::string& GetInputShadowProperties() const;
1006 * @brief Sets the input underline's properties string.
1008 * @note The string is stored to be recovered.
1010 * @param[in] underlineProperties The underline's properties string.
1012 void SetInputUnderlineProperties( const std::string& underlineProperties );
1015 * @brief Retrieves the input underline's properties string.
1017 * @return The underline's properties string.
1019 const std::string& GetInputUnderlineProperties() const;
1022 * @brief Sets the input emboss's properties string.
1024 * @note The string is stored to be recovered.
1026 * @param[in] embossProperties The emboss's properties string.
1028 void SetInputEmbossProperties( const std::string& embossProperties );
1031 * @brief Retrieves the input emboss's properties string.
1033 * @return The emboss's properties string.
1035 const std::string& GetInputEmbossProperties() const;
1038 * @brief Sets input the outline's properties string.
1040 * @note The string is stored to be recovered.
1042 * @param[in] outlineProperties The outline's properties string.
1044 void SetInputOutlineProperties( const std::string& outlineProperties );
1047 * @brief Retrieves the input outline's properties string.
1049 * @return The outline's properties string.
1051 const std::string& GetInputOutlineProperties() const;
1054 * @brief Set the control's interface.
1056 * @param[in] controlInterface The control's interface.
1058 void SetControlInterface( ControlInterface* controlInterface );
1060 public: // Queries & retrieves.
1063 * @brief Return the layout engine.
1065 * @return A reference to the layout engine.
1067 Layout::Engine& GetLayoutEngine();
1070 * @brief Return a view of the text.
1072 * @return A reference to the view.
1077 * @copydoc Control::GetNaturalSize()
1079 Vector3 GetNaturalSize();
1082 * @copydoc Control::GetHeightForWidth()
1084 float GetHeightForWidth( float width );
1087 * @brief Retrieves the text's number of lines for a given width.
1088 * @param[in] width The width of the text's area.
1089 * @ return The number of lines.
1091 int GetLineCount( float width );
1094 * @brief Retrieves the text's model.
1096 * @return A pointer to the text's model.
1098 const ModelInterface* const GetTextModel() const;
1101 * @brief Used to get scrolled distance by user input
1103 * @return Distance from last scroll offset to new scroll offset
1105 float GetScrollAmountByUserInput();
1108 * @brief Get latest scroll amount, control size and layout size
1110 * This method is used to get information of control's scroll
1111 * @param[out] scrollPosition The current scrolled position
1112 * @param[out] controlHeight The size of a UI control
1113 * @param[out] layoutHeight The size of a bounding box to layout text within.
1115 * @return Whether the text scroll position is changed or not after last update.
1117 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1120 * @brief Used to set the hidden input option
1122 void SetHiddenInputOption( const Property::Map& options );
1125 * @brief Used to get the hidden input option
1127 void GetHiddenInputOption( Property::Map& options );
1130 * @brief Sets the Placeholder Properties.
1132 * @param[in] map The placeholder property map
1134 void SetPlaceholderProperty( const Property::Map& map );
1137 * @brief Retrieves the Placeholder Property map.
1139 * @param[out] map The property map
1141 void GetPlaceholderProperty( Property::Map& map );
1143 public: // Relayout.
1146 * @brief Triggers a relayout which updates View (if necessary).
1148 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1149 * @param[in] size A the size of a bounding box to layout text within.
1151 * @return Whether the text model or decorations were updated.
1153 UpdateTextType Relayout( const Size& size );
1156 * @brief Request a relayout using the ControlInterface.
1158 void RequestRelayout();
1160 public: // Input style change signals.
1163 * @return Whether the queue of input style changed signals is empty.
1165 bool IsInputStyleChangedSignalsQueueEmpty();
1168 * @brief Process all pending input style changed signals.
1170 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1171 * text controls. Text controls may send signals to state the input style has changed.
1173 void ProcessInputStyleChangedSignals();
1175 public: // Text-input Event Queuing.
1178 * @brief Called by editable UI controls when keyboard focus is gained.
1180 void KeyboardFocusGainEvent();
1183 * @brief Called by editable UI controls when focus is lost.
1185 void KeyboardFocusLostEvent();
1188 * @brief Called by editable UI controls when key events are received.
1190 * @param[in] event The key event.
1191 * @param[in] type Used to distinguish between regular key events and IMF events.
1193 bool KeyEvent( const Dali::KeyEvent& event );
1196 * @brief Called by editable UI controls when a tap gesture occurs.
1197 * @param[in] tapCount The number of taps.
1198 * @param[in] x The x position relative to the top-left of the parent control.
1199 * @param[in] y The y position relative to the top-left of the parent control.
1201 void TapEvent( unsigned int tapCount, float x, float y );
1204 * @brief Called by editable UI controls when a pan gesture occurs.
1206 * @param[in] state The state of the gesture.
1207 * @param[in] displacement This distance panned since the last pan gesture.
1209 void PanEvent( Gesture::State state, const Vector2& displacement );
1212 * @brief Called by editable UI controls when a long press gesture occurs.
1214 * @param[in] state The state of the gesture.
1215 * @param[in] x The x position relative to the top-left of the parent control.
1216 * @param[in] y The y position relative to the top-left of the parent control.
1218 void LongPressEvent( Gesture::State state, float x, float y );
1221 * @brief Event received from IMF manager
1223 * @param[in] imfManager The IMF manager.
1224 * @param[in] imfEvent The event received.
1225 * @return A data struture indicating if update is needed, cursor position and current text.
1227 ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
1230 * @brief Event from Clipboard notifying an Item has been selected for pasting
1232 void PasteClipboardItemEvent();
1235 * @brief Return true when text control should clear key input focus when escape key is pressed.
1237 * @return Whether text control should clear key input focus or not when escape key is pressed.
1239 bool ShouldClearFocusOnEscape() const;
1241 protected: // Inherit from Text::Decorator::ControllerInterface.
1244 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1246 virtual void GetTargetSize( Vector2& targetSize );
1249 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1251 virtual void AddDecoration( Actor& actor, bool needsClipping );
1254 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1256 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1258 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1261 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1263 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1265 protected: // Inherit from HiddenText.
1268 * @brief Invoked from HiddenText when showing time of the last character was expired
1270 virtual void DisplayTimeExpired();
1275 * @brief Called by editable UI controls when key events are received.
1277 * @param[in] text The text to insert.
1278 * @param[in] type Used to distinguish between regular key events and IMF events.
1280 void InsertText( const std::string& text, InsertType type );
1283 * @brief Paste given string into Text model
1284 * @param[in] stringToPaste this string will be inserted into the text model
1286 void PasteText( const std::string& stringToPaste );
1289 * @brief Remove a given number of characters
1291 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1292 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1293 * style when pre-edit text is removed.
1295 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1296 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1297 * @param[in] type Whether to update the input style.
1298 * @return True if the remove was successful.
1300 bool RemoveText( int cursorOffset,
1301 int numberOfCharacters,
1302 UpdateInputStyleType type );
1305 * @brief Checks if text is selected and if so removes it.
1306 * @return true if text was removed
1308 bool RemoveSelectedText();
1310 private: // Relayout.
1313 * @brief Lays-out the text.
1315 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1317 * @param[in] size A the size of a bounding box to layout text within.
1318 * @param[in] operations The layout operations which need to be done.
1319 * @param[out] layoutSize The size of the laid-out text.
1321 bool DoRelayout( const Size& size,
1322 OperationsMask operations,
1326 * @brief Calulates the vertical offset to align the text inside the bounding box.
1328 * @param[in] size The size of the bounding box.
1330 void CalculateVerticalOffset( const Size& size );
1335 * @brief Process queued events which modify the model.
1337 void ProcessModifyEvents();
1340 * @brief Used to process an event queued from SetText()
1342 void TextReplacedEvent();
1345 * @brief Used to process an event queued from key events etc.
1347 void TextInsertedEvent();
1350 * @brief Used to process an event queued from backspace key etc.
1352 void TextDeletedEvent();
1355 * @brief Creates a selection event.
1357 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1359 * @param[in] x The x position relative to the top-left of the parent control.
1360 * @param[in] y The y position relative to the top-left of the parent control.
1361 * @param[in] selectAll Whether the whole text is selected.
1363 void SelectEvent( float x, float y, bool selectAll );
1366 * @brief Helper to KeyEvent() to handle the backspace case.
1368 * @return True if a character was deleted.
1370 bool BackspaceKeyEvent();
1372 private: // Helpers.
1375 * @brief Used to remove the text included the placeholder text.
1380 * @brief Helper to show the place holder text..
1382 void ShowPlaceholderText();
1385 * @brief Helper to clear font-specific data (only).
1387 void ClearFontData();
1390 * @brief Helper to clear text's style data.
1392 void ClearStyleData();
1395 * @brief Used to reset the cursor position after setting a new text.
1397 * @param[in] cursorIndex Where to place the cursor.
1399 void ResetCursorPosition( CharacterIndex cursorIndex );
1402 * @brief Used to reset the scroll position after setting a new text.
1404 void ResetScrollPosition();
1406 private: // Private contructors & copy operator.
1409 * @brief Private constructor.
1414 * @brief Private constructor.
1416 Controller( ControlInterface* controlInterface );
1419 * @brief Private constructor.
1421 Controller( ControlInterface* controlInterface,
1422 EditableControlInterface* editableControlInterface );
1425 Controller( const Controller& handle );
1428 Controller& operator=( const Controller& handle );
1430 protected: // Destructor.
1433 * @brief A reference counted object may only be deleted by calling Unreference().
1435 virtual ~Controller();
1445 } // namespace Toolkit
1449 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H