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