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