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/devel-api/controls/text-controls/text-label-devel.h>
29 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
30 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
31 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
32 #include <dali-toolkit/internal/text/hidden-text.h>
33 #include <dali-toolkit/internal/text/text-model-interface.h>
45 class ControlInterface;
46 class EditableControlInterface;
48 class RenderingController;
50 typedef IntrusivePtr<Controller> ControllerPtr;
53 * @brief A Text Controller is used by UI Controls which display text.
55 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
56 * It provides a view of the text that can be used by rendering back-ends.
58 * For selectable/editable UI controls, the controller handles input events from the UI control
59 * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
61 * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
63 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
65 public: // Enumerated types.
68 * @brief Text related operations to be done in the relayout process.
72 NO_OPERATION = 0x0000,
73 CONVERT_TO_UTF32 = 0x0001,
75 VALIDATE_FONTS = 0x0004,
76 GET_LINE_BREAKS = 0x0008,
77 GET_WORD_BREAKS = 0x0010,
80 GET_GLYPH_METRICS = 0x0080,
82 UPDATE_LAYOUT_SIZE = 0x0200,
86 UPDATE_DIRECTION = 0x2000,
87 ALL_OPERATIONS = 0xFFFF
91 * @brief Used to distinguish between regular key events and IMF events
100 * @brief Used to specify whether to update the input style.
102 enum UpdateInputStyleType
105 DONT_UPDATE_INPUT_STYLE
109 * @brief Used to specify what has been updated after the Relayout() method has been called.
113 NONE_UPDATED = 0x0, ///< Nothing has been updated.
114 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
115 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
119 * @brief Different placeholder-text can be shown when the control is active/inactive.
123 PLACEHOLDER_TYPE_ACTIVE,
124 PLACEHOLDER_TYPE_INACTIVE,
128 * @brief Enumeration for Font Size Type.
132 POINT_SIZE, // The size of font in points.
133 PIXEL_SIZE // The size of font in pixels.
140 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
141 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
142 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
146 public: // Constructor.
149 * @brief Create a new instance of a Controller.
151 * @return A pointer to a new Controller.
153 static ControllerPtr New();
156 * @brief Create a new instance of a Controller.
158 * @param[in] controlInterface The control's interface.
160 * @return A pointer to a new Controller.
162 static ControllerPtr New( ControlInterface* controlInterface );
165 * @brief Create a new instance of a Controller.
167 * @param[in] controlInterface The control's interface.
168 * @param[in] editableControlInterface The editable control's interface.
170 * @return A pointer to a new Controller.
172 static ControllerPtr New( ControlInterface* controlInterface,
173 EditableControlInterface* editableControlInterface );
175 public: // Configure the text controller.
178 * @brief Called to enable text input.
180 * @note Selectable or editable controls should call this once after Controller::New().
181 * @param[in] decorator Used to create cursor, selection handle decorations etc.
183 void EnableTextInput( DecoratorPtr decorator );
186 * @brief Used to switch between bitmap & vector based glyphs
188 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
190 void SetGlyphType( TextAbstraction::GlyphType glyphType );
193 * @brief Enables/disables the mark-up processor.
195 * By default is disabled.
197 * @param[in] enable Whether to enable the mark-up processor.
199 void SetMarkupProcessorEnabled( bool enable );
202 * @brief Retrieves whether the mark-up processor is enabled.
204 * By default is disabled.
206 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
208 bool IsMarkupProcessorEnabled() const;
211 * @brief Enables/disables the auto text scrolling
213 * By default is disabled.
215 * @param[in] enable Whether to enable the auto scrolling
217 void SetAutoScrollEnabled( bool enable );
220 * @brief Retrieves whether auto text scrolling is enabled.
222 * By default is disabled.
224 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
226 bool IsAutoScrollEnabled() const;
229 * @brief Get direction of the text from the first line of text,
230 * @return bool rtl (right to left) is true
232 CharacterDirection GetAutoScrollDirection() const;
235 * @brief Get the alignment offset of the first line of text.
237 * @return The alignment offset.
239 float GetAutoScrollLineAlignment() const;
242 * @brief Enables the horizontal scrolling.
244 * @param[in] enable Whether to enable the horizontal scrolling.
246 void SetHorizontalScrollEnabled( bool enable );
249 * @brief Retrieves whether the horizontal scrolling is enabled.
251 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
253 bool IsHorizontalScrollEnabled() const;
256 * @brief Enables the vertical scrolling.
258 * @param[in] enable Whether to enable the vertical scrolling.
260 void SetVerticalScrollEnabled( bool enable );
263 * @brief Retrieves whether the verticall scrolling is enabled.
265 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
267 bool IsVerticalScrollEnabled() const;
270 * @brief Enables the smooth handle panning.
272 * @param[in] enable Whether to enable the smooth handle panning.
274 void SetSmoothHandlePanEnabled( bool enable );
277 * @brief Retrieves whether the smooth handle panning is enabled.
279 * @return @e true if the smooth handle panning is enabled.
281 bool IsSmoothHandlePanEnabled() const;
284 * @brief Sets the maximum number of characters that can be inserted into the TextModel
286 * @param[in] maxCharacters maximum number of characters to be accepted
288 void SetMaximumNumberOfCharacters( Length maxCharacters );
291 * @brief Sets the maximum number of characters that can be inserted into the TextModel
293 * @param[in] maxCharacters maximum number of characters to be accepted
295 int GetMaximumNumberOfCharacters();
298 * @brief Called to enable/disable cursor blink.
300 * @note Only editable controls should calls this.
301 * @param[in] enabled Whether the cursor should blink or not.
303 void SetEnableCursorBlink( bool enable );
306 * @brief Query whether cursor blink is enabled.
308 * @return Whether the cursor should blink or not.
310 bool GetEnableCursorBlink() const;
313 * @brief Whether to enable the multi-line layout.
315 * @param[in] enable \e true enables the multi-line (by default)
317 void SetMultiLineEnabled( bool enable );
320 * @return Whether the multi-line layout is enabled.
322 bool IsMultiLineEnabled() const;
325 * @brief Sets the text's horizontal alignment.
327 * @param[in] alignment The horizontal alignment.
329 void SetHorizontalAlignment( HorizontalAlignment::Type alignment );
332 * @copydoc ModelInterface::GetHorizontalAlignment()
334 HorizontalAlignment::Type GetHorizontalAlignment() const;
337 * @brief Sets the text's vertical alignment.
339 * @param[in] alignment The vertical alignment.
341 void SetVerticalAlignment( VerticalAlignment::Type alignment );
344 * @copydoc ModelInterface::GetVerticalAlignment()
346 VerticalAlignment::Type GetVerticalAlignment() const;
349 * @brief Sets the text's wrap mode
350 * @param[in] text wrap mode The unit of wrapping
352 void SetLineWrapMode( Text::LineWrap::Mode textWarpMode );
355 * @brief Retrieve text wrap mode previously set.
356 * @return text wrap mode
358 Text::LineWrap::Mode GetLineWrapMode() const;
361 * @brief Enable or disable the text elide.
363 * @param[in] enabled Whether to enable the text elide.
365 void SetTextElideEnabled( bool enabled );
368 * @copydoc ModelInterface::IsTextElideEnabled()
370 bool IsTextElideEnabled() const;
373 * @brief Enable or disable the placeholder text elide.
374 * @param enabled Whether to enable the placeholder text elide.
376 void SetPlaceholderTextElideEnabled( bool enabled );
379 * @brief Whether the placeholder text elide property is enabled.
380 * @return True if the placeholder text elide property is enabled, false otherwise.
382 bool IsPlaceholderTextElideEnabled() const;
385 * @brief Enable or disable the text selection.
386 * @param[in] enabled Whether to enable the text selection.
388 void SetSelectionEnabled( bool enabled );
391 * @brief Whether the text selection is enabled or not.
392 * @return True if the text selection is enabled
394 bool IsSelectionEnabled() const;
397 * @brief Enable or disable the text selection using Shift key.
398 * @param enabled Whether to enable the text selection using Shift key
400 void SetShiftSelectionEnabled( bool enabled );
403 * @brief Whether the text selection using Shift key is enabled or not.
404 * @return True if the text selection using Shift key is enabled
406 bool IsShiftSelectionEnabled() const;
409 * @brief Enable or disable the grab handles for text selection.
411 * @param[in] enabled Whether to enable the grab handles
413 void SetGrabHandleEnabled( bool enabled );
416 * @brief Returns whether the grab handles are enabled.
418 * @return True if the grab handles are enabled
420 bool IsGrabHandleEnabled() const;
423 * @brief Sets input type to password
425 * @note The string is displayed hidden character
427 * @param[in] passwordInput True if password input is enabled.
429 void SetInputModePassword( bool passwordInput );
432 * @brief Returns whether the input mode type is set as password.
434 * @return True if input mode type is password
436 bool IsInputModePassword();
439 * @brief Sets the action when there is a double tap event on top of a text area with no text.
441 * @param[in] action The action to do.
443 void SetNoTextDoubleTapAction( NoTextTap::Action action );
446 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
448 * @return The action to do.
450 NoTextTap::Action GetNoTextDoubleTapAction() const;
453 * @briefSets the action when there is a long press event on top of a text area with no text.
455 * @param[in] action The action to do.
457 void SetNoTextLongPressAction( NoTextTap::Action action );
460 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
462 * @return The action to do.
464 NoTextTap::Action GetNoTextLongPressAction() const;
467 * @brief Query if Underline settings were provided by string or map
468 * @return bool true if set by string
470 bool IsUnderlineSetByString();
473 * Set method underline setting were set by
474 * @param[in] bool, true if set by string
476 void UnderlineSetByString( bool setByString );
479 * @brief Query if shadow settings were provided by string or map
480 * @return bool true if set by string
482 bool IsShadowSetByString();
485 * Set method shadow setting were set by
486 * @param[in] bool, true if set by string
488 void ShadowSetByString( bool setByString );
491 * @brief Query if outline settings were provided by string or map
492 * @return bool true if set by string
494 bool IsOutlineSetByString();
497 * Set method outline setting were set by
498 * @param[in] bool, true if set by string
500 void OutlineSetByString( bool setByString );
503 * @brief Query if font style settings were provided by string or map
504 * @return bool true if set by string
506 bool IsFontStyleSetByString();
509 * Set method font style setting were set by
510 * @param[in] bool, true if set by string
512 void FontStyleSetByString( bool setByString );
517 * @brief Replaces any text previously set.
519 * @note This will be converted into UTF-32 when stored in the text model.
520 * @param[in] text A string of UTF-8 characters.
522 void SetText( const std::string& text );
525 * @brief Retrieve any text previously set.
527 * @param[out] text A string of UTF-8 characters.
529 void GetText( std::string& text ) const;
532 * @brief Replaces any placeholder text previously set.
534 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
535 * @param[in] text A string of UTF-8 characters.
537 void SetPlaceholderText( PlaceholderType type, const std::string& text );
540 * @brief Retrieve any placeholder text previously set.
542 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
543 * @param[out] A string of UTF-8 characters.
545 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
548 * @ brief Update the text after a font change
549 * @param[in] newDefaultFont The new font to change to
551 void UpdateAfterFontChange( const std::string& newDefaultFont );
553 public: // Default style & Input style
556 * @brief Set the default font family.
558 * @param[in] defaultFontFamily The default font family.
560 void SetDefaultFontFamily( const std::string& defaultFontFamily );
563 * @brief Retrieve the default font family.
565 * @return The default font family.
567 const std::string& GetDefaultFontFamily() const;
570 * @brief Sets the placeholder text font family.
571 * @param[in] placeholderTextFontFamily The placeholder text font family.
573 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
576 * @brief Retrieves the placeholder text font family.
578 * @return The placeholder text font family
580 const std::string& GetPlaceholderFontFamily() const;
583 * @brief Sets the default font weight.
585 * @param[in] weight The font weight.
587 void SetDefaultFontWeight( FontWeight weight );
590 * @brief Whether the font's weight has been defined.
592 bool IsDefaultFontWeightDefined() const;
595 * @brief Retrieves the default font weight.
597 * @return The default font weight.
599 FontWeight GetDefaultFontWeight() const;
602 * @brief Sets the placeholder text font weight.
604 * @param[in] weight The font weight
606 void SetPlaceholderTextFontWeight( FontWeight weight );
609 * @brief Whether the font's weight has been defined.
611 * @return True if the placeholder text font weight is defined
613 bool IsPlaceholderTextFontWeightDefined() const;
616 * @brief Retrieves the placeholder text font weight.
618 * @return The placeholder text font weight
620 FontWeight GetPlaceholderTextFontWeight() const;
623 * @brief Sets the default font width.
625 * @param[in] width The font width.
627 void SetDefaultFontWidth( FontWidth width );
630 * @brief Whether the font's width has been defined.
632 bool IsDefaultFontWidthDefined() const;
635 * @brief Retrieves the default font width.
637 * @return The default font width.
639 FontWidth GetDefaultFontWidth() const;
642 * @brief Sets the placeholder text font width.
644 * @param[in] width The font width
646 void SetPlaceholderTextFontWidth( FontWidth width );
649 * @brief Whether the font's width has been defined.
651 * @return True if the placeholder text font width is defined
653 bool IsPlaceholderTextFontWidthDefined() const;
656 * @brief Retrieves the placeholder text font width.
658 * @return The placeholder text font width
660 FontWidth GetPlaceholderTextFontWidth() const;
663 * @brief Sets the default font slant.
665 * @param[in] slant The font slant.
667 void SetDefaultFontSlant( FontSlant slant );
670 * @brief Whether the font's slant has been defined.
672 bool IsDefaultFontSlantDefined() const;
675 * @brief Retrieves the default font slant.
677 * @return The default font slant.
679 FontSlant GetDefaultFontSlant() const;
682 * @brief Sets the placeholder text font slant.
684 * @param[in] slant The font slant
686 void SetPlaceholderTextFontSlant( FontSlant slant );
689 * @brief Whether the font's slant has been defined.
691 * @return True if the placeholder text font slant is defined
693 bool IsPlaceholderTextFontSlantDefined() const;
696 * @brief Retrieves the placeholder text font slant.
698 * @return The placeholder text font slant
700 FontSlant GetPlaceholderTextFontSlant() const;
703 * @brief Set the default font size.
705 * @param[in] fontSize The default font size
706 * @param[in] type The font size type is point size or pixel size
708 void SetDefaultFontSize( float fontSize, FontSizeType type );
711 * @brief Retrieve the default point size.
713 * @param[in] type The font size type
714 * @return The default point size.
716 float GetDefaultFontSize( FontSizeType type ) const;
719 * @brief Sets the Placeholder text font size.
720 * @param[in] fontSize The placeholder text font size
721 * @param[in] type The font size type is point size or pixel size
723 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
726 * @brief Retrieves the Placeholder text font size.
727 * @param[in] type The font size type
728 * @return The placeholder font size
730 float GetPlaceholderTextFontSize( FontSizeType type ) const;
733 * @brief Sets the text's default color.
735 * @param color The default color.
737 void SetDefaultColor( const Vector4& color );
740 * @brief Retrieves the text's default color.
742 * @return The default color.
744 const Vector4& GetDefaultColor() const;
747 * @brief Set the text color
749 * @param textColor The text color
751 void SetPlaceholderTextColor( const Vector4& textColor );
754 * @brief Retrieve the text color
756 * @return The text color
758 const Vector4& GetPlaceholderTextColor() const;
761 * @brief Set the shadow offset.
763 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
765 void SetShadowOffset( const Vector2& shadowOffset );
768 * @brief Retrieve the shadow offset.
770 * @return The shadow offset.
772 const Vector2& GetShadowOffset() const;
775 * @brief Set the shadow color.
777 * @param[in] shadowColor The shadow color.
779 void SetShadowColor( const Vector4& shadowColor );
782 * @brief Retrieve the shadow color.
784 * @return The shadow color.
786 const Vector4& GetShadowColor() const;
789 * @brief Set the shadow blur radius.
791 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
793 void SetShadowBlurRadius( const float& shadowBlurRadius );
796 * @brief Retrieve the shadow blur radius.
798 * @return The shadow blur radius.
800 const float& GetShadowBlurRadius() const;
803 * @brief Set the underline color.
805 * @param[in] color color of underline.
807 void SetUnderlineColor( const Vector4& color );
810 * @brief Retrieve the underline color.
812 * @return The underline color.
814 const Vector4& GetUnderlineColor() const;
817 * @brief Set the underline enabled flag.
819 * @param[in] enabled The underline enabled flag.
821 void SetUnderlineEnabled( bool enabled );
824 * @brief Returns whether the text is underlined or not.
826 * @return The underline state.
828 bool IsUnderlineEnabled() const;
831 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
833 * @param[in] height The height in pixels of the underline
835 void SetUnderlineHeight( float height );
838 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
840 * @return The height of the underline, or 0 if height is not overrided.
842 float GetUnderlineHeight() const;
845 * @brief Set the outline color.
847 * @param[in] color color of outline.
849 void SetOutlineColor( const Vector4& color );
852 * @brief Retrieve the outline color.
854 * @return The outline color.
856 const Vector4& GetOutlineColor() const;
859 * @brief Set the outline width
861 * @param[in] width The width in pixels of the outline, 0 indicates no outline
863 void SetOutlineWidth( unsigned int width );
866 * @brief Retrieves the width of an outline
868 * @return The width of the outline.
870 unsigned int GetOutlineWidth() const;
873 * @brief Sets the emboss's properties string.
875 * @note The string is stored to be recovered.
877 * @param[in] embossProperties The emboss's properties string.
879 void SetDefaultEmbossProperties( const std::string& embossProperties );
882 * @brief Retrieves the emboss's properties string.
884 * @return The emboss's properties string.
886 const std::string& GetDefaultEmbossProperties() const;
889 * @brief Sets the outline's properties string.
891 * @note The string is stored to be recovered.
893 * @param[in] outlineProperties The outline's properties string.
895 void SetDefaultOutlineProperties( const std::string& outlineProperties );
898 * @brief Retrieves the outline's properties string.
900 * @return The outline's properties string.
902 const std::string& GetDefaultOutlineProperties() const;
905 * @brief Sets the default line spacing.
907 * @param[in] lineSpacing The line spacing.
909 * @return True if lineSpacing has been updated, false otherwise
911 bool SetDefaultLineSpacing( float lineSpacing );
914 * @brief Retrieves the default line spacing.
916 * @return The line spacing.
918 float GetDefaultLineSpacing() const;
921 * @brief Sets the input text's color.
923 * @param[in] color The input text's color.
925 void SetInputColor( const Vector4& color );
928 * @brief Retrieves the input text's color.
930 * @return The input text's color.
932 const Vector4& GetInputColor() const;
935 * @brief Sets the input text's font family name.
937 * @param[in] fontFamily The text's font family name.
939 void SetInputFontFamily( const std::string& fontFamily );
942 * @brief Retrieves the input text's font family name.
944 * @return The input text's font family name.
946 const std::string& GetInputFontFamily() const;
949 * @brief Sets the input font's weight.
951 * @param[in] weight The input font's weight.
953 void SetInputFontWeight( FontWeight weight );
956 * @return Whether the font's weight has been defined.
958 bool IsInputFontWeightDefined() const;
961 * @brief Retrieves the input font's weight.
963 * @return The input font's weight.
965 FontWeight GetInputFontWeight() const;
968 * @brief Sets the input font's width.
970 * @param[in] width The input font's width.
972 void SetInputFontWidth( FontWidth width );
975 * @return Whether the font's width has been defined.
977 bool IsInputFontWidthDefined() const;
980 * @brief Retrieves the input font's width.
982 * @return The input font's width.
984 FontWidth GetInputFontWidth() const;
987 * @brief Sets the input font's slant.
989 * @param[in] slant The input font's slant.
991 void SetInputFontSlant( FontSlant slant );
994 * @return Whether the font's slant has been defined.
996 bool IsInputFontSlantDefined() const;
999 * @brief Retrieves the input font's slant.
1001 * @return The input font's slant.
1003 FontSlant GetInputFontSlant() const;
1006 * @brief Sets the input font's point size.
1008 * @param[in] size The input font's point size.
1010 void SetInputFontPointSize( float size );
1013 * @brief Retrieves the input font's point size.
1015 * @return The input font's point size.
1017 float GetInputFontPointSize() const;
1020 * @brief Sets the input line spacing.
1022 * @param[in] lineSpacing The line spacing.
1024 void SetInputLineSpacing( float lineSpacing );
1027 * @brief Retrieves the input line spacing.
1029 * @return The line spacing.
1031 float GetInputLineSpacing() const;
1034 * @brief Sets the input shadow's properties string.
1036 * @note The string is stored to be recovered.
1038 * @param[in] shadowProperties The shadow's properties string.
1040 void SetInputShadowProperties( const std::string& shadowProperties );
1043 * @brief Retrieves the input shadow's properties string.
1045 * @return The shadow's properties string.
1047 const std::string& GetInputShadowProperties() const;
1050 * @brief Sets the input underline's properties string.
1052 * @note The string is stored to be recovered.
1054 * @param[in] underlineProperties The underline's properties string.
1056 void SetInputUnderlineProperties( const std::string& underlineProperties );
1059 * @brief Retrieves the input underline's properties string.
1061 * @return The underline's properties string.
1063 const std::string& GetInputUnderlineProperties() const;
1066 * @brief Sets the input emboss's properties string.
1068 * @note The string is stored to be recovered.
1070 * @param[in] embossProperties The emboss's properties string.
1072 void SetInputEmbossProperties( const std::string& embossProperties );
1075 * @brief Retrieves the input emboss's properties string.
1077 * @return The emboss's properties string.
1079 const std::string& GetInputEmbossProperties() const;
1082 * @brief Sets input the outline's properties string.
1084 * @note The string is stored to be recovered.
1086 * @param[in] outlineProperties The outline's properties string.
1088 void SetInputOutlineProperties( const std::string& outlineProperties );
1091 * @brief Retrieves the input outline's properties string.
1093 * @return The outline's properties string.
1095 const std::string& GetInputOutlineProperties() const;
1098 * @brief Set the control's interface.
1100 * @param[in] controlInterface The control's interface.
1102 void SetControlInterface( ControlInterface* controlInterface );
1104 public: // Queries & retrieves.
1107 * @brief Return the layout engine.
1109 * @return A reference to the layout engine.
1111 Layout::Engine& GetLayoutEngine();
1114 * @brief Return a view of the text.
1116 * @return A reference to the view.
1121 * @copydoc Control::GetNaturalSize()
1123 Vector3 GetNaturalSize();
1126 * @copydoc Control::GetHeightForWidth()
1128 float GetHeightForWidth( float width );
1131 * @brief Retrieves the text's number of lines for a given width.
1132 * @param[in] width The width of the text's area.
1133 * @ return The number of lines.
1135 int GetLineCount( float width );
1138 * @brief Retrieves the text's model.
1140 * @return A pointer to the text's model.
1142 const ModelInterface* const GetTextModel() const;
1145 * @brief Used to get scrolled distance by user input
1147 * @return Distance from last scroll offset to new scroll offset
1149 float GetScrollAmountByUserInput();
1152 * @brief Get latest scroll amount, control size and layout size
1154 * This method is used to get information of control's scroll
1155 * @param[out] scrollPosition The current scrolled position
1156 * @param[out] controlHeight The size of a UI control
1157 * @param[out] layoutHeight The size of a bounding box to layout text within.
1159 * @return Whether the text scroll position is changed or not after last update.
1161 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1164 * @brief Used to set the hidden input option
1166 void SetHiddenInputOption( const Property::Map& options );
1169 * @brief Used to get the hidden input option
1171 void GetHiddenInputOption( Property::Map& options );
1174 * @brief Sets the Placeholder Properties.
1176 * @param[in] map The placeholder property map
1178 void SetPlaceholderProperty( const Property::Map& map );
1181 * @brief Retrieves the Placeholder Property map.
1183 * @param[out] map The property map
1185 void GetPlaceholderProperty( Property::Map& map );
1188 * @brief Checks text direction.
1189 * @return The text direction.
1191 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1194 * @brief Retrieves vertical line alignment
1195 * @return The vertical line alignment
1197 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1200 * @brief Sets vertical line alignment
1201 * @param[in] alignment The vertical line alignment for the text
1203 void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
1205 public: // Relayout.
1208 * @brief Triggers a relayout which updates View (if necessary).
1210 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1211 * @param[in] size A the size of a bounding box to layout text within.
1213 * @return Whether the text model or decorations were updated.
1215 UpdateTextType Relayout( const Size& size );
1218 * @brief Request a relayout using the ControlInterface.
1220 void RequestRelayout();
1222 public: // Input style change signals.
1225 * @return Whether the queue of input style changed signals is empty.
1227 bool IsInputStyleChangedSignalsQueueEmpty();
1230 * @brief Process all pending input style changed signals.
1232 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1233 * text controls. Text controls may send signals to state the input style has changed.
1235 void ProcessInputStyleChangedSignals();
1237 public: // Text-input Event Queuing.
1240 * @brief Called by editable UI controls when keyboard focus is gained.
1242 void KeyboardFocusGainEvent();
1245 * @brief Called by editable UI controls when focus is lost.
1247 void KeyboardFocusLostEvent();
1250 * @brief Called by editable UI controls when key events are received.
1252 * @param[in] event The key event.
1253 * @param[in] type Used to distinguish between regular key events and IMF events.
1255 bool KeyEvent( const Dali::KeyEvent& event );
1258 * @brief Called by editable UI controls when a tap gesture occurs.
1259 * @param[in] tapCount The number of taps.
1260 * @param[in] x The x position relative to the top-left of the parent control.
1261 * @param[in] y The y position relative to the top-left of the parent control.
1263 void TapEvent( unsigned int tapCount, float x, float y );
1266 * @brief Called by editable UI controls when a pan gesture occurs.
1268 * @param[in] state The state of the gesture.
1269 * @param[in] displacement This distance panned since the last pan gesture.
1271 void PanEvent( Gesture::State state, const Vector2& displacement );
1274 * @brief Called by editable UI controls when a long press gesture occurs.
1276 * @param[in] state The state of the gesture.
1277 * @param[in] x The x position relative to the top-left of the parent control.
1278 * @param[in] y The y position relative to the top-left of the parent control.
1280 void LongPressEvent( Gesture::State state, float x, float y );
1283 * @brief Event received from IMF manager
1285 * @param[in] imfManager The IMF manager.
1286 * @param[in] imfEvent The event received.
1287 * @return A data struture indicating if update is needed, cursor position and current text.
1289 ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
1292 * @brief Event from Clipboard notifying an Item has been selected for pasting
1294 void PasteClipboardItemEvent();
1297 * @brief Return true when text control should clear key input focus when escape key is pressed.
1299 * @return Whether text control should clear key input focus or not when escape key is pressed.
1301 bool ShouldClearFocusOnEscape() const;
1303 protected: // Inherit from Text::Decorator::ControllerInterface.
1306 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1308 virtual void GetTargetSize( Vector2& targetSize );
1311 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1313 virtual void AddDecoration( Actor& actor, bool needsClipping );
1316 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1318 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1320 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1323 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1325 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1327 protected: // Inherit from HiddenText.
1330 * @brief Invoked from HiddenText when showing time of the last character was expired
1332 virtual void DisplayTimeExpired();
1337 * @brief Called by editable UI controls when key events are received.
1339 * @param[in] text The text to insert.
1340 * @param[in] type Used to distinguish between regular key events and IMF events.
1342 void InsertText( const std::string& text, InsertType type );
1345 * @brief Paste given string into Text model
1346 * @param[in] stringToPaste this string will be inserted into the text model
1348 void PasteText( const std::string& stringToPaste );
1351 * @brief Remove a given number of characters
1353 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1354 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1355 * style when pre-edit text is removed.
1357 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1358 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1359 * @param[in] type Whether to update the input style.
1360 * @return True if the remove was successful.
1362 bool RemoveText( int cursorOffset,
1363 int numberOfCharacters,
1364 UpdateInputStyleType type );
1367 * @brief Checks if text is selected and if so removes it.
1368 * @return true if text was removed
1370 bool RemoveSelectedText();
1372 private: // Relayout.
1375 * @brief Lays-out the text.
1377 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1379 * @param[in] size A the size of a bounding box to layout text within.
1380 * @param[in] operations The layout operations which need to be done.
1381 * @param[out] layoutSize The size of the laid-out text.
1383 bool DoRelayout( const Size& size,
1384 OperationsMask operations,
1388 * @brief Calulates the vertical offset to align the text inside the bounding box.
1390 * @param[in] size The size of the bounding box.
1392 void CalculateVerticalOffset( const Size& size );
1397 * @brief Process queued events which modify the model.
1399 void ProcessModifyEvents();
1402 * @brief Used to process an event queued from SetText()
1404 void TextReplacedEvent();
1407 * @brief Used to process an event queued from key events etc.
1409 void TextInsertedEvent();
1412 * @brief Used to process an event queued from backspace key etc.
1414 void TextDeletedEvent();
1417 * @brief Creates a selection event.
1419 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1421 * @param[in] x The x position relative to the top-left of the parent control.
1422 * @param[in] y The y position relative to the top-left of the parent control.
1423 * @param[in] selectAll Whether the whole text is selected.
1425 void SelectEvent( float x, float y, bool selectAll );
1428 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1430 * @param[in] keyCode The keycode for the key pressed
1431 * @return True if a character was deleted.
1433 bool DeleteEvent( int keyCode );
1435 private: // Helpers.
1438 * @brief Used to remove the text included the placeholder text.
1443 * @brief Helper to show the place holder text..
1445 void ShowPlaceholderText();
1448 * @brief Helper to clear font-specific data (only).
1450 void ClearFontData();
1453 * @brief Helper to clear text's style data.
1455 void ClearStyleData();
1458 * @brief Used to reset the cursor position after setting a new text.
1460 * @param[in] cursorIndex Where to place the cursor.
1462 void ResetCursorPosition( CharacterIndex cursorIndex );
1465 * @brief Used to reset the scroll position after setting a new text.
1467 void ResetScrollPosition();
1469 private: // Private contructors & copy operator.
1472 * @brief Private constructor.
1477 * @brief Private constructor.
1479 Controller( ControlInterface* controlInterface );
1482 * @brief Private constructor.
1484 Controller( ControlInterface* controlInterface,
1485 EditableControlInterface* editableControlInterface );
1488 Controller( const Controller& handle );
1491 Controller& operator=( const Controller& handle );
1493 protected: // Destructor.
1496 * @brief A reference counted object may only be deleted by calling Unreference().
1498 virtual ~Controller();
1502 struct Impl; ///< Made public for testing purposes
1511 } // namespace Toolkit
1515 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H