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