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 Sets input type to password
426 * @note The string is displayed hidden character
428 * @param[in] passwordInput True if password input is enabled.
430 void SetInputModePassword( bool passwordInput );
433 * @brief Returns whether the input mode type is set as password.
435 * @return True if input mode type is password
437 bool IsInputModePassword();
440 * @brief Sets the action when there is a double tap event on top of a text area with no text.
442 * @param[in] action The action to do.
444 void SetNoTextDoubleTapAction( NoTextTap::Action action );
447 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
449 * @return The action to do.
451 NoTextTap::Action GetNoTextDoubleTapAction() const;
454 * @briefSets the action when there is a long press event on top of a text area with no text.
456 * @param[in] action The action to do.
458 void SetNoTextLongPressAction( NoTextTap::Action action );
461 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
463 * @return The action to do.
465 NoTextTap::Action GetNoTextLongPressAction() const;
468 * @brief Query if Underline settings were provided by string or map
469 * @return bool true if set by string
471 bool IsUnderlineSetByString();
474 * Set method underline setting were set by
475 * @param[in] bool, true if set by string
477 void UnderlineSetByString( bool setByString );
480 * @brief Query if shadow settings were provided by string or map
481 * @return bool true if set by string
483 bool IsShadowSetByString();
486 * Set method shadow setting were set by
487 * @param[in] bool, true if set by string
489 void ShadowSetByString( bool setByString );
492 * @brief Query if outline settings were provided by string or map
493 * @return bool true if set by string
495 bool IsOutlineSetByString();
498 * Set method outline setting were set by
499 * @param[in] bool, true if set by string
501 void OutlineSetByString( bool setByString );
504 * @brief Query if font style settings were provided by string or map
505 * @return bool true if set by string
507 bool IsFontStyleSetByString();
510 * Set method font style setting were set by
511 * @param[in] bool, true if set by string
513 void FontStyleSetByString( bool setByString );
518 * @brief Replaces any text previously set.
520 * @note This will be converted into UTF-32 when stored in the text model.
521 * @param[in] text A string of UTF-8 characters.
523 void SetText( const std::string& text );
526 * @brief Retrieve any text previously set.
528 * @param[out] text A string of UTF-8 characters.
530 void GetText( std::string& text ) const;
533 * @brief Replaces any placeholder text previously set.
535 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
536 * @param[in] text A string of UTF-8 characters.
538 void SetPlaceholderText( PlaceholderType type, const std::string& text );
541 * @brief Retrieve any placeholder text previously set.
543 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
544 * @param[out] A string of UTF-8 characters.
546 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
549 * @ brief Update the text after a font change
550 * @param[in] newDefaultFont The new font to change to
552 void UpdateAfterFontChange( const std::string& newDefaultFont );
554 public: // Default style & Input style
557 * @brief Set the default font family.
559 * @param[in] defaultFontFamily The default font family.
561 void SetDefaultFontFamily( const std::string& defaultFontFamily );
564 * @brief Retrieve the default font family.
566 * @return The default font family.
568 const std::string& GetDefaultFontFamily() const;
571 * @brief Sets the placeholder text font family.
572 * @param[in] placeholderTextFontFamily The placeholder text font family.
574 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
577 * @brief Retrieves the placeholder text font family.
579 * @return The placeholder text font family
581 const std::string& GetPlaceholderFontFamily() const;
584 * @brief Sets the default font weight.
586 * @param[in] weight The font weight.
588 void SetDefaultFontWeight( FontWeight weight );
591 * @brief Whether the font's weight has been defined.
593 bool IsDefaultFontWeightDefined() const;
596 * @brief Retrieves the default font weight.
598 * @return The default font weight.
600 FontWeight GetDefaultFontWeight() const;
603 * @brief Sets the placeholder text font weight.
605 * @param[in] weight The font weight
607 void SetPlaceholderTextFontWeight( FontWeight weight );
610 * @brief Whether the font's weight has been defined.
612 * @return True if the placeholder text font weight is defined
614 bool IsPlaceholderTextFontWeightDefined() const;
617 * @brief Retrieves the placeholder text font weight.
619 * @return The placeholder text font weight
621 FontWeight GetPlaceholderTextFontWeight() const;
624 * @brief Sets the default font width.
626 * @param[in] width The font width.
628 void SetDefaultFontWidth( FontWidth width );
631 * @brief Whether the font's width has been defined.
633 bool IsDefaultFontWidthDefined() const;
636 * @brief Retrieves the default font width.
638 * @return The default font width.
640 FontWidth GetDefaultFontWidth() const;
643 * @brief Sets the placeholder text font width.
645 * @param[in] width The font width
647 void SetPlaceholderTextFontWidth( FontWidth width );
650 * @brief Whether the font's width has been defined.
652 * @return True if the placeholder text font width is defined
654 bool IsPlaceholderTextFontWidthDefined() const;
657 * @brief Retrieves the placeholder text font width.
659 * @return The placeholder text font width
661 FontWidth GetPlaceholderTextFontWidth() const;
664 * @brief Sets the default font slant.
666 * @param[in] slant The font slant.
668 void SetDefaultFontSlant( FontSlant slant );
671 * @brief Whether the font's slant has been defined.
673 bool IsDefaultFontSlantDefined() const;
676 * @brief Retrieves the default font slant.
678 * @return The default font slant.
680 FontSlant GetDefaultFontSlant() const;
683 * @brief Sets the placeholder text font slant.
685 * @param[in] slant The font slant
687 void SetPlaceholderTextFontSlant( FontSlant slant );
690 * @brief Whether the font's slant has been defined.
692 * @return True if the placeholder text font slant is defined
694 bool IsPlaceholderTextFontSlantDefined() const;
697 * @brief Retrieves the placeholder text font slant.
699 * @return The placeholder text font slant
701 FontSlant GetPlaceholderTextFontSlant() const;
704 * @brief Set the default font size.
706 * @param[in] fontSize The default font size
707 * @param[in] type The font size type is point size or pixel size
709 void SetDefaultFontSize( float fontSize, FontSizeType type );
712 * @brief Retrieve the default point size.
714 * @param[in] type The font size type
715 * @return The default point size.
717 float GetDefaultFontSize( FontSizeType type ) const;
720 * @brief Sets the Placeholder text font size.
721 * @param[in] fontSize The placeholder text font size
722 * @param[in] type The font size type is point size or pixel size
724 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
727 * @brief Retrieves the Placeholder text font size.
728 * @param[in] type The font size type
729 * @return The placeholder font size
731 float GetPlaceholderTextFontSize( FontSizeType type ) const;
734 * @brief Sets the text's default color.
736 * @param color The default color.
738 void SetDefaultColor( const Vector4& color );
741 * @brief Retrieves the text's default color.
743 * @return The default color.
745 const Vector4& GetDefaultColor() const;
748 * @brief Set the text color
750 * @param textColor The text color
752 void SetPlaceholderTextColor( const Vector4& textColor );
755 * @brief Retrieve the text color
757 * @return The text color
759 const Vector4& GetPlaceholderTextColor() const;
762 * @brief Set the shadow offset.
764 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
766 void SetShadowOffset( const Vector2& shadowOffset );
769 * @brief Retrieve the shadow offset.
771 * @return The shadow offset.
773 const Vector2& GetShadowOffset() const;
776 * @brief Set the shadow color.
778 * @param[in] shadowColor The shadow color.
780 void SetShadowColor( const Vector4& shadowColor );
783 * @brief Retrieve the shadow color.
785 * @return The shadow color.
787 const Vector4& GetShadowColor() const;
790 * @brief Set the shadow blur radius.
792 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
794 void SetShadowBlurRadius( const float& shadowBlurRadius );
797 * @brief Retrieve the shadow blur radius.
799 * @return The shadow blur radius.
801 const float& GetShadowBlurRadius() const;
804 * @brief Set the underline color.
806 * @param[in] color color of underline.
808 void SetUnderlineColor( const Vector4& color );
811 * @brief Retrieve the underline color.
813 * @return The underline color.
815 const Vector4& GetUnderlineColor() const;
818 * @brief Set the underline enabled flag.
820 * @param[in] enabled The underline enabled flag.
822 void SetUnderlineEnabled( bool enabled );
825 * @brief Returns whether the text is underlined or not.
827 * @return The underline state.
829 bool IsUnderlineEnabled() const;
832 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
834 * @param[in] height The height in pixels of the underline
836 void SetUnderlineHeight( float height );
839 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
841 * @return The height of the underline, or 0 if height is not overrided.
843 float GetUnderlineHeight() const;
846 * @brief Set the outline color.
848 * @param[in] color color of outline.
850 void SetOutlineColor( const Vector4& color );
853 * @brief Retrieve the outline color.
855 * @return The outline color.
857 const Vector4& GetOutlineColor() const;
860 * @brief Set the outline width
862 * @param[in] width The width in pixels of the outline, 0 indicates no outline
864 void SetOutlineWidth( unsigned int width );
867 * @brief Retrieves the width of an outline
869 * @return The width of the outline.
871 unsigned int GetOutlineWidth() const;
874 * @brief Set the background color.
876 * @param[in] color color of background.
878 void SetBackgroundColor( const Vector4& color );
881 * @brief Retrieve the background color.
883 * @return The background color.
885 const Vector4& GetBackgroundColor() const;
888 * @brief Set the background enabled flag.
890 * @param[in] enabled The background enabled flag.
892 void SetBackgroundEnabled( bool enabled );
895 * @brief Returns whether to enable text background or not.
897 * @return Whether text background is enabled.
899 bool IsBackgroundEnabled() const;
902 * @brief Sets the emboss's properties string.
904 * @note The string is stored to be recovered.
906 * @param[in] embossProperties The emboss's properties string.
908 void SetDefaultEmbossProperties( const std::string& embossProperties );
911 * @brief Retrieves the emboss's properties string.
913 * @return The emboss's properties string.
915 const std::string& GetDefaultEmbossProperties() const;
918 * @brief Sets the outline's properties string.
920 * @note The string is stored to be recovered.
922 * @param[in] outlineProperties The outline's properties string.
924 void SetDefaultOutlineProperties( const std::string& outlineProperties );
927 * @brief Retrieves the outline's properties string.
929 * @return The outline's properties string.
931 const std::string& GetDefaultOutlineProperties() const;
934 * @brief Sets the default line spacing.
936 * @param[in] lineSpacing The line spacing.
938 * @return True if lineSpacing has been updated, false otherwise
940 bool SetDefaultLineSpacing( float lineSpacing );
943 * @brief Retrieves the default line spacing.
945 * @return The line spacing.
947 float GetDefaultLineSpacing() const;
950 * @brief Sets the input text's color.
952 * @param[in] color The input text's color.
954 void SetInputColor( const Vector4& color );
957 * @brief Retrieves the input text's color.
959 * @return The input text's color.
961 const Vector4& GetInputColor() const;
964 * @brief Sets the input text's font family name.
966 * @param[in] fontFamily The text's font family name.
968 void SetInputFontFamily( const std::string& fontFamily );
971 * @brief Retrieves the input text's font family name.
973 * @return The input text's font family name.
975 const std::string& GetInputFontFamily() const;
978 * @brief Sets the input font's weight.
980 * @param[in] weight The input font's weight.
982 void SetInputFontWeight( FontWeight weight );
985 * @return Whether the font's weight has been defined.
987 bool IsInputFontWeightDefined() const;
990 * @brief Retrieves the input font's weight.
992 * @return The input font's weight.
994 FontWeight GetInputFontWeight() const;
997 * @brief Sets the input font's width.
999 * @param[in] width The input font's width.
1001 void SetInputFontWidth( FontWidth width );
1004 * @return Whether the font's width has been defined.
1006 bool IsInputFontWidthDefined() const;
1009 * @brief Retrieves the input font's width.
1011 * @return The input font's width.
1013 FontWidth GetInputFontWidth() const;
1016 * @brief Sets the input font's slant.
1018 * @param[in] slant The input font's slant.
1020 void SetInputFontSlant( FontSlant slant );
1023 * @return Whether the font's slant has been defined.
1025 bool IsInputFontSlantDefined() const;
1028 * @brief Retrieves the input font's slant.
1030 * @return The input font's slant.
1032 FontSlant GetInputFontSlant() const;
1035 * @brief Sets the input font's point size.
1037 * @param[in] size The input font's point size.
1039 void SetInputFontPointSize( float size );
1042 * @brief Retrieves the input font's point size.
1044 * @return The input font's point size.
1046 float GetInputFontPointSize() const;
1049 * @brief Sets the input line spacing.
1051 * @param[in] lineSpacing The line spacing.
1053 void SetInputLineSpacing( float lineSpacing );
1056 * @brief Retrieves the input line spacing.
1058 * @return The line spacing.
1060 float GetInputLineSpacing() const;
1063 * @brief Sets the input shadow's properties string.
1065 * @note The string is stored to be recovered.
1067 * @param[in] shadowProperties The shadow's properties string.
1069 void SetInputShadowProperties( const std::string& shadowProperties );
1072 * @brief Retrieves the input shadow's properties string.
1074 * @return The shadow's properties string.
1076 const std::string& GetInputShadowProperties() const;
1079 * @brief Sets the input underline's properties string.
1081 * @note The string is stored to be recovered.
1083 * @param[in] underlineProperties The underline's properties string.
1085 void SetInputUnderlineProperties( const std::string& underlineProperties );
1088 * @brief Retrieves the input underline's properties string.
1090 * @return The underline's properties string.
1092 const std::string& GetInputUnderlineProperties() const;
1095 * @brief Sets the input emboss's properties string.
1097 * @note The string is stored to be recovered.
1099 * @param[in] embossProperties The emboss's properties string.
1101 void SetInputEmbossProperties( const std::string& embossProperties );
1104 * @brief Retrieves the input emboss's properties string.
1106 * @return The emboss's properties string.
1108 const std::string& GetInputEmbossProperties() const;
1111 * @brief Sets input the outline's properties string.
1113 * @note The string is stored to be recovered.
1115 * @param[in] outlineProperties The outline's properties string.
1117 void SetInputOutlineProperties( const std::string& outlineProperties );
1120 * @brief Retrieves the input outline's properties string.
1122 * @return The outline's properties string.
1124 const std::string& GetInputOutlineProperties() const;
1127 * @brief Set the control's interface.
1129 * @param[in] controlInterface The control's interface.
1131 void SetControlInterface( ControlInterface* controlInterface );
1133 public: // Queries & retrieves.
1136 * @brief Return the layout engine.
1138 * @return A reference to the layout engine.
1140 Layout::Engine& GetLayoutEngine();
1143 * @brief Return a view of the text.
1145 * @return A reference to the view.
1150 * @copydoc Control::GetNaturalSize()
1152 Vector3 GetNaturalSize();
1155 * @copydoc Control::GetHeightForWidth()
1157 float GetHeightForWidth( float width );
1160 * @brief Retrieves the text's number of lines for a given width.
1161 * @param[in] width The width of the text's area.
1162 * @ return The number of lines.
1164 int GetLineCount( float width );
1167 * @brief Retrieves the text's model.
1169 * @return A pointer to the text's model.
1171 const ModelInterface* const GetTextModel() const;
1174 * @brief Used to get scrolled distance by user input
1176 * @return Distance from last scroll offset to new scroll offset
1178 float GetScrollAmountByUserInput();
1181 * @brief Get latest scroll amount, control size and layout size
1183 * This method is used to get information of control's scroll
1184 * @param[out] scrollPosition The current scrolled position
1185 * @param[out] controlHeight The size of a UI control
1186 * @param[out] layoutHeight The size of a bounding box to layout text within.
1188 * @return Whether the text scroll position is changed or not after last update.
1190 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1193 * @brief Used to set the hidden input option
1195 void SetHiddenInputOption( const Property::Map& options );
1198 * @brief Used to get the hidden input option
1200 void GetHiddenInputOption( Property::Map& options );
1203 * @brief Sets the Placeholder Properties.
1205 * @param[in] map The placeholder property map
1207 void SetPlaceholderProperty( const Property::Map& map );
1210 * @brief Retrieves the Placeholder Property map.
1212 * @param[out] map The property map
1214 void GetPlaceholderProperty( Property::Map& map );
1217 * @brief Checks text direction.
1218 * @return The text direction.
1220 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1223 * @brief Retrieves vertical line alignment
1224 * @return The vertical line alignment
1226 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1229 * @brief Sets vertical line alignment
1230 * @param[in] alignment The vertical line alignment for the text
1232 void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
1235 * @brief Retrieves ignoreSpaceAfterText value from model
1236 * @return The value of ignoreSpaceAfterText
1238 bool IsIgnoreSpacesAfterText() const;
1241 * @brief Sets ignoreSpaceAfterText value to model
1242 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1244 void SetIgnoreSpacesAfterText( bool ignore );
1247 * @brief Retrieves matchSystemLanguageDirection value from model
1248 * @return The value of matchSystemLanguageDirection
1250 bool IsMatchSystemLanguageDirection() const;
1253 * @brief Sets matchSystemLanguageDirection value to model
1254 * @param[in] match The value of matchSystemLanguageDirection for the text
1256 void SetMatchSystemLanguageDirection( bool match );
1258 public: // Relayout.
1261 * @brief Triggers a relayout which updates View (if necessary).
1263 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1264 * @param[in] size A the size of a bounding box to layout text within.
1265 * @param[in] layoutDirection The direction of the system language.
1267 * @return Whether the text model or decorations were updated.
1269 UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT );
1272 * @brief Request a relayout using the ControlInterface.
1274 void RequestRelayout();
1276 public: // Input style change signals.
1279 * @return Whether the queue of input style changed signals is empty.
1281 bool IsInputStyleChangedSignalsQueueEmpty();
1284 * @brief Process all pending input style changed signals.
1286 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1287 * text controls. Text controls may send signals to state the input style has changed.
1289 void ProcessInputStyleChangedSignals();
1291 public: // Text-input Event Queuing.
1294 * @brief Called by editable UI controls when keyboard focus is gained.
1296 void KeyboardFocusGainEvent();
1299 * @brief Called by editable UI controls when focus is lost.
1301 void KeyboardFocusLostEvent();
1304 * @brief Called by editable UI controls when key events are received.
1306 * @param[in] event The key event.
1307 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1309 bool KeyEvent( const Dali::KeyEvent& event );
1312 * @brief Called by editable UI controls when a tap gesture occurs.
1313 * @param[in] tapCount The number of taps.
1314 * @param[in] x The x position relative to the top-left of the parent control.
1315 * @param[in] y The y position relative to the top-left of the parent control.
1317 void TapEvent( unsigned int tapCount, float x, float y );
1320 * @brief Called by editable UI controls when a pan gesture occurs.
1322 * @param[in] state The state of the gesture.
1323 * @param[in] displacement This distance panned since the last pan gesture.
1325 void PanEvent( Gesture::State state, const Vector2& displacement );
1328 * @brief Called by editable UI controls when a long press gesture occurs.
1330 * @param[in] state The state of the gesture.
1331 * @param[in] x The x position relative to the top-left of the parent control.
1332 * @param[in] y The y position relative to the top-left of the parent control.
1334 void LongPressEvent( Gesture::State state, float x, float y );
1337 * @brief Event received from input method context
1339 * @param[in] inputMethodContext The input method context.
1340 * @param[in] inputMethodContextEvent The event received.
1341 * @return A data struture indicating if update is needed, cursor position and current text.
1343 InputMethodContext::CallbackData OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent );
1346 * @brief Event from Clipboard notifying an Item has been selected for pasting
1348 void PasteClipboardItemEvent();
1351 * @brief Return true when text control should clear key input focus when escape key is pressed.
1353 * @return Whether text control should clear key input focus or not when escape key is pressed.
1355 bool ShouldClearFocusOnEscape() const;
1357 protected: // Inherit from Text::Decorator::ControllerInterface.
1360 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1362 virtual void GetTargetSize( Vector2& targetSize );
1365 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1367 virtual void AddDecoration( Actor& actor, bool needsClipping );
1370 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1372 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1374 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1377 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1379 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1381 protected: // Inherit from HiddenText.
1384 * @brief Invoked from HiddenText when showing time of the last character was expired
1386 virtual void DisplayTimeExpired();
1391 * @brief Called by editable UI controls when key events are received.
1393 * @param[in] text The text to insert.
1394 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1396 void InsertText( const std::string& text, InsertType type );
1399 * @brief Paste given string into Text model
1400 * @param[in] stringToPaste this string will be inserted into the text model
1402 void PasteText( const std::string& stringToPaste );
1405 * @brief Remove a given number of characters
1407 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1408 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1409 * style when pre-edit text is removed.
1411 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1412 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1413 * @param[in] type Whether to update the input style.
1414 * @return True if the remove was successful.
1416 bool RemoveText( int cursorOffset,
1417 int numberOfCharacters,
1418 UpdateInputStyleType type );
1421 * @brief Checks if text is selected and if so removes it.
1422 * @return true if text was removed
1424 bool RemoveSelectedText();
1426 private: // Relayout.
1429 * @brief Lays-out the text.
1431 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1433 * @param[in] size A the size of a bounding box to layout text within.
1434 * @param[in] operations The layout operations which need to be done.
1435 * @param[out] layoutSize The size of the laid-out text.
1437 bool DoRelayout( const Size& size,
1438 OperationsMask operations,
1442 * @brief Calulates the vertical offset to align the text inside the bounding box.
1444 * @param[in] size The size of the bounding box.
1446 void CalculateVerticalOffset( const Size& size );
1451 * @brief Process queued events which modify the model.
1453 void ProcessModifyEvents();
1456 * @brief Used to process an event queued from SetText()
1458 void TextReplacedEvent();
1461 * @brief Used to process an event queued from key events etc.
1463 void TextInsertedEvent();
1466 * @brief Used to process an event queued from backspace key etc.
1468 void TextDeletedEvent();
1471 * @brief Creates a selection event.
1473 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1475 * @param[in] x The x position relative to the top-left of the parent control.
1476 * @param[in] y The y position relative to the top-left of the parent control.
1477 * @param[in] selectAll Whether the whole text is selected.
1479 void SelectEvent( float x, float y, bool selectAll );
1482 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1484 * @param[in] keyCode The keycode for the key pressed
1485 * @return True if a character was deleted.
1487 bool DeleteEvent( int keyCode );
1489 private: // Helpers.
1492 * @brief Used to remove the text included the placeholder text.
1497 * @brief Helper to show the place holder text..
1499 void ShowPlaceholderText();
1502 * @brief Helper to clear font-specific data (only).
1504 void ClearFontData();
1507 * @brief Helper to clear text's style data.
1509 void ClearStyleData();
1512 * @brief Used to reset the cursor position after setting a new text.
1514 * @param[in] cursorIndex Where to place the cursor.
1516 void ResetCursorPosition( CharacterIndex cursorIndex );
1519 * @brief Used to reset the scroll position after setting a new text.
1521 void ResetScrollPosition();
1523 private: // Private contructors & copy operator.
1526 * @brief Private constructor.
1531 * @brief Private constructor.
1533 Controller( ControlInterface* controlInterface );
1536 * @brief Private constructor.
1538 Controller( ControlInterface* controlInterface,
1539 EditableControlInterface* editableControlInterface );
1542 Controller( const Controller& handle );
1545 Controller& operator=( const Controller& handle );
1547 protected: // Destructor.
1550 * @brief A reference counted object may only be deleted by calling Unreference().
1552 virtual ~Controller();
1556 struct Impl; ///< Made public for testing purposes
1565 } // namespace Toolkit
1569 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H