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