1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/devel-api/adaptor-framework/input-method-context.h>
23 #include <dali/public-api/events/gesture.h>
26 #include <dali-toolkit/public-api/text/text-enumerations.h>
27 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
28 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
29 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
30 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
31 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
32 #include <dali-toolkit/internal/text/hidden-text.h>
33 #include <dali-toolkit/internal/text/text-model-interface.h>
45 class ControlInterface;
46 class EditableControlInterface;
48 class RenderingController;
50 typedef IntrusivePtr<Controller> ControllerPtr;
53 * @brief A Text Controller is used by UI Controls which display text.
55 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
56 * It provides a view of the text that can be used by rendering back-ends.
58 * For selectable/editable UI controls, the controller handles input events from the UI control
59 * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
61 * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
63 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
65 public: // Enumerated types.
68 * @brief Text related operations to be done in the relayout process.
72 NO_OPERATION = 0x0000,
73 CONVERT_TO_UTF32 = 0x0001,
75 VALIDATE_FONTS = 0x0004,
76 GET_LINE_BREAKS = 0x0008,
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 InputMethodContext 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.
182 * @param[in] inputMethodContext Used to manager ime.
184 void EnableTextInput( DecoratorPtr decorator, InputMethodContext& inputMethodContext );
187 * @brief Used to switch between bitmap & vector based glyphs
189 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
191 void SetGlyphType( TextAbstraction::GlyphType glyphType );
194 * @brief Enables/disables the mark-up processor.
196 * By default is disabled.
198 * @param[in] enable Whether to enable the mark-up processor.
200 void SetMarkupProcessorEnabled( bool enable );
203 * @brief Retrieves whether the mark-up processor is enabled.
205 * By default is disabled.
207 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
209 bool IsMarkupProcessorEnabled() const;
212 * @brief Enables/disables the auto text scrolling
214 * By default is disabled.
216 * @param[in] enable Whether to enable the auto scrolling
218 void SetAutoScrollEnabled( bool enable );
221 * @brief Retrieves whether auto text scrolling is enabled.
223 * By default is disabled.
225 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
227 bool IsAutoScrollEnabled() const;
230 * @brief Get direction of the text from the first line of text,
231 * @return bool rtl (right to left) is true
233 CharacterDirection GetAutoScrollDirection() const;
236 * @brief Get the alignment offset of the first line of text.
238 * @return The alignment offset.
240 float GetAutoScrollLineAlignment() const;
243 * @brief Enables the horizontal scrolling.
245 * @param[in] enable Whether to enable the horizontal scrolling.
247 void SetHorizontalScrollEnabled( bool enable );
250 * @brief Retrieves whether the horizontal scrolling is enabled.
252 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
254 bool IsHorizontalScrollEnabled() const;
257 * @brief Enables the vertical scrolling.
259 * @param[in] enable Whether to enable the vertical scrolling.
261 void SetVerticalScrollEnabled( bool enable );
264 * @brief Retrieves whether the verticall scrolling is enabled.
266 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
268 bool IsVerticalScrollEnabled() const;
271 * @brief Enables the smooth handle panning.
273 * @param[in] enable Whether to enable the smooth handle panning.
275 void SetSmoothHandlePanEnabled( bool enable );
278 * @brief Retrieves whether the smooth handle panning is enabled.
280 * @return @e true if the smooth handle panning is enabled.
282 bool IsSmoothHandlePanEnabled() const;
285 * @brief Sets the maximum number of characters that can be inserted into the TextModel
287 * @param[in] maxCharacters maximum number of characters to be accepted
289 void SetMaximumNumberOfCharacters( Length maxCharacters );
292 * @brief Sets the maximum number of characters that can be inserted into the TextModel
294 * @param[in] maxCharacters maximum number of characters to be accepted
296 int GetMaximumNumberOfCharacters();
299 * @brief Called to enable/disable cursor blink.
301 * @note Only editable controls should calls this.
302 * @param[in] enabled Whether the cursor should blink or not.
304 void SetEnableCursorBlink( bool enable );
307 * @brief Query whether cursor blink is enabled.
309 * @return Whether the cursor should blink or not.
311 bool GetEnableCursorBlink() const;
314 * @brief Whether to enable the multi-line layout.
316 * @param[in] enable \e true enables the multi-line (by default)
318 void SetMultiLineEnabled( bool enable );
321 * @return Whether the multi-line layout is enabled.
323 bool IsMultiLineEnabled() const;
326 * @brief Sets the text's horizontal alignment.
328 * @param[in] alignment The horizontal alignment.
330 void SetHorizontalAlignment( HorizontalAlignment::Type alignment );
333 * @copydoc ModelInterface::GetHorizontalAlignment()
335 HorizontalAlignment::Type GetHorizontalAlignment() const;
338 * @brief Sets the text's vertical alignment.
340 * @param[in] alignment The vertical alignment.
342 void SetVerticalAlignment( VerticalAlignment::Type alignment );
345 * @copydoc ModelInterface::GetVerticalAlignment()
347 VerticalAlignment::Type GetVerticalAlignment() const;
350 * @brief Sets the text's wrap mode
351 * @param[in] text wrap mode The unit of wrapping
353 void SetLineWrapMode( Text::LineWrap::Mode textWarpMode );
356 * @brief Retrieve text wrap mode previously set.
357 * @return text wrap mode
359 Text::LineWrap::Mode GetLineWrapMode() const;
362 * @brief Enable or disable the text elide.
364 * @param[in] enabled Whether to enable the text elide.
366 void SetTextElideEnabled( bool enabled );
369 * @copydoc ModelInterface::IsTextElideEnabled()
371 bool IsTextElideEnabled() const;
374 * @brief Enable or disable the placeholder text elide.
375 * @param enabled Whether to enable the placeholder text elide.
377 void SetPlaceholderTextElideEnabled( bool enabled );
380 * @brief Whether the placeholder text elide property is enabled.
381 * @return True if the placeholder text elide property is enabled, false otherwise.
383 bool IsPlaceholderTextElideEnabled() const;
386 * @brief Enable or disable the text selection.
387 * @param[in] enabled Whether to enable the text selection.
389 void SetSelectionEnabled( bool enabled );
392 * @brief Whether the text selection is enabled or not.
393 * @return True if the text selection is enabled
395 bool IsSelectionEnabled() const;
398 * @brief Enable or disable the text selection using Shift key.
399 * @param enabled Whether to enable the text selection using Shift key
401 void SetShiftSelectionEnabled( bool enabled );
404 * @brief Whether the text selection using Shift key is enabled or not.
405 * @return True if the text selection using Shift key is enabled
407 bool IsShiftSelectionEnabled() const;
410 * @brief Enable or disable the grab handles for text selection.
412 * @param[in] enabled Whether to enable the grab handles
414 void SetGrabHandleEnabled( bool enabled );
417 * @brief Returns whether the grab handles are enabled.
419 * @return True if the grab handles are enabled
421 bool IsGrabHandleEnabled() const;
424 * @brief Enable or disable the grab handles for text selection.
426 * @param[in] enabled Whether to enable the grab handles
428 void SetGrabHandlePopupEnabled( bool enabled );
431 * @brief Returns whether the grab handles are enabled.
433 * @return True if the grab handles are enabled
435 bool IsGrabHandlePopupEnabled() const;
438 * @brief Sets input type to password
440 * @note The string is displayed hidden character
442 * @param[in] passwordInput True if password input is enabled.
444 void SetInputModePassword( bool passwordInput );
447 * @brief Returns whether the input mode type is set as password.
449 * @return True if input mode type is password
451 bool IsInputModePassword();
454 * @brief Sets the action when there is a double tap event on top of a text area with no text.
456 * @param[in] action The action to do.
458 void SetNoTextDoubleTapAction( NoTextTap::Action action );
461 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
463 * @return The action to do.
465 NoTextTap::Action GetNoTextDoubleTapAction() const;
468 * @briefSets the action when there is a long press event on top of a text area with no text.
470 * @param[in] action The action to do.
472 void SetNoTextLongPressAction( NoTextTap::Action action );
475 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
477 * @return The action to do.
479 NoTextTap::Action GetNoTextLongPressAction() const;
482 * @brief Query if Underline settings were provided by string or map
483 * @return bool true if set by string
485 bool IsUnderlineSetByString();
488 * Set method underline setting were set by
489 * @param[in] bool, true if set by string
491 void UnderlineSetByString( bool setByString );
494 * @brief Query if shadow settings were provided by string or map
495 * @return bool true if set by string
497 bool IsShadowSetByString();
500 * Set method shadow setting were set by
501 * @param[in] bool, true if set by string
503 void ShadowSetByString( bool setByString );
506 * @brief Query if outline settings were provided by string or map
507 * @return bool true if set by string
509 bool IsOutlineSetByString();
512 * Set method outline setting were set by
513 * @param[in] bool, true if set by string
515 void OutlineSetByString( bool setByString );
518 * @brief Query if font style settings were provided by string or map
519 * @return bool true if set by string
521 bool IsFontStyleSetByString();
524 * Set method font style setting were set by
525 * @param[in] bool, true if set by string
527 void FontStyleSetByString( bool setByString );
532 * @brief Replaces any text previously set.
534 * @note This will be converted into UTF-32 when stored in the text model.
535 * @param[in] text A string of UTF-8 characters.
537 void SetText( const std::string& text );
540 * @brief Retrieve any text previously set.
542 * @param[out] text A string of UTF-8 characters.
544 void GetText( std::string& text ) const;
547 * @brief Replaces any placeholder text previously set.
549 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
550 * @param[in] text A string of UTF-8 characters.
552 void SetPlaceholderText( PlaceholderType type, const std::string& text );
555 * @brief Retrieve any placeholder text previously set.
557 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
558 * @param[out] A string of UTF-8 characters.
560 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
563 * @ brief Update the text after a font change
564 * @param[in] newDefaultFont The new font to change to
566 void UpdateAfterFontChange( const std::string& newDefaultFont );
568 public: // Default style & Input style
571 * @brief Set the default font family.
573 * @param[in] defaultFontFamily The default font family.
575 void SetDefaultFontFamily( const std::string& defaultFontFamily );
578 * @brief Retrieve the default font family.
580 * @return The default font family.
582 const std::string& GetDefaultFontFamily() const;
585 * @brief Sets the placeholder text font family.
586 * @param[in] placeholderTextFontFamily The placeholder text font family.
588 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
591 * @brief Retrieves the placeholder text font family.
593 * @return The placeholder text font family
595 const std::string& GetPlaceholderFontFamily() const;
598 * @brief Sets the default font weight.
600 * @param[in] weight The font weight.
602 void SetDefaultFontWeight( FontWeight weight );
605 * @brief Whether the font's weight has been defined.
607 bool IsDefaultFontWeightDefined() const;
610 * @brief Retrieves the default font weight.
612 * @return The default font weight.
614 FontWeight GetDefaultFontWeight() const;
617 * @brief Sets the placeholder text font weight.
619 * @param[in] weight The font weight
621 void SetPlaceholderTextFontWeight( FontWeight weight );
624 * @brief Whether the font's weight has been defined.
626 * @return True if the placeholder text font weight is defined
628 bool IsPlaceholderTextFontWeightDefined() const;
631 * @brief Retrieves the placeholder text font weight.
633 * @return The placeholder text font weight
635 FontWeight GetPlaceholderTextFontWeight() const;
638 * @brief Sets the default font width.
640 * @param[in] width The font width.
642 void SetDefaultFontWidth( FontWidth width );
645 * @brief Whether the font's width has been defined.
647 bool IsDefaultFontWidthDefined() const;
650 * @brief Retrieves the default font width.
652 * @return The default font width.
654 FontWidth GetDefaultFontWidth() const;
657 * @brief Sets the placeholder text font width.
659 * @param[in] width The font width
661 void SetPlaceholderTextFontWidth( FontWidth width );
664 * @brief Whether the font's width has been defined.
666 * @return True if the placeholder text font width is defined
668 bool IsPlaceholderTextFontWidthDefined() const;
671 * @brief Retrieves the placeholder text font width.
673 * @return The placeholder text font width
675 FontWidth GetPlaceholderTextFontWidth() const;
678 * @brief Sets the default font slant.
680 * @param[in] slant The font slant.
682 void SetDefaultFontSlant( FontSlant slant );
685 * @brief Whether the font's slant has been defined.
687 bool IsDefaultFontSlantDefined() const;
690 * @brief Retrieves the default font slant.
692 * @return The default font slant.
694 FontSlant GetDefaultFontSlant() const;
697 * @brief Sets the placeholder text font slant.
699 * @param[in] slant The font slant
701 void SetPlaceholderTextFontSlant( FontSlant slant );
704 * @brief Whether the font's slant has been defined.
706 * @return True if the placeholder text font slant is defined
708 bool IsPlaceholderTextFontSlantDefined() const;
711 * @brief Retrieves the placeholder text font slant.
713 * @return The placeholder text font slant
715 FontSlant GetPlaceholderTextFontSlant() const;
718 * @brief Set the default font size.
720 * @param[in] fontSize The default font size
721 * @param[in] type The font size type is point size or pixel size
723 void SetDefaultFontSize( float fontSize, FontSizeType type );
726 * @brief Retrieve the default point size.
728 * @param[in] type The font size type
729 * @return The default point size.
731 float GetDefaultFontSize( FontSizeType type ) const;
734 * @brief Sets the Placeholder text font size.
735 * @param[in] fontSize The placeholder text font size
736 * @param[in] type The font size type is point size or pixel size
738 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
741 * @brief Retrieves the Placeholder text font size.
742 * @param[in] type The font size type
743 * @return The placeholder font size
745 float GetPlaceholderTextFontSize( FontSizeType type ) const;
748 * @brief Sets the text's default color.
750 * @param color The default color.
752 void SetDefaultColor( const Vector4& color );
755 * @brief Retrieves the text's default color.
757 * @return The default color.
759 const Vector4& GetDefaultColor() const;
762 * @brief Set the text color
764 * @param textColor The text color
766 void SetPlaceholderTextColor( const Vector4& textColor );
769 * @brief Retrieve the text color
771 * @return The text color
773 const Vector4& GetPlaceholderTextColor() const;
776 * @brief Set the shadow offset.
778 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
780 void SetShadowOffset( const Vector2& shadowOffset );
783 * @brief Retrieve the shadow offset.
785 * @return The shadow offset.
787 const Vector2& GetShadowOffset() const;
790 * @brief Set the shadow color.
792 * @param[in] shadowColor The shadow color.
794 void SetShadowColor( const Vector4& shadowColor );
797 * @brief Retrieve the shadow color.
799 * @return The shadow color.
801 const Vector4& GetShadowColor() const;
804 * @brief Set the shadow blur radius.
806 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
808 void SetShadowBlurRadius( const float& shadowBlurRadius );
811 * @brief Retrieve the shadow blur radius.
813 * @return The shadow blur radius.
815 const float& GetShadowBlurRadius() const;
818 * @brief Set the underline color.
820 * @param[in] color color of underline.
822 void SetUnderlineColor( const Vector4& color );
825 * @brief Retrieve the underline color.
827 * @return The underline color.
829 const Vector4& GetUnderlineColor() const;
832 * @brief Set the underline enabled flag.
834 * @param[in] enabled The underline enabled flag.
836 void SetUnderlineEnabled( bool enabled );
839 * @brief Returns whether the text is underlined or not.
841 * @return The underline state.
843 bool IsUnderlineEnabled() const;
846 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
848 * @param[in] height The height in pixels of the underline
850 void SetUnderlineHeight( float height );
853 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
855 * @return The height of the underline, or 0 if height is not overrided.
857 float GetUnderlineHeight() const;
860 * @brief Set the outline color.
862 * @param[in] color color of outline.
864 void SetOutlineColor( const Vector4& color );
867 * @brief Retrieve the outline color.
869 * @return The outline color.
871 const Vector4& GetOutlineColor() const;
874 * @brief Set the outline width
876 * @param[in] width The width in pixels of the outline, 0 indicates no outline
878 void SetOutlineWidth( uint16_t width );
881 * @brief Retrieves the width of an outline
883 * @return The width of the outline.
885 uint16_t GetOutlineWidth() const;
888 * @brief Set the background color.
890 * @param[in] color color of background.
892 void SetBackgroundColor( const Vector4& color );
895 * @brief Retrieve the background color.
897 * @return The background color.
899 const Vector4& GetBackgroundColor() const;
902 * @brief Set the background enabled flag.
904 * @param[in] enabled The background enabled flag.
906 void SetBackgroundEnabled( bool enabled );
909 * @brief Returns whether to enable text background or not.
911 * @return Whether text background is enabled.
913 bool IsBackgroundEnabled() const;
916 * @brief Sets the emboss's properties string.
918 * @note The string is stored to be recovered.
920 * @param[in] embossProperties The emboss's properties string.
922 void SetDefaultEmbossProperties( const std::string& embossProperties );
925 * @brief Retrieves the emboss's properties string.
927 * @return The emboss's properties string.
929 const std::string& GetDefaultEmbossProperties() const;
932 * @brief Sets the outline's properties string.
934 * @note The string is stored to be recovered.
936 * @param[in] outlineProperties The outline's properties string.
938 void SetDefaultOutlineProperties( const std::string& outlineProperties );
941 * @brief Retrieves the outline's properties string.
943 * @return The outline's properties string.
945 const std::string& GetDefaultOutlineProperties() const;
948 * @brief Sets the default line spacing.
950 * @param[in] lineSpacing The line spacing.
952 * @return True if lineSpacing has been updated, false otherwise
954 bool SetDefaultLineSpacing( float lineSpacing );
957 * @brief Retrieves the default line spacing.
959 * @return The line spacing.
961 float GetDefaultLineSpacing() const;
964 * @brief Sets the input text's color.
966 * @param[in] color The input text's color.
968 void SetInputColor( const Vector4& color );
971 * @brief Retrieves the input text's color.
973 * @return The input text's color.
975 const Vector4& GetInputColor() const;
978 * @brief Sets the input text's font family name.
980 * @param[in] fontFamily The text's font family name.
982 void SetInputFontFamily( const std::string& fontFamily );
985 * @brief Retrieves the input text's font family name.
987 * @return The input text's font family name.
989 const std::string& GetInputFontFamily() const;
992 * @brief Sets the input font's weight.
994 * @param[in] weight The input font's weight.
996 void SetInputFontWeight( FontWeight weight );
999 * @return Whether the font's weight has been defined.
1001 bool IsInputFontWeightDefined() const;
1004 * @brief Retrieves the input font's weight.
1006 * @return The input font's weight.
1008 FontWeight GetInputFontWeight() const;
1011 * @brief Sets the input font's width.
1013 * @param[in] width The input font's width.
1015 void SetInputFontWidth( FontWidth width );
1018 * @return Whether the font's width has been defined.
1020 bool IsInputFontWidthDefined() const;
1023 * @brief Retrieves the input font's width.
1025 * @return The input font's width.
1027 FontWidth GetInputFontWidth() const;
1030 * @brief Sets the input font's slant.
1032 * @param[in] slant The input font's slant.
1034 void SetInputFontSlant( FontSlant slant );
1037 * @return Whether the font's slant has been defined.
1039 bool IsInputFontSlantDefined() const;
1042 * @brief Retrieves the input font's slant.
1044 * @return The input font's slant.
1046 FontSlant GetInputFontSlant() const;
1049 * @brief Sets the input font's point size.
1051 * @param[in] size The input font's point size.
1053 void SetInputFontPointSize( float size );
1056 * @brief Retrieves the input font's point size.
1058 * @return The input font's point size.
1060 float GetInputFontPointSize() const;
1063 * @brief Sets the input line spacing.
1065 * @param[in] lineSpacing The line spacing.
1067 void SetInputLineSpacing( float lineSpacing );
1070 * @brief Retrieves the input line spacing.
1072 * @return The line spacing.
1074 float GetInputLineSpacing() const;
1077 * @brief Sets the input shadow's properties string.
1079 * @note The string is stored to be recovered.
1081 * @param[in] shadowProperties The shadow's properties string.
1083 void SetInputShadowProperties( const std::string& shadowProperties );
1086 * @brief Retrieves the input shadow's properties string.
1088 * @return The shadow's properties string.
1090 const std::string& GetInputShadowProperties() const;
1093 * @brief Sets the input underline's properties string.
1095 * @note The string is stored to be recovered.
1097 * @param[in] underlineProperties The underline's properties string.
1099 void SetInputUnderlineProperties( const std::string& underlineProperties );
1102 * @brief Retrieves the input underline's properties string.
1104 * @return The underline's properties string.
1106 const std::string& GetInputUnderlineProperties() const;
1109 * @brief Sets the input emboss's properties string.
1111 * @note The string is stored to be recovered.
1113 * @param[in] embossProperties The emboss's properties string.
1115 void SetInputEmbossProperties( const std::string& embossProperties );
1118 * @brief Retrieves the input emboss's properties string.
1120 * @return The emboss's properties string.
1122 const std::string& GetInputEmbossProperties() const;
1125 * @brief Sets input the outline's properties string.
1127 * @note The string is stored to be recovered.
1129 * @param[in] outlineProperties The outline's properties string.
1131 void SetInputOutlineProperties( const std::string& outlineProperties );
1134 * @brief Retrieves the input outline's properties string.
1136 * @return The outline's properties string.
1138 const std::string& GetInputOutlineProperties() const;
1141 * @brief Set the control's interface.
1143 * @param[in] controlInterface The control's interface.
1145 void SetControlInterface( ControlInterface* controlInterface );
1147 public: // Queries & retrieves.
1150 * @brief Return the layout engine.
1152 * @return A reference to the layout engine.
1154 Layout::Engine& GetLayoutEngine();
1157 * @brief Return a view of the text.
1159 * @return A reference to the view.
1164 * @copydoc Control::GetNaturalSize()
1166 Vector3 GetNaturalSize();
1169 * @copydoc Control::GetHeightForWidth()
1171 float GetHeightForWidth( float width );
1174 * @brief Retrieves the text's number of lines for a given width.
1175 * @param[in] width The width of the text's area.
1176 * @ return The number of lines.
1178 int GetLineCount( float width );
1181 * @brief Retrieves the text's model.
1183 * @return A pointer to the text's model.
1185 const ModelInterface* const GetTextModel() const;
1188 * @brief Used to get scrolled distance by user input
1190 * @return Distance from last scroll offset to new scroll offset
1192 float GetScrollAmountByUserInput();
1195 * @brief Get latest scroll amount, control size and layout size
1197 * This method is used to get information of control's scroll
1198 * @param[out] scrollPosition The current scrolled position
1199 * @param[out] controlHeight The size of a UI control
1200 * @param[out] layoutHeight The size of a bounding box to layout text within.
1202 * @return Whether the text scroll position is changed or not after last update.
1204 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1207 * @brief Used to set the hidden input option
1209 void SetHiddenInputOption( const Property::Map& options );
1212 * @brief Used to get the hidden input option
1214 void GetHiddenInputOption( Property::Map& options );
1217 * @brief Sets the Placeholder Properties.
1219 * @param[in] map The placeholder property map
1221 void SetPlaceholderProperty( const Property::Map& map );
1224 * @brief Retrieves the Placeholder Property map.
1226 * @param[out] map The property map
1228 void GetPlaceholderProperty( Property::Map& map );
1231 * @brief Checks text direction.
1232 * @return The text direction.
1234 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1237 * @brief Retrieves vertical line alignment
1238 * @return The vertical line alignment
1240 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1243 * @brief Sets vertical line alignment
1244 * @param[in] alignment The vertical line alignment for the text
1246 void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
1249 * @brief Retrieves ignoreSpaceAfterText value from model
1250 * @return The value of ignoreSpaceAfterText
1252 bool IsIgnoreSpacesAfterText() const;
1255 * @brief Sets ignoreSpaceAfterText value to model
1256 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1258 void SetIgnoreSpacesAfterText( bool ignore );
1261 * @brief Retrieves matchSystemLanguageDirection value from model
1262 * @return The value of matchSystemLanguageDirection
1264 bool IsMatchSystemLanguageDirection() const;
1267 * @brief Sets matchSystemLanguageDirection value to model
1268 * @param[in] match The value of matchSystemLanguageDirection for the text
1270 void SetMatchSystemLanguageDirection( bool match );
1273 * @brief Sets layoutDirection value
1274 * @param[in] layoutDirection The value of system language direction
1276 void SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection );
1279 * @brief Retrieves if showing real text or not.
1280 * @return The value of showing real text.
1282 bool IsShowingRealText() const;
1284 public: // Relayout.
1287 * @brief Triggers a relayout which updates View (if necessary).
1289 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1290 * @param[in] size A the size of a bounding box to layout text within.
1291 * @param[in] layoutDirection The direction of the system language.
1293 * @return Whether the text model or decorations were updated.
1295 UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT );
1298 * @brief Request a relayout using the ControlInterface.
1300 void RequestRelayout();
1302 public: // Input style change signals.
1305 * @return Whether the queue of input style changed signals is empty.
1307 bool IsInputStyleChangedSignalsQueueEmpty();
1310 * @brief Process all pending input style changed signals.
1312 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1313 * text controls. Text controls may send signals to state the input style has changed.
1315 void ProcessInputStyleChangedSignals();
1317 public: // Text-input Event Queuing.
1320 * @brief Called by editable UI controls when keyboard focus is gained.
1322 void KeyboardFocusGainEvent();
1325 * @brief Called by editable UI controls when focus is lost.
1327 void KeyboardFocusLostEvent();
1330 * @brief Called by editable UI controls when key events are received.
1332 * @param[in] event The key event.
1333 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1335 bool KeyEvent( const Dali::KeyEvent& event );
1338 * @brief Called by editable UI controls when a tap gesture occurs.
1339 * @param[in] tapCount The number of taps.
1340 * @param[in] x The x position relative to the top-left of the parent control.
1341 * @param[in] y The y position relative to the top-left of the parent control.
1343 void TapEvent( unsigned int tapCount, float x, float y );
1346 * @brief Called by editable UI controls when a pan gesture occurs.
1348 * @param[in] state The state of the gesture.
1349 * @param[in] displacement This distance panned since the last pan gesture.
1351 void PanEvent( Gesture::State state, const Vector2& displacement );
1354 * @brief Called by editable UI controls when a long press gesture occurs.
1356 * @param[in] state The state of the gesture.
1357 * @param[in] x The x position relative to the top-left of the parent control.
1358 * @param[in] y The y position relative to the top-left of the parent control.
1360 void LongPressEvent( Gesture::State state, float x, float y );
1363 * @brief Creates a selection event.
1365 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1367 * @param[in] x The x position relative to the top-left of the parent control.
1368 * @param[in] y The y position relative to the top-left of the parent control.
1369 * @param[in] selectAll Whether the whole text is selected.
1371 void SelectEvent( float x, float y, bool selectAll );
1374 * @brief Event received from input method context
1376 * @param[in] inputMethodContext The input method context.
1377 * @param[in] inputMethodContextEvent The event received.
1378 * @return A data struture indicating if update is needed, cursor position and current text.
1380 InputMethodContext::CallbackData OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent );
1383 * @brief Event from Clipboard notifying an Item has been selected for pasting
1385 void PasteClipboardItemEvent();
1388 * @brief Return true when text control should clear key input focus when escape key is pressed.
1390 * @return Whether text control should clear key input focus or not when escape key is pressed.
1392 bool ShouldClearFocusOnEscape() const;
1394 protected: // Inherit from Text::Decorator::ControllerInterface.
1397 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1399 virtual void GetTargetSize( Vector2& targetSize );
1402 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1404 virtual void AddDecoration( Actor& actor, bool needsClipping );
1407 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1409 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1411 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1414 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1416 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1418 protected: // Inherit from HiddenText.
1421 * @brief Invoked from HiddenText when showing time of the last character was expired
1423 virtual void DisplayTimeExpired();
1428 * @brief Called by editable UI controls when key events are received.
1430 * @param[in] text The text to insert.
1431 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1433 void InsertText( const std::string& text, InsertType type );
1436 * @brief Paste given string into Text model
1437 * @param[in] stringToPaste this string will be inserted into the text model
1439 void PasteText( const std::string& stringToPaste );
1442 * @brief Remove a given number of characters
1444 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1445 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1446 * style when pre-edit text is removed.
1448 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1449 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1450 * @param[in] type Whether to update the input style.
1451 * @return True if the remove was successful.
1453 bool RemoveText( int cursorOffset,
1454 int numberOfCharacters,
1455 UpdateInputStyleType type );
1458 * @brief Checks if text is selected and if so removes it.
1459 * @return true if text was removed
1461 bool RemoveSelectedText();
1463 private: // Relayout.
1466 * @brief Lays-out the text.
1468 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1470 * @param[in] size A the size of a bounding box to layout text within.
1471 * @param[in] operations The layout operations which need to be done.
1472 * @param[out] layoutSize The size of the laid-out text.
1474 bool DoRelayout( const Size& size,
1475 OperationsMask operations,
1479 * @brief Calulates the vertical offset to align the text inside the bounding box.
1481 * @param[in] size The size of the bounding box.
1483 void CalculateVerticalOffset( const Size& size );
1488 * @brief Process queued events which modify the model.
1490 void ProcessModifyEvents();
1493 * @brief Used to process an event queued from SetText()
1495 void TextReplacedEvent();
1498 * @brief Used to process an event queued from key events etc.
1500 void TextInsertedEvent();
1503 * @brief Used to process an event queued from backspace key etc.
1505 void TextDeletedEvent();
1508 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1510 * @param[in] keyCode The keycode for the key pressed
1511 * @return True if a character was deleted.
1513 bool DeleteEvent( int keyCode );
1515 private: // Helpers.
1518 * @brief Used to remove the text included the placeholder text.
1523 * @brief Helper to show the place holder text..
1525 void ShowPlaceholderText();
1528 * @brief Helper to clear font-specific data (only).
1530 void ClearFontData();
1533 * @brief Helper to clear text's style data.
1535 void ClearStyleData();
1538 * @brief Used to reset the cursor position after setting a new text.
1540 * @param[in] cursorIndex Where to place the cursor.
1542 void ResetCursorPosition( CharacterIndex cursorIndex );
1545 * @brief Used to reset the scroll position after setting a new text.
1547 void ResetScrollPosition();
1549 private: // Private contructors & copy operator.
1552 * @brief Private constructor.
1557 * @brief Private constructor.
1559 Controller( ControlInterface* controlInterface );
1562 * @brief Private constructor.
1564 Controller( ControlInterface* controlInterface,
1565 EditableControlInterface* editableControlInterface );
1568 Controller( const Controller& handle );
1571 Controller& operator=( const Controller& handle );
1573 protected: // Destructor.
1576 * @brief A reference counted object may only be deleted by calling Unreference().
1578 virtual ~Controller();
1582 struct Impl; ///< Made public for testing purposes
1591 } // namespace Toolkit
1595 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H