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