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