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