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.
154 TEXT_FIT_FONT_SIZE_TYPE
158 public: // Constructor.
161 * @brief Create a new instance of a Controller.
163 * @return A pointer to a new Controller.
165 static ControllerPtr New();
168 * @brief Create a new instance of a Controller.
170 * @param[in] controlInterface The control's interface.
172 * @return A pointer to a new Controller.
174 static ControllerPtr New( ControlInterface* controlInterface );
177 * @brief Create a new instance of a Controller.
179 * @param[in] controlInterface The control's interface.
180 * @param[in] editableControlInterface The editable control's interface.
182 * @return A pointer to a new Controller.
184 static ControllerPtr New( ControlInterface* controlInterface,
185 EditableControlInterface* editableControlInterface );
187 public: // Configure the text controller.
190 * @brief Called to enable text input.
192 * @note Selectable or editable controls should call this once after Controller::New().
193 * @param[in] decorator Used to create cursor, selection handle decorations etc.
194 * @param[in] inputMethodContext Used to manager ime.
196 void EnableTextInput( DecoratorPtr decorator, InputMethodContext& inputMethodContext );
199 * @brief Used to switch between bitmap & vector based glyphs
201 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
203 void SetGlyphType( TextAbstraction::GlyphType glyphType );
206 * @brief Enables/disables the mark-up processor.
208 * By default is disabled.
210 * @param[in] enable Whether to enable the mark-up processor.
212 void SetMarkupProcessorEnabled( bool enable );
215 * @brief Retrieves whether the mark-up processor is enabled.
217 * By default is disabled.
219 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
221 bool IsMarkupProcessorEnabled() const;
224 * @brief Enables/disables the auto text scrolling
226 * By default is disabled.
228 * @param[in] enable Whether to enable the auto scrolling
230 void SetAutoScrollEnabled( bool enable );
233 * @brief Retrieves whether auto text scrolling is enabled.
235 * By default is disabled.
237 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
239 bool IsAutoScrollEnabled() const;
242 * @brief Get direction of the text from the first line of text,
243 * @return bool rtl (right to left) is true
245 CharacterDirection GetAutoScrollDirection() const;
248 * @brief Get the alignment offset of the first line of text.
250 * @return The alignment offset.
252 float GetAutoScrollLineAlignment() const;
255 * @brief Enables the horizontal scrolling.
257 * @param[in] enable Whether to enable the horizontal scrolling.
259 void SetHorizontalScrollEnabled( bool enable );
262 * @brief Retrieves whether the horizontal scrolling is enabled.
264 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
266 bool IsHorizontalScrollEnabled() const;
269 * @brief Enables the vertical scrolling.
271 * @param[in] enable Whether to enable the vertical scrolling.
273 void SetVerticalScrollEnabled( bool enable );
276 * @brief Retrieves whether the verticall scrolling is enabled.
278 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
280 bool IsVerticalScrollEnabled() const;
283 * @brief Enables the smooth handle panning.
285 * @param[in] enable Whether to enable the smooth handle panning.
287 void SetSmoothHandlePanEnabled( bool enable );
290 * @brief Retrieves whether the smooth handle panning is enabled.
292 * @return @e true if the smooth handle panning is enabled.
294 bool IsSmoothHandlePanEnabled() const;
297 * @brief Sets the maximum number of characters that can be inserted into the TextModel
299 * @param[in] maxCharacters maximum number of characters to be accepted
301 void SetMaximumNumberOfCharacters( Length maxCharacters );
304 * @brief Sets the maximum number of characters that can be inserted into the TextModel
306 * @param[in] maxCharacters maximum number of characters to be accepted
308 int GetMaximumNumberOfCharacters();
311 * @brief Called to enable/disable cursor blink.
313 * @note Only editable controls should calls this.
314 * @param[in] enabled Whether the cursor should blink or not.
316 void SetEnableCursorBlink( bool enable );
319 * @brief Query whether cursor blink is enabled.
321 * @return Whether the cursor should blink or not.
323 bool GetEnableCursorBlink() const;
326 * @brief Whether to enable the multi-line layout.
328 * @param[in] enable \e true enables the multi-line (by default)
330 void SetMultiLineEnabled( bool enable );
333 * @return Whether the multi-line layout is enabled.
335 bool IsMultiLineEnabled() const;
338 * @brief Sets the text's horizontal alignment.
340 * @param[in] alignment The horizontal alignment.
342 void SetHorizontalAlignment( HorizontalAlignment::Type alignment );
345 * @copydoc ModelInterface::GetHorizontalAlignment()
347 HorizontalAlignment::Type GetHorizontalAlignment() const;
350 * @brief Sets the text's vertical alignment.
352 * @param[in] alignment The vertical alignment.
354 void SetVerticalAlignment( VerticalAlignment::Type alignment );
357 * @copydoc ModelInterface::GetVerticalAlignment()
359 VerticalAlignment::Type GetVerticalAlignment() const;
362 * @brief Sets the text's wrap mode
363 * @param[in] text wrap mode The unit of wrapping
365 void SetLineWrapMode( Text::LineWrap::Mode textWarpMode );
368 * @brief Retrieve text wrap mode previously set.
369 * @return text wrap mode
371 Text::LineWrap::Mode GetLineWrapMode() const;
374 * @brief Enable or disable the text elide.
376 * @param[in] enabled Whether to enable the text elide.
378 void SetTextElideEnabled( bool enabled );
381 * @copydoc ModelInterface::IsTextElideEnabled()
383 bool IsTextElideEnabled() const;
386 * @brief Enable or disable the text fit.
388 * @param[in] enabled Whether to enable the text fit.
390 void SetTextFitEnabled(bool enabled);
393 * @brief Whether the text fit is enabled or not.
395 * @return True if the text fit is enabled
397 bool IsTextFitEnabled() const;
400 * @brief Sets minimum size valid for text fit.
402 * @param[in] minimum size value.
403 * @param[in] type The font size type is point size or pixel size
405 void SetTextFitMinSize( float pointSize, FontSizeType type );
408 * @brief Retrieves the minimum point size valid for text fit.
410 * @return The minimum point size valid for text fit
412 float GetTextFitMinSize() const;
415 * @brief Sets maximum size valid for text fit.
417 * @param[in] maximum size value.
418 * @param[in] type The font size type is point size or pixel size
420 void SetTextFitMaxSize( float pointSize, FontSizeType type );
423 * @brief Retrieves the maximum point size valid for text fit.
425 * @return The maximum point size valid for text fit
427 float GetTextFitMaxSize() const;
430 * @brief Sets step size for font increase valid for text fit.
432 * @param[in] step size value.
433 * @param[in] type The font size type is point size or pixel size
435 void SetTextFitStepSize( float step, FontSizeType type );
438 * @brief Retrieves the step point size valid for text fit.
440 * @return The step point size valid for text fit
442 float GetTextFitStepSize() const;
445 * @brief Sets content size valid for text fit.
447 * @param[in] Content size value.
449 void SetTextFitContentSize(Vector2 size);
452 * @brief Retrieves the content size valid for text fit.
454 * @return The content size valid for text fit
456 Vector2 GetTextFitContentSize() const;
459 * @brief Enable or disable the placeholder text elide.
460 * @param enabled Whether to enable the placeholder text elide.
462 void SetPlaceholderTextElideEnabled( bool enabled );
465 * @brief Whether the placeholder text elide property is enabled.
466 * @return True if the placeholder text elide property is enabled, false otherwise.
468 bool IsPlaceholderTextElideEnabled() const;
471 * @brief Enable or disable the text selection.
472 * @param[in] enabled Whether to enable the text selection.
474 void SetSelectionEnabled( bool enabled );
477 * @brief Whether the text selection is enabled or not.
478 * @return True if the text selection is enabled
480 bool IsSelectionEnabled() const;
483 * @brief Enable or disable the text selection using Shift key.
484 * @param enabled Whether to enable the text selection using Shift key
486 void SetShiftSelectionEnabled( bool enabled );
489 * @brief Whether the text selection using Shift key is enabled or not.
490 * @return True if the text selection using Shift key is enabled
492 bool IsShiftSelectionEnabled() const;
495 * @brief Enable or disable the grab handles for text selection.
497 * @param[in] enabled Whether to enable the grab handles
499 void SetGrabHandleEnabled( bool enabled );
502 * @brief Returns whether the grab handles are enabled.
504 * @return True if the grab handles are enabled
506 bool IsGrabHandleEnabled() const;
509 * @brief Enable or disable the grab handles for text selection.
511 * @param[in] enabled Whether to enable the grab handles
513 void SetGrabHandlePopupEnabled( bool enabled );
516 * @brief Returns whether the grab handles are enabled.
518 * @return True if the grab handles are enabled
520 bool IsGrabHandlePopupEnabled() const;
523 * @brief Sets input type to password
525 * @note The string is displayed hidden character
527 * @param[in] passwordInput True if password input is enabled.
529 void SetInputModePassword( bool passwordInput );
532 * @brief Returns whether the input mode type is set as password.
534 * @return True if input mode type is password
536 bool IsInputModePassword();
539 * @brief Sets the action when there is a double tap event on top of a text area with no text.
541 * @param[in] action The action to do.
543 void SetNoTextDoubleTapAction( NoTextTap::Action action );
546 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
548 * @return The action to do.
550 NoTextTap::Action GetNoTextDoubleTapAction() const;
553 * @briefSets the action when there is a long press event on top of a text area with no text.
555 * @param[in] action The action to do.
557 void SetNoTextLongPressAction( NoTextTap::Action action );
560 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
562 * @return The action to do.
564 NoTextTap::Action GetNoTextLongPressAction() const;
567 * @brief Query if Underline settings were provided by string or map
568 * @return bool true if set by string
570 bool IsUnderlineSetByString();
573 * Set method underline setting were set by
574 * @param[in] bool, true if set by string
576 void UnderlineSetByString( bool setByString );
579 * @brief Query if shadow settings were provided by string or map
580 * @return bool true if set by string
582 bool IsShadowSetByString();
585 * Set method shadow setting were set by
586 * @param[in] bool, true if set by string
588 void ShadowSetByString( bool setByString );
591 * @brief Query if outline settings were provided by string or map
592 * @return bool true if set by string
594 bool IsOutlineSetByString();
597 * Set method outline setting were set by
598 * @param[in] bool, true if set by string
600 void OutlineSetByString( bool setByString );
603 * @brief Query if font style settings were provided by string or map
604 * @return bool true if set by string
606 bool IsFontStyleSetByString();
609 * Set method font style setting were set by
610 * @param[in] bool, true if set by string
612 void FontStyleSetByString( bool setByString );
617 * @brief Replaces any text previously set.
619 * @note This will be converted into UTF-32 when stored in the text model.
620 * @param[in] text A string of UTF-8 characters.
622 void SetText( const std::string& text );
625 * @brief Retrieve any text previously set.
627 * @param[out] text A string of UTF-8 characters.
629 void GetText( std::string& text ) const;
632 * @brief Replaces any placeholder text previously set.
634 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
635 * @param[in] text A string of UTF-8 characters.
637 void SetPlaceholderText( PlaceholderType type, const std::string& text );
640 * @brief Retrieve any placeholder text previously set.
642 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
643 * @param[out] A string of UTF-8 characters.
645 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
648 * @ brief Update the text after a font change
649 * @param[in] newDefaultFont The new font to change to
651 void UpdateAfterFontChange( const std::string& newDefaultFont );
653 public: // Default style & Input style
656 * @brief Set the default font family.
658 * @param[in] defaultFontFamily The default font family.
660 void SetDefaultFontFamily( const std::string& defaultFontFamily );
663 * @brief Retrieve the default font family.
665 * @return The default font family.
667 const std::string& GetDefaultFontFamily() const;
670 * @brief Sets the placeholder text font family.
671 * @param[in] placeholderTextFontFamily The placeholder text font family.
673 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
676 * @brief Retrieves the placeholder text font family.
678 * @return The placeholder text font family
680 const std::string& GetPlaceholderFontFamily() const;
683 * @brief Sets the default font weight.
685 * @param[in] weight The font weight.
687 void SetDefaultFontWeight( FontWeight weight );
690 * @brief Whether the font's weight has been defined.
692 bool IsDefaultFontWeightDefined() const;
695 * @brief Retrieves the default font weight.
697 * @return The default font weight.
699 FontWeight GetDefaultFontWeight() const;
702 * @brief Sets the placeholder text font weight.
704 * @param[in] weight The font weight
706 void SetPlaceholderTextFontWeight( FontWeight weight );
709 * @brief Whether the font's weight has been defined.
711 * @return True if the placeholder text font weight is defined
713 bool IsPlaceholderTextFontWeightDefined() const;
716 * @brief Retrieves the placeholder text font weight.
718 * @return The placeholder text font weight
720 FontWeight GetPlaceholderTextFontWeight() const;
723 * @brief Sets the default font width.
725 * @param[in] width The font width.
727 void SetDefaultFontWidth( FontWidth width );
730 * @brief Whether the font's width has been defined.
732 bool IsDefaultFontWidthDefined() const;
735 * @brief Retrieves the default font width.
737 * @return The default font width.
739 FontWidth GetDefaultFontWidth() const;
742 * @brief Sets the placeholder text font width.
744 * @param[in] width The font width
746 void SetPlaceholderTextFontWidth( FontWidth width );
749 * @brief Whether the font's width has been defined.
751 * @return True if the placeholder text font width is defined
753 bool IsPlaceholderTextFontWidthDefined() const;
756 * @brief Retrieves the placeholder text font width.
758 * @return The placeholder text font width
760 FontWidth GetPlaceholderTextFontWidth() const;
763 * @brief Sets the default font slant.
765 * @param[in] slant The font slant.
767 void SetDefaultFontSlant( FontSlant slant );
770 * @brief Whether the font's slant has been defined.
772 bool IsDefaultFontSlantDefined() const;
775 * @brief Retrieves the default font slant.
777 * @return The default font slant.
779 FontSlant GetDefaultFontSlant() const;
782 * @brief Sets the placeholder text font slant.
784 * @param[in] slant The font slant
786 void SetPlaceholderTextFontSlant( FontSlant slant );
789 * @brief Whether the font's slant has been defined.
791 * @return True if the placeholder text font slant is defined
793 bool IsPlaceholderTextFontSlantDefined() const;
796 * @brief Retrieves the placeholder text font slant.
798 * @return The placeholder text font slant
800 FontSlant GetPlaceholderTextFontSlant() const;
803 * @brief Set the default font size.
805 * @param[in] fontSize The default font size
806 * @param[in] type The font size type is point size or pixel size
808 void SetDefaultFontSize( float fontSize, FontSizeType type );
811 * @brief Retrieve the default point size.
813 * @param[in] type The font size type
814 * @return The default point size.
816 float GetDefaultFontSize( FontSizeType type ) const;
819 * @brief Sets the Placeholder text font size.
820 * @param[in] fontSize The placeholder text font size
821 * @param[in] type The font size type is point size or pixel size
823 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
826 * @brief Retrieves the Placeholder text font size.
827 * @param[in] type The font size type
828 * @return The placeholder font size
830 float GetPlaceholderTextFontSize( FontSizeType type ) const;
833 * @brief Sets the text's default color.
835 * @param color The default color.
837 void SetDefaultColor( const Vector4& color );
840 * @brief Retrieves the text's default color.
842 * @return The default color.
844 const Vector4& GetDefaultColor() const;
847 * @brief Set the text color
849 * @param textColor The text color
851 void SetPlaceholderTextColor( const Vector4& textColor );
854 * @brief Retrieve the text color
856 * @return The text color
858 const Vector4& GetPlaceholderTextColor() const;
861 * @brief Set the shadow offset.
863 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
865 void SetShadowOffset( const Vector2& shadowOffset );
868 * @brief Retrieve the shadow offset.
870 * @return The shadow offset.
872 const Vector2& GetShadowOffset() const;
875 * @brief Set the shadow color.
877 * @param[in] shadowColor The shadow color.
879 void SetShadowColor( const Vector4& shadowColor );
882 * @brief Retrieve the shadow color.
884 * @return The shadow color.
886 const Vector4& GetShadowColor() const;
889 * @brief Set the shadow blur radius.
891 * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
893 void SetShadowBlurRadius( const float& shadowBlurRadius );
896 * @brief Retrieve the shadow blur radius.
898 * @return The shadow blur radius.
900 const float& GetShadowBlurRadius() const;
903 * @brief Set the underline color.
905 * @param[in] color color of underline.
907 void SetUnderlineColor( const Vector4& color );
910 * @brief Retrieve the underline color.
912 * @return The underline color.
914 const Vector4& GetUnderlineColor() const;
917 * @brief Set the underline enabled flag.
919 * @param[in] enabled The underline enabled flag.
921 void SetUnderlineEnabled( bool enabled );
924 * @brief Returns whether the text is underlined or not.
926 * @return The underline state.
928 bool IsUnderlineEnabled() const;
931 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
933 * @param[in] height The height in pixels of the underline
935 void SetUnderlineHeight( float height );
938 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
940 * @return The height of the underline, or 0 if height is not overrided.
942 float GetUnderlineHeight() const;
945 * @brief Set the outline color.
947 * @param[in] color color of outline.
949 void SetOutlineColor( const Vector4& color );
952 * @brief Retrieve the outline color.
954 * @return The outline color.
956 const Vector4& GetOutlineColor() const;
959 * @brief Set the outline width
961 * @param[in] width The width in pixels of the outline, 0 indicates no outline
963 void SetOutlineWidth( uint16_t width );
966 * @brief Retrieves the width of an outline
968 * @return The width of the outline.
970 uint16_t GetOutlineWidth() const;
973 * @brief Set the background color.
975 * @param[in] color color of background.
977 void SetBackgroundColor( const Vector4& color );
980 * @brief Retrieve the background color.
982 * @return The background color.
984 const Vector4& GetBackgroundColor() const;
987 * @brief Set the background enabled flag.
989 * @param[in] enabled The background enabled flag.
991 void SetBackgroundEnabled( bool enabled );
994 * @brief Returns whether to enable text background or not.
996 * @return Whether text background is enabled.
998 bool IsBackgroundEnabled() const;
1001 * @brief Sets the emboss's properties string.
1003 * @note The string is stored to be recovered.
1005 * @param[in] embossProperties The emboss's properties string.
1007 void SetDefaultEmbossProperties( const std::string& embossProperties );
1010 * @brief Retrieves the emboss's properties string.
1012 * @return The emboss's properties string.
1014 const std::string& GetDefaultEmbossProperties() const;
1017 * @brief Sets the outline's properties string.
1019 * @note The string is stored to be recovered.
1021 * @param[in] outlineProperties The outline's properties string.
1023 void SetDefaultOutlineProperties( const std::string& outlineProperties );
1026 * @brief Retrieves the outline's properties string.
1028 * @return The outline's properties string.
1030 const std::string& GetDefaultOutlineProperties() const;
1033 * @brief Sets the default line spacing.
1035 * @param[in] lineSpacing The line spacing.
1037 * @return True if lineSpacing has been updated, false otherwise
1039 bool SetDefaultLineSpacing( float lineSpacing );
1042 * @brief Retrieves the default line spacing.
1044 * @return The line spacing.
1046 float GetDefaultLineSpacing() const;
1049 * @brief Sets the input text's color.
1051 * @param[in] color The input text's color.
1053 void SetInputColor( const Vector4& color );
1056 * @brief Retrieves the input text's color.
1058 * @return The input text's color.
1060 const Vector4& GetInputColor() const;
1063 * @brief Sets the input text's font family name.
1065 * @param[in] fontFamily The text's font family name.
1067 void SetInputFontFamily( const std::string& fontFamily );
1070 * @brief Retrieves the input text's font family name.
1072 * @return The input text's font family name.
1074 const std::string& GetInputFontFamily() const;
1077 * @brief Sets the input font's weight.
1079 * @param[in] weight The input font's weight.
1081 void SetInputFontWeight( FontWeight weight );
1084 * @return Whether the font's weight has been defined.
1086 bool IsInputFontWeightDefined() const;
1089 * @brief Retrieves the input font's weight.
1091 * @return The input font's weight.
1093 FontWeight GetInputFontWeight() const;
1096 * @brief Sets the input font's width.
1098 * @param[in] width The input font's width.
1100 void SetInputFontWidth( FontWidth width );
1103 * @return Whether the font's width has been defined.
1105 bool IsInputFontWidthDefined() const;
1108 * @brief Retrieves the input font's width.
1110 * @return The input font's width.
1112 FontWidth GetInputFontWidth() const;
1115 * @brief Sets the input font's slant.
1117 * @param[in] slant The input font's slant.
1119 void SetInputFontSlant( FontSlant slant );
1122 * @return Whether the font's slant has been defined.
1124 bool IsInputFontSlantDefined() const;
1127 * @brief Retrieves the input font's slant.
1129 * @return The input font's slant.
1131 FontSlant GetInputFontSlant() const;
1134 * @brief Sets the input font's point size.
1136 * @param[in] size The input font's point size.
1138 void SetInputFontPointSize( float size );
1141 * @brief Retrieves the input font's point size.
1143 * @return The input font's point size.
1145 float GetInputFontPointSize() const;
1148 * @brief Sets the input line spacing.
1150 * @param[in] lineSpacing The line spacing.
1152 void SetInputLineSpacing( float lineSpacing );
1155 * @brief Retrieves the input line spacing.
1157 * @return The line spacing.
1159 float GetInputLineSpacing() const;
1162 * @brief Sets the input shadow's properties string.
1164 * @note The string is stored to be recovered.
1166 * @param[in] shadowProperties The shadow's properties string.
1168 void SetInputShadowProperties( const std::string& shadowProperties );
1171 * @brief Retrieves the input shadow's properties string.
1173 * @return The shadow's properties string.
1175 const std::string& GetInputShadowProperties() const;
1178 * @brief Sets the input underline's properties string.
1180 * @note The string is stored to be recovered.
1182 * @param[in] underlineProperties The underline's properties string.
1184 void SetInputUnderlineProperties( const std::string& underlineProperties );
1187 * @brief Retrieves the input underline's properties string.
1189 * @return The underline's properties string.
1191 const std::string& GetInputUnderlineProperties() const;
1194 * @brief Sets the input emboss's properties string.
1196 * @note The string is stored to be recovered.
1198 * @param[in] embossProperties The emboss's properties string.
1200 void SetInputEmbossProperties( const std::string& embossProperties );
1203 * @brief Retrieves the input emboss's properties string.
1205 * @return The emboss's properties string.
1207 const std::string& GetInputEmbossProperties() const;
1210 * @brief Sets input the outline's properties string.
1212 * @note The string is stored to be recovered.
1214 * @param[in] outlineProperties The outline's properties string.
1216 void SetInputOutlineProperties( const std::string& outlineProperties );
1219 * @brief Retrieves the input outline's properties string.
1221 * @return The outline's properties string.
1223 const std::string& GetInputOutlineProperties() const;
1226 * @brief Set the control's interface.
1228 * @param[in] controlInterface The control's interface.
1230 void SetControlInterface( ControlInterface* controlInterface );
1232 public: // Queries & retrieves.
1235 * @brief Return the layout engine.
1237 * @return A reference to the layout engine.
1239 Layout::Engine& GetLayoutEngine();
1242 * @brief Return a view of the text.
1244 * @return A reference to the view.
1249 * @copydoc Control::GetNaturalSize()
1251 Vector3 GetNaturalSize();
1254 * @copydoc Control::GetHeightForWidth()
1256 float GetHeightForWidth( float width );
1259 * @brief Calculates the point size for text for given layout()
1261 void FitPointSizeforLayout( Size layoutSize );
1264 * @brief Checks if the point size fits within the layout size.
1266 * @return Whether the point size fits within the layout size.
1268 bool CheckForTextFit( float pointSize, Size& layoutSize );
1271 * @brief Retrieves the text's number of lines for a given width.
1272 * @param[in] width The width of the text's area.
1273 * @ return The number of lines.
1275 int GetLineCount( float width );
1278 * @brief Retrieves the text's model.
1280 * @return A pointer to the text's model.
1282 const ModelInterface* const GetTextModel() const;
1285 * @brief Used to get scrolled distance by user input
1287 * @return Distance from last scroll offset to new scroll offset
1289 float GetScrollAmountByUserInput();
1292 * @brief Get latest scroll amount, control size and layout size
1294 * This method is used to get information of control's scroll
1295 * @param[out] scrollPosition The current scrolled position
1296 * @param[out] controlHeight The size of a UI control
1297 * @param[out] layoutHeight The size of a bounding box to layout text within.
1299 * @return Whether the text scroll position is changed or not after last update.
1301 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1304 * @brief Used to set the hidden input option
1306 void SetHiddenInputOption( const Property::Map& options );
1309 * @brief Used to get the hidden input option
1311 void GetHiddenInputOption( Property::Map& options );
1314 * @brief Sets the Placeholder Properties.
1316 * @param[in] map The placeholder property map
1318 void SetPlaceholderProperty( const Property::Map& map );
1321 * @brief Retrieves the Placeholder Property map.
1323 * @param[out] map The property map
1325 void GetPlaceholderProperty( Property::Map& map );
1328 * @brief Checks text direction.
1329 * @return The text direction.
1331 Toolkit::DevelText::TextDirection::Type GetTextDirection();
1334 * @brief Retrieves vertical line alignment
1335 * @return The vertical line alignment
1337 Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1340 * @brief Sets vertical line alignment
1341 * @param[in] alignment The vertical line alignment for the text
1343 void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
1346 * @brief Retrieves ignoreSpaceAfterText value from model
1347 * @return The value of ignoreSpaceAfterText
1349 bool IsIgnoreSpacesAfterText() const;
1352 * @brief Sets ignoreSpaceAfterText value to model
1353 * @param[in] ignore The value of ignoreSpacesAfterText for the text
1355 void SetIgnoreSpacesAfterText( bool ignore );
1358 * @brief Retrieves matchSystemLanguageDirection value from model
1359 * @return The value of matchSystemLanguageDirection
1361 bool IsMatchSystemLanguageDirection() const;
1364 * @brief Sets matchSystemLanguageDirection value to model
1365 * @param[in] match The value of matchSystemLanguageDirection for the text
1367 void SetMatchSystemLanguageDirection( bool match );
1370 * @brief Sets layoutDirection value
1371 * @param[in] layoutDirection The value of system language direction
1373 void SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection );
1376 * @brief Retrieves if showing real text or not.
1377 * @return The value of showing real text.
1379 bool IsShowingRealText() const;
1381 public: // Relayout.
1384 * @brief Triggers a relayout which updates View (if necessary).
1386 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1387 * @param[in] size A the size of a bounding box to layout text within.
1388 * @param[in] layoutDirection The direction of the system language.
1390 * @return Whether the text model or decorations were updated.
1392 UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT );
1395 * @brief Request a relayout using the ControlInterface.
1397 void RequestRelayout();
1399 public: // Input style change signals.
1402 * @return Whether the queue of input style changed signals is empty.
1404 bool IsInputStyleChangedSignalsQueueEmpty();
1407 * @brief Process all pending input style changed signals.
1409 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1410 * text controls. Text controls may send signals to state the input style has changed.
1412 void ProcessInputStyleChangedSignals();
1414 public: // Text-input Event Queuing.
1417 * @brief Called by editable UI controls when keyboard focus is gained.
1419 void KeyboardFocusGainEvent();
1422 * @brief Called by editable UI controls when focus is lost.
1424 void KeyboardFocusLostEvent();
1427 * @brief Called by editable UI controls when key events are received.
1429 * @param[in] event The key event.
1430 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1432 bool KeyEvent( const Dali::KeyEvent& event );
1435 * @brief Called by editable UI controls when a tap gesture occurs.
1436 * @param[in] tapCount The number of taps.
1437 * @param[in] x The x position relative to the top-left of the parent control.
1438 * @param[in] y The y position relative to the top-left of the parent control.
1440 void TapEvent( unsigned int tapCount, float x, float y );
1443 * @brief Called by editable UI controls when a pan gesture occurs.
1445 * @param[in] state The state of the gesture.
1446 * @param[in] displacement This distance panned since the last pan gesture.
1448 void PanEvent( Gesture::State state, const Vector2& displacement );
1451 * @brief Called by editable UI controls when a long press gesture occurs.
1453 * @param[in] state The state of the gesture.
1454 * @param[in] x The x position relative to the top-left of the parent control.
1455 * @param[in] y The y position relative to the top-left of the parent control.
1457 void LongPressEvent( Gesture::State state, float x, float y );
1460 * @brief Creates a selection event.
1462 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1464 * @param[in] x The x position relative to the top-left of the parent control.
1465 * @param[in] y The y position relative to the top-left of the parent control.
1466 * @param[in] selectAll Whether the whole text is selected.
1468 void SelectEvent( float x, float y, bool selectAll );
1471 * @brief Event received from input method context
1473 * @param[in] inputMethodContext The input method context.
1474 * @param[in] inputMethodContextEvent The event received.
1475 * @return A data struture indicating if update is needed, cursor position and current text.
1477 InputMethodContext::CallbackData OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent );
1480 * @brief Event from Clipboard notifying an Item has been selected for pasting
1482 void PasteClipboardItemEvent();
1485 * @brief Return true when text control should clear key input focus when escape key is pressed.
1487 * @return Whether text control should clear key input focus or not when escape key is pressed.
1489 bool ShouldClearFocusOnEscape() const;
1491 protected: // Inherit from Text::Decorator::ControllerInterface.
1494 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1496 virtual void GetTargetSize( Vector2& targetSize );
1499 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1501 virtual void AddDecoration( Actor& actor, bool needsClipping );
1504 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1506 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1508 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1511 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1513 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1515 protected: // Inherit from HiddenText.
1518 * @brief Invoked from HiddenText when showing time of the last character was expired
1520 virtual void DisplayTimeExpired();
1525 * @brief Called by editable UI controls when key events are received.
1527 * @param[in] text The text to insert.
1528 * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1530 void InsertText( const std::string& text, InsertType type );
1533 * @brief Paste given string into Text model
1534 * @param[in] stringToPaste this string will be inserted into the text model
1536 void PasteText( const std::string& stringToPaste );
1539 * @brief Remove a given number of characters
1541 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1542 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1543 * style when pre-edit text is removed.
1545 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1546 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1547 * @param[in] type Whether to update the input style.
1548 * @return True if the remove was successful.
1550 bool RemoveText( int cursorOffset,
1551 int numberOfCharacters,
1552 UpdateInputStyleType type );
1555 * @brief Checks if text is selected and if so removes it.
1556 * @return true if text was removed
1558 bool RemoveSelectedText();
1560 private: // Relayout.
1563 * @brief Lays-out the text.
1565 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1567 * @param[in] size A the size of a bounding box to layout text within.
1568 * @param[in] operations The layout operations which need to be done.
1569 * @param[out] layoutSize The size of the laid-out text.
1571 bool DoRelayout( const Size& size,
1572 OperationsMask operations,
1576 * @brief Calulates the vertical offset to align the text inside the bounding box.
1578 * @param[in] size The size of the bounding box.
1580 void CalculateVerticalOffset( const Size& size );
1585 * @brief Process queued events which modify the model.
1587 void ProcessModifyEvents();
1590 * @brief Used to process an event queued from SetText()
1592 void TextReplacedEvent();
1595 * @brief Used to process an event queued from key events etc.
1597 void TextInsertedEvent();
1600 * @brief Used to process an event queued from backspace key etc.
1602 void TextDeletedEvent();
1605 * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1607 * @param[in] keyCode The keycode for the key pressed
1608 * @return True if a character was deleted.
1610 bool DeleteEvent( int keyCode );
1612 private: // Helpers.
1615 * @brief Used to remove the text included the placeholder text.
1620 * @brief Helper to show the place holder text..
1622 void ShowPlaceholderText();
1625 * @brief Helper to clear font-specific data (only).
1627 void ClearFontData();
1630 * @brief Helper to clear text's style data.
1632 void ClearStyleData();
1635 * @brief Used to reset the cursor position after setting a new text.
1637 * @param[in] cursorIndex Where to place the cursor.
1639 void ResetCursorPosition( CharacterIndex cursorIndex );
1642 * @brief Used to reset the scroll position after setting a new text.
1644 void ResetScrollPosition();
1646 private: // Private contructors & copy operator.
1649 * @brief Private constructor.
1654 * @brief Private constructor.
1656 Controller( ControlInterface* controlInterface );
1659 * @brief Private constructor.
1661 Controller( ControlInterface* controlInterface,
1662 EditableControlInterface* editableControlInterface );
1665 Controller( const Controller& handle );
1668 Controller& operator=( const Controller& handle );
1670 protected: // Destructor.
1673 * @brief A reference counted object may only be deleted by calling Unreference().
1675 virtual ~Controller();
1679 struct Impl; ///< Made public for testing purposes
1688 } // namespace Toolkit
1692 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H