Replace std::string global variables with C-style string.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / controller / text-controller.h
1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali-toolkit/devel-api/text/spanned.h>
23 #include <dali/devel-api/adaptor-framework/input-method-context.h>
24 #include <dali/public-api/events/gesture.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/devel-api/controls/text-controls/text-anchor-devel.h>
28 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
30 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
31 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
32 #include <dali-toolkit/internal/text/hidden-text.h>
33 #include <dali-toolkit/internal/text/input-filter.h>
34 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
35 #include <dali-toolkit/internal/text/text-anchor-control-interface.h>
36 #include <dali-toolkit/internal/text/text-model-interface.h>
37 #include <dali-toolkit/internal/text/text-selectable-control-interface.h>
38 #include <dali-toolkit/public-api/text/text-enumerations.h>
39
40 namespace Dali::Toolkit::Text
41 {
42 class Controller;
43 class ControlInterface;
44 class EditableControlInterface;
45 class View;
46 class RenderingController;
47
48 /**
49    * @brief Text selection operations .
50    */
51 enum SelectionType
52 {
53   INTERACTIVE = 0x0000, ///< Select the word where the cursor is located.
54   ALL         = 0x0001, ///< Select the whole text.
55   NONE        = 0x0002, ///< Unselect the whole text.
56   RANGE       = 0x0003  ///< Select the range text.
57 };
58
59 typedef IntrusivePtr<Controller> ControllerPtr;
60
61 /**
62  * @brief A Text Controller is used by UI Controls which display text.
63  *
64  * It manipulates the Logical & Visual text models on behalf of the UI Controls.
65  * It provides a view of the text that can be used by rendering back-ends.
66  *
67  * For selectable/editable UI controls, the controller handles input events from the UI control
68  * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
69  *
70  * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
71  */
72 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
73 {
74 public: // Enumerated types.
75   /**
76    * @brief Text related operations to be done in the relayout process.
77    */
78   enum OperationsMask
79   {
80     NO_OPERATION       = 0x0000,
81     CONVERT_TO_UTF32   = 0x0001,
82     GET_SCRIPTS        = 0x0002,
83     VALIDATE_FONTS     = 0x0004,
84     GET_LINE_BREAKS    = 0x0008,
85     BIDI_INFO          = 0x0010,
86     SHAPE_TEXT         = 0x0020,
87     GET_GLYPH_METRICS  = 0x0040,
88     LAYOUT             = 0x0080,
89     UPDATE_LAYOUT_SIZE = 0x0100,
90     REORDER            = 0x0200,
91     ALIGN              = 0x0400,
92     COLOR              = 0x0800,
93     UPDATE_DIRECTION   = 0x1000,
94     ALL_OPERATIONS     = 0xFFFF
95   };
96
97   /**
98    * @brief Used to distinguish between regular key events and InputMethodContext events
99    */
100   enum InsertType
101   {
102     COMMIT,
103     PRE_EDIT
104   };
105
106   /**
107    * @brief Used to specify whether to update the input style.
108    */
109   enum UpdateInputStyleType
110   {
111     UPDATE_INPUT_STYLE,
112     DONT_UPDATE_INPUT_STYLE
113   };
114
115   /**
116    * @brief Used to specify what has been updated after the Relayout() method has been called.
117    */
118   enum UpdateTextType
119   {
120     NONE_UPDATED      = 0x0, ///< Nothing has been updated.
121     MODEL_UPDATED     = 0x1, ///< The text's model has been updated.
122     DECORATOR_UPDATED = 0x2  ///< The decoration has been updated.
123   };
124
125   /**
126    * @brief Different placeholder-text can be shown when the control is active/inactive.
127    */
128   enum PlaceholderType
129   {
130     PLACEHOLDER_TYPE_ACTIVE,
131     PLACEHOLDER_TYPE_INACTIVE,
132   };
133
134   /**
135    * @brief Enumeration for Font Size Type.
136    */
137   enum FontSizeType
138   {
139     POINT_SIZE, // The size of font in points.
140     PIXEL_SIZE  // The size of font in pixels.
141   };
142
143   struct NoTextTap
144   {
145     enum Action
146     {
147       NO_ACTION,           ///< Does no action if there is a tap on top of an area with no text.
148       HIGHLIGHT,           ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
149       SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
150     };
151   };
152
153   struct TextFitInfo
154   {
155     enum Property
156     {
157       TEXT_FIT_ENABLE,
158       TEXT_FIT_MIN_SIZE,
159       TEXT_FIT_MAX_SIZE,
160       TEXT_FIT_STEP_SIZE,
161       TEXT_FIT_FONT_SIZE_TYPE
162     };
163   };
164
165 public: // Constructor.
166   /**
167    * @brief Create a new instance of a Controller.
168    *
169    * @return A pointer to a new Controller.
170    */
171   static ControllerPtr New()
172   {
173     return ControllerPtr(new Controller());
174   }
175
176   /**
177    * @brief Create a new instance of a Controller.
178    *
179    * @param[in] controlInterface The control's interface.
180    *
181    * @return A pointer to a new Controller.
182    */
183   static ControllerPtr New(ControlInterface* controlInterface)
184   {
185     return ControllerPtr(new Controller(controlInterface));
186   }
187
188   /**
189    * @brief Create a new instance of a Controller.
190    *
191    * @param[in] controlInterface The control's interface.
192    * @param[in] editableControlInterface The editable control's interface.
193    * @param[in] selectableControlInterface The selectable control's interface.
194    * @param[in] anchorControlInterface The anchor control's interface.
195    *
196    * @return A pointer to a new Controller.
197    */
198   static ControllerPtr New(ControlInterface*           controlInterface,
199                            EditableControlInterface*   editableControlInterface,
200                            SelectableControlInterface* selectableControlInterface,
201                            AnchorControlInterface*     anchorControlInterface)
202   {
203     return ControllerPtr(new Controller(controlInterface,
204                                         editableControlInterface,
205                                         selectableControlInterface,
206                                         anchorControlInterface));
207   }
208
209 public: // Configure the text controller.
210   /**
211    * @brief Called to enable text input.
212    *
213    * @note Selectable or editable controls should call this once after Controller::New().
214    * @param[in] decorator Used to create cursor, selection handle decorations etc.
215    * @param[in] inputMethodContext Used to manager ime.
216    */
217   void EnableTextInput(DecoratorPtr decorator, InputMethodContext& inputMethodContext);
218
219   /**
220    * @brief Used to switch between bitmap & vector based glyphs
221    *
222    * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
223    */
224   void SetGlyphType(TextAbstraction::GlyphType glyphType);
225
226   /**
227    * @brief Enables/disables the mark-up processor.
228    *
229    * By default is disabled.
230    *
231    * @param[in] enable Whether to enable the mark-up processor.
232    */
233   void SetMarkupProcessorEnabled(bool enable);
234
235   /**
236    * @brief Retrieves whether the mark-up processor is enabled.
237    *
238    * By default is disabled.
239    *
240    * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
241    */
242   bool IsMarkupProcessorEnabled() const;
243
244   /**
245    * @brief Retrieves whether the current text contains anchors.
246    *
247    * @return @e true if the current text contains anchors. @e false.
248    */
249   bool HasAnchors() const;
250
251   /**
252    * @brief Enables/disables the auto text scrolling
253    *
254    * By default is disabled.
255    *
256    * @param[in] enable Whether to enable the auto scrolling
257    */
258   void SetAutoScrollEnabled(bool enable);
259
260   /**
261    * @brief Whether the auto scrolling texture exceed max texture.
262    *
263    * By default is false.
264    *
265    * @param[in] exceed Whether the auto scrolling texture exceed max texture.
266    */
267   void SetAutoScrollMaxTextureExceeded(bool exceed);
268
269   /**
270    * @brief Retrieves whether auto text scrolling is enabled.
271    *
272    * By default is disabled.
273    *
274    * @return @e true if auto scrolling is enabled, otherwise returns @e false.
275    */
276   bool IsAutoScrollEnabled() const;
277
278   /**
279    * @brief Get direction of the text from the first line of text,
280    * @return bool rtl (right to left) is true
281    */
282   CharacterDirection GetAutoScrollDirection() const;
283
284   /**
285    * @brief Get the alignment offset of the first line of text.
286    *
287    * @return The alignment offset.
288    */
289   float GetAutoScrollLineAlignment() const;
290
291   /**
292    * @brief Enables the horizontal scrolling.
293    *
294    * @param[in] enable Whether to enable the horizontal scrolling.
295    */
296   void SetHorizontalScrollEnabled(bool enable);
297
298   /**
299    * @brief Retrieves whether the horizontal scrolling is enabled.
300    *
301    * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
302    */
303   bool IsHorizontalScrollEnabled() const;
304
305   /**
306    * @brief Enables the vertical scrolling.
307    *
308    * @param[in] enable Whether to enable the vertical scrolling.
309    */
310   void SetVerticalScrollEnabled(bool enable);
311
312   /**
313    * @brief Retrieves whether the verticall scrolling is enabled.
314    *
315    * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
316    */
317   bool IsVerticalScrollEnabled() const;
318
319   /**
320    * @brief Enables the smooth handle panning.
321    *
322    * @param[in] enable Whether to enable the smooth handle panning.
323    */
324   void SetSmoothHandlePanEnabled(bool enable);
325
326   /**
327    * @brief Retrieves whether the smooth handle panning is enabled.
328    *
329    * @return @e true if the smooth handle panning is enabled.
330    */
331   bool IsSmoothHandlePanEnabled() const;
332
333   /**
334    * @brief Sets the maximum number of characters that can be inserted into the TextModel
335    *
336    * @param[in] maxCharacters maximum number of characters to be accepted
337    */
338   void SetMaximumNumberOfCharacters(Length maxCharacters);
339
340   /**
341    * @brief Sets the maximum number of characters that can be inserted into the TextModel
342    *
343    * @param[in] maxCharacters maximum number of characters to be accepted
344    */
345   int GetMaximumNumberOfCharacters();
346
347   /**
348    * @brief Called to enable/disable cursor blink.
349    *
350    * @note Only editable controls should calls this.
351    * @param[in] enabled Whether the cursor should blink or not.
352    */
353   void SetEnableCursorBlink(bool enable);
354
355   /**
356    * @brief Query whether cursor blink is enabled.
357    *
358    * @return Whether the cursor should blink or not.
359    */
360   bool GetEnableCursorBlink() const;
361
362   /**
363    * @brief Whether to enable the multi-line layout.
364    *
365    * @param[in] enable \e true enables the multi-line (by default)
366    */
367   void SetMultiLineEnabled(bool enable);
368
369   /**
370    * @return Whether the multi-line layout is enabled.
371    */
372   bool IsMultiLineEnabled() const;
373
374   /**
375    * @brief Sets the text's horizontal alignment.
376    *
377    * @param[in] alignment The horizontal alignment.
378    */
379   void SetHorizontalAlignment(HorizontalAlignment::Type alignment);
380
381   /**
382    * @copydoc ModelInterface::GetHorizontalAlignment()
383    */
384   HorizontalAlignment::Type GetHorizontalAlignment() const;
385
386   /**
387    * @brief Sets the text's vertical alignment.
388    *
389    * @param[in] alignment The vertical alignment.
390    */
391   void SetVerticalAlignment(VerticalAlignment::Type alignment);
392
393   /**
394    * @copydoc ModelInterface::GetVerticalAlignment()
395    */
396   VerticalAlignment::Type GetVerticalAlignment() const;
397
398   /**
399    * @brief Sets the text's wrap mode
400    * @param[in] text wrap mode The unit of wrapping
401    */
402   void SetLineWrapMode(Text::LineWrap::Mode textWarpMode);
403
404   /**
405    * @brief Retrieve text wrap mode previously set.
406    * @return text wrap mode
407    */
408   Text::LineWrap::Mode GetLineWrapMode() const;
409
410   /**
411    * @brief Enable or disable the text elide.
412    *
413    * @param[in] enabled Whether to enable the text elide.
414    */
415   void SetTextElideEnabled(bool enabled);
416
417   /**
418    * @copydoc ModelInterface::IsTextElideEnabled()
419    */
420   bool IsTextElideEnabled() const;
421
422   /**
423    * @brief Enable or disable the text fit.
424    *
425    * @param[in] enabled Whether to enable the text fit.
426    */
427   void SetTextFitEnabled(bool enabled);
428
429   /**
430    * @brief Whether the text fit is enabled or not.
431    *
432    * @return True if the text fit is enabled
433    */
434   bool IsTextFitEnabled() const;
435
436   /**
437    * @brief Sets minimum size valid for text fit.
438    *
439    * @param[in] minimum size value.
440    * @param[in] type The font size type is point size or pixel size
441    */
442   void SetTextFitMinSize(float pointSize, FontSizeType type);
443
444   /**
445    * @brief Retrieves the minimum point size valid for text fit.
446    *
447    * @return The minimum point size valid for text fit
448    */
449   float GetTextFitMinSize() const;
450
451   /**
452    * @brief Sets maximum size valid for text fit.
453    *
454    * @param[in] maximum size value.
455    * @param[in] type The font size type is point size or pixel size
456    */
457   void SetTextFitMaxSize(float pointSize, FontSizeType type);
458
459   /**
460    * @brief Retrieves the maximum point size valid for text fit.
461    *
462    * @return The maximum point size valid for text fit
463    */
464   float GetTextFitMaxSize() const;
465
466   /**
467    * @brief Sets step size for font increase valid for text fit.
468    *
469    * @param[in] step size value.
470    * @param[in] type The font size type is point size or pixel size
471    */
472   void SetTextFitStepSize(float step, FontSizeType type);
473
474   /**
475    * @brief Retrieves the step point size valid for text fit.
476    *
477    * @return The step point size valid for text fit
478    */
479   float GetTextFitStepSize() const;
480
481   /**
482    * @brief Sets content size valid for text fit.
483    *
484    * @param[in] Content size value.
485    */
486   void SetTextFitContentSize(Vector2 size);
487
488   /**
489    * @brief Retrieves the content size valid for text fit.
490    *
491    * @return The content size valid for text fit
492    */
493   Vector2 GetTextFitContentSize() const;
494
495   /**
496    * @brief Retrieve the fited point size.
497    *
498    * @return The fited point size.
499    */
500   float GetTextFitPointSize() const;
501
502   /**
503    * @brief Sets whether the text fit properties have changed.
504    *
505    * @param[in] changed Whether to changed the text fit.
506    */
507   void SetTextFitChanged(bool changed);
508
509   /**
510    * @brief Whether the text fit properties are changed or not.
511    *
512    * @return True if the text fit properties are changed
513    */
514   bool IsTextFitChanged() const;
515
516   /**
517    * @brief Sets disabled color opacity.
518    *
519    * @param[in] opacity The color opacity value in disabled state.
520    */
521   void SetDisabledColorOpacity(float opacity);
522
523   /**
524    * @brief Retrieves the disabled color opacity.
525    *
526    * @return The disabled color opacity value for disabled state.
527    */
528   float GetDisabledColorOpacity() const;
529
530   /**
531    * @brief Enable or disable the placeholder text elide.
532    * @param enabled Whether to enable the placeholder text elide.
533    */
534   void SetPlaceholderTextElideEnabled(bool enabled);
535
536   /**
537    * @brief Whether the placeholder text elide property is enabled.
538    * @return True if the placeholder text elide property is enabled, false otherwise.
539    */
540   bool IsPlaceholderTextElideEnabled() const;
541
542   /**
543    * @brief Enable or disable the text selection.
544    * @param[in] enabled Whether to enable the text selection.
545    */
546   void SetSelectionEnabled(bool enabled);
547
548   /**
549    * @brief Whether the text selection is enabled or not.
550    * @return True if the text selection is enabled
551    */
552   bool IsSelectionEnabled() const;
553
554   /**
555    * @brief Enable or disable the text selection using Shift key.
556    * @param enabled Whether to enable the text selection using Shift key
557    */
558   void SetShiftSelectionEnabled(bool enabled);
559
560   /**
561    * @brief Whether the text selection using Shift key is enabled or not.
562    * @return True if the text selection using Shift key is enabled
563    */
564   bool IsShiftSelectionEnabled() const;
565
566   /**
567    * @brief Enable or disable the grab handles for text selection.
568    *
569    * @param[in] enabled Whether to enable the grab handles
570    */
571   void SetGrabHandleEnabled(bool enabled);
572
573   /**
574    * @brief Returns whether the grab handles are enabled.
575    *
576    * @return True if the grab handles are enabled
577    */
578   bool IsGrabHandleEnabled() const;
579
580   /**
581    * @brief Enable or disable the grab handles for text selection.
582    *
583    * @param[in] enabled Whether to enable the grab handles
584    */
585   void SetGrabHandlePopupEnabled(bool enabled);
586
587   /**
588    * @brief Returns whether the grab handles are enabled.
589    *
590    * @return True if the grab handles are enabled
591    */
592   bool IsGrabHandlePopupEnabled() const;
593
594   /**
595    * @brief Sets input type to password
596    *
597    * @note The string is displayed hidden character
598    *
599    * @param[in] passwordInput True if password input is enabled.
600    */
601   void SetInputModePassword(bool passwordInput);
602
603   /**
604    * @brief Returns whether the input mode type is set as password.
605    *
606    * @return True if input mode type is password
607    */
608   bool IsInputModePassword();
609
610   /**
611    * @brief Sets the action when there is a double tap event on top of a text area with no text.
612    *
613    * @param[in] action The action to do.
614    */
615   void SetNoTextDoubleTapAction(NoTextTap::Action action);
616
617   /**
618    * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
619    *
620    * @return The action to do.
621    */
622   NoTextTap::Action GetNoTextDoubleTapAction() const;
623
624   /**
625    * @briefSets the action when there is a long press event on top of a text area with no text.
626    *
627    * @param[in] action The action to do.
628    */
629   void SetNoTextLongPressAction(NoTextTap::Action action);
630
631   /**
632    * @brief Retrieves the action when there is a long press event on top of a text area with no text.
633    *
634    * @return The action to do.
635    */
636   NoTextTap::Action GetNoTextLongPressAction() const;
637
638   /**
639    * @brief Query if Underline settings were provided by string or map
640    * @return bool true if set by string
641    */
642   bool IsUnderlineSetByString();
643
644   /**
645    * Set method underline setting were set by
646    * @param[in] bool, true if set by string
647    */
648   void UnderlineSetByString(bool setByString);
649
650   /**
651    * @brief Query if shadow settings were provided by string or map
652    * @return bool true if set by string
653    */
654   bool IsShadowSetByString();
655
656   /**
657    * Set method shadow setting were set by
658    * @param[in] bool, true if set by string
659    */
660   void ShadowSetByString(bool setByString);
661
662   /**
663    * @brief Query if outline settings were provided by string or map
664    * @return bool true if set by string
665    */
666   bool IsOutlineSetByString();
667
668   /**
669    * Set method outline setting were set by
670    * @param[in] bool, true if set by string
671    */
672   void OutlineSetByString(bool setByString);
673
674   /**
675    * @brief Query if font style settings were provided by string or map
676    * @return bool true if set by string
677    */
678   bool IsFontStyleSetByString();
679
680   /**
681    * Set method font style setting were set by
682    * @param[in] bool, true if set by string
683    */
684   void FontStyleSetByString(bool setByString);
685
686   /**
687    * @brief Query if Strikethrough settings were provided by string or map
688    * @return bool true if set by string
689    */
690   bool IsStrikethroughSetByString();
691
692   /**
693    * Set method Strikethrough setting were set by
694    * @param[in] bool, true if set by string
695    */
696   void StrikethroughSetByString(bool setByString);
697
698   /**
699    * @brief Set the override used for strikethrough height, 0 indicates height will be supplied by font metrics
700    *
701    * @param[in] height The height in pixels of the strikethrough
702    */
703   void SetStrikethroughHeight(float height);
704
705   /**
706    * @brief Retrieves the override height of an strikethrough, 0 indicates height is supplied by font metrics
707    *
708    * @return The height of the strikethrough, or 0 if height is not overrided.
709    */
710   float GetStrikethroughHeight() const;
711
712   /**
713    * @brief Set the strikethrough color.
714    *
715    * @param[in] color color of strikethrough.
716    */
717   void SetStrikethroughColor(const Vector4& color);
718
719   /**
720    * @brief Retrieve the strikethrough color.
721    *
722    * @return The strikethrough color.
723    */
724   const Vector4& GetStrikethroughColor() const;
725
726   /**
727    * @brief Set the strikethrough enabled flag.
728    *
729    * @param[in] enabled The strikethrough enabled flag.
730    */
731   void SetStrikethroughEnabled(bool enabled);
732
733   /**
734    * @brief Returns whether the text has a strikethrough or not.
735    *
736    * @return The strikethrough state.
737    */
738   bool IsStrikethroughEnabled() const;
739
740 public: // Update.
741   /**
742    * @brief Replaces any text previously set.
743    *
744    * @note This will be converted into UTF-32 when stored in the text model.
745    * @param[in] text A string of UTF-8 characters.
746    */
747   void SetText(const std::string& text);
748
749   /**
750    * @brief Retrieve any text previously set.
751    *
752    * @param[out] text A string of UTF-8 characters.
753    */
754   void GetText(std::string& text) const;
755
756   /**
757  * @brief Set the @p spannedText
758  * the spanned text contains content (text) and  format (spans with ranges)
759  * the text is copied into text-controller and the spans are applied on ranges
760  *
761  * @param[in] spannedText the text with spans.
762  */
763   void SetSpannedText(const Text::Spanned& spannedText);
764
765   /**
766    * @brief Replaces any placeholder text previously set.
767    *
768    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
769    * @param[in] text A string of UTF-8 characters.
770    */
771   void SetPlaceholderText(PlaceholderType type, const std::string& text);
772
773   /**
774    * @brief Retrieve any placeholder text previously set.
775    *
776    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
777    * @param[out] A string of UTF-8 characters.
778    */
779   void GetPlaceholderText(PlaceholderType type, std::string& text) const;
780
781   /**
782    * @ brief Update the text after a font change
783    * @param[in] newDefaultFont The new font to change to
784    */
785   void UpdateAfterFontChange(const std::string& newDefaultFont);
786
787   /**
788    * @brief The method acquires currently selected text
789    * @param selectedText variable to place selected text in
790    */
791   void RetrieveSelection(std::string& selectedText) const;
792
793   /**
794    * @brief The method sets selection in given range
795    * @param start index of first character
796    * @param end   index of first character after selection
797    */
798   void SetSelection(int start, int end);
799
800   /**
801    * @brief This method retrieve indexes of current selection
802    *
803    * @return a pair, where first element is left index of selection and second is the right one
804    */
805   std::pair<int, int> GetSelectionIndexes() const;
806
807   /**
808    * Place string in system clipboard
809    * @param source std::string
810    */
811   void CopyStringToClipboard(const std::string& source);
812
813   /**
814    * Place currently selected text in system clipboard
815    * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard
816    */
817   void SendSelectionToClipboard(bool deleteAfterSending);
818
819 public: // Default style & Input style
820   /**
821    * @brief Set the default font family.
822    *
823    * @param[in] defaultFontFamily The default font family.
824    */
825   void SetDefaultFontFamily(const std::string& defaultFontFamily);
826
827   /**
828    * @brief Retrieve the default font family.
829    *
830    * @return The default font family.
831    */
832   std::string GetDefaultFontFamily() const;
833
834   /**
835    * @brief Sets the placeholder text font family.
836    * @param[in] placeholderTextFontFamily The placeholder text font family.
837    */
838   void SetPlaceholderFontFamily(const std::string& placeholderTextFontFamily);
839
840   /**
841    * @brief Retrieves the placeholder text font family.
842    *
843    * @return The placeholder text font family
844    */
845   std::string GetPlaceholderFontFamily() const;
846
847   /**
848    * @brief Sets the default font weight.
849    *
850    * @param[in] weight The font weight.
851    */
852   void SetDefaultFontWeight(FontWeight weight);
853
854   /**
855    * @brief Whether the font's weight has been defined.
856    */
857   bool IsDefaultFontWeightDefined() const;
858
859   /**
860    * @brief Retrieves the default font weight.
861    *
862    * @return The default font weight.
863    */
864   FontWeight GetDefaultFontWeight() const;
865
866   /**
867    * @brief Sets the placeholder text font weight.
868    *
869    * @param[in] weight The font weight
870    */
871   void SetPlaceholderTextFontWeight(FontWeight weight);
872
873   /**
874    * @brief Whether the font's weight has been defined.
875    *
876    * @return True if the placeholder text font weight is defined
877    */
878   bool IsPlaceholderTextFontWeightDefined() const;
879
880   /**
881    * @brief Retrieves the placeholder text font weight.
882    *
883    * @return The placeholder text font weight
884    */
885   FontWeight GetPlaceholderTextFontWeight() const;
886
887   /**
888    * @brief Sets the default font width.
889    *
890    * @param[in] width The font width.
891    */
892   void SetDefaultFontWidth(FontWidth width);
893
894   /**
895    * @brief Whether the font's width has been defined.
896    */
897   bool IsDefaultFontWidthDefined() const;
898
899   /**
900    * @brief Retrieves the default font width.
901    *
902    * @return The default font width.
903    */
904   FontWidth GetDefaultFontWidth() const;
905
906   /**
907    * @brief Sets the placeholder text font width.
908    *
909    * @param[in] width The font width
910    */
911   void SetPlaceholderTextFontWidth(FontWidth width);
912
913   /**
914    * @brief Whether the font's width has been defined.
915    *
916    * @return True if the placeholder text font width is defined
917    */
918   bool IsPlaceholderTextFontWidthDefined() const;
919
920   /**
921    * @brief Retrieves the placeholder text font width.
922    *
923    * @return The placeholder text font width
924    */
925   FontWidth GetPlaceholderTextFontWidth() const;
926
927   /**
928    * @brief Sets the default font slant.
929    *
930    * @param[in] slant The font slant.
931    */
932   void SetDefaultFontSlant(FontSlant slant);
933
934   /**
935    * @brief Whether the font's slant has been defined.
936    */
937   bool IsDefaultFontSlantDefined() const;
938
939   /**
940    * @brief Retrieves the default font slant.
941    *
942    * @return The default font slant.
943    */
944   FontSlant GetDefaultFontSlant() const;
945
946   /**
947    * @brief Sets the placeholder text font slant.
948    *
949    * @param[in] slant The font slant
950    */
951   void SetPlaceholderTextFontSlant(FontSlant slant);
952
953   /**
954    * @brief Whether the font's slant has been defined.
955    *
956    * @return True if the placeholder text font slant is defined
957    */
958   bool IsPlaceholderTextFontSlantDefined() const;
959
960   /**
961    * @brief Retrieves the placeholder text font slant.
962    *
963    * @return The placeholder text font slant
964    */
965   FontSlant GetPlaceholderTextFontSlant() const;
966
967   /**
968    * @brief Set the default font size.
969    *
970    * @param[in] fontSize The default font size
971    * @param[in] type The font size type is point size or pixel size
972    */
973   void SetDefaultFontSize(float fontSize, FontSizeType type);
974
975   /**
976    * @brief Retrieve the default point size.
977    *
978    * @param[in] type The font size type
979    * @return The default point size.
980    */
981   float GetDefaultFontSize(FontSizeType type) const;
982
983   /**
984    * @brief Set the font size scale.
985    *
986    * @param[in] scale The font size scale
987    */
988   void SetFontSizeScale(float scale);
989
990   /**
991    * @brief Get the font size scale.
992    *
993    * @return The font size scale.
994    */
995   float GetFontSizeScale() const;
996
997   /**
998    * @brief Set the font size scale enabled flag.
999    *
1000    * @param[in] enabled whether to enable the font size scale.
1001    */
1002   void SetFontSizeScaleEnabled(bool enabled);
1003
1004   /**
1005    * @brief Returns whether the font size scale is enabled or not.
1006    *
1007    * @return @e true if the font size scale is enabled, otherwise returns @e false.
1008    */
1009   bool IsFontSizeScaleEnabled() const;
1010
1011   /**
1012    * @brief Sets the Placeholder text font size.
1013    * @param[in] fontSize The placeholder text font size
1014    * @param[in] type The font size type is point size or pixel size
1015    */
1016   void SetPlaceholderTextFontSize(float fontSize, FontSizeType type);
1017
1018   /**
1019    * @brief Retrieves the Placeholder text font size.
1020    * @param[in] type The font size type
1021    * @return The placeholder font size
1022    */
1023   float GetPlaceholderTextFontSize(FontSizeType type) const;
1024
1025   /**
1026    * @brief Sets the text's default color.
1027    *
1028    * @param color The default color.
1029    */
1030   void SetDefaultColor(const Vector4& color);
1031
1032   /**
1033    * @brief Retrieves the text's default color.
1034    *
1035    * @return The default color.
1036    */
1037   const Vector4& GetDefaultColor() const;
1038
1039   /**
1040    * @brief Sets the user interaction enabled.
1041    *
1042    * @param enabled whether to enable the user interaction.
1043    */
1044   void SetUserInteractionEnabled(bool enabled);
1045
1046   /**
1047    * @brief Whether the user interaction is enabled.
1048    *
1049    * @return true if the user interaction is enabled, false otherwise.
1050    */
1051   bool IsUserInteractionEnabled() const;
1052
1053   /**
1054    * @brief Set the text color
1055    *
1056    * @param textColor The text color
1057    */
1058   void SetPlaceholderTextColor(const Vector4& textColor);
1059
1060   /**
1061    * @brief Retrieve the text color
1062    *
1063    * @return The text color
1064    */
1065   const Vector4& GetPlaceholderTextColor() const;
1066
1067   /**
1068    * @brief Set the shadow offset.
1069    *
1070    * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
1071    */
1072   void SetShadowOffset(const Vector2& shadowOffset);
1073
1074   /**
1075    * @brief Retrieve the shadow offset.
1076    *
1077    * @return The shadow offset.
1078    */
1079   const Vector2& GetShadowOffset() const;
1080
1081   /**
1082    * @brief Set the shadow color.
1083    *
1084    * @param[in] shadowColor The shadow color.
1085    */
1086   void SetShadowColor(const Vector4& shadowColor);
1087
1088   /**
1089    * @brief Retrieve the shadow color.
1090    *
1091    * @return The shadow color.
1092    */
1093   const Vector4& GetShadowColor() const;
1094
1095   /**
1096    * @brief Set the shadow blur radius.
1097    *
1098    * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
1099    */
1100   void SetShadowBlurRadius(const float& shadowBlurRadius);
1101
1102   /**
1103    * @brief Retrieve the shadow blur radius.
1104    *
1105    * @return The shadow blur radius.
1106    */
1107   const float& GetShadowBlurRadius() const;
1108
1109   /**
1110    * @brief Set the underline color.
1111    *
1112    * @param[in] color color of underline.
1113    */
1114   void SetUnderlineColor(const Vector4& color);
1115
1116   /**
1117    * @brief Retrieve the underline color.
1118    *
1119    * @return The underline color.
1120    */
1121   const Vector4& GetUnderlineColor() const;
1122
1123   /**
1124    * @brief Set the underline enabled flag.
1125    *
1126    * @param[in] enabled The underline enabled flag.
1127    */
1128   void SetUnderlineEnabled(bool enabled);
1129
1130   /**
1131    * @brief Returns whether the text is underlined or not.
1132    *
1133    * @return The underline state.
1134    */
1135   bool IsUnderlineEnabled() const;
1136
1137   /**
1138    * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
1139    *
1140    * @param[in] height The height in pixels of the underline
1141    */
1142   void SetUnderlineHeight(float height);
1143
1144   /**
1145    * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
1146    *
1147    * @return The height of the underline, or 0 if height is not overrided.
1148    */
1149   float GetUnderlineHeight() const;
1150
1151   /**
1152    * @brief Sets the underline type.
1153    * @param[in] type The underline type.
1154    */
1155   void SetUnderlineType(Text::Underline::Type type);
1156
1157   /**
1158    * @brief Retrieve underline type.
1159    * @return The underline type.
1160    */
1161   Text::Underline::Type GetUnderlineType() const;
1162
1163   /**
1164    * @brief Set the width of the dashes of the dashed underline.
1165    *
1166    * @param[in] width The width in pixels of the dashes of the dashed underline.
1167    */
1168   void SetDashedUnderlineWidth(float width);
1169
1170   /**
1171    * @brief Retrieves the width of the dashes of the dashed underline.
1172    *
1173    * @return The width of the dashes of the dashed underline.
1174    */
1175   float GetDashedUnderlineWidth() const;
1176
1177   /**
1178    * @brief Set the gap between the dashes of the dashed underline.
1179    *
1180    * @param[in] gap The gap between the dashes of the dashed underline.
1181    */
1182   void SetDashedUnderlineGap(float gap);
1183
1184   /**
1185    * @brief Retrieves the gap between the dashes of the dashed underline.
1186    *
1187    * @return The The gap between the dashes of the dashed underline.
1188    */
1189   float GetDashedUnderlineGap() const;
1190
1191   /**
1192    * @brief Set the outline color.
1193    *
1194    * @param[in] color color of outline.
1195    */
1196   void SetOutlineColor(const Vector4& color);
1197
1198   /**
1199    * @brief Retrieve the outline color.
1200    *
1201    * @return The outline color.
1202    */
1203   const Vector4& GetOutlineColor() const;
1204
1205   /**
1206    * @brief Set the outline width
1207    *
1208    * @param[in] width The width in pixels of the outline, 0 indicates no outline
1209    */
1210   void SetOutlineWidth(uint16_t width);
1211
1212   /**
1213    * @brief Retrieves the width of an outline
1214    *
1215    * @return The width of the outline.
1216    */
1217   uint16_t GetOutlineWidth() const;
1218
1219   /**
1220    * @brief Set the background color.
1221    *
1222    * @param[in] color color of background.
1223    */
1224   void SetBackgroundColor(const Vector4& color);
1225
1226   /**
1227    * @brief Retrieve the background color.
1228    *
1229    * @return The background color.
1230    */
1231   const Vector4& GetBackgroundColor() const;
1232
1233   /**
1234    * @brief Set the background enabled flag.
1235    *
1236    * @param[in] enabled The background enabled flag.
1237    */
1238   void SetBackgroundEnabled(bool enabled);
1239
1240   /**
1241    * @brief Returns whether to enable text background or not.
1242    *
1243    * @return Whether text background is enabled.
1244    */
1245   bool IsBackgroundEnabled() const;
1246
1247   /**
1248    * @brief Sets the emboss's properties string.
1249    *
1250    * @note The string is stored to be recovered.
1251    *
1252    * @param[in] embossProperties The emboss's properties string.
1253    */
1254   void SetDefaultEmbossProperties(const std::string& embossProperties);
1255
1256   /**
1257    * @brief Retrieves the emboss's properties string.
1258    *
1259    * @return The emboss's properties string.
1260    */
1261   std::string GetDefaultEmbossProperties() const;
1262
1263   /**
1264    * @brief Sets the outline's properties string.
1265    *
1266    * @note The string is stored to be recovered.
1267    *
1268    * @param[in] outlineProperties The outline's properties string.
1269    */
1270   void SetDefaultOutlineProperties(const std::string& outlineProperties);
1271
1272   /**
1273    * @brief Retrieves the outline's properties string.
1274    *
1275    * @return The outline's properties string.
1276    */
1277   std::string GetDefaultOutlineProperties() const;
1278
1279   /**
1280    * @brief Sets the default line spacing.
1281    *
1282    * @param[in] lineSpacing The line spacing.
1283    *
1284    * @return True if lineSpacing has been updated, false otherwise
1285    */
1286   bool SetDefaultLineSpacing(float lineSpacing);
1287
1288   /**
1289    * @brief Retrieves the default line spacing.
1290    *
1291    * @return The line spacing.
1292    */
1293   float GetDefaultLineSpacing() const;
1294
1295   /**
1296    * @brief Sets the default line size.
1297    *
1298    * @param[in] lineSize The line size.
1299    *
1300    * @return True if lineSize has been updated, false otherwise
1301    */
1302   bool SetDefaultLineSize(float lineSize);
1303
1304   /**
1305    * @brief Retrieves the default line size.
1306    *
1307    * @return The line size.
1308    */
1309   float GetDefaultLineSize() const;
1310
1311   /**
1312    * @brief Sets the relative line size to the original line size.
1313    *
1314    * @param[in] relativeLineSize The relativeline size.
1315    *
1316    * @return True if relativeLineSize has been updated, false otherwise
1317    */
1318   bool SetRelativeLineSize(float lineSize);
1319
1320   /**
1321    * @brief Retrieves the relative line size.
1322    *
1323    * @return The relative line size.
1324    */
1325   float GetRelativeLineSize() const;
1326
1327   /**
1328    * @brief Sets the input text's color.
1329    *
1330    * @param[in] color The input text's color.
1331    */
1332   void SetInputColor(const Vector4& color);
1333
1334   /**
1335    * @brief Retrieves the input text's color.
1336    *
1337    * @return The input text's color.
1338    */
1339   const Vector4& GetInputColor() const;
1340
1341   /**
1342    * @brief Sets the input text's font family name.
1343    *
1344    * @param[in] fontFamily The text's font family name.
1345    */
1346   void SetInputFontFamily(const std::string& fontFamily);
1347
1348   /**
1349    * @brief Retrieves the input text's font family name.
1350    *
1351    * @return The input text's font family name.
1352    */
1353   std::string GetInputFontFamily() const;
1354
1355   /**
1356    * @brief Sets the input font's weight.
1357    *
1358    * @param[in] weight The input font's weight.
1359    */
1360   void SetInputFontWeight(FontWeight weight);
1361
1362   /**
1363    * @return Whether the font's weight has been defined.
1364    */
1365   bool IsInputFontWeightDefined() const;
1366
1367   /**
1368    * @brief Retrieves the input font's weight.
1369    *
1370    * @return The input font's weight.
1371    */
1372   FontWeight GetInputFontWeight() const;
1373
1374   /**
1375    * @brief Sets the input font's width.
1376    *
1377    * @param[in] width The input font's width.
1378    */
1379   void SetInputFontWidth(FontWidth width);
1380
1381   /**
1382    * @return Whether the font's width has been defined.
1383    */
1384   bool IsInputFontWidthDefined() const;
1385
1386   /**
1387    * @brief Retrieves the input font's width.
1388    *
1389    * @return The input font's width.
1390    */
1391   FontWidth GetInputFontWidth() const;
1392
1393   /**
1394    * @brief Sets the input font's slant.
1395    *
1396    * @param[in] slant The input font's slant.
1397    */
1398   void SetInputFontSlant(FontSlant slant);
1399
1400   /**
1401    * @return Whether the font's slant has been defined.
1402    */
1403   bool IsInputFontSlantDefined() const;
1404
1405   /**
1406    * @brief Retrieves the input font's slant.
1407    *
1408    * @return The input font's slant.
1409    */
1410   FontSlant GetInputFontSlant() const;
1411
1412   /**
1413    * @brief Sets the input font's point size.
1414    *
1415    * @param[in] size The input font's point size.
1416    */
1417   void SetInputFontPointSize(float size);
1418
1419   /**
1420    * @brief Retrieves the input font's point size.
1421    *
1422    * @return The input font's point size.
1423    */
1424   float GetInputFontPointSize() const;
1425
1426   /**
1427    * @brief Sets the input line spacing.
1428    *
1429    * @param[in] lineSpacing The line spacing.
1430    */
1431   void SetInputLineSpacing(float lineSpacing);
1432
1433   /**
1434    * @brief Retrieves the input line spacing.
1435    *
1436    * @return The line spacing.
1437    */
1438   float GetInputLineSpacing() const;
1439
1440   /**
1441    * @brief Sets the input shadow's properties string.
1442    *
1443    * @note The string is stored to be recovered.
1444    *
1445    * @param[in] shadowProperties The shadow's properties string.
1446    */
1447   void SetInputShadowProperties(const std::string& shadowProperties);
1448
1449   /**
1450    * @brief Retrieves the input shadow's properties string.
1451    *
1452    * @return The shadow's properties string.
1453    */
1454   std::string GetInputShadowProperties() const;
1455
1456   /**
1457    * @brief Sets the input underline's properties string.
1458    *
1459    * @note The string is stored to be recovered.
1460    *
1461    * @param[in] underlineProperties The underline's properties string.
1462    */
1463   void SetInputUnderlineProperties(const std::string& underlineProperties);
1464
1465   /**
1466    * @brief Retrieves the input underline's properties string.
1467    *
1468    * @return The underline's properties string.
1469    */
1470   std::string GetInputUnderlineProperties() const;
1471
1472   /**
1473    * @brief Sets the input emboss's properties string.
1474    *
1475    * @note The string is stored to be recovered.
1476    *
1477    * @param[in] embossProperties The emboss's properties string.
1478    */
1479   void SetInputEmbossProperties(const std::string& embossProperties);
1480
1481   /**
1482    * @brief Retrieves the input emboss's properties string.
1483    *
1484    * @return The emboss's properties string.
1485    */
1486   std::string GetInputEmbossProperties() const;
1487
1488   /**
1489    * @brief Sets input the outline's properties string.
1490    *
1491    * @note The string is stored to be recovered.
1492    *
1493    * @param[in] outlineProperties The outline's properties string.
1494    */
1495   void SetInputOutlineProperties(const std::string& outlineProperties);
1496
1497   /**
1498    * @brief Retrieves the input outline's properties string.
1499    *
1500    * @return The outline's properties string.
1501    */
1502   std::string GetInputOutlineProperties() const;
1503
1504   /**
1505    * @brief Sets the input strikethrough's properties string.
1506    *
1507    * @note The string is stored to be recovered.
1508    *
1509    * @param[in] strikethroughProperties The strikethrough's properties string.
1510    */
1511   void SetInputStrikethroughProperties(const std::string& strikethroughProperties);
1512
1513   /**
1514    * @brief Retrieves the input strikethrough's properties string.
1515    *
1516    * @return The strikethrough's properties string.
1517    */
1518   std::string GetInputStrikethroughProperties() const;
1519
1520   /**
1521    * @brief Set the control's interface.
1522    *
1523    * @param[in] controlInterface The control's interface.
1524    */
1525   void SetControlInterface(ControlInterface* controlInterface);
1526
1527   /**
1528    * @brief Set the anchor control's interface.
1529    *
1530    * @param[in] anchorControlInterface The control's interface.
1531    */
1532   void SetAnchorControlInterface(AnchorControlInterface* anchorControlInterface);
1533
1534   /**
1535    * @brief Sets the character spacing.
1536    *
1537    * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
1538    *
1539    * @param[in] characterSpacing The character spacing.
1540    */
1541   void SetCharacterSpacing(float characterSpacing);
1542
1543   /**
1544    * @brief Retrieves the character spacing.
1545    *
1546    * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
1547    *
1548    * @return The character spacing.
1549    */
1550   const float GetCharacterSpacing() const;
1551
1552 public: // Queries & retrieves.
1553   /**
1554    * @brief Return the layout engine.
1555    *
1556    * @return A reference to the layout engine.
1557    */
1558   Layout::Engine& GetLayoutEngine();
1559
1560   /**
1561    * @brief Return a view of the text.
1562    *
1563    * @return A reference to the view.
1564    */
1565   View& GetView();
1566
1567   /**
1568    * @copydoc Control::GetNaturalSize()
1569    */
1570   Vector3 GetNaturalSize();
1571
1572   /**
1573    * @copydoc Control::GetHeightForWidth()
1574    */
1575   float GetHeightForWidth(float width);
1576
1577   /**
1578    * @brief Calculates the point size for text for given layout()
1579    */
1580   void FitPointSizeforLayout(Size layoutSize);
1581
1582   /**
1583    * @brief Checks if the point size fits within the layout size.
1584    *
1585    * @return Whether the point size fits within the layout size.
1586    */
1587   bool CheckForTextFit(float pointSize, Size& layoutSize);
1588
1589   /**
1590    * @brief Retrieves the text's number of lines for a given width.
1591    * @param[in] width The width of the text's area.
1592    * @ return The number of lines.
1593    */
1594   int GetLineCount(float width);
1595
1596   /**
1597    * @brief Retrieves the text's model.
1598    *
1599    * @return A pointer to the text's model.
1600    */
1601   const ModelInterface* GetTextModel() const;
1602
1603   /**
1604    * @brief Used to get scrolled distance by user input
1605    *
1606    * @return Distance from last scroll offset to new scroll offset
1607    */
1608   float GetScrollAmountByUserInput();
1609
1610   /**
1611    * @brief Get latest scroll amount, control size and layout size
1612    *
1613    * This method is used to get information of control's scroll
1614    * @param[out] scrollPosition The current scrolled position
1615    * @param[out] controlHeight The size of a UI control
1616    * @param[out] layoutHeight The size of a bounding box to layout text within.
1617    *
1618    * @return Whether the text scroll position is changed or not after last update.
1619    */
1620   bool GetTextScrollInfo(float& scrollPosition, float& controlHeight, float& layoutHeight);
1621
1622   /**
1623    * @brief Used to set the hidden input option
1624    */
1625   void SetHiddenInputOption(const Property::Map& options);
1626
1627   /**
1628    * @brief Used to get the hidden input option
1629    */
1630   void GetHiddenInputOption(Property::Map& options);
1631
1632   /**
1633    * @brief Used to set the input filter option
1634    */
1635   void SetInputFilterOption(const Property::Map& options);
1636
1637   /**
1638    * @brief Used to get the input filter option
1639    */
1640   void GetInputFilterOption(Property::Map& options);
1641
1642   /**
1643    * @brief Sets the Placeholder Properties.
1644    *
1645    * @param[in] map The placeholder property map
1646    */
1647   void SetPlaceholderProperty(const Property::Map& map);
1648
1649   /**
1650    * @brief Retrieves the Placeholder Property map.
1651    *
1652    * @param[out] map The property map
1653    */
1654   void GetPlaceholderProperty(Property::Map& map);
1655
1656   /**
1657    * @brief Checks text direction.
1658    * @return The text direction.
1659    */
1660   Toolkit::DevelText::TextDirection::Type GetTextDirection();
1661
1662   /**
1663    * @brief Retrieves vertical line alignment
1664    * @return The vertical line alignment
1665    */
1666   Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1667
1668   /**
1669    * @brief Sets vertical line alignment
1670    * @param[in] alignment The vertical line alignment for the text
1671    */
1672   void SetVerticalLineAlignment(Toolkit::DevelText::VerticalLineAlignment::Type alignment);
1673
1674   /**
1675    * @brief Retrieves ellipsis position
1676    * @return The ellipsis position
1677    */
1678   Toolkit::DevelText::EllipsisPosition::Type GetEllipsisPosition() const;
1679
1680   /**
1681    * @brief Sets ellipsis position
1682    * @param[in] ellipsisPosition The ellipsis position for the text
1683    */
1684   void SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition);
1685
1686   /**
1687    * @brief Retrieves ignoreSpaceAfterText value from model
1688    * @return The value of ignoreSpaceAfterText
1689    */
1690   bool IsIgnoreSpacesAfterText() const;
1691
1692   /**
1693    * @brief Sets ignoreSpaceAfterText value to model
1694    * @param[in] ignore The value of ignoreSpacesAfterText for the text
1695    */
1696   void SetIgnoreSpacesAfterText(bool ignore);
1697
1698   /**
1699    * @brief Sets SetMatchLayoutDirection value to model
1700    * @param[in] match The value of matchLayoutDirection for the text
1701    */
1702   void SetMatchLayoutDirection(DevelText::MatchLayoutDirection type);
1703
1704   /**
1705    * @brief Retrieves matchLayoutDirection value from model
1706    * @return The value of matchLayoutDirection
1707    */
1708   DevelText::MatchLayoutDirection GetMatchLayoutDirection() const;
1709
1710   /**
1711    * @brief Sets layoutDirection type value.
1712    * @param[in] layoutDirection The value of the layout direction type.
1713    */
1714   void SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection);
1715
1716   /**
1717    * @brief Gets layoutDirection type value.
1718    * @param[in] actor The actor which will get the layout direction type.
1719    * @return The value of the layout direction type.
1720    */
1721   Dali::LayoutDirection::Type GetLayoutDirection(Dali::Actor& actor) const;
1722
1723   /**
1724    * @brief Get the rendered size of a specific text range.
1725    * if the requested text is at multilines, multiple sizes will be returned for each text located in a separate line.
1726    * if a line contains characters with different directions, multiple sizes will be returned for each block of contiguous characters with the same direction.
1727    *
1728    * @param[in] startIndex start index of the text requested to calculate size for.
1729    * @param[in] endIndex end index(included) of the text requested to calculate size for.
1730    * @return list of sizes of the reuested text.
1731    */
1732   Vector<Vector2> GetTextSize(CharacterIndex startIndex, CharacterIndex endIndex);
1733
1734   /**
1735    * @brief Get the top/left rendered position of a specific text range.
1736    * if the requested text is at multilines, multiple positions will be returned for each text located in a separate line.
1737    * if a line contains characters with different directions, multiple positions will be returned for each block of contiguous characters with the same direction.
1738    *
1739    * @param[in] startIndex start index of the text requested to get position to.
1740    * @param[in] endIndex end index(included) of the text requested to get position to.
1741    * @return list of positions of the requested text.
1742    */
1743   Vector<Vector2> GetTextPosition(CharacterIndex startIndex, CharacterIndex endIndex);
1744
1745   /**
1746    * @brief Get the line bounding rectangle.
1747    * if the requested index is out of range or the line is not yet rendered, a rect of {0, 0, 0, 0} is returned.
1748    *
1749    * @param[in] lineIndex line index to which we want to calculate the geometry for.
1750    * @return bounding rectangle.
1751    */
1752   Rect<float> GetLineBoundingRectangle(const uint32_t lineIndex);
1753
1754   /**
1755    * @brief Get the char bounding rectangle.
1756    * If the text is not yet rendered or the index > text.Count(); a rect of {0, 0, 0, 0} is returned.
1757    *
1758    * @param[in] charIndex character index to which we want to calculate the geometry for.
1759    * @return bounding rectangle.
1760    */
1761   Rect<float> GetCharacterBoundingRectangle(const uint32_t charIndex);
1762
1763   /**
1764    * @brief Get the character index.
1765    * If the text is not yet rendered or the text is empty, -1 is returned.
1766    *
1767    * @param[in] visualX visual x position.
1768    * @param[in] visualY visual y position.
1769    * @return character index.
1770    */
1771   int GetCharacterIndexAtPosition(float visualX, float visualY);
1772
1773   /**
1774    * @brief Gets the bounding box of a specific text range.
1775    *
1776    * @param[in] startIndex start index of the text requested to get bounding box to.
1777    * @param[in] endIndex end index(included) of the text requested to get bounding box to.
1778    * @return bounding box of the requested text.
1779    */
1780   Rect<> GetTextBoundingRectangle(CharacterIndex startIndex, CharacterIndex endIndex);
1781
1782   /**
1783    * @brief Sets the layout direction changed.
1784    */
1785   void ChangedLayoutDirection();
1786
1787   /**
1788    * @brief Retrieves if showing real text or not.
1789    * @return The value of showing real text.
1790    */
1791   bool IsShowingRealText() const;
1792
1793 public: // Relayout.
1794   /**
1795    * @brief Triggers a relayout which updates View (if necessary).
1796    *
1797    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1798    * @param[in] size A the size of a bounding box to layout text within.
1799    * @param[in] layoutDirection The direction of the system language.
1800    *
1801    * @return Whether the text model or decorations were updated.
1802    */
1803   UpdateTextType Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT);
1804
1805   /**
1806    * @brief Request a relayout using the ControlInterface.
1807    */
1808   void RequestRelayout();
1809
1810 public: // Input style change signals.
1811   /**
1812    * @return Whether the queue of input style changed signals is empty.
1813    */
1814   bool IsInputStyleChangedSignalsQueueEmpty();
1815
1816   /**
1817    * @brief Process all pending input style changed signals.
1818    *
1819    * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1820    * text controls. Text controls may send signals to state the input style has changed.
1821    */
1822   void ProcessInputStyleChangedSignals();
1823
1824 public: // Text-input Event Queuing.
1825   /**
1826    * @brief Called by editable UI controls when keyboard focus is gained.
1827    */
1828   void KeyboardFocusGainEvent();
1829
1830   /**
1831    * @brief Called by editable UI controls when focus is lost.
1832    */
1833   void KeyboardFocusLostEvent();
1834
1835   /**
1836    * @brief Called by editable UI controls when key events are received.
1837    *
1838    * @param[in] event The key event.
1839    * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1840    */
1841   bool KeyEvent(const Dali::KeyEvent& event);
1842
1843   /**
1844    * @brief Called by anchor when a tap gesture occurs.
1845    * @param[in] x The x position relative to the top-left of the parent control.
1846    * @param[in] y The y position relative to the top-left of the parent control.
1847    */
1848   void AnchorEvent(float x, float y);
1849
1850   /**
1851    * @brief Called by editable UI controls when a tap gesture occurs.
1852    * @param[in] tapCount The number of taps.
1853    * @param[in] x The x position relative to the top-left of the parent control.
1854    * @param[in] y The y position relative to the top-left of the parent control.
1855    */
1856   void TapEvent(unsigned int tapCount, float x, float y);
1857
1858   /**
1859    * @brief Called by editable UI controls when a pan gesture occurs.
1860    *
1861    * @param[in] state The state of the gesture.
1862    * @param[in] displacement This distance panned since the last pan gesture.
1863    */
1864   void PanEvent(GestureState state, const Vector2& displacement);
1865
1866   /**
1867    * @brief Called by editable UI controls when a long press gesture occurs.
1868    *
1869    * @param[in] state The state of the gesture.
1870    * @param[in] x The x position relative to the top-left of the parent control.
1871    * @param[in] y The y position relative to the top-left of the parent control.
1872    */
1873   void LongPressEvent(GestureState state, float x, float y);
1874
1875   /**
1876    * @brief Used to get the Primary cursor position.
1877    *
1878    * @return Primary cursor position.
1879    */
1880   CharacterIndex GetPrimaryCursorPosition() const;
1881
1882   /**
1883    * @brief Used to set the Primary cursor position.
1884    *
1885    * @param[in] index for the Primary cursor position.
1886    * @param[in] focused true if UI control has gained focus to receive key event, false otherwise.
1887    * @return[in] true if cursor position changed, false otherwise.
1888    */
1889   bool SetPrimaryCursorPosition(CharacterIndex index, bool focused);
1890
1891   /**
1892    * @brief Creates a selection event.
1893    *
1894    * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1895    *
1896    * @param[in] x The x position relative to the top-left of the parent control.
1897    * @param[in] y The y position relative to the top-left of the parent control.
1898    * @param[in] selection type like the whole text is selected or unselected.
1899    */
1900   void SelectEvent(float x, float y, SelectionType selection);
1901
1902   /**
1903    * @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
1904    */
1905   void SetTextSelectionRange(const uint32_t* start, const uint32_t* end);
1906
1907   /**
1908    * @copydoc Text::SelectableControlInterface::GetTextSelectionRange()
1909    */
1910   Uint32Pair GetTextSelectionRange() const;
1911
1912   /**
1913    * @copydoc Text::SelectableControlInterface::SelectWholeText()
1914    */
1915   void SelectWholeText();
1916
1917   /**
1918    * @copydoc Text::EditableControlInterface::CopyText()
1919    */
1920   string CopyText();
1921
1922   /**
1923    * @copydoc Text::EditableControlInterface::CutText()
1924    */
1925   string CutText();
1926
1927   /**
1928    * @copydoc Text::EditableControlInterface::PasteText()
1929    */
1930   void PasteText();
1931
1932   /**
1933    * @copydoc Text::SelectableControlInterface::SelectNone()
1934    */
1935   void SelectNone();
1936
1937   /**
1938    * @copydoc Text::SelectableControlInterface::SelectText()
1939    */
1940   void SelectText(const uint32_t start, const uint32_t end);
1941
1942   /**
1943    * @copydoc Text::SelectableControlInterface::GetSelectedText()
1944    */
1945   string GetSelectedText() const;
1946
1947   /**
1948    * @copydoc Text::EditableControlInterface::IsEditable()
1949    */
1950   virtual bool IsEditable() const;
1951
1952   /**
1953    * @copydoc Text::EditableControlInterface::SetEditable()
1954    */
1955   virtual void SetEditable(bool editable);
1956
1957   /**
1958    * @copydoc Dali::Toolkit::Internal::TextEditor::ScrollBy()
1959    */
1960   virtual void ScrollBy(Vector2 scroll);
1961
1962   /**
1963    * @brief Whether the text is scrollable.
1964    * @return Returns true if the text is scrollable.
1965    */
1966   bool IsScrollable(const Vector2& displacement);
1967
1968   /**
1969    * @copydoc Dali::Toolkit::Internal::TextEditor::GetHorizontalScrollPosition()
1970    */
1971   float GetHorizontalScrollPosition();
1972
1973   /**
1974    * @copydoc Dali::Toolkit::Internal::TextEditor::GetVerticalScrollPosition()
1975    */
1976   float GetVerticalScrollPosition();
1977
1978   /**
1979    * @brief Event received from input method context
1980    *
1981    * @param[in] inputMethodContext The input method context.
1982    * @param[in] inputMethodContextEvent The event received.
1983    * @return A data struture indicating if update is needed, cursor position and current text.
1984    */
1985   InputMethodContext::CallbackData OnInputMethodContextEvent(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent);
1986
1987   /**
1988    * @brief Event from Clipboard notifying an Item has been selected for pasting
1989    */
1990   void PasteClipboardItemEvent();
1991
1992   /**
1993    * @brief Return true when text control should clear key input focus when escape key is pressed.
1994    *
1995    * @return Whether text control should clear key input focus or not when escape key is pressed.
1996    */
1997   bool ShouldClearFocusOnEscape() const;
1998
1999   /**
2000    * @brief Create an actor that renders the text background color
2001    *
2002    * @return the created actor or an empty handle if no background color needs to be rendered.
2003    */
2004   Actor CreateBackgroundActor();
2005
2006   /**
2007    * @brief Used to reset the cursor position after setting a new text.
2008    *
2009    * @param[in] cursorIndex Where to place the cursor.
2010    */
2011   void ResetCursorPosition(CharacterIndex cursorIndex);
2012
2013   /**
2014    * @brief The method acquires current position of cursor
2015    * @return unsigned value with cursor position
2016    */
2017   CharacterIndex GetCursorPosition();
2018
2019   /**
2020    * @brief Resets a provided vector with actors that marks the position of anchors in markup enabled text
2021    *
2022    * @param[out] anchorActors the vector of actor (empty collection if no anchors available).
2023    */
2024   void GetAnchorActors(std::vector<Toolkit::TextAnchor>& anchorActors);
2025
2026   /**
2027    * @brief Return an index of first anchor in the anchor vector whose boundaries includes given character offset
2028    *
2029    * @param[in] characterOffset A position in text coords.
2030    *
2031    * @return the index in anchor vector (-1 if an anchor not found)
2032    */
2033   int GetAnchorIndex(size_t characterOffset);
2034
2035 protected: // Inherit from Text::Decorator::ControllerInterface.
2036   /**
2037    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
2038    */
2039   void GetTargetSize(Vector2& targetSize) override;
2040
2041   /**
2042    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
2043    */
2044   void AddDecoration(Actor& actor, DecorationType type, bool needsClipping) override;
2045
2046   /**
2047    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
2048    */
2049   void DecorationEvent(HandleType handle, HandleState state, float x, float y) override;
2050
2051 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
2052   /**
2053    * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
2054    */
2055   void TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::Buttons button) override;
2056
2057 protected: // Inherit from HiddenText.
2058   /**
2059    * @brief Invoked from HiddenText when showing time of the last character was expired
2060    */
2061   void DisplayTimeExpired() override;
2062
2063 private: // Private contructors & copy operator.
2064   /**
2065    * @brief Private constructor.
2066    */
2067   Controller()
2068   : Controller(nullptr, nullptr, nullptr, nullptr)
2069   {
2070   }
2071
2072   /**
2073    * @brief Private constructor.
2074    */
2075   Controller(ControlInterface* controlInterface)
2076   : Controller(controlInterface, nullptr, nullptr, nullptr)
2077   {
2078   }
2079
2080   /**
2081    * @brief Private constructor.
2082    */
2083   Controller(ControlInterface*           controlInterface,
2084              EditableControlInterface*   editableControlInterface,
2085              SelectableControlInterface* selectableControlInterface,
2086              AnchorControlInterface*     anchorControlInterface);
2087
2088   Controller(const Controller& handle) = delete;
2089   Controller& operator=(const Controller& handle) = delete;
2090
2091 protected: // Destructor.
2092   /**
2093    * @brief A reference counted object may only be deleted by calling Unreference().
2094    */
2095   virtual ~Controller();
2096
2097 public:
2098   struct Impl; ///< Made public for testing purposes
2099
2100 private:
2101   struct EventHandler;
2102   struct InputFontHandler;
2103   struct InputProperties;
2104   struct PlaceholderHandler;
2105   struct Relayouter;
2106   struct TextUpdater;
2107   struct SpannableHandler;
2108
2109   std::unique_ptr<Impl> mImpl{nullptr};
2110 };
2111
2112 } // namespace Dali::Toolkit::Text
2113
2114 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H