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 Sets input type to password
360 * @note The string is displayed hidden character
362 * @param[in] passwordInput True if password input is enabled.
364 void SetInputModePassword( bool passwordInput );
367 * @brief Returns whether the input mode type is set as password.
369 * @return True if input mode type is password
371 bool IsInputModePassword();
374 * @brief Sets the action when there is a double tap event on top of a text area with no text.
376 * @param[in] action The action to do.
378 void SetNoTextDoubleTapAction( NoTextTap::Action action );
381 * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
383 * @return The action to do.
385 NoTextTap::Action GetNoTextDoubleTapAction() const;
388 * @briefSets the action when there is a long press event on top of a text area with no text.
390 * @param[in] action The action to do.
392 void SetNoTextLongPressAction( NoTextTap::Action action );
395 * @brief Retrieves the action when there is a long press event on top of a text area with no text.
397 * @return The action to do.
399 NoTextTap::Action GetNoTextLongPressAction() const;
404 * @brief Replaces any text previously set.
406 * @note This will be converted into UTF-32 when stored in the text model.
407 * @param[in] text A string of UTF-8 characters.
409 void SetText( const std::string& text );
412 * @brief Retrieve any text previously set.
414 * @param[out] text A string of UTF-8 characters.
416 void GetText( std::string& text ) const;
419 * @brief Replaces any placeholder text previously set.
421 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
422 * @param[in] text A string of UTF-8 characters.
424 void SetPlaceholderText( PlaceholderType type, const std::string& text );
427 * @brief Retrieve any placeholder text previously set.
429 * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
430 * @param[out] A string of UTF-8 characters.
432 void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
435 * @ brief Update the text after a font change
436 * @param[in] newDefaultFont The new font to change to
438 void UpdateAfterFontChange( const std::string& newDefaultFont );
440 public: // Default style & Input style
443 * @brief Set the default font family.
445 * @param[in] defaultFontFamily The default font family.
447 void SetDefaultFontFamily( const std::string& defaultFontFamily );
450 * @brief Retrieve the default font family.
452 * @return The default font family.
454 const std::string& GetDefaultFontFamily() const;
457 * @brief Sets the default font weight.
459 * @param[in] weight The font weight.
461 void SetDefaultFontWeight( FontWeight weight );
464 * @brief Whether the font's weight has been defined.
466 bool IsDefaultFontWeightDefined() const;
469 * @brief Retrieves the default font weight.
471 * @return The default font weight.
473 FontWeight GetDefaultFontWeight() const;
476 * @brief Sets the default font width.
478 * @param[in] width The font width.
480 void SetDefaultFontWidth( FontWidth width );
483 * @brief Whether the font's width has been defined.
485 bool IsDefaultFontWidthDefined() const;
488 * @brief Retrieves the default font width.
490 * @return The default font width.
492 FontWidth GetDefaultFontWidth() const;
495 * @brief Sets the default font slant.
497 * @param[in] slant The font slant.
499 void SetDefaultFontSlant( FontSlant slant );
502 * @brief Whether the font's slant has been defined.
504 bool IsDefaultFontSlantDefined() const;
507 * @brief Retrieves the default font slant.
509 * @return The default font slant.
511 FontSlant GetDefaultFontSlant() const;
514 * @brief Set the default font size.
516 * @param[in] size The default font size.
517 * @param[in] type The font size type is point size or pixel size
519 void SetDefaultFontSize( float fontSize, FontSizeType type );
522 * @brief Retrieve the default point size.
524 * @param[in] type The font size type
525 * @return The default point size.
527 float GetDefaultFontSize( FontSizeType type ) const;
530 * @brief Sets the text's default color.
532 * @param color The default color.
534 void SetDefaultColor( const Vector4& color );
537 * @brief Retrieves the text's default color.
539 * @return The default color.
541 const Vector4& GetDefaultColor() const;
544 * @brief Set the text color
546 * @param textColor The text color
548 void SetPlaceholderTextColor( const Vector4& textColor );
551 * @brief Retrieve the text color
553 * @return The text color
555 const Vector4& GetPlaceholderTextColor() const;
558 * @brief Set the shadow offset.
560 * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
562 void SetShadowOffset( const Vector2& shadowOffset );
565 * @brief Retrieve the shadow offset.
567 * @return The shadow offset.
569 const Vector2& GetShadowOffset() const;
572 * @brief Set the shadow color.
574 * @param[in] shadowColor The shadow color.
576 void SetShadowColor( const Vector4& shadowColor );
579 * @brief Retrieve the shadow color.
581 * @return The shadow color.
583 const Vector4& GetShadowColor() const;
586 * @brief Set the underline color.
588 * @param[in] color color of underline.
590 void SetUnderlineColor( const Vector4& color );
593 * @brief Retrieve the underline color.
595 * @return The underline color.
597 const Vector4& GetUnderlineColor() const;
600 * @brief Set the underline enabled flag.
602 * @param[in] enabled The underline enabled flag.
604 void SetUnderlineEnabled( bool enabled );
607 * @brief Returns whether the text is underlined or not.
609 * @return The underline state.
611 bool IsUnderlineEnabled() const;
614 * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
616 * @param[in] height The height in pixels of the underline
618 void SetUnderlineHeight( float height );
621 * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
623 * @return The height of the underline, or 0 if height is not overrided.
625 float GetUnderlineHeight() const;
628 * @brief Sets the emboss's properties string.
630 * @note The string is stored to be recovered.
632 * @param[in] embossProperties The emboss's properties string.
634 void SetDefaultEmbossProperties( const std::string& embossProperties );
637 * @brief Retrieves the emboss's properties string.
639 * @return The emboss's properties string.
641 const std::string& GetDefaultEmbossProperties() const;
644 * @brief Sets the outline's properties string.
646 * @note The string is stored to be recovered.
648 * @param[in] outlineProperties The outline's properties string.
650 void SetDefaultOutlineProperties( const std::string& outlineProperties );
653 * @brief Retrieves the outline's properties string.
655 * @return The outline's properties string.
657 const std::string& GetDefaultOutlineProperties() const;
660 * @brief Sets the default line spacing.
662 * @param[in] lineSpacing The line spacing.
664 void SetDefaultLineSpacing( float lineSpacing );
667 * @brief Retrieves the default line spacing.
669 * @return The line spacing.
671 float GetDefaultLineSpacing() const;
674 * @brief Sets the input text's color.
676 * @param[in] color The input text's color.
678 void SetInputColor( const Vector4& color );
681 * @brief Retrieves the input text's color.
683 * @return The input text's color.
685 const Vector4& GetInputColor() const;
688 * @brief Sets the input text's font family name.
690 * @param[in] fontFamily The text's font family name.
692 void SetInputFontFamily( const std::string& fontFamily );
695 * @brief Retrieves the input text's font family name.
697 * @return The input text's font family name.
699 const std::string& GetInputFontFamily() const;
702 * @brief Sets the input font's weight.
704 * @param[in] weight The input font's weight.
706 void SetInputFontWeight( FontWeight weight );
709 * @return Whether the font's weight has been defined.
711 bool IsInputFontWeightDefined() const;
714 * @brief Retrieves the input font's weight.
716 * @return The input font's weight.
718 FontWeight GetInputFontWeight() const;
721 * @brief Sets the input font's width.
723 * @param[in] width The input font's width.
725 void SetInputFontWidth( FontWidth width );
728 * @return Whether the font's width has been defined.
730 bool IsInputFontWidthDefined() const;
733 * @brief Retrieves the input font's width.
735 * @return The input font's width.
737 FontWidth GetInputFontWidth() const;
740 * @brief Sets the input font's slant.
742 * @param[in] slant The input font's slant.
744 void SetInputFontSlant( FontSlant slant );
747 * @return Whether the font's slant has been defined.
749 bool IsInputFontSlantDefined() const;
752 * @brief Retrieves the input font's slant.
754 * @return The input font's slant.
756 FontSlant GetInputFontSlant() const;
759 * @brief Sets the input font's point size.
761 * @param[in] size The input font's point size.
763 void SetInputFontPointSize( float size );
766 * @brief Retrieves the input font's point size.
768 * @return The input font's point size.
770 float GetInputFontPointSize() const;
773 * @brief Sets the input line spacing.
775 * @param[in] lineSpacing The line spacing.
777 void SetInputLineSpacing( float lineSpacing );
780 * @brief Retrieves the input line spacing.
782 * @return The line spacing.
784 float GetInputLineSpacing() const;
787 * @brief Sets the input shadow's properties string.
789 * @note The string is stored to be recovered.
791 * @param[in] shadowProperties The shadow's properties string.
793 void SetInputShadowProperties( const std::string& shadowProperties );
796 * @brief Retrieves the input shadow's properties string.
798 * @return The shadow's properties string.
800 const std::string& GetInputShadowProperties() const;
803 * @brief Sets the input underline's properties string.
805 * @note The string is stored to be recovered.
807 * @param[in] underlineProperties The underline's properties string.
809 void SetInputUnderlineProperties( const std::string& underlineProperties );
812 * @brief Retrieves the input underline's properties string.
814 * @return The underline's properties string.
816 const std::string& GetInputUnderlineProperties() const;
819 * @brief Sets the input emboss's properties string.
821 * @note The string is stored to be recovered.
823 * @param[in] embossProperties The emboss's properties string.
825 void SetInputEmbossProperties( const std::string& embossProperties );
828 * @brief Retrieves the input emboss's properties string.
830 * @return The emboss's properties string.
832 const std::string& GetInputEmbossProperties() const;
835 * @brief Sets input the outline's properties string.
837 * @note The string is stored to be recovered.
839 * @param[in] outlineProperties The outline's properties string.
841 void SetInputOutlineProperties( const std::string& outlineProperties );
844 * @brief Retrieves the input outline's properties string.
846 * @return The outline's properties string.
848 const std::string& GetInputOutlineProperties() const;
850 public: // Queries & retrieves.
853 * @brief Return the layout engine.
855 * @return A reference to the layout engine.
857 Layout::Engine& GetLayoutEngine();
860 * @brief Return a view of the text.
862 * @return A reference to the view.
867 * @copydoc Control::GetNaturalSize()
869 Vector3 GetNaturalSize();
872 * @copydoc Control::GetHeightForWidth()
874 float GetHeightForWidth( float width );
877 * @brief Retrieves the text's model.
879 * @return A pointer to the text's model.
881 const ModelInterface* const GetTextModel() const;
884 * @brief Used to get scrolled distance by user input
886 * @return Distance from last scroll offset to new scroll offset
888 float GetScrollAmountByUserInput();
891 * @brief Get latest scroll amount, control size and layout size
893 * This method is used to get information of control's scroll
894 * @param[out] scrollPosition The current scrolled position
895 * @param[out] controlHeight The size of a UI control
896 * @param[out] layoutHeight The size of a bounding box to layout text within.
898 * @return Whether the text scroll position is changed or not after last update.
900 bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
903 * @brief Used to set the hidden input option
905 void SetHiddenInputOption( const Property::Map& options );
908 * @brief Used to get the hidden input option
910 void GetHiddenInputOption( Property::Map& options );
915 * @brief Triggers a relayout which updates View (if necessary).
917 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
918 * @param[in] size A the size of a bounding box to layout text within.
920 * @return Whether the text model or decorations were updated.
922 UpdateTextType Relayout( const Size& size );
925 * @brief Request a relayout using the ControlInterface.
927 void RequestRelayout();
929 public: // Input style change signals.
932 * @return Whether the queue of input style changed signals is empty.
934 bool IsInputStyleChangedSignalsQueueEmpty();
937 * @brief Process all pending input style changed signals.
939 * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
940 * text controls. Text controls may send signals to state the input style has changed.
942 void ProcessInputStyleChangedSignals();
944 public: // Text-input Event Queuing.
947 * @brief Called by editable UI controls when keyboard focus is gained.
949 void KeyboardFocusGainEvent();
952 * @brief Called by editable UI controls when focus is lost.
954 void KeyboardFocusLostEvent();
957 * @brief Called by editable UI controls when key events are received.
959 * @param[in] event The key event.
960 * @param[in] type Used to distinguish between regular key events and IMF events.
962 bool KeyEvent( const Dali::KeyEvent& event );
965 * @brief Called by editable UI controls when a tap gesture occurs.
966 * @param[in] tapCount The number of taps.
967 * @param[in] x The x position relative to the top-left of the parent control.
968 * @param[in] y The y position relative to the top-left of the parent control.
970 void TapEvent( unsigned int tapCount, float x, float y );
973 * @brief Called by editable UI controls when a pan gesture occurs.
975 * @param[in] state The state of the gesture.
976 * @param[in] displacement This distance panned since the last pan gesture.
978 void PanEvent( Gesture::State state, const Vector2& displacement );
981 * @brief Called by editable UI controls when a long press gesture occurs.
983 * @param[in] state The state of the gesture.
984 * @param[in] x The x position relative to the top-left of the parent control.
985 * @param[in] y The y position relative to the top-left of the parent control.
987 void LongPressEvent( Gesture::State state, float x, float y );
990 * @brief Event received from IMF manager
992 * @param[in] imfManager The IMF manager.
993 * @param[in] imfEvent The event received.
994 * @return A data struture indicating if update is needed, cursor position and current text.
996 ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
999 * @brief Event from Clipboard notifying an Item has been selected for pasting
1001 void PasteClipboardItemEvent();
1003 protected: // Inherit from Text::Decorator::ControllerInterface.
1006 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1008 virtual void GetTargetSize( Vector2& targetSize );
1011 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1013 virtual void AddDecoration( Actor& actor, bool needsClipping );
1016 * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1018 virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1020 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1023 * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1025 virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1027 protected: // Inherit from HiddenText.
1030 * @brief Invoked from HiddenText when showing time of the last character was expired
1032 virtual void DisplayTimeExpired();
1037 * @brief Called by editable UI controls when key events are received.
1039 * @param[in] text The text to insert.
1040 * @param[in] type Used to distinguish between regular key events and IMF events.
1042 void InsertText( const std::string& text, InsertType type );
1045 * @brief Paste given string into Text model
1046 * @param[in] stringToPaste this string will be inserted into the text model
1048 void PasteText( const std::string& stringToPaste );
1051 * @brief Remove a given number of characters
1053 * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1054 * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1055 * style when pre-edit text is removed.
1057 * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1058 * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1059 * @param[in] type Whether to update the input style.
1060 * @return True if the remove was successful.
1062 bool RemoveText( int cursorOffset,
1063 int numberOfCharacters,
1064 UpdateInputStyleType type );
1067 * @brief Checks if text is selected and if so removes it.
1068 * @return true if text was removed
1070 bool RemoveSelectedText();
1072 private: // Relayout.
1075 * @brief Lays-out the text.
1077 * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1079 * @param[in] size A the size of a bounding box to layout text within.
1080 * @param[in] operations The layout operations which need to be done.
1081 * @param[out] layoutSize The size of the laid-out text.
1083 bool DoRelayout( const Size& size,
1084 OperationsMask operations,
1088 * @brief Calulates the vertical offset to align the text inside the bounding box.
1090 * @param[in] size The size of the bounding box.
1092 void CalculateVerticalOffset( const Size& size );
1097 * @brief Process queued events which modify the model.
1099 void ProcessModifyEvents();
1102 * @brief Used to process an event queued from SetText()
1104 void TextReplacedEvent();
1107 * @brief Used to process an event queued from key events etc.
1109 void TextInsertedEvent();
1112 * @brief Used to process an event queued from backspace key etc.
1114 void TextDeletedEvent();
1117 * @brief Creates a selection event.
1119 * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1121 * @param[in] x The x position relative to the top-left of the parent control.
1122 * @param[in] y The y position relative to the top-left of the parent control.
1123 * @param[in] selectAll Whether the whole text is selected.
1125 void SelectEvent( float x, float y, bool selectAll );
1128 * @brief Helper to KeyEvent() to handle the backspace case.
1130 * @return True if a character was deleted.
1132 bool BackspaceKeyEvent();
1134 private: // Helpers.
1137 * @brief Used to remove the text included the placeholder text.
1142 * @brief Helper to show the place holder text..
1144 void ShowPlaceholderText();
1147 * @brief Helper to clear font-specific data (only).
1149 void ClearFontData();
1152 * @brief Helper to clear text's style data.
1154 void ClearStyleData();
1157 * @brief Used to reset the cursor position after setting a new text.
1159 * @param[in] cursorIndex Where to place the cursor.
1161 void ResetCursorPosition( CharacterIndex cursorIndex );
1164 * @brief Used to reset the scroll position after setting a new text.
1166 void ResetScrollPosition();
1168 private: // Private contructors & copy operator.
1171 * @brief Private constructor.
1176 * @brief Private constructor.
1178 Controller( ControlInterface* controlInterface );
1181 * @brief Private constructor.
1183 Controller( ControlInterface* controlInterface,
1184 EditableControlInterface* editableControlInterface );
1187 Controller( const Controller& handle );
1190 Controller& operator=( const Controller& handle );
1192 protected: // Destructor.
1195 * @brief A reference counted object may only be deleted by calling Unreference().
1197 virtual ~Controller();
1207 } // namespace Toolkit
1211 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H