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