1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/devel-api/adaptor-framework/imf-manager.h>
23 #include <dali/public-api/events/gesture.h>
26 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
27 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
28 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
29 #include <dali-toolkit/internal/text/hidden-text.h>
30 #include <dali-toolkit/internal/text/text-model-interface.h>
42 class ControlInterface;
43 class EditableControlInterface;
45 class RenderingController;
47 typedef IntrusivePtr<Controller> ControllerPtr;
50 * @brief A Text Controller is used by UI Controls which display text.
52 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
53 * It provides a view of the text that can be used by rendering back-ends.
55 * For selectable/editable UI controls, the controller handles input events from the UI control
56 * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
58 * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
60 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
62 public: // Enumerated types.
65 * @brief Text related operations to be done in the relayout process.
69 NO_OPERATION = 0x0000,
70 CONVERT_TO_UTF32 = 0x0001,
72 VALIDATE_FONTS = 0x0004,
73 GET_LINE_BREAKS = 0x0008,
74 GET_WORD_BREAKS = 0x0010,
77 GET_GLYPH_METRICS = 0x0080,
79 UPDATE_LAYOUT_SIZE = 0x0200,
83 UPDATE_DIRECTION = 0x2000,
84 ALL_OPERATIONS = 0xFFFF
88 * @brief Used to distinguish between regular key events and IMF events
97 * @brief Used to specify whether to update the input style.
99 enum UpdateInputStyleType
102 DONT_UPDATE_INPUT_STYLE
106 * @brief Used to specify what has been updated after the Relayout() method has been called.
110 NONE_UPDATED = 0x0, ///< Nothing has been updated.
111 MODEL_UPDATED = 0x1, ///< The text's model has been updated.
112 DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
116 * @brief Different placeholder-text can be shown when the control is active/inactive.
120 PLACEHOLDER_TYPE_ACTIVE,
121 PLACEHOLDER_TYPE_INACTIVE,
125 * @brief Enumeration for Font Size Type.
129 POINT_SIZE, // The size of font in points.
130 PIXEL_SIZE // The size of font in pixels.
137 NO_ACTION, ///< Does no action if there is a tap on top of an area with no text.
138 HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
139 SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
143 public: // Constructor.
146 * @brief Create a new instance of a Controller.
148 * @return A pointer to a new Controller.
150 static ControllerPtr New();
153 * @brief Create a new instance of a Controller.
155 * @param[in] controlInterface The control's interface.
157 * @return A pointer to a new Controller.
159 static ControllerPtr New( ControlInterface* controlInterface );
162 * @brief Create a new instance of a Controller.
164 * @param[in] controlInterface The control's interface.
165 * @param[in] editableControlInterface The editable control's interface.
167 * @return A pointer to a new Controller.
169 static ControllerPtr New( ControlInterface* controlInterface,
170 EditableControlInterface* editableControlInterface );
172 public: // Configure the text controller.
175 * @brief Called to enable text input.
177 * @note Selectable or editable controls should call this once after Controller::New().
178 * @param[in] decorator Used to create cursor, selection handle decorations etc.
180 void EnableTextInput( DecoratorPtr decorator );
183 * @brief Used to switch between bitmap & vector based glyphs
185 * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
187 void SetGlyphType( TextAbstraction::GlyphType glyphType );
190 * @brief Enables/disables the mark-up processor.
192 * By default is disabled.
194 * @param[in] enable Whether to enable the mark-up processor.
196 void SetMarkupProcessorEnabled( bool enable );
199 * @brief Retrieves whether the mark-up processor is enabled.
201 * By default is disabled.
203 * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
205 bool IsMarkupProcessorEnabled() const;
208 * @brief Enables/disables the auto text scrolling
210 * By default is disabled.
212 * @param[in] enable Whether to enable the auto scrolling
214 void SetAutoScrollEnabled( bool enable );
217 * @brief Retrieves whether auto text scrolling is enabled.
219 * By default is disabled.
221 * @return @e true if auto scrolling is enabled, otherwise returns @e false.
223 bool IsAutoScrollEnabled() const;
226 * @brief Get direction of the text from the first line of text,
227 * @return bool rtl (right to left) is true
229 CharacterDirection GetAutoScrollDirection() const;
232 * @brief Get the alignment offset of the first line of text.
234 * @return The alignment offset.
236 float GetAutoScrollLineAlignment() const;
239 * @brief Enables the horizontal scrolling.
241 * @param[in] enable Whether to enable the horizontal scrolling.
243 void SetHorizontalScrollEnabled( bool enable );
246 * @brief Retrieves whether the horizontal scrolling is enabled.
248 * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
250 bool IsHorizontalScrollEnabled() const;
253 * @brief Enables the vertical scrolling.
255 * @param[in] enable Whether to enable the vertical scrolling.
257 void SetVerticalScrollEnabled( bool enable );
260 * @brief Retrieves whether the verticall scrolling is enabled.
262 * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
264 bool IsVerticalScrollEnabled() const;
267 * @brief Enables the smooth handle panning.
269 * @param[in] enable Whether to enable the smooth handle panning.
271 void SetSmoothHandlePanEnabled( bool enable );
274 * @brief Retrieves whether the smooth handle panning is enabled.
276 * @return @e true if the smooth handle panning is enabled.
278 bool IsSmoothHandlePanEnabled() const;
281 * @brief Sets the maximum number of characters that can be inserted into the TextModel
283 * @param[in] maxCharacters maximum number of characters to be accepted
285 void SetMaximumNumberOfCharacters( Length maxCharacters );
288 * @brief Sets the maximum number of characters that can be inserted into the TextModel
290 * @param[in] maxCharacters maximum number of characters to be accepted
292 int GetMaximumNumberOfCharacters();
295 * @brief Called to enable/disable cursor blink.
297 * @note Only editable controls should calls this.
298 * @param[in] enabled Whether the cursor should blink or not.
300 void SetEnableCursorBlink( bool enable );
303 * @brief Query whether cursor blink is enabled.
305 * @return Whether the cursor should blink or not.
307 bool GetEnableCursorBlink() const;
310 * @brief Whether to enable the multi-line layout.
312 * @param[in] enable \e true enables the multi-line (by default)
314 void SetMultiLineEnabled( bool enable );
317 * @return Whether the multi-line layout is enabled.
319 bool IsMultiLineEnabled() const;
322 * @brief Sets the text's horizontal alignment.
324 * @param[in] alignment The horizontal alignment.
326 void SetHorizontalAlignment( Layout::HorizontalAlignment alignment );
329 * @copydoc ModelInterface::GetHorizontalAlignment()
331 Layout::HorizontalAlignment GetHorizontalAlignment() const;
334 * @brief Sets the text's vertical alignment.
336 * @param[in] alignment The vertical alignment.
338 void SetVerticalAlignment( Layout::VerticalAlignment alignment );
341 * @copydoc ModelInterface::GetVerticalAlignment()
343 Layout::VerticalAlignment GetVerticalAlignment() const;
346 * @brief Enable or disable the text elide.
348 * @param[in] enabled Whether to enable the text elide.
350 void SetTextElideEnabled( bool enabled );
353 * @copydoc ModelInterface::IsTextElideEnabled()
355 bool IsTextElideEnabled() const;
358 * @brief Enable or disable the text selection.
359 * @param[in] enabled Whether to enable the text selection.
361 void SetSelectionEnabled( bool enabled );
364 * @brief Whether the text selection is enabled or not.
365 * @return True if the text selection is enabled
367 bool IsSelectionEnabled() const;
370 * @brief Sets input type to password
372 * @note The string is displayed hidden character
374 * @param[in] passwordInput True if password input is enabled.
376 void SetInputModePassword( bool passwordInput );
379 * @brief Returns whether the input mode type is set as password.
381 * @return True if input mode type is password
383 bool IsInputModePassword();
386 * @brief Sets the action when there is a double tap event on top of a text area with no text.
388 * @param[in] action The action to do.
390 void SetNoTextDoubleTapAction( NoTextTap::Action action );
393 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
395 * @return The action to do.
397 NoTextTap::Action GetNoTextDoubleTapAction() const;
400 * @briefSets the action when there is a long press event on top of a text area with no text.
402 * @param[in] action The action to do.
404 void SetNoTextLongPressAction( NoTextTap::Action action );
407 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
409 * @return The action to do.
411 NoTextTap::Action GetNoTextLongPressAction() const;
414 * @brief Query if Underline settings were provided by string or map
415 * @return bool true if set by string
417 bool IsUnderlineSetByString();
420 * Set method underline setting were set by
421 * @param[in] bool, true if set by string
423 void UnderlineSetByString( bool setByString );
426 * @brief Query if shadow settings were provided by string or map
427 * @return bool true if set by string
429 bool IsShadowSetByString();
432 * Set method shadow setting were set by
433 * @param[in] bool, true if set by string
435 void ShadowSetByString( bool setByString );
438 * @brief Query if font style settings were provided by string or map
439 * @return bool true if set by string
441 bool IsFontStyleSetByString();
444 * Set method font style setting were set by
445 * @param[in] bool, true if set by string
447 void FontStyleSetByString( bool setByString );
452 * @brief Replaces any text previously set.
454 * @note This will be converted into UTF-32 when stored in the text model.
455 * @param[in] text A string of UTF-8 characters.
457 void SetText( const std::string& text );
460 * @brief Retrieve any text previously set.
462 * @param[out] text A string of UTF-8 characters.
464 void GetText( std::string& text ) const;
467 * @brief Replaces any placeholder text previously set.
469 * @param[in] text A string of UTF-8 characters.
471 void SetPlaceholderText( const std::string& text );
474 * @brief Replaces any placeholder text previously set.
476 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
477 * @param[in] text A string of UTF-8 characters.
479 void SetPlaceholderText( PlaceholderType type, const std::string& text );
482 * @brief Retrieve any placeholder text previously set.
484 * @param[out] A string of UTF-8 characters.
486 void GetPlaceholderText( std::string& text ) const;
489 * @brief Retrieve any placeholder text previously set.
491 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
492 * @param[out] A string of UTF-8 characters.
494 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
497 * @ brief Update the text after a font change
498 * @param[in] newDefaultFont The new font to change to
500 void UpdateAfterFontChange( const std::string& newDefaultFont );
502 public: // Default style & Input style
505 * @brief Set the default font family.
507 * @param[in] defaultFontFamily The default font family.
509 void SetDefaultFontFamily( const std::string& defaultFontFamily );
512 * @brief Retrieve the default font family.
514 * @return The default font family.
516 const std::string& GetDefaultFontFamily() const;
519 * @brief Sets the placeholder text font family.
520 * @param[in] placeholderTextFontFamily The placeholder text font family.
522 void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
525 * @brief Retrieves the placeholder text font family.
527 * @return The placeholder text font family
529 const std::string& GetPlaceholderFontFamily() const;
532 * @brief Sets the default font weight.
534 * @param[in] weight The font weight.
536 void SetDefaultFontWeight( FontWeight weight );
539 * @brief Whether the font's weight has been defined.
541 bool IsDefaultFontWeightDefined() const;
544 * @brief Retrieves the default font weight.
546 * @return The default font weight.
548 FontWeight GetDefaultFontWeight() const;
551 * @brief Sets the placeholder text font weight.
553 * @param[in] weight The font weight
555 void SetPlaceholderTextFontWeight( FontWeight weight );
558 * @brief Whether the font's weight has been defined.
560 * @return True if the placeholder text font weight is defined
562 bool IsPlaceholderTextFontWeightDefined() const;
565 * @brief Retrieves the placeholder text font weight.
567 * @return The placeholder text font weight
569 FontWeight GetPlaceholderTextFontWeight() const;
572 * @brief Sets the default font width.
574 * @param[in] width The font width.
576 void SetDefaultFontWidth( FontWidth width );
579 * @brief Whether the font's width has been defined.
581 bool IsDefaultFontWidthDefined() const;
584 * @brief Retrieves the default font width.
586 * @return The default font width.
588 FontWidth GetDefaultFontWidth() const;
591 * @brief Sets the placeholder text font width.
593 * @param[in] width The font width
595 void SetPlaceholderTextFontWidth( FontWidth width );
598 * @brief Whether the font's width has been defined.
600 * @return True if the placeholder text font width is defined
602 bool IsPlaceholderTextFontWidthDefined() const;
605 * @brief Retrieves the placeholder text font width.
607 * @return The placeholder text font width
609 FontWidth GetPlaceholderTextFontWidth() const;
612 * @brief Sets the default font slant.
614 * @param[in] slant The font slant.
616 void SetDefaultFontSlant( FontSlant slant );
619 * @brief Whether the font's slant has been defined.
621 bool IsDefaultFontSlantDefined() const;
624 * @brief Retrieves the default font slant.
626 * @return The default font slant.
628 FontSlant GetDefaultFontSlant() const;
631 * @brief Sets the placeholder text font slant.
633 * @param[in] slant The font slant
635 void SetPlaceholderTextFontSlant( FontSlant slant );
638 * @brief Whether the font's slant has been defined.
640 * @return True if the placeholder text font slant is defined
642 bool IsPlaceholderTextFontSlantDefined() const;
645 * @brief Retrieves the placeholder text font slant.
647 * @return The placeholder text font slant
649 FontSlant GetPlaceholderTextFontSlant() const;
652 * @brief Set the default font size.
654 * @param[in] fontSize The default font size
655 * @param[in] type The font size type is point size or pixel size
657 void SetDefaultFontSize( float fontSize, FontSizeType type );
660 * @brief Retrieve the default point size.
662 * @param[in] type The font size type
663 * @return The default point size.
665 float GetDefaultFontSize( FontSizeType type ) const;
668 * @brief Sets the Placeholder text font size.
669 * @param[in] fontSize The placeholder text font size
670 * @param[in] type The font size type is point size or pixel size
672 void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
675 * @brief Retrieves the Placeholder text font size.
676 * @param[in] type The font size type
677 * @return The placeholder font size
679 float GetPlaceholderTextFontSize( FontSizeType type ) const;
682 * @brief Sets the text's default color.
684 * @param color The default color.
686 void SetDefaultColor( const Vector4& color );
689 * @brief Retrieves the text's default color.
691 * @return The default color.
693 const Vector4& GetDefaultColor() const;
696 * @brief Set the text color
698 * @param textColor The text color
700 void SetPlaceholderTextColor( const Vector4& textColor );
703 * @brief Retrieve the text color
705 * @return The text color
707 const Vector4& GetPlaceholderTextColor() const;
710 * @brief Set the shadow offset.
712 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
714 void SetShadowOffset( const Vector2& shadowOffset );
717 * @brief Retrieve the shadow offset.
719 * @return The shadow offset.
721 const Vector2& GetShadowOffset() const;
724 * @brief Set the shadow color.
726 * @param[in] shadowColor The shadow color.
728 void SetShadowColor( const Vector4& shadowColor );
731 * @brief Retrieve the shadow color.
733 * @return The shadow color.
735 const Vector4& GetShadowColor() const;
738 * @brief Set the underline color.
740 * @param[in] color color of underline.
742 void SetUnderlineColor( const Vector4& color );
745 * @brief Retrieve the underline color.
747 * @return The underline color.
749 const Vector4& GetUnderlineColor() const;
752 * @brief Set the underline enabled flag.
754 * @param[in] enabled The underline enabled flag.
756 void SetUnderlineEnabled( bool enabled );
759 * @brief Returns whether the text is underlined or not.
761 * @return The underline state.
763 bool IsUnderlineEnabled() const;
766 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
768 * @param[in] height The height in pixels of the underline
770 void SetUnderlineHeight( float height );
773 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
775 * @return The height of the underline, or 0 if height is not overrided.
777 float GetUnderlineHeight() const;
780 * @brief Sets the emboss's properties string.
782 * @note The string is stored to be recovered.
784 * @param[in] embossProperties The emboss's properties string.
786 void SetDefaultEmbossProperties( const std::string& embossProperties );
789 * @brief Retrieves the emboss's properties string.
791 * @return The emboss's properties string.
793 const std::string& GetDefaultEmbossProperties() const;
796 * @brief Sets the outline's properties string.
798 * @note The string is stored to be recovered.
800 * @param[in] outlineProperties The outline's properties string.
802 void SetDefaultOutlineProperties( const std::string& outlineProperties );
805 * @brief Retrieves the outline's properties string.
807 * @return The outline's properties string.
809 const std::string& GetDefaultOutlineProperties() const;
812 * @brief Sets the default line spacing.
814 * @param[in] lineSpacing The line spacing.
816 void SetDefaultLineSpacing( float lineSpacing );
819 * @brief Retrieves the default line spacing.
821 * @return The line spacing.
823 float GetDefaultLineSpacing() const;
826 * @brief Sets the input text's color.
828 * @param[in] color The input text's color.
830 void SetInputColor( const Vector4& color );
833 * @brief Retrieves the input text's color.
835 * @return The input text's color.
837 const Vector4& GetInputColor() const;
840 * @brief Sets the input text's font family name.
842 * @param[in] fontFamily The text's font family name.
844 void SetInputFontFamily( const std::string& fontFamily );
847 * @brief Retrieves the input text's font family name.
849 * @return The input text's font family name.
851 const std::string& GetInputFontFamily() const;
854 * @brief Sets the input font's weight.
856 * @param[in] weight The input font's weight.
858 void SetInputFontWeight( FontWeight weight );
861 * @return Whether the font's weight has been defined.
863 bool IsInputFontWeightDefined() const;
866 * @brief Retrieves the input font's weight.
868 * @return The input font's weight.
870 FontWeight GetInputFontWeight() const;
873 * @brief Sets the input font's width.
875 * @param[in] width The input font's width.
877 void SetInputFontWidth( FontWidth width );
880 * @return Whether the font's width has been defined.
882 bool IsInputFontWidthDefined() const;
885 * @brief Retrieves the input font's width.
887 * @return The input font's width.
889 FontWidth GetInputFontWidth() const;
892 * @brief Sets the input font's slant.
894 * @param[in] slant The input font's slant.
896 void SetInputFontSlant( FontSlant slant );
899 * @return Whether the font's slant has been defined.
901 bool IsInputFontSlantDefined() const;
904 * @brief Retrieves the input font's slant.
906 * @return The input font's slant.
908 FontSlant GetInputFontSlant() const;
911 * @brief Sets the input font's point size.
913 * @param[in] size The input font's point size.
915 void SetInputFontPointSize( float size );
918 * @brief Retrieves the input font's point size.
920 * @return The input font's point size.
922 float GetInputFontPointSize() const;
925 * @brief Sets the input line spacing.
927 * @param[in] lineSpacing The line spacing.
929 void SetInputLineSpacing( float lineSpacing );
932 * @brief Retrieves the input line spacing.
934 * @return The line spacing.
936 float GetInputLineSpacing() const;
939 * @brief Sets the input shadow's properties string.
941 * @note The string is stored to be recovered.
943 * @param[in] shadowProperties The shadow's properties string.
945 void SetInputShadowProperties( const std::string& shadowProperties );
948 * @brief Retrieves the input shadow's properties string.
950 * @return The shadow's properties string.
952 const std::string& GetInputShadowProperties() const;
955 * @brief Sets the input underline's properties string.
957 * @note The string is stored to be recovered.
959 * @param[in] underlineProperties The underline's properties string.
961 void SetInputUnderlineProperties( const std::string& underlineProperties );
964 * @brief Retrieves the input underline's properties string.
966 * @return The underline's properties string.
968 const std::string& GetInputUnderlineProperties() const;
971 * @brief Sets the input emboss's properties string.
973 * @note The string is stored to be recovered.
975 * @param[in] embossProperties The emboss's properties string.
977 void SetInputEmbossProperties( const std::string& embossProperties );
980 * @brief Retrieves the input emboss's properties string.
982 * @return The emboss's properties string.
984 const std::string& GetInputEmbossProperties() const;
987 * @brief Sets input the outline's properties string.
989 * @note The string is stored to be recovered.
991 * @param[in] outlineProperties The outline's properties string.
993 void SetInputOutlineProperties( const std::string& outlineProperties );
996 * @brief Retrieves the input outline's properties string.
998 * @return The outline's properties string.
1000 const std::string& GetInputOutlineProperties() const;
1002 public: // Queries & retrieves.
1005 * @brief Return the layout engine.
1007 * @return A reference to the layout engine.
1009 Layout::Engine& GetLayoutEngine();
1012 * @brief Return a view of the text.
1014 * @return A reference to the view.
1019 * @copydoc Control::GetNaturalSize()
1021 Vector3 GetNaturalSize();
1024 * @copydoc Control::GetHeightForWidth()
1026 float GetHeightForWidth( float width );
1029 * @brief Retrieves the text's number of lines for a given width.
1030 * @param[in] width The width of the text's area.
1031 * @ return The number of lines.
1033 int GetLineCount( float width );
1036 * @brief Retrieves the text's model.
1038 * @return A pointer to the text's model.
1040 const ModelInterface* const GetTextModel() const;
1043 * @brief Used to get scrolled distance by user input
1045 * @return Distance from last scroll offset to new scroll offset
1047 float GetScrollAmountByUserInput();
1050 * @brief Get latest scroll amount, control size and layout size
1052 * This method is used to get information of control's scroll
1053 * @param[out] scrollPosition The current scrolled position
1054 * @param[out] controlHeight The size of a UI control
1055 * @param[out] layoutHeight The size of a bounding box to layout text within.
1057 * @return Whether the text scroll position is changed or not after last update.
1059 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1062 * @brief Used to set the hidden input option
1064 void SetHiddenInputOption( const Property::Map& options );
1067 * @brief Used to get the hidden input option
1069 void GetHiddenInputOption( Property::Map& options );
1072 * @brief Sets the Placeholder Properties.
1074 * @param[in] map The placeholder property map
1076 void SetPlaceholderProperty( const Property::Map& map );
1079 * @brief Retrieves the Placeholder Property map.
1081 * @param[out] map The property map
1083 void GetPlaceholderProperty( Property::Map& map );
1085 public: // Relayout.
1088 * @brief Triggers a relayout which updates View (if necessary).
1090 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1091 * @param[in] size A the size of a bounding box to layout text within.
1093 * @return Whether the text model or decorations were updated.
1095 UpdateTextType Relayout( const Size& size );
1098 * @brief Request a relayout using the ControlInterface.
1100 void RequestRelayout();
1102 public: // Input style change signals.
1105 * @return Whether the queue of input style changed signals is empty.
1107 bool IsInputStyleChangedSignalsQueueEmpty();
1110 * @brief Process all pending input style changed signals.
1112 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1113 * text controls. Text controls may send signals to state the input style has changed.
1115 void ProcessInputStyleChangedSignals();
1117 public: // Text-input Event Queuing.
1120 * @brief Called by editable UI controls when keyboard focus is gained.
1122 void KeyboardFocusGainEvent();
1125 * @brief Called by editable UI controls when focus is lost.
1127 void KeyboardFocusLostEvent();
1130 * @brief Called by editable UI controls when key events are received.
1132 * @param[in] event The key event.
1133 * @param[in] type Used to distinguish between regular key events and IMF events.
1135 bool KeyEvent( const Dali::KeyEvent& event );
1138 * @brief Called by editable UI controls when a tap gesture occurs.
1139 * @param[in] tapCount The number of taps.
1140 * @param[in] x The x position relative to the top-left of the parent control.
1141 * @param[in] y The y position relative to the top-left of the parent control.
1143 void TapEvent( unsigned int tapCount, float x, float y );
1146 * @brief Called by editable UI controls when a pan gesture occurs.
1148 * @param[in] state The state of the gesture.
1149 * @param[in] displacement This distance panned since the last pan gesture.
1151 void PanEvent( Gesture::State state, const Vector2& displacement );
1154 * @brief Called by editable UI controls when a long press gesture occurs.
1156 * @param[in] state The state of the gesture.
1157 * @param[in] x The x position relative to the top-left of the parent control.
1158 * @param[in] y The y position relative to the top-left of the parent control.
1160 void LongPressEvent( Gesture::State state, float x, float y );
1163 * @brief Event received from IMF manager
1165 * @param[in] imfManager The IMF manager.
1166 * @param[in] imfEvent The event received.
1167 * @return A data struture indicating if update is needed, cursor position and current text.
1169 ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
1172 * @brief Event from Clipboard notifying an Item has been selected for pasting
1174 void PasteClipboardItemEvent();
1176 protected: // Inherit from Text::Decorator::ControllerInterface.
1179 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1181 virtual void GetTargetSize( Vector2& targetSize );
1184 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1186 virtual void AddDecoration( Actor& actor, bool needsClipping );
1189 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1191 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1193 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1196 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1198 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1200 protected: // Inherit from HiddenText.
1203 * @brief Invoked from HiddenText when showing time of the last character was expired
1205 virtual void DisplayTimeExpired();
1210 * @brief Called by editable UI controls when key events are received.
1212 * @param[in] text The text to insert.
1213 * @param[in] type Used to distinguish between regular key events and IMF events.
1215 void InsertText( const std::string& text, InsertType type );
1218 * @brief Paste given string into Text model
1219 * @param[in] stringToPaste this string will be inserted into the text model
1221 void PasteText( const std::string& stringToPaste );
1224 * @brief Remove a given number of characters
1226 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1227 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1228 * style when pre-edit text is removed.
1230 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1231 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1232 * @param[in] type Whether to update the input style.
1233 * @return True if the remove was successful.
1235 bool RemoveText( int cursorOffset,
1236 int numberOfCharacters,
1237 UpdateInputStyleType type );
1240 * @brief Checks if text is selected and if so removes it.
1241 * @return true if text was removed
1243 bool RemoveSelectedText();
1245 private: // Relayout.
1248 * @brief Lays-out the text.
1250 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1252 * @param[in] size A the size of a bounding box to layout text within.
1253 * @param[in] operations The layout operations which need to be done.
1254 * @param[out] layoutSize The size of the laid-out text.
1256 bool DoRelayout( const Size& size,
1257 OperationsMask operations,
1261 * @brief Calulates the vertical offset to align the text inside the bounding box.
1263 * @param[in] size The size of the bounding box.
1265 void CalculateVerticalOffset( const Size& size );
1270 * @brief Process queued events which modify the model.
1272 void ProcessModifyEvents();
1275 * @brief Used to process an event queued from SetText()
1277 void TextReplacedEvent();
1280 * @brief Used to process an event queued from key events etc.
1282 void TextInsertedEvent();
1285 * @brief Used to process an event queued from backspace key etc.
1287 void TextDeletedEvent();
1290 * @brief Creates a selection event.
1292 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1294 * @param[in] x The x position relative to the top-left of the parent control.
1295 * @param[in] y The y position relative to the top-left of the parent control.
1296 * @param[in] selectAll Whether the whole text is selected.
1298 void SelectEvent( float x, float y, bool selectAll );
1301 * @brief Helper to KeyEvent() to handle the backspace case.
1303 * @return True if a character was deleted.
1305 bool BackspaceKeyEvent();
1307 private: // Helpers.
1310 * @brief Used to remove the text included the placeholder text.
1315 * @brief Helper to show the place holder text..
1317 void ShowPlaceholderText();
1320 * @brief Helper to clear font-specific data (only).
1322 void ClearFontData();
1325 * @brief Helper to clear text's style data.
1327 void ClearStyleData();
1330 * @brief Used to reset the cursor position after setting a new text.
1332 * @param[in] cursorIndex Where to place the cursor.
1334 void ResetCursorPosition( CharacterIndex cursorIndex );
1337 * @brief Used to reset the scroll position after setting a new text.
1339 void ResetScrollPosition();
1341 private: // Private contructors & copy operator.
1344 * @brief Private constructor.
1349 * @brief Private constructor.
1351 Controller( ControlInterface* controlInterface );
1354 * @brief Private constructor.
1356 Controller( ControlInterface* controlInterface,
1357 EditableControlInterface* editableControlInterface );
1360 Controller( const Controller& handle );
1363 Controller& operator=( const Controller& handle );
1365 protected: // Destructor.
1368 * @brief A reference counted object may only be deleted by calling Unreference().
1370 virtual ~Controller();
1380 } // namespace Toolkit
1384 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H