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