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