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