db9d6cfb82a4dd2e405308bcc0dce9a229bf0851
[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 line size valid for text fit.
518    *
519    * @param[in] lineSize line size value
520    */
521   void SetTextFitLineSize(float lineSize);
522
523   /**
524    * @brief Sets disabled color opacity.
525    *
526    * @param[in] opacity The color opacity value in disabled state.
527    */
528   void SetDisabledColorOpacity(float opacity);
529
530   /**
531    * @brief Retrieves the disabled color opacity.
532    *
533    * @return The disabled color opacity value for disabled state.
534    */
535   float GetDisabledColorOpacity() const;
536
537   /**
538    * @brief Enable or disable the placeholder text elide.
539    * @param enabled Whether to enable the placeholder text elide.
540    */
541   void SetPlaceholderTextElideEnabled(bool enabled);
542
543   /**
544    * @brief Whether the placeholder text elide property is enabled.
545    * @return True if the placeholder text elide property is enabled, false otherwise.
546    */
547   bool IsPlaceholderTextElideEnabled() const;
548
549   /**
550    * @brief Enable or disable the text selection.
551    * @param[in] enabled Whether to enable the text selection.
552    */
553   void SetSelectionEnabled(bool enabled);
554
555   /**
556    * @brief Whether the text selection is enabled or not.
557    * @return True if the text selection is enabled
558    */
559   bool IsSelectionEnabled() const;
560
561   /**
562    * @brief Enable or disable the text selection using Shift key.
563    * @param enabled Whether to enable the text selection using Shift key
564    */
565   void SetShiftSelectionEnabled(bool enabled);
566
567   /**
568    * @brief Whether the text selection using Shift key is enabled or not.
569    * @return True if the text selection using Shift key is enabled
570    */
571   bool IsShiftSelectionEnabled() const;
572
573   /**
574    * @brief Enable or disable the grab handles for text selection.
575    *
576    * @param[in] enabled Whether to enable the grab handles
577    */
578   void SetGrabHandleEnabled(bool enabled);
579
580   /**
581    * @brief Returns whether the grab handles are enabled.
582    *
583    * @return True if the grab handles are enabled
584    */
585   bool IsGrabHandleEnabled() const;
586
587   /**
588    * @brief Enable or disable the grab handles for text selection.
589    *
590    * @param[in] enabled Whether to enable the grab handles
591    */
592   void SetGrabHandlePopupEnabled(bool enabled);
593
594   /**
595    * @brief Returns whether the grab handles are enabled.
596    *
597    * @return True if the grab handles are enabled
598    */
599   bool IsGrabHandlePopupEnabled() const;
600
601   /**
602    * @brief Sets input type to password
603    *
604    * @note The string is displayed hidden character
605    *
606    * @param[in] passwordInput True if password input is enabled.
607    */
608   void SetInputModePassword(bool passwordInput);
609
610   /**
611    * @brief Returns whether the input mode type is set as password.
612    *
613    * @return True if input mode type is password
614    */
615   bool IsInputModePassword();
616
617   /**
618    * @brief Sets the action when there is a double tap event on top of a text area with no text.
619    *
620    * @param[in] action The action to do.
621    */
622   void SetNoTextDoubleTapAction(NoTextTap::Action action);
623
624   /**
625    * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
626    *
627    * @return The action to do.
628    */
629   NoTextTap::Action GetNoTextDoubleTapAction() const;
630
631   /**
632    * @briefSets the action when there is a long press event on top of a text area with no text.
633    *
634    * @param[in] action The action to do.
635    */
636   void SetNoTextLongPressAction(NoTextTap::Action action);
637
638   /**
639    * @brief Retrieves the action when there is a long press event on top of a text area with no text.
640    *
641    * @return The action to do.
642    */
643   NoTextTap::Action GetNoTextLongPressAction() const;
644
645   /**
646    * @brief Query if Underline settings were provided by string or map
647    * @return bool true if set by string
648    */
649   bool IsUnderlineSetByString();
650
651   /**
652    * Set method underline setting were set by
653    * @param[in] bool, true if set by string
654    */
655   void UnderlineSetByString(bool setByString);
656
657   /**
658    * @brief Query if shadow settings were provided by string or map
659    * @return bool true if set by string
660    */
661   bool IsShadowSetByString();
662
663   /**
664    * Set method shadow setting were set by
665    * @param[in] bool, true if set by string
666    */
667   void ShadowSetByString(bool setByString);
668
669   /**
670    * @brief Query if outline settings were provided by string or map
671    * @return bool true if set by string
672    */
673   bool IsOutlineSetByString();
674
675   /**
676    * Set method outline setting were set by
677    * @param[in] bool, true if set by string
678    */
679   void OutlineSetByString(bool setByString);
680
681   /**
682    * @brief Query if font style settings were provided by string or map
683    * @return bool true if set by string
684    */
685   bool IsFontStyleSetByString();
686
687   /**
688    * Set method font style setting were set by
689    * @param[in] bool, true if set by string
690    */
691   void FontStyleSetByString(bool setByString);
692
693   /**
694    * @brief Query if Strikethrough settings were provided by string or map
695    * @return bool true if set by string
696    */
697   bool IsStrikethroughSetByString();
698
699   /**
700    * Set method Strikethrough setting were set by
701    * @param[in] bool, true if set by string
702    */
703   void StrikethroughSetByString(bool setByString);
704
705   /**
706    * @brief Set the override used for strikethrough height, 0 indicates height will be supplied by font metrics
707    *
708    * @param[in] height The height in pixels of the strikethrough
709    */
710   void SetStrikethroughHeight(float height);
711
712   /**
713    * @brief Retrieves the override height of an strikethrough, 0 indicates height is supplied by font metrics
714    *
715    * @return The height of the strikethrough, or 0 if height is not overrided.
716    */
717   float GetStrikethroughHeight() const;
718
719   /**
720    * @brief Set the strikethrough color.
721    *
722    * @param[in] color color of strikethrough.
723    */
724   void SetStrikethroughColor(const Vector4& color);
725
726   /**
727    * @brief Retrieve the strikethrough color.
728    *
729    * @return The strikethrough color.
730    */
731   const Vector4& GetStrikethroughColor() const;
732
733   /**
734    * @brief Set the strikethrough enabled flag.
735    *
736    * @param[in] enabled The strikethrough enabled flag.
737    */
738   void SetStrikethroughEnabled(bool enabled);
739
740   /**
741    * @brief Returns whether the text has a strikethrough or not.
742    *
743    * @return The strikethrough state.
744    */
745   bool IsStrikethroughEnabled() const;
746
747 public: // Update.
748   /**
749    * @brief Replaces any text previously set.
750    *
751    * @note This will be converted into UTF-32 when stored in the text model.
752    * @param[in] text A string of UTF-8 characters.
753    */
754   void SetText(const std::string& text);
755
756   /**
757    * @brief Retrieve any text previously set.
758    *
759    * @param[out] text A string of UTF-8 characters.
760    */
761   void GetText(std::string& text) const;
762
763   /**
764    * @brief Retrieves number of characters previously set.
765    *
766    * @return A length of string of UTF-32 characters.
767    */
768   Length GetNumberOfCharacters() const;
769
770   /**
771  * @brief Set the @p spannedText
772  * the spanned text contains content (text) and  format (spans with ranges)
773  * the text is copied into text-controller and the spans are applied on ranges
774  *
775  * @param[in] spannedText the text with spans.
776  */
777   void SetSpannedText(const Text::Spanned& spannedText);
778
779   /**
780    * @brief Replaces any placeholder text previously set.
781    *
782    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
783    * @param[in] text A string of UTF-8 characters.
784    */
785   void SetPlaceholderText(PlaceholderType type, const std::string& text);
786
787   /**
788    * @brief Retrieve any placeholder text previously set.
789    *
790    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
791    * @param[out] A string of UTF-8 characters.
792    */
793   void GetPlaceholderText(PlaceholderType type, std::string& text) const;
794
795   /**
796    * @ brief Update the text after a font change
797    * @param[in] newDefaultFont The new font to change to
798    */
799   void UpdateAfterFontChange(const std::string& newDefaultFont);
800
801   /**
802    * @brief The method acquires currently selected text
803    * @param selectedText variable to place selected text in
804    */
805   void RetrieveSelection(std::string& selectedText) const;
806
807   /**
808    * @brief The method sets selection in given range
809    * @param start index of first character
810    * @param end   index of first character after selection
811    */
812   void SetSelection(int start, int end);
813
814   /**
815    * @brief This method retrieve indexes of current selection
816    *
817    * @return a pair, where first element is left index of selection and second is the right one
818    */
819   std::pair<int, int> GetSelectionIndexes() const;
820
821   /**
822    * Place string in system clipboard
823    * @param source std::string
824    */
825   void CopyStringToClipboard(const std::string& source);
826
827   /**
828    * Place currently selected text in system clipboard
829    * @param deleteAfterSending flag pointing if text should be deleted after sending to clipboard
830    */
831   void SendSelectionToClipboard(bool deleteAfterSending);
832
833 public: // Default style & Input style
834   /**
835    * @brief Set the default font family.
836    *
837    * @param[in] defaultFontFamily The default font family.
838    */
839   void SetDefaultFontFamily(const std::string& defaultFontFamily);
840
841   /**
842    * @brief Retrieve the default font family.
843    *
844    * @return The default font family.
845    */
846   std::string GetDefaultFontFamily() const;
847
848   /**
849    * @brief Sets the placeholder text font family.
850    * @param[in] placeholderTextFontFamily The placeholder text font family.
851    */
852   void SetPlaceholderFontFamily(const std::string& placeholderTextFontFamily);
853
854   /**
855    * @brief Retrieves the placeholder text font family.
856    *
857    * @return The placeholder text font family
858    */
859   std::string GetPlaceholderFontFamily() const;
860
861   /**
862    * @brief Sets the default font weight.
863    *
864    * @param[in] weight The font weight.
865    */
866   void SetDefaultFontWeight(FontWeight weight);
867
868   /**
869    * @brief Whether the font's weight has been defined.
870    */
871   bool IsDefaultFontWeightDefined() const;
872
873   /**
874    * @brief Retrieves the default font weight.
875    *
876    * @return The default font weight.
877    */
878   FontWeight GetDefaultFontWeight() const;
879
880   /**
881    * @brief Sets the placeholder text font weight.
882    *
883    * @param[in] weight The font weight
884    */
885   void SetPlaceholderTextFontWeight(FontWeight weight);
886
887   /**
888    * @brief Whether the font's weight has been defined.
889    *
890    * @return True if the placeholder text font weight is defined
891    */
892   bool IsPlaceholderTextFontWeightDefined() const;
893
894   /**
895    * @brief Retrieves the placeholder text font weight.
896    *
897    * @return The placeholder text font weight
898    */
899   FontWeight GetPlaceholderTextFontWeight() const;
900
901   /**
902    * @brief Sets the default font width.
903    *
904    * @param[in] width The font width.
905    */
906   void SetDefaultFontWidth(FontWidth width);
907
908   /**
909    * @brief Whether the font's width has been defined.
910    */
911   bool IsDefaultFontWidthDefined() const;
912
913   /**
914    * @brief Retrieves the default font width.
915    *
916    * @return The default font width.
917    */
918   FontWidth GetDefaultFontWidth() const;
919
920   /**
921    * @brief Sets the placeholder text font width.
922    *
923    * @param[in] width The font width
924    */
925   void SetPlaceholderTextFontWidth(FontWidth width);
926
927   /**
928    * @brief Whether the font's width has been defined.
929    *
930    * @return True if the placeholder text font width is defined
931    */
932   bool IsPlaceholderTextFontWidthDefined() const;
933
934   /**
935    * @brief Retrieves the placeholder text font width.
936    *
937    * @return The placeholder text font width
938    */
939   FontWidth GetPlaceholderTextFontWidth() const;
940
941   /**
942    * @brief Sets the default font slant.
943    *
944    * @param[in] slant The font slant.
945    */
946   void SetDefaultFontSlant(FontSlant slant);
947
948   /**
949    * @brief Whether the font's slant has been defined.
950    */
951   bool IsDefaultFontSlantDefined() const;
952
953   /**
954    * @brief Retrieves the default font slant.
955    *
956    * @return The default font slant.
957    */
958   FontSlant GetDefaultFontSlant() const;
959
960   /**
961    * @brief Sets the placeholder text font slant.
962    *
963    * @param[in] slant The font slant
964    */
965   void SetPlaceholderTextFontSlant(FontSlant slant);
966
967   /**
968    * @brief Whether the font's slant has been defined.
969    *
970    * @return True if the placeholder text font slant is defined
971    */
972   bool IsPlaceholderTextFontSlantDefined() const;
973
974   /**
975    * @brief Retrieves the placeholder text font slant.
976    *
977    * @return The placeholder text font slant
978    */
979   FontSlant GetPlaceholderTextFontSlant() const;
980
981   /**
982    * @brief Set the default font size.
983    *
984    * @param[in] fontSize The default font size
985    * @param[in] type The font size type is point size or pixel size
986    */
987   void SetDefaultFontSize(float fontSize, FontSizeType type);
988
989   /**
990    * @brief Retrieve the default point size.
991    *
992    * @param[in] type The font size type
993    * @return The default point size.
994    */
995   float GetDefaultFontSize(FontSizeType type) const;
996
997   /**
998    * @brief Set the font size scale.
999    *
1000    * @param[in] scale The font size scale
1001    */
1002   void SetFontSizeScale(float scale);
1003
1004   /**
1005    * @brief Get the font size scale.
1006    *
1007    * @return The font size scale.
1008    */
1009   float GetFontSizeScale() const;
1010
1011   /**
1012    * @brief Set the font size scale enabled flag.
1013    *
1014    * @param[in] enabled whether to enable the font size scale.
1015    */
1016   void SetFontSizeScaleEnabled(bool enabled);
1017
1018   /**
1019    * @brief Returns whether the font size scale is enabled or not.
1020    *
1021    * @return @e true if the font size scale is enabled, otherwise returns @e false.
1022    */
1023   bool IsFontSizeScaleEnabled() const;
1024
1025   /**
1026    * @brief Sets the Placeholder text font size.
1027    * @param[in] fontSize The placeholder text font size
1028    * @param[in] type The font size type is point size or pixel size
1029    */
1030   void SetPlaceholderTextFontSize(float fontSize, FontSizeType type);
1031
1032   /**
1033    * @brief Retrieves the Placeholder text font size.
1034    * @param[in] type The font size type
1035    * @return The placeholder font size
1036    */
1037   float GetPlaceholderTextFontSize(FontSizeType type) const;
1038
1039   /**
1040    * @brief Sets the text's default color.
1041    *
1042    * @param color The default color.
1043    */
1044   void SetDefaultColor(const Vector4& color);
1045
1046   /**
1047    * @brief Retrieves the text's default color.
1048    *
1049    * @return The default color.
1050    */
1051   const Vector4& GetDefaultColor() const;
1052
1053   /**
1054    * @brief Sets the user interaction enabled.
1055    *
1056    * @param enabled whether to enable the user interaction.
1057    */
1058   void SetUserInteractionEnabled(bool enabled);
1059
1060   /**
1061    * @brief Whether the user interaction is enabled.
1062    *
1063    * @return true if the user interaction is enabled, false otherwise.
1064    */
1065   bool IsUserInteractionEnabled() const;
1066
1067   /**
1068    * @brief Set the text color
1069    *
1070    * @param textColor The text color
1071    */
1072   void SetPlaceholderTextColor(const Vector4& textColor);
1073
1074   /**
1075    * @brief Retrieve the text color
1076    *
1077    * @return The text color
1078    */
1079   const Vector4& GetPlaceholderTextColor() const;
1080
1081   /**
1082    * @brief Set the shadow offset.
1083    *
1084    * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
1085    */
1086   void SetShadowOffset(const Vector2& shadowOffset);
1087
1088   /**
1089    * @brief Retrieve the shadow offset.
1090    *
1091    * @return The shadow offset.
1092    */
1093   const Vector2& GetShadowOffset() const;
1094
1095   /**
1096    * @brief Set the shadow color.
1097    *
1098    * @param[in] shadowColor The shadow color.
1099    */
1100   void SetShadowColor(const Vector4& shadowColor);
1101
1102   /**
1103    * @brief Retrieve the shadow color.
1104    *
1105    * @return The shadow color.
1106    */
1107   const Vector4& GetShadowColor() const;
1108
1109   /**
1110    * @brief Set the shadow blur radius.
1111    *
1112    * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
1113    */
1114   void SetShadowBlurRadius(const float& shadowBlurRadius);
1115
1116   /**
1117    * @brief Retrieve the shadow blur radius.
1118    *
1119    * @return The shadow blur radius.
1120    */
1121   const float& GetShadowBlurRadius() const;
1122
1123   /**
1124    * @brief Set the underline color.
1125    *
1126    * @param[in] color color of underline.
1127    */
1128   void SetUnderlineColor(const Vector4& color);
1129
1130   /**
1131    * @brief Retrieve the underline color.
1132    *
1133    * @return The underline color.
1134    */
1135   const Vector4& GetUnderlineColor() const;
1136
1137   /**
1138    * @brief Set the underline enabled flag.
1139    *
1140    * @param[in] enabled The underline enabled flag.
1141    */
1142   void SetUnderlineEnabled(bool enabled);
1143
1144   /**
1145    * @brief Returns whether the text is underlined or not.
1146    *
1147    * @return The underline state.
1148    */
1149   bool IsUnderlineEnabled() const;
1150
1151   /**
1152    * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
1153    *
1154    * @param[in] height The height in pixels of the underline
1155    */
1156   void SetUnderlineHeight(float height);
1157
1158   /**
1159    * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
1160    *
1161    * @return The height of the underline, or 0 if height is not overrided.
1162    */
1163   float GetUnderlineHeight() const;
1164
1165   /**
1166    * @brief Sets the underline type.
1167    * @param[in] type The underline type.
1168    */
1169   void SetUnderlineType(Text::Underline::Type type);
1170
1171   /**
1172    * @brief Retrieve underline type.
1173    * @return The underline type.
1174    */
1175   Text::Underline::Type GetUnderlineType() const;
1176
1177   /**
1178    * @brief Set the width of the dashes of the dashed underline.
1179    *
1180    * @param[in] width The width in pixels of the dashes of the dashed underline.
1181    */
1182   void SetDashedUnderlineWidth(float width);
1183
1184   /**
1185    * @brief Retrieves the width of the dashes of the dashed underline.
1186    *
1187    * @return The width of the dashes of the dashed underline.
1188    */
1189   float GetDashedUnderlineWidth() const;
1190
1191   /**
1192    * @brief Set the gap between the dashes of the dashed underline.
1193    *
1194    * @param[in] gap The gap between the dashes of the dashed underline.
1195    */
1196   void SetDashedUnderlineGap(float gap);
1197
1198   /**
1199    * @brief Retrieves the gap between the dashes of the dashed underline.
1200    *
1201    * @return The The gap between the dashes of the dashed underline.
1202    */
1203   float GetDashedUnderlineGap() const;
1204
1205   /**
1206    * @brief Set the outline color.
1207    *
1208    * @param[in] color color of outline.
1209    */
1210   void SetOutlineColor(const Vector4& color);
1211
1212   /**
1213    * @brief Retrieve the outline color.
1214    *
1215    * @return The outline color.
1216    */
1217   const Vector4& GetOutlineColor() const;
1218
1219   /**
1220    * @brief Set the outline width
1221    *
1222    * @param[in] width The width in pixels of the outline, 0 indicates no outline
1223    */
1224   void SetOutlineWidth(uint16_t width);
1225
1226   /**
1227    * @brief Retrieves the width of an outline
1228    *
1229    * @return The width of the outline.
1230    */
1231   uint16_t GetOutlineWidth() const;
1232
1233   /**
1234    * @brief Set the background color.
1235    *
1236    * @param[in] color color of background.
1237    */
1238   void SetBackgroundColor(const Vector4& color);
1239
1240   /**
1241    * @brief Retrieve the background color.
1242    *
1243    * @return The background color.
1244    */
1245   const Vector4& GetBackgroundColor() const;
1246
1247   /**
1248    * @brief Set the background enabled flag.
1249    *
1250    * @param[in] enabled The background enabled flag.
1251    */
1252   void SetBackgroundEnabled(bool enabled);
1253
1254   /**
1255    * @brief Returns whether to enable text background or not.
1256    *
1257    * @return Whether text background is enabled.
1258    */
1259   bool IsBackgroundEnabled() const;
1260
1261   /**
1262    * @brief Sets the emboss's properties string.
1263    *
1264    * @note The string is stored to be recovered.
1265    *
1266    * @param[in] embossProperties The emboss's properties string.
1267    */
1268   void SetDefaultEmbossProperties(const std::string& embossProperties);
1269
1270   /**
1271    * @brief Retrieves the emboss's properties string.
1272    *
1273    * @return The emboss's properties string.
1274    */
1275   std::string GetDefaultEmbossProperties() const;
1276
1277   /**
1278    * @brief Sets the outline's properties string.
1279    *
1280    * @note The string is stored to be recovered.
1281    *
1282    * @param[in] outlineProperties The outline's properties string.
1283    */
1284   void SetDefaultOutlineProperties(const std::string& outlineProperties);
1285
1286   /**
1287    * @brief Retrieves the outline's properties string.
1288    *
1289    * @return The outline's properties string.
1290    */
1291   std::string GetDefaultOutlineProperties() const;
1292
1293   /**
1294    * @brief Sets the default line spacing.
1295    *
1296    * @param[in] lineSpacing The line spacing.
1297    *
1298    * @return True if lineSpacing has been updated, false otherwise
1299    */
1300   bool SetDefaultLineSpacing(float lineSpacing);
1301
1302   /**
1303    * @brief Retrieves the default line spacing.
1304    *
1305    * @return The line spacing.
1306    */
1307   float GetDefaultLineSpacing() const;
1308
1309   /**
1310    * @brief Sets the default line size.
1311    *
1312    * @param[in] lineSize The line size.
1313    *
1314    * @return True if lineSize has been updated, false otherwise
1315    */
1316   bool SetDefaultLineSize(float lineSize);
1317
1318   /**
1319    * @brief Retrieves the default line size.
1320    *
1321    * @return The line size.
1322    */
1323   float GetDefaultLineSize() const;
1324
1325   /**
1326    * @brief Sets the relative line size to the original line size.
1327    *
1328    * @param[in] relativeLineSize The relativeline size.
1329    *
1330    * @return True if relativeLineSize has been updated, false otherwise
1331    */
1332   bool SetRelativeLineSize(float lineSize);
1333
1334   /**
1335    * @brief Retrieves the relative line size.
1336    *
1337    * @return The relative line size.
1338    */
1339   float GetRelativeLineSize() const;
1340
1341   /**
1342    * @brief Sets the input text's color.
1343    *
1344    * @param[in] color The input text's color.
1345    */
1346   void SetInputColor(const Vector4& color);
1347
1348   /**
1349    * @brief Retrieves the input text's color.
1350    *
1351    * @return The input text's color.
1352    */
1353   const Vector4& GetInputColor() const;
1354
1355   /**
1356    * @brief Sets the input text's font family name.
1357    *
1358    * @param[in] fontFamily The text's font family name.
1359    */
1360   void SetInputFontFamily(const std::string& fontFamily);
1361
1362   /**
1363    * @brief Retrieves the input text's font family name.
1364    *
1365    * @return The input text's font family name.
1366    */
1367   std::string GetInputFontFamily() const;
1368
1369   /**
1370    * @brief Sets the input font's weight.
1371    *
1372    * @param[in] weight The input font's weight.
1373    */
1374   void SetInputFontWeight(FontWeight weight);
1375
1376   /**
1377    * @return Whether the font's weight has been defined.
1378    */
1379   bool IsInputFontWeightDefined() const;
1380
1381   /**
1382    * @brief Retrieves the input font's weight.
1383    *
1384    * @return The input font's weight.
1385    */
1386   FontWeight GetInputFontWeight() const;
1387
1388   /**
1389    * @brief Sets the input font's width.
1390    *
1391    * @param[in] width The input font's width.
1392    */
1393   void SetInputFontWidth(FontWidth width);
1394
1395   /**
1396    * @return Whether the font's width has been defined.
1397    */
1398   bool IsInputFontWidthDefined() const;
1399
1400   /**
1401    * @brief Retrieves the input font's width.
1402    *
1403    * @return The input font's width.
1404    */
1405   FontWidth GetInputFontWidth() const;
1406
1407   /**
1408    * @brief Sets the input font's slant.
1409    *
1410    * @param[in] slant The input font's slant.
1411    */
1412   void SetInputFontSlant(FontSlant slant);
1413
1414   /**
1415    * @return Whether the font's slant has been defined.
1416    */
1417   bool IsInputFontSlantDefined() const;
1418
1419   /**
1420    * @brief Retrieves the input font's slant.
1421    *
1422    * @return The input font's slant.
1423    */
1424   FontSlant GetInputFontSlant() const;
1425
1426   /**
1427    * @brief Sets the input font's point size.
1428    *
1429    * @param[in] size The input font's point size.
1430    */
1431   void SetInputFontPointSize(float size);
1432
1433   /**
1434    * @brief Retrieves the input font's point size.
1435    *
1436    * @return The input font's point size.
1437    */
1438   float GetInputFontPointSize() const;
1439
1440   /**
1441    * @brief Sets the input line spacing.
1442    *
1443    * @param[in] lineSpacing The line spacing.
1444    */
1445   void SetInputLineSpacing(float lineSpacing);
1446
1447   /**
1448    * @brief Retrieves the input line spacing.
1449    *
1450    * @return The line spacing.
1451    */
1452   float GetInputLineSpacing() const;
1453
1454   /**
1455    * @brief Sets the input shadow's properties string.
1456    *
1457    * @note The string is stored to be recovered.
1458    *
1459    * @param[in] shadowProperties The shadow's properties string.
1460    */
1461   void SetInputShadowProperties(const std::string& shadowProperties);
1462
1463   /**
1464    * @brief Retrieves the input shadow's properties string.
1465    *
1466    * @return The shadow's properties string.
1467    */
1468   std::string GetInputShadowProperties() const;
1469
1470   /**
1471    * @brief Sets the input underline's properties string.
1472    *
1473    * @note The string is stored to be recovered.
1474    *
1475    * @param[in] underlineProperties The underline's properties string.
1476    */
1477   void SetInputUnderlineProperties(const std::string& underlineProperties);
1478
1479   /**
1480    * @brief Retrieves the input underline's properties string.
1481    *
1482    * @return The underline's properties string.
1483    */
1484   std::string GetInputUnderlineProperties() const;
1485
1486   /**
1487    * @brief Sets the input emboss's properties string.
1488    *
1489    * @note The string is stored to be recovered.
1490    *
1491    * @param[in] embossProperties The emboss's properties string.
1492    */
1493   void SetInputEmbossProperties(const std::string& embossProperties);
1494
1495   /**
1496    * @brief Retrieves the input emboss's properties string.
1497    *
1498    * @return The emboss's properties string.
1499    */
1500   std::string GetInputEmbossProperties() const;
1501
1502   /**
1503    * @brief Sets input the outline's properties string.
1504    *
1505    * @note The string is stored to be recovered.
1506    *
1507    * @param[in] outlineProperties The outline's properties string.
1508    */
1509   void SetInputOutlineProperties(const std::string& outlineProperties);
1510
1511   /**
1512    * @brief Retrieves the input outline's properties string.
1513    *
1514    * @return The outline's properties string.
1515    */
1516   std::string GetInputOutlineProperties() const;
1517
1518   /**
1519    * @brief Sets the input strikethrough's properties string.
1520    *
1521    * @note The string is stored to be recovered.
1522    *
1523    * @param[in] strikethroughProperties The strikethrough's properties string.
1524    */
1525   void SetInputStrikethroughProperties(const std::string& strikethroughProperties);
1526
1527   /**
1528    * @brief Retrieves the input strikethrough's properties string.
1529    *
1530    * @return The strikethrough's properties string.
1531    */
1532   std::string GetInputStrikethroughProperties() const;
1533
1534   /**
1535    * @brief Set the control's interface.
1536    *
1537    * @param[in] controlInterface The control's interface.
1538    */
1539   void SetControlInterface(ControlInterface* controlInterface);
1540
1541   /**
1542    * @brief Set the anchor control's interface.
1543    *
1544    * @param[in] anchorControlInterface The control's interface.
1545    */
1546   void SetAnchorControlInterface(AnchorControlInterface* anchorControlInterface);
1547
1548   /**
1549    * @brief Sets the character spacing.
1550    *
1551    * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
1552    *
1553    * @param[in] characterSpacing The character spacing.
1554    */
1555   void SetCharacterSpacing(float characterSpacing);
1556
1557   /**
1558    * @brief Retrieves the character spacing.
1559    *
1560    * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
1561    *
1562    * @return The character spacing.
1563    */
1564   const float GetCharacterSpacing() const;
1565
1566 public: // Queries & retrieves.
1567   /**
1568    * @brief Return the layout engine.
1569    *
1570    * @return A reference to the layout engine.
1571    */
1572   Layout::Engine& GetLayoutEngine();
1573
1574   /**
1575    * @brief Return a view of the text.
1576    *
1577    * @return A reference to the view.
1578    */
1579   View& GetView();
1580
1581   /**
1582    * @copydoc Control::GetNaturalSize()
1583    */
1584   Vector3 GetNaturalSize();
1585
1586   /**
1587    * @copydoc Control::GetHeightForWidth()
1588    */
1589   float GetHeightForWidth(float width);
1590
1591   /**
1592    * @brief Calculates the point size for text for given layout()
1593    */
1594   void FitPointSizeforLayout(Size layoutSize);
1595
1596   /**
1597    * @brief Checks if the point size fits within the layout size.
1598    *
1599    * @return Whether the point size fits within the layout size.
1600    */
1601   bool CheckForTextFit(float pointSize, Size& layoutSize);
1602
1603   /**
1604    * @brief Retrieves the text's number of lines for a given width.
1605    * @param[in] width The width of the text's area.
1606    * @ return The number of lines.
1607    */
1608   int GetLineCount(float width);
1609
1610   /**
1611    * @brief Retrieves the text's model.
1612    *
1613    * @return A pointer to the text's model.
1614    */
1615   const ModelInterface* GetTextModel() const;
1616
1617   /**
1618    * @brief Used to get scrolled distance by user input
1619    *
1620    * @return Distance from last scroll offset to new scroll offset
1621    */
1622   float GetScrollAmountByUserInput();
1623
1624   /**
1625    * @brief Get latest scroll amount, control size and layout size
1626    *
1627    * This method is used to get information of control's scroll
1628    * @param[out] scrollPosition The current scrolled position
1629    * @param[out] controlHeight The size of a UI control
1630    * @param[out] layoutHeight The size of a bounding box to layout text within.
1631    *
1632    * @return Whether the text scroll position is changed or not after last update.
1633    */
1634   bool GetTextScrollInfo(float& scrollPosition, float& controlHeight, float& layoutHeight);
1635
1636   /**
1637    * @brief Used to set the hidden input option
1638    */
1639   void SetHiddenInputOption(const Property::Map& options);
1640
1641   /**
1642    * @brief Used to get the hidden input option
1643    */
1644   void GetHiddenInputOption(Property::Map& options);
1645
1646   /**
1647    * @brief Used to set the input filter option
1648    */
1649   void SetInputFilterOption(const Property::Map& options);
1650
1651   /**
1652    * @brief Used to get the input filter option
1653    */
1654   void GetInputFilterOption(Property::Map& options);
1655
1656   /**
1657    * @brief Sets the Placeholder Properties.
1658    *
1659    * @param[in] map The placeholder property map
1660    */
1661   void SetPlaceholderProperty(const Property::Map& map);
1662
1663   /**
1664    * @brief Retrieves the Placeholder Property map.
1665    *
1666    * @param[out] map The property map
1667    */
1668   void GetPlaceholderProperty(Property::Map& map);
1669
1670   /**
1671    * @brief Checks text direction.
1672    * @return The text direction.
1673    */
1674   Toolkit::DevelText::TextDirection::Type GetTextDirection();
1675
1676   /**
1677    * @brief Retrieves vertical line alignment
1678    * @return The vertical line alignment
1679    */
1680   Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1681
1682   /**
1683    * @brief Sets vertical line alignment
1684    * @param[in] alignment The vertical line alignment for the text
1685    */
1686   void SetVerticalLineAlignment(Toolkit::DevelText::VerticalLineAlignment::Type alignment);
1687
1688   /**
1689    * @brief Retrieves ellipsis position
1690    * @return The ellipsis position
1691    */
1692   Toolkit::DevelText::EllipsisPosition::Type GetEllipsisPosition() const;
1693
1694   /**
1695    * @brief Sets ellipsis position
1696    * @param[in] ellipsisPosition The ellipsis position for the text
1697    */
1698   void SetEllipsisPosition(Toolkit::DevelText::EllipsisPosition::Type ellipsisPosition);
1699
1700   /**
1701    * @brief Retrieves ignoreSpaceAfterText value from model
1702    * @return The value of ignoreSpaceAfterText
1703    */
1704   bool IsIgnoreSpacesAfterText() const;
1705
1706   /**
1707    * @brief Sets ignoreSpaceAfterText value to model
1708    * @param[in] ignore The value of ignoreSpacesAfterText for the text
1709    */
1710   void SetIgnoreSpacesAfterText(bool ignore);
1711
1712   /**
1713    * @brief Sets SetMatchLayoutDirection value to model
1714    * @param[in] match The value of matchLayoutDirection for the text
1715    */
1716   void SetMatchLayoutDirection(DevelText::MatchLayoutDirection type);
1717
1718   /**
1719    * @brief Retrieves matchLayoutDirection value from model
1720    * @return The value of matchLayoutDirection
1721    */
1722   DevelText::MatchLayoutDirection GetMatchLayoutDirection() const;
1723
1724   /**
1725    * @brief Sets layoutDirection type value.
1726    * @param[in] layoutDirection The value of the layout direction type.
1727    */
1728   void SetLayoutDirection(Dali::LayoutDirection::Type layoutDirection);
1729
1730   /**
1731    * @brief Gets layoutDirection type value.
1732    * @param[in] actor The actor which will get the layout direction type.
1733    * @return The value of the layout direction type.
1734    */
1735   Dali::LayoutDirection::Type GetLayoutDirection(Dali::Actor& actor) const;
1736
1737   /**
1738    * @brief Get the rendered size of a specific text range.
1739    * if the requested text is at multilines, multiple sizes will be returned for each text located in a separate line.
1740    * if a line contains characters with different directions, multiple sizes will be returned for each block of contiguous characters with the same direction.
1741    *
1742    * @param[in] startIndex start index of the text requested to calculate size for.
1743    * @param[in] endIndex end index(included) of the text requested to calculate size for.
1744    * @return list of sizes of the reuested text.
1745    */
1746   Vector<Vector2> GetTextSize(CharacterIndex startIndex, CharacterIndex endIndex);
1747
1748   /**
1749    * @brief Get the top/left rendered position of a specific text range.
1750    * if the requested text is at multilines, multiple positions will be returned for each text located in a separate line.
1751    * if a line contains characters with different directions, multiple positions will be returned for each block of contiguous characters with the same direction.
1752    *
1753    * @param[in] startIndex start index of the text requested to get position to.
1754    * @param[in] endIndex end index(included) of the text requested to get position to.
1755    * @return list of positions of the requested text.
1756    */
1757   Vector<Vector2> GetTextPosition(CharacterIndex startIndex, CharacterIndex endIndex);
1758
1759   /**
1760    * @brief Get the line bounding rectangle.
1761    * if the requested index is out of range or the line is not yet rendered, a rect of {0, 0, 0, 0} is returned.
1762    *
1763    * @param[in] lineIndex line index to which we want to calculate the geometry for.
1764    * @return bounding rectangle.
1765    */
1766   Rect<float> GetLineBoundingRectangle(const uint32_t lineIndex);
1767
1768   /**
1769    * @brief Get the char bounding rectangle.
1770    * If the text is not yet rendered or the index > text.Count(); a rect of {0, 0, 0, 0} is returned.
1771    *
1772    * @param[in] charIndex character index to which we want to calculate the geometry for.
1773    * @return bounding rectangle.
1774    */
1775   Rect<float> GetCharacterBoundingRectangle(const uint32_t charIndex);
1776
1777   /**
1778    * @brief Get the character index.
1779    * If the text is not yet rendered or the text is empty, -1 is returned.
1780    *
1781    * @param[in] visualX visual x position.
1782    * @param[in] visualY visual y position.
1783    * @return character index.
1784    */
1785   int GetCharacterIndexAtPosition(float visualX, float visualY);
1786
1787   /**
1788    * @brief Gets the bounding box of a specific text range.
1789    *
1790    * @param[in] startIndex start index of the text requested to get bounding box to.
1791    * @param[in] endIndex end index(included) of the text requested to get bounding box to.
1792    * @return bounding box of the requested text.
1793    */
1794   Rect<> GetTextBoundingRectangle(CharacterIndex startIndex, CharacterIndex endIndex);
1795
1796   /**
1797    * @brief Sets the layout direction changed.
1798    */
1799   void ChangedLayoutDirection();
1800
1801   /**
1802    * @brief Retrieves if showing real text or not.
1803    * @return The value of showing real text.
1804    */
1805   bool IsShowingRealText() const;
1806
1807 public: // Relayout.
1808   /**
1809    * @brief Triggers a relayout which updates View (if necessary).
1810    *
1811    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1812    * @param[in] size A the size of a bounding box to layout text within.
1813    * @param[in] layoutDirection The direction of the system language.
1814    *
1815    * @return Whether the text model or decorations were updated.
1816    */
1817   UpdateTextType Relayout(const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT);
1818
1819   /**
1820    * @brief Request a relayout using the ControlInterface.
1821    */
1822   void RequestRelayout();
1823
1824 public: // Input style change signals.
1825   /**
1826    * @return Whether the queue of input style changed signals is empty.
1827    */
1828   bool IsInputStyleChangedSignalsQueueEmpty();
1829
1830   /**
1831    * @brief Process all pending input style changed signals.
1832    *
1833    * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1834    * text controls. Text controls may send signals to state the input style has changed.
1835    */
1836   void ProcessInputStyleChangedSignals();
1837
1838 public: // Text-input Event Queuing.
1839   /**
1840    * @brief Called by editable UI controls when keyboard focus is gained.
1841    */
1842   void KeyboardFocusGainEvent();
1843
1844   /**
1845    * @brief Called by editable UI controls when focus is lost.
1846    */
1847   void KeyboardFocusLostEvent();
1848
1849   /**
1850    * @brief Called by editable UI controls when key events are received.
1851    *
1852    * @param[in] event The key event.
1853    * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1854    */
1855   bool KeyEvent(const Dali::KeyEvent& event);
1856
1857   /**
1858    * @brief Called by anchor when a tap gesture occurs.
1859    * @param[in] x The x position relative to the top-left of the parent control.
1860    * @param[in] y The y position relative to the top-left of the parent control.
1861    */
1862   void AnchorEvent(float x, float y);
1863
1864   /**
1865    * @brief Called by editable UI controls when a tap gesture occurs.
1866    * @param[in] tapCount The number of taps.
1867    * @param[in] x The x position relative to the top-left of the parent control.
1868    * @param[in] y The y position relative to the top-left of the parent control.
1869    */
1870   void TapEvent(unsigned int tapCount, float x, float y);
1871
1872   /**
1873    * @brief Called by editable UI controls when a pan gesture occurs.
1874    *
1875    * @param[in] state The state of the gesture.
1876    * @param[in] displacement This distance panned since the last pan gesture.
1877    */
1878   void PanEvent(GestureState state, const Vector2& displacement);
1879
1880   /**
1881    * @brief Called by editable UI controls when a long press gesture occurs.
1882    *
1883    * @param[in] state The state of the gesture.
1884    * @param[in] x The x position relative to the top-left of the parent control.
1885    * @param[in] y The y position relative to the top-left of the parent control.
1886    */
1887   void LongPressEvent(GestureState state, float x, float y);
1888
1889   /**
1890    * @brief Used to get the Primary cursor position.
1891    *
1892    * @return Primary cursor position.
1893    */
1894   CharacterIndex GetPrimaryCursorPosition() const;
1895
1896   /**
1897    * @brief Used to set the Primary cursor position.
1898    *
1899    * @param[in] index for the Primary cursor position.
1900    * @param[in] focused true if UI control has gained focus to receive key event, false otherwise.
1901    * @return[in] true if cursor position changed, false otherwise.
1902    */
1903   bool SetPrimaryCursorPosition(CharacterIndex index, bool focused);
1904
1905   /**
1906    * @brief Creates a selection event.
1907    *
1908    * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1909    *
1910    * @param[in] x The x position relative to the top-left of the parent control.
1911    * @param[in] y The y position relative to the top-left of the parent control.
1912    * @param[in] selection type like the whole text is selected or unselected.
1913    */
1914   void SelectEvent(float x, float y, SelectionType selection);
1915
1916   /**
1917    * @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
1918    */
1919   void SetTextSelectionRange(const uint32_t* start, const uint32_t* end);
1920
1921   /**
1922    * @copydoc Text::SelectableControlInterface::GetTextSelectionRange()
1923    */
1924   Uint32Pair GetTextSelectionRange() const;
1925
1926   /**
1927    * @copydoc Text::SelectableControlInterface::SelectWholeText()
1928    */
1929   void SelectWholeText();
1930
1931   /**
1932    * @copydoc Text::EditableControlInterface::CopyText()
1933    */
1934   string CopyText();
1935
1936   /**
1937    * @copydoc Text::EditableControlInterface::CutText()
1938    */
1939   string CutText();
1940
1941   /**
1942    * @copydoc Text::EditableControlInterface::PasteText()
1943    */
1944   void PasteText();
1945
1946   /**
1947    * @copydoc Text::SelectableControlInterface::SelectNone()
1948    */
1949   void SelectNone();
1950
1951   /**
1952    * @copydoc Text::SelectableControlInterface::SelectText()
1953    */
1954   void SelectText(const uint32_t start, const uint32_t end);
1955
1956   /**
1957    * @copydoc Text::SelectableControlInterface::GetSelectedText()
1958    */
1959   string GetSelectedText() const;
1960
1961   /**
1962    * @copydoc Text::EditableControlInterface::IsEditable()
1963    */
1964   virtual bool IsEditable() const;
1965
1966   /**
1967    * @copydoc Text::EditableControlInterface::SetEditable()
1968    */
1969   virtual void SetEditable(bool editable);
1970
1971   /**
1972    * @copydoc Dali::Toolkit::Internal::TextEditor::ScrollBy()
1973    */
1974   virtual void ScrollBy(Vector2 scroll);
1975
1976   /**
1977    * @brief Whether the text is scrollable.
1978    * @return Returns true if the text is scrollable.
1979    */
1980   bool IsScrollable(const Vector2& displacement);
1981
1982   /**
1983    * @copydoc Dali::Toolkit::Internal::TextEditor::GetHorizontalScrollPosition()
1984    */
1985   float GetHorizontalScrollPosition();
1986
1987   /**
1988    * @copydoc Dali::Toolkit::Internal::TextEditor::GetVerticalScrollPosition()
1989    */
1990   float GetVerticalScrollPosition();
1991
1992   /**
1993    * @brief Event received from input method context
1994    *
1995    * @param[in] inputMethodContext The input method context.
1996    * @param[in] inputMethodContextEvent The event received.
1997    * @return A data struture indicating if update is needed, cursor position and current text.
1998    */
1999   InputMethodContext::CallbackData OnInputMethodContextEvent(InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent);
2000
2001   /**
2002    * @brief Event from Clipboard notifying an Item has been selected for pasting
2003    */
2004   void PasteClipboardItemEvent();
2005
2006   /**
2007    * @brief Return true when text control should clear key input focus when escape key is pressed.
2008    *
2009    * @return Whether text control should clear key input focus or not when escape key is pressed.
2010    */
2011   bool ShouldClearFocusOnEscape() const;
2012
2013   /**
2014    * @brief Create an actor that renders the text background color
2015    *
2016    * @return the created actor or an empty handle if no background color needs to be rendered.
2017    */
2018   Actor CreateBackgroundActor();
2019
2020   /**
2021    * @brief Used to reset the cursor position after setting a new text.
2022    *
2023    * @param[in] cursorIndex Where to place the cursor.
2024    */
2025   void ResetCursorPosition(CharacterIndex cursorIndex);
2026
2027   /**
2028    * @brief The method acquires current position of cursor
2029    * @return unsigned value with cursor position
2030    */
2031   CharacterIndex GetCursorPosition();
2032
2033   /**
2034    * @brief Resets a provided vector with actors that marks the position of anchors in markup enabled text
2035    *
2036    * @param[out] anchorActors the vector of actor (empty collection if no anchors available).
2037    */
2038   void GetAnchorActors(std::vector<Toolkit::TextAnchor>& anchorActors);
2039
2040   /**
2041    * @brief Return an index of first anchor in the anchor vector whose boundaries includes given character offset
2042    *
2043    * @param[in] characterOffset A position in text coords.
2044    *
2045    * @return the index in anchor vector (-1 if an anchor not found)
2046    */
2047   int GetAnchorIndex(size_t characterOffset);
2048
2049 protected: // Inherit from Text::Decorator::ControllerInterface.
2050   /**
2051    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
2052    */
2053   void GetTargetSize(Vector2& targetSize) override;
2054
2055   /**
2056    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
2057    */
2058   void AddDecoration(Actor& actor, DecorationType type, bool needsClipping) override;
2059
2060   /**
2061    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
2062    */
2063   void DecorationEvent(HandleType handle, HandleState state, float x, float y) override;
2064
2065 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
2066   /**
2067    * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
2068    */
2069   void TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::Buttons button) override;
2070
2071 protected: // Inherit from HiddenText.
2072   /**
2073    * @brief Invoked from HiddenText when showing time of the last character was expired
2074    */
2075   void DisplayTimeExpired() override;
2076
2077 private: // Private contructors & copy operator.
2078   /**
2079    * @brief Private constructor.
2080    */
2081   Controller()
2082   : Controller(nullptr, nullptr, nullptr, nullptr)
2083   {
2084   }
2085
2086   /**
2087    * @brief Private constructor.
2088    */
2089   Controller(ControlInterface* controlInterface)
2090   : Controller(controlInterface, nullptr, nullptr, nullptr)
2091   {
2092   }
2093
2094   /**
2095    * @brief Private constructor.
2096    */
2097   Controller(ControlInterface*           controlInterface,
2098              EditableControlInterface*   editableControlInterface,
2099              SelectableControlInterface* selectableControlInterface,
2100              AnchorControlInterface*     anchorControlInterface);
2101
2102   Controller(const Controller& handle) = delete;
2103   Controller& operator=(const Controller& handle) = delete;
2104
2105 protected: // Destructor.
2106   /**
2107    * @brief A reference counted object may only be deleted by calling Unreference().
2108    */
2109   virtual ~Controller();
2110
2111 public:
2112   struct Impl; ///< Made public for testing purposes
2113
2114 private:
2115   struct EventHandler;
2116   struct InputFontHandler;
2117   struct InputProperties;
2118   struct PlaceholderHandler;
2119   struct Relayouter;
2120   struct TextUpdater;
2121   struct SpannableHandler;
2122
2123   std::unique_ptr<Impl> mImpl{nullptr};
2124 };
2125
2126 } // namespace Dali::Toolkit::Text
2127
2128 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H