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 default font weight.
521 * @param[in] weight The font weight.
523 void SetDefaultFontWeight( FontWeight weight );
526 * @brief Whether the font's weight has been defined.
528 bool IsDefaultFontWeightDefined() const;
531 * @brief Retrieves the default font weight.
533 * @return The default font weight.
535 FontWeight GetDefaultFontWeight() const;
538 * @brief Sets the default font width.
540 * @param[in] width The font width.
542 void SetDefaultFontWidth( FontWidth width );
545 * @brief Whether the font's width has been defined.
547 bool IsDefaultFontWidthDefined() const;
550 * @brief Retrieves the default font width.
552 * @return The default font width.
554 FontWidth GetDefaultFontWidth() const;
557 * @brief Sets the default font slant.
559 * @param[in] slant The font slant.
561 void SetDefaultFontSlant( FontSlant slant );
564 * @brief Whether the font's slant has been defined.
566 bool IsDefaultFontSlantDefined() const;
569 * @brief Retrieves the default font slant.
571 * @return The default font slant.
573 FontSlant GetDefaultFontSlant() const;
576 * @brief Set the default font size.
578 * @param[in] size The default font size.
579 * @param[in] type The font size type is point size or pixel size
581 void SetDefaultFontSize( float fontSize, FontSizeType type );
584 * @brief Retrieve the default point size.
586 * @param[in] type The font size type
587 * @return The default point size.
589 float GetDefaultFontSize( FontSizeType type ) const;
592 * @brief Sets the text's default color.
594 * @param color The default color.
596 void SetDefaultColor( const Vector4& color );
599 * @brief Retrieves the text's default color.
601 * @return The default color.
603 const Vector4& GetDefaultColor() const;
606 * @brief Set the text color
608 * @param textColor The text color
610 void SetPlaceholderTextColor( const Vector4& textColor );
613 * @brief Retrieve the text color
615 * @return The text color
617 const Vector4& GetPlaceholderTextColor() const;
620 * @brief Set the shadow offset.
622 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
624 void SetShadowOffset( const Vector2& shadowOffset );
627 * @brief Retrieve the shadow offset.
629 * @return The shadow offset.
631 const Vector2& GetShadowOffset() const;
634 * @brief Set the shadow color.
636 * @param[in] shadowColor The shadow color.
638 void SetShadowColor( const Vector4& shadowColor );
641 * @brief Retrieve the shadow color.
643 * @return The shadow color.
645 const Vector4& GetShadowColor() const;
648 * @brief Set the underline color.
650 * @param[in] color color of underline.
652 void SetUnderlineColor( const Vector4& color );
655 * @brief Retrieve the underline color.
657 * @return The underline color.
659 const Vector4& GetUnderlineColor() const;
662 * @brief Set the underline enabled flag.
664 * @param[in] enabled The underline enabled flag.
666 void SetUnderlineEnabled( bool enabled );
669 * @brief Returns whether the text is underlined or not.
671 * @return The underline state.
673 bool IsUnderlineEnabled() const;
676 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
678 * @param[in] height The height in pixels of the underline
680 void SetUnderlineHeight( float height );
683 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
685 * @return The height of the underline, or 0 if height is not overrided.
687 float GetUnderlineHeight() const;
690 * @brief Sets the emboss's properties string.
692 * @note The string is stored to be recovered.
694 * @param[in] embossProperties The emboss's properties string.
696 void SetDefaultEmbossProperties( const std::string& embossProperties );
699 * @brief Retrieves the emboss's properties string.
701 * @return The emboss's properties string.
703 const std::string& GetDefaultEmbossProperties() const;
706 * @brief Sets the outline's properties string.
708 * @note The string is stored to be recovered.
710 * @param[in] outlineProperties The outline's properties string.
712 void SetDefaultOutlineProperties( const std::string& outlineProperties );
715 * @brief Retrieves the outline's properties string.
717 * @return The outline's properties string.
719 const std::string& GetDefaultOutlineProperties() const;
722 * @brief Sets the default line spacing.
724 * @param[in] lineSpacing The line spacing.
726 void SetDefaultLineSpacing( float lineSpacing );
729 * @brief Retrieves the default line spacing.
731 * @return The line spacing.
733 float GetDefaultLineSpacing() const;
736 * @brief Sets the input text's color.
738 * @param[in] color The input text's color.
740 void SetInputColor( const Vector4& color );
743 * @brief Retrieves the input text's color.
745 * @return The input text's color.
747 const Vector4& GetInputColor() const;
750 * @brief Sets the input text's font family name.
752 * @param[in] fontFamily The text's font family name.
754 void SetInputFontFamily( const std::string& fontFamily );
757 * @brief Retrieves the input text's font family name.
759 * @return The input text's font family name.
761 const std::string& GetInputFontFamily() const;
764 * @brief Sets the input font's weight.
766 * @param[in] weight The input font's weight.
768 void SetInputFontWeight( FontWeight weight );
771 * @return Whether the font's weight has been defined.
773 bool IsInputFontWeightDefined() const;
776 * @brief Retrieves the input font's weight.
778 * @return The input font's weight.
780 FontWeight GetInputFontWeight() const;
783 * @brief Sets the input font's width.
785 * @param[in] width The input font's width.
787 void SetInputFontWidth( FontWidth width );
790 * @return Whether the font's width has been defined.
792 bool IsInputFontWidthDefined() const;
795 * @brief Retrieves the input font's width.
797 * @return The input font's width.
799 FontWidth GetInputFontWidth() const;
802 * @brief Sets the input font's slant.
804 * @param[in] slant The input font's slant.
806 void SetInputFontSlant( FontSlant slant );
809 * @return Whether the font's slant has been defined.
811 bool IsInputFontSlantDefined() const;
814 * @brief Retrieves the input font's slant.
816 * @return The input font's slant.
818 FontSlant GetInputFontSlant() const;
821 * @brief Sets the input font's point size.
823 * @param[in] size The input font's point size.
825 void SetInputFontPointSize( float size );
828 * @brief Retrieves the input font's point size.
830 * @return The input font's point size.
832 float GetInputFontPointSize() const;
835 * @brief Sets the input line spacing.
837 * @param[in] lineSpacing The line spacing.
839 void SetInputLineSpacing( float lineSpacing );
842 * @brief Retrieves the input line spacing.
844 * @return The line spacing.
846 float GetInputLineSpacing() const;
849 * @brief Sets the input shadow's properties string.
851 * @note The string is stored to be recovered.
853 * @param[in] shadowProperties The shadow's properties string.
855 void SetInputShadowProperties( const std::string& shadowProperties );
858 * @brief Retrieves the input shadow's properties string.
860 * @return The shadow's properties string.
862 const std::string& GetInputShadowProperties() const;
865 * @brief Sets the input underline's properties string.
867 * @note The string is stored to be recovered.
869 * @param[in] underlineProperties The underline's properties string.
871 void SetInputUnderlineProperties( const std::string& underlineProperties );
874 * @brief Retrieves the input underline's properties string.
876 * @return The underline's properties string.
878 const std::string& GetInputUnderlineProperties() const;
881 * @brief Sets the input emboss's properties string.
883 * @note The string is stored to be recovered.
885 * @param[in] embossProperties The emboss's properties string.
887 void SetInputEmbossProperties( const std::string& embossProperties );
890 * @brief Retrieves the input emboss's properties string.
892 * @return The emboss's properties string.
894 const std::string& GetInputEmbossProperties() const;
897 * @brief Sets input the outline's properties string.
899 * @note The string is stored to be recovered.
901 * @param[in] outlineProperties The outline's properties string.
903 void SetInputOutlineProperties( const std::string& outlineProperties );
906 * @brief Retrieves the input outline's properties string.
908 * @return The outline's properties string.
910 const std::string& GetInputOutlineProperties() const;
912 public: // Queries & retrieves.
915 * @brief Return the layout engine.
917 * @return A reference to the layout engine.
919 Layout::Engine& GetLayoutEngine();
922 * @brief Return a view of the text.
924 * @return A reference to the view.
929 * @copydoc Control::GetNaturalSize()
931 Vector3 GetNaturalSize();
934 * @copydoc Control::GetHeightForWidth()
936 float GetHeightForWidth( float width );
939 * @brief Retrieves the text's number of lines for a given width.
940 * @param[in] width The width of the text's area.
941 * @ return The number of lines.
943 int GetLineCount( float width );
946 * @brief Retrieves the text's model.
948 * @return A pointer to the text's model.
950 const ModelInterface* const GetTextModel() const;
953 * @brief Used to get scrolled distance by user input
955 * @return Distance from last scroll offset to new scroll offset
957 float GetScrollAmountByUserInput();
960 * @brief Get latest scroll amount, control size and layout size
962 * This method is used to get information of control's scroll
963 * @param[out] scrollPosition The current scrolled position
964 * @param[out] controlHeight The size of a UI control
965 * @param[out] layoutHeight The size of a bounding box to layout text within.
967 * @return Whether the text scroll position is changed or not after last update.
969 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
972 * @brief Used to set the hidden input option
974 void SetHiddenInputOption( const Property::Map& options );
977 * @brief Used to get the hidden input option
979 void GetHiddenInputOption( Property::Map& options );
984 * @brief Triggers a relayout which updates View (if necessary).
986 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
987 * @param[in] size A the size of a bounding box to layout text within.
989 * @return Whether the text model or decorations were updated.
991 UpdateTextType Relayout( const Size& size );
994 * @brief Request a relayout using the ControlInterface.
996 void RequestRelayout();
998 public: // Input style change signals.
1001 * @return Whether the queue of input style changed signals is empty.
1003 bool IsInputStyleChangedSignalsQueueEmpty();
1006 * @brief Process all pending input style changed signals.
1008 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1009 * text controls. Text controls may send signals to state the input style has changed.
1011 void ProcessInputStyleChangedSignals();
1013 public: // Text-input Event Queuing.
1016 * @brief Called by editable UI controls when keyboard focus is gained.
1018 void KeyboardFocusGainEvent();
1021 * @brief Called by editable UI controls when focus is lost.
1023 void KeyboardFocusLostEvent();
1026 * @brief Called by editable UI controls when key events are received.
1028 * @param[in] event The key event.
1029 * @param[in] type Used to distinguish between regular key events and IMF events.
1031 bool KeyEvent( const Dali::KeyEvent& event );
1034 * @brief Called by editable UI controls when a tap gesture occurs.
1035 * @param[in] tapCount The number of taps.
1036 * @param[in] x The x position relative to the top-left of the parent control.
1037 * @param[in] y The y position relative to the top-left of the parent control.
1039 void TapEvent( unsigned int tapCount, float x, float y );
1042 * @brief Called by editable UI controls when a pan gesture occurs.
1044 * @param[in] state The state of the gesture.
1045 * @param[in] displacement This distance panned since the last pan gesture.
1047 void PanEvent( Gesture::State state, const Vector2& displacement );
1050 * @brief Called by editable UI controls when a long press gesture occurs.
1052 * @param[in] state The state of the gesture.
1053 * @param[in] x The x position relative to the top-left of the parent control.
1054 * @param[in] y The y position relative to the top-left of the parent control.
1056 void LongPressEvent( Gesture::State state, float x, float y );
1059 * @brief Event received from IMF manager
1061 * @param[in] imfManager The IMF manager.
1062 * @param[in] imfEvent The event received.
1063 * @return A data struture indicating if update is needed, cursor position and current text.
1065 ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
1068 * @brief Event from Clipboard notifying an Item has been selected for pasting
1070 void PasteClipboardItemEvent();
1072 protected: // Inherit from Text::Decorator::ControllerInterface.
1075 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1077 virtual void GetTargetSize( Vector2& targetSize );
1080 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1082 virtual void AddDecoration( Actor& actor, bool needsClipping );
1085 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1087 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1089 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1092 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1094 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1096 protected: // Inherit from HiddenText.
1099 * @brief Invoked from HiddenText when showing time of the last character was expired
1101 virtual void DisplayTimeExpired();
1106 * @brief Called by editable UI controls when key events are received.
1108 * @param[in] text The text to insert.
1109 * @param[in] type Used to distinguish between regular key events and IMF events.
1111 void InsertText( const std::string& text, InsertType type );
1114 * @brief Paste given string into Text model
1115 * @param[in] stringToPaste this string will be inserted into the text model
1117 void PasteText( const std::string& stringToPaste );
1120 * @brief Remove a given number of characters
1122 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1123 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1124 * style when pre-edit text is removed.
1126 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1127 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1128 * @param[in] type Whether to update the input style.
1129 * @return True if the remove was successful.
1131 bool RemoveText( int cursorOffset,
1132 int numberOfCharacters,
1133 UpdateInputStyleType type );
1136 * @brief Checks if text is selected and if so removes it.
1137 * @return true if text was removed
1139 bool RemoveSelectedText();
1141 private: // Relayout.
1144 * @brief Lays-out the text.
1146 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1148 * @param[in] size A the size of a bounding box to layout text within.
1149 * @param[in] operations The layout operations which need to be done.
1150 * @param[out] layoutSize The size of the laid-out text.
1152 bool DoRelayout( const Size& size,
1153 OperationsMask operations,
1157 * @brief Calulates the vertical offset to align the text inside the bounding box.
1159 * @param[in] size The size of the bounding box.
1161 void CalculateVerticalOffset( const Size& size );
1166 * @brief Process queued events which modify the model.
1168 void ProcessModifyEvents();
1171 * @brief Used to process an event queued from SetText()
1173 void TextReplacedEvent();
1176 * @brief Used to process an event queued from key events etc.
1178 void TextInsertedEvent();
1181 * @brief Used to process an event queued from backspace key etc.
1183 void TextDeletedEvent();
1186 * @brief Creates a selection event.
1188 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1190 * @param[in] x The x position relative to the top-left of the parent control.
1191 * @param[in] y The y position relative to the top-left of the parent control.
1192 * @param[in] selectAll Whether the whole text is selected.
1194 void SelectEvent( float x, float y, bool selectAll );
1197 * @brief Helper to KeyEvent() to handle the backspace case.
1199 * @return True if a character was deleted.
1201 bool BackspaceKeyEvent();
1203 private: // Helpers.
1206 * @brief Used to remove the text included the placeholder text.
1211 * @brief Helper to show the place holder text..
1213 void ShowPlaceholderText();
1216 * @brief Helper to clear font-specific data (only).
1218 void ClearFontData();
1221 * @brief Helper to clear text's style data.
1223 void ClearStyleData();
1226 * @brief Used to reset the cursor position after setting a new text.
1228 * @param[in] cursorIndex Where to place the cursor.
1230 void ResetCursorPosition( CharacterIndex cursorIndex );
1233 * @brief Used to reset the scroll position after setting a new text.
1235 void ResetScrollPosition();
1237 private: // Private contructors & copy operator.
1240 * @brief Private constructor.
1245 * @brief Private constructor.
1247 Controller( ControlInterface* controlInterface );
1250 * @brief Private constructor.
1252 Controller( ControlInterface* controlInterface,
1253 EditableControlInterface* editableControlInterface );
1256 Controller( const Controller& handle );
1259 Controller& operator=( const Controller& handle );
1261 protected: // Destructor.
1264 * @brief A reference counted object may only be deleted by calling Unreference().
1266 virtual ~Controller();
1276 } // namespace Toolkit
1280 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H