Merge "Added config section to stylesheet" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller.h
1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
3
4 /*
5  * Copyright (c) 2017 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/imf-manager.h>
23 #include <dali/public-api/events/gesture.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
27 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
28 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
29 #include <dali-toolkit/internal/text/hidden-text.h>
30 #include <dali-toolkit/internal/text/text-model-interface.h>
31
32 namespace Dali
33 {
34
35 namespace Toolkit
36 {
37
38 namespace Text
39 {
40
41 class Controller;
42 class ControlInterface;
43 class EditableControlInterface;
44 class View;
45 class RenderingController;
46
47 typedef IntrusivePtr<Controller> ControllerPtr;
48
49 /**
50  * @brief A Text Controller is used by UI Controls which display text.
51  *
52  * It manipulates the Logical & Visual text models on behalf of the UI Controls.
53  * It provides a view of the text that can be used by rendering back-ends.
54  *
55  * For selectable/editable UI controls, the controller handles input events from the UI control
56  * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
57  *
58  * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
59  */
60 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
61 {
62 public: // Enumerated types.
63
64   /**
65    * @brief Text related operations to be done in the relayout process.
66    */
67   enum OperationsMask
68   {
69     NO_OPERATION       = 0x0000,
70     CONVERT_TO_UTF32   = 0x0001,
71     GET_SCRIPTS        = 0x0002,
72     VALIDATE_FONTS     = 0x0004,
73     GET_LINE_BREAKS    = 0x0008,
74     GET_WORD_BREAKS    = 0x0010,
75     BIDI_INFO          = 0x0020,
76     SHAPE_TEXT         = 0x0040,
77     GET_GLYPH_METRICS  = 0x0080,
78     LAYOUT             = 0x0100,
79     UPDATE_LAYOUT_SIZE = 0x0200,
80     REORDER            = 0x0400,
81     ALIGN              = 0x0800,
82     COLOR              = 0x1000,
83     UPDATE_DIRECTION   = 0x2000,
84     ALL_OPERATIONS     = 0xFFFF
85   };
86
87   /**
88    * @brief Used to distinguish between regular key events and IMF events
89    */
90   enum InsertType
91   {
92     COMMIT,
93     PRE_EDIT
94   };
95
96   /**
97    * @brief Used to specify whether to update the input style.
98    */
99   enum UpdateInputStyleType
100   {
101     UPDATE_INPUT_STYLE,
102     DONT_UPDATE_INPUT_STYLE
103   };
104
105   /**
106    * @brief Used to specify what has been updated after the Relayout() method has been called.
107    */
108   enum UpdateTextType
109   {
110     NONE_UPDATED      = 0x0, ///< Nothing has been updated.
111     MODEL_UPDATED     = 0x1, ///< The text's model has been updated.
112     DECORATOR_UPDATED = 0x2  ///< The decoration has been updated.
113   };
114
115   /**
116    * @brief Different placeholder-text can be shown when the control is active/inactive.
117    */
118   enum PlaceholderType
119   {
120     PLACEHOLDER_TYPE_ACTIVE,
121     PLACEHOLDER_TYPE_INACTIVE,
122   };
123
124   /**
125    * @brief Enumeration for Font Size Type.
126    */
127   enum FontSizeType
128   {
129     POINT_SIZE,   // The size of font in points.
130     PIXEL_SIZE    // The size of font in pixels.
131   };
132
133   struct NoTextTap
134   {
135     enum Action
136     {
137       NO_ACTION,           ///< Does no action if there is a tap on top of an area with no text.
138       HIGHLIGHT,           ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup.
139       SHOW_SELECTION_POPUP ///< Shows the text's selection popup.
140     };
141   };
142
143 public: // Constructor.
144
145   /**
146    * @brief Create a new instance of a Controller.
147    *
148    * @return A pointer to a new Controller.
149    */
150   static ControllerPtr New();
151
152   /**
153    * @brief Create a new instance of a Controller.
154    *
155    * @param[in] controlInterface The control's interface.
156    *
157    * @return A pointer to a new Controller.
158    */
159   static ControllerPtr New( ControlInterface* controlInterface );
160
161   /**
162    * @brief Create a new instance of a Controller.
163    *
164    * @param[in] controlInterface The control's interface.
165    * @param[in] editableControlInterface The editable control's interface.
166    *
167    * @return A pointer to a new Controller.
168    */
169   static ControllerPtr New( ControlInterface* controlInterface,
170                             EditableControlInterface* editableControlInterface );
171
172 public: // Configure the text controller.
173
174   /**
175    * @brief Called to enable text input.
176    *
177    * @note Selectable or editable controls should call this once after Controller::New().
178    * @param[in] decorator Used to create cursor, selection handle decorations etc.
179    */
180   void EnableTextInput( DecoratorPtr decorator );
181
182   /**
183    * @brief Used to switch between bitmap & vector based glyphs
184    *
185    * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
186    */
187   void SetGlyphType( TextAbstraction::GlyphType glyphType );
188
189   /**
190    * @brief Enables/disables the mark-up processor.
191    *
192    * By default is disabled.
193    *
194    * @param[in] enable Whether to enable the mark-up processor.
195    */
196   void SetMarkupProcessorEnabled( bool enable );
197
198   /**
199    * @brief Retrieves whether the mark-up processor is enabled.
200    *
201    * By default is disabled.
202    *
203    * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
204    */
205   bool IsMarkupProcessorEnabled() const;
206
207   /**
208    * @brief Enables/disables the auto text scrolling
209    *
210    * By default is disabled.
211    *
212    * @param[in] enable Whether to enable the auto scrolling
213    */
214   void SetAutoScrollEnabled( bool enable );
215
216   /**
217    * @brief Retrieves whether auto text scrolling is enabled.
218    *
219    * By default is disabled.
220    *
221    * @return @e true if auto scrolling is enabled, otherwise returns @e false.
222    */
223   bool IsAutoScrollEnabled() const;
224
225   /**
226    * @brief Get direction of the text from the first line of text,
227    * @return bool rtl (right to left) is true
228    */
229   CharacterDirection GetAutoScrollDirection() const;
230
231   /**
232    * @brief Get the alignment offset of the first line of text.
233    *
234    * @return The alignment offset.
235    */
236   float GetAutoScrollLineAlignment() const;
237
238   /**
239    * @brief Enables the horizontal scrolling.
240    *
241    * @param[in] enable Whether to enable the horizontal scrolling.
242    */
243   void SetHorizontalScrollEnabled( bool enable );
244
245   /**
246    * @brief Retrieves whether the horizontal scrolling is enabled.
247    *
248    * @return @e true if the horizontal scrolling is enabled, otherwise it returns @e false.
249    */
250   bool IsHorizontalScrollEnabled() const;
251
252   /**
253    * @brief Enables the vertical scrolling.
254    *
255    * @param[in] enable Whether to enable the vertical scrolling.
256    */
257   void SetVerticalScrollEnabled( bool enable );
258
259   /**
260    * @brief Retrieves whether the verticall scrolling is enabled.
261    *
262    * @return @e true if the vertical scrolling is enabled, otherwise it returns @e false.
263    */
264   bool IsVerticalScrollEnabled() const;
265
266   /**
267    * @brief Enables the smooth handle panning.
268    *
269    * @param[in] enable Whether to enable the smooth handle panning.
270    */
271   void SetSmoothHandlePanEnabled( bool enable );
272
273   /**
274    * @brief Retrieves whether the smooth handle panning is enabled.
275    *
276    * @return @e true if the smooth handle panning is enabled.
277    */
278   bool IsSmoothHandlePanEnabled() const;
279
280   /**
281    * @brief Sets the maximum number of characters that can be inserted into the TextModel
282    *
283    * @param[in] maxCharacters maximum number of characters to be accepted
284    */
285   void SetMaximumNumberOfCharacters( Length maxCharacters );
286
287   /**
288    * @brief Sets the maximum number of characters that can be inserted into the TextModel
289    *
290    * @param[in] maxCharacters maximum number of characters to be accepted
291    */
292   int GetMaximumNumberOfCharacters();
293
294   /**
295    * @brief Called to enable/disable cursor blink.
296    *
297    * @note Only editable controls should calls this.
298    * @param[in] enabled Whether the cursor should blink or not.
299    */
300   void SetEnableCursorBlink( bool enable );
301
302   /**
303    * @brief Query whether cursor blink is enabled.
304    *
305    * @return Whether the cursor should blink or not.
306    */
307   bool GetEnableCursorBlink() const;
308
309   /**
310    * @brief Whether to enable the multi-line layout.
311    *
312    * @param[in] enable \e true enables the multi-line (by default)
313    */
314   void SetMultiLineEnabled( bool enable );
315
316   /**
317    * @return Whether the multi-line layout is enabled.
318    */
319   bool IsMultiLineEnabled() const;
320
321   /**
322    * @brief Sets the text's horizontal alignment.
323    *
324    * @param[in] alignment The horizontal alignment.
325    */
326   void SetHorizontalAlignment( Layout::HorizontalAlignment alignment );
327
328   /**
329    * @copydoc ModelInterface::GetHorizontalAlignment()
330    */
331   Layout::HorizontalAlignment GetHorizontalAlignment() const;
332
333   /**
334    * @brief Sets the text's vertical alignment.
335    *
336    * @param[in] alignment The vertical alignment.
337    */
338   void SetVerticalAlignment( Layout::VerticalAlignment alignment );
339
340   /**
341    * @copydoc ModelInterface::GetVerticalAlignment()
342    */
343   Layout::VerticalAlignment GetVerticalAlignment() const;
344
345   /**
346    * @brief Enable or disable the text elide.
347    *
348    * @param[in] enabled Whether to enable the text elide.
349    */
350   void SetTextElideEnabled( bool enabled );
351
352   /**
353    * @copydoc ModelInterface::IsTextElideEnabled()
354    */
355   bool IsTextElideEnabled() const;
356
357   /**
358    * @brief Enable or disable the text selection.
359    * @param[in] enabled Whether to enable the text selection.
360    */
361   void SetSelectionEnabled( bool enabled );
362
363   /**
364    * @brief Whether the text selection is enabled or not.
365    * @return True if the text selection is enabled
366    */
367   bool IsSelectionEnabled() const;
368
369   /**
370    * @brief Sets input type to password
371    *
372    * @note The string is displayed hidden character
373    *
374    * @param[in] passwordInput True if password input is enabled.
375    */
376   void SetInputModePassword( bool passwordInput );
377
378   /**
379    * @brief Returns whether the input mode type is set as password.
380    *
381    * @return True if input mode type is password
382    */
383   bool IsInputModePassword();
384
385   /**
386    * @brief Sets the action when there is a double tap event on top of a text area with no text.
387    *
388    * @param[in] action The action to do.
389    */
390   void SetNoTextDoubleTapAction( NoTextTap::Action action );
391
392   /**
393    * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
394    *
395    * @return The action to do.
396    */
397   NoTextTap::Action GetNoTextDoubleTapAction() const;
398
399   /**
400    * @briefSets the action when there is a long press event on top of a text area with no text.
401    *
402    * @param[in] action The action to do.
403    */
404   void SetNoTextLongPressAction( NoTextTap::Action action );
405
406   /**
407    * @brief Retrieves the action when there is a long press event on top of a text area with no text.
408    *
409    * @return The action to do.
410    */
411   NoTextTap::Action GetNoTextLongPressAction() const;
412
413   /**
414    * @brief Query if Underline settings were provided by string or map
415    * @return bool true if set by string
416    */
417   bool IsUnderlineSetByString();
418
419   /**
420    * Set method underline setting were set by
421    * @param[in] bool, true if set by string
422    */
423   void UnderlineSetByString( bool setByString );
424
425   /**
426    * @brief Query if shadow settings were provided by string or map
427    * @return bool true if set by string
428    */
429   bool IsShadowSetByString();
430
431   /**
432    * Set method shadow setting were set by
433    * @param[in] bool, true if set by string
434    */
435   void ShadowSetByString( bool setByString );
436
437   /**
438    * @brief Query if font style settings were provided by string or map
439    * @return bool true if set by string
440    */
441   bool IsFontStyleSetByString();
442
443   /**
444    * Set method font style setting were set by
445    * @param[in] bool, true if set by string
446    */
447   void FontStyleSetByString( bool setByString );
448
449 public: // Update.
450
451   /**
452    * @brief Replaces any text previously set.
453    *
454    * @note This will be converted into UTF-32 when stored in the text model.
455    * @param[in] text A string of UTF-8 characters.
456    */
457   void SetText( const std::string& text );
458
459   /**
460    * @brief Retrieve any text previously set.
461    *
462    * @param[out] text A string of UTF-8 characters.
463    */
464   void GetText( std::string& text ) const;
465
466   /**
467    * @brief Replaces any placeholder text previously set.
468    *
469    * @param[in] text A string of UTF-8 characters.
470    */
471   void SetPlaceholderText( const std::string& text );
472
473   /**
474    * @brief Replaces any placeholder text previously set.
475    *
476    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
477    * @param[in] text A string of UTF-8 characters.
478    */
479   void SetPlaceholderText( PlaceholderType type, const std::string& text );
480
481   /**
482    * @brief Retrieve any placeholder text previously set.
483    *
484    * @param[out] A string of UTF-8 characters.
485    */
486   void GetPlaceholderText( std::string& text ) const;
487
488   /**
489    * @brief Retrieve any placeholder text previously set.
490    *
491    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
492    * @param[out] A string of UTF-8 characters.
493    */
494   void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
495
496   /**
497    * @ brief Update the text after a font change
498    * @param[in] newDefaultFont The new font to change to
499    */
500   void UpdateAfterFontChange( const std::string& newDefaultFont );
501
502 public: // Default style & Input style
503
504   /**
505    * @brief Set the default font family.
506    *
507    * @param[in] defaultFontFamily The default font family.
508    */
509   void SetDefaultFontFamily( const std::string& defaultFontFamily );
510
511   /**
512    * @brief Retrieve the default font family.
513    *
514    * @return The default font family.
515    */
516   const std::string& GetDefaultFontFamily() const;
517
518   /**
519    * @brief Sets the default font weight.
520    *
521    * @param[in] weight The font weight.
522    */
523   void SetDefaultFontWeight( FontWeight weight );
524
525   /**
526    * @brief Whether the font's weight has been defined.
527    */
528   bool IsDefaultFontWeightDefined() const;
529
530   /**
531    * @brief Retrieves the default font weight.
532    *
533    * @return The default font weight.
534    */
535   FontWeight GetDefaultFontWeight() const;
536
537   /**
538    * @brief Sets the default font width.
539    *
540    * @param[in] width The font width.
541    */
542   void SetDefaultFontWidth( FontWidth width );
543
544   /**
545    * @brief Whether the font's width has been defined.
546    */
547   bool IsDefaultFontWidthDefined() const;
548
549   /**
550    * @brief Retrieves the default font width.
551    *
552    * @return The default font width.
553    */
554   FontWidth GetDefaultFontWidth() const;
555
556   /**
557    * @brief Sets the default font slant.
558    *
559    * @param[in] slant The font slant.
560    */
561   void SetDefaultFontSlant( FontSlant slant );
562
563   /**
564    * @brief Whether the font's slant has been defined.
565    */
566   bool IsDefaultFontSlantDefined() const;
567
568   /**
569    * @brief Retrieves the default font slant.
570    *
571    * @return The default font slant.
572    */
573   FontSlant GetDefaultFontSlant() const;
574
575   /**
576    * @brief Set the default font size.
577    *
578    * @param[in] size The default font size.
579    * @param[in] type The font size type is point size or pixel size
580    */
581   void SetDefaultFontSize( float fontSize, FontSizeType type );
582
583   /**
584    * @brief Retrieve the default point size.
585    *
586    * @param[in] type The font size type
587    * @return The default point size.
588    */
589   float GetDefaultFontSize( FontSizeType type ) const;
590
591   /**
592    * @brief Sets the text's default color.
593    *
594    * @param color The default color.
595    */
596   void SetDefaultColor( const Vector4& color );
597
598   /**
599    * @brief Retrieves the text's default color.
600    *
601    * @return The default color.
602    */
603   const Vector4& GetDefaultColor() const;
604
605   /**
606    * @brief Set the text color
607    *
608    * @param textColor The text color
609    */
610   void SetPlaceholderTextColor( const Vector4& textColor );
611
612   /**
613    * @brief Retrieve the text color
614    *
615    * @return The text color
616    */
617   const Vector4& GetPlaceholderTextColor() const;
618
619   /**
620    * @brief Set the shadow offset.
621    *
622    * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
623    */
624   void SetShadowOffset( const Vector2& shadowOffset );
625
626   /**
627    * @brief Retrieve the shadow offset.
628    *
629    * @return The shadow offset.
630    */
631   const Vector2& GetShadowOffset() const;
632
633   /**
634    * @brief Set the shadow color.
635    *
636    * @param[in] shadowColor The shadow color.
637    */
638   void SetShadowColor( const Vector4& shadowColor );
639
640   /**
641    * @brief Retrieve the shadow color.
642    *
643    * @return The shadow color.
644    */
645   const Vector4& GetShadowColor() const;
646
647   /**
648    * @brief Set the underline color.
649    *
650    * @param[in] color color of underline.
651    */
652   void SetUnderlineColor( const Vector4& color );
653
654   /**
655    * @brief Retrieve the underline color.
656    *
657    * @return The underline color.
658    */
659   const Vector4& GetUnderlineColor() const;
660
661   /**
662    * @brief Set the underline enabled flag.
663    *
664    * @param[in] enabled The underline enabled flag.
665    */
666   void SetUnderlineEnabled( bool enabled );
667
668   /**
669    * @brief Returns whether the text is underlined or not.
670    *
671    * @return The underline state.
672    */
673   bool IsUnderlineEnabled() const;
674
675   /**
676    * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
677    *
678    * @param[in] height The height in pixels of the underline
679    */
680   void SetUnderlineHeight( float height );
681
682   /**
683    * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
684    *
685    * @return The height of the underline, or 0 if height is not overrided.
686    */
687   float GetUnderlineHeight() const;
688
689   /**
690    * @brief Sets the emboss's properties string.
691    *
692    * @note The string is stored to be recovered.
693    *
694    * @param[in] embossProperties The emboss's properties string.
695    */
696   void SetDefaultEmbossProperties( const std::string& embossProperties );
697
698   /**
699    * @brief Retrieves the emboss's properties string.
700    *
701    * @return The emboss's properties string.
702    */
703   const std::string& GetDefaultEmbossProperties() const;
704
705   /**
706    * @brief Sets the outline's properties string.
707    *
708    * @note The string is stored to be recovered.
709    *
710    * @param[in] outlineProperties The outline's properties string.
711    */
712   void SetDefaultOutlineProperties( const std::string& outlineProperties );
713
714   /**
715    * @brief Retrieves the outline's properties string.
716    *
717    * @return The outline's properties string.
718    */
719   const std::string& GetDefaultOutlineProperties() const;
720
721   /**
722    * @brief Sets the default line spacing.
723    *
724    * @param[in] lineSpacing The line spacing.
725    */
726   void SetDefaultLineSpacing( float lineSpacing );
727
728   /**
729    * @brief Retrieves the default line spacing.
730    *
731    * @return The line spacing.
732    */
733   float GetDefaultLineSpacing() const;
734
735   /**
736    * @brief Sets the input text's color.
737    *
738    * @param[in] color The input text's color.
739    */
740   void SetInputColor( const Vector4& color );
741
742   /**
743    * @brief Retrieves the input text's color.
744    *
745    * @return The input text's color.
746    */
747   const Vector4& GetInputColor() const;
748
749   /**
750    * @brief Sets the input text's font family name.
751    *
752    * @param[in] fontFamily The text's font family name.
753    */
754   void SetInputFontFamily( const std::string& fontFamily );
755
756   /**
757    * @brief Retrieves the input text's font family name.
758    *
759    * @return The input text's font family name.
760    */
761   const std::string& GetInputFontFamily() const;
762
763   /**
764    * @brief Sets the input font's weight.
765    *
766    * @param[in] weight The input font's weight.
767    */
768   void SetInputFontWeight( FontWeight weight );
769
770   /**
771    * @return Whether the font's weight has been defined.
772    */
773   bool IsInputFontWeightDefined() const;
774
775   /**
776    * @brief Retrieves the input font's weight.
777    *
778    * @return The input font's weight.
779    */
780   FontWeight GetInputFontWeight() const;
781
782   /**
783    * @brief Sets the input font's width.
784    *
785    * @param[in] width The input font's width.
786    */
787   void SetInputFontWidth( FontWidth width );
788
789   /**
790    * @return Whether the font's width has been defined.
791    */
792   bool IsInputFontWidthDefined() const;
793
794   /**
795    * @brief Retrieves the input font's width.
796    *
797    * @return The input font's width.
798    */
799   FontWidth GetInputFontWidth() const;
800
801   /**
802    * @brief Sets the input font's slant.
803    *
804    * @param[in] slant The input font's slant.
805    */
806   void SetInputFontSlant( FontSlant slant );
807
808   /**
809    * @return Whether the font's slant has been defined.
810    */
811   bool IsInputFontSlantDefined() const;
812
813   /**
814    * @brief Retrieves the input font's slant.
815    *
816    * @return The input font's slant.
817    */
818   FontSlant GetInputFontSlant() const;
819
820   /**
821    * @brief Sets the input font's point size.
822    *
823    * @param[in] size The input font's point size.
824    */
825   void SetInputFontPointSize( float size );
826
827   /**
828    * @brief Retrieves the input font's point size.
829    *
830    * @return The input font's point size.
831    */
832   float GetInputFontPointSize() const;
833
834   /**
835    * @brief Sets the input line spacing.
836    *
837    * @param[in] lineSpacing The line spacing.
838    */
839   void SetInputLineSpacing( float lineSpacing );
840
841   /**
842    * @brief Retrieves the input line spacing.
843    *
844    * @return The line spacing.
845    */
846   float GetInputLineSpacing() const;
847
848   /**
849    * @brief Sets the input shadow's properties string.
850    *
851    * @note The string is stored to be recovered.
852    *
853    * @param[in] shadowProperties The shadow's properties string.
854    */
855   void SetInputShadowProperties( const std::string& shadowProperties );
856
857   /**
858    * @brief Retrieves the input shadow's properties string.
859    *
860    * @return The shadow's properties string.
861    */
862   const std::string& GetInputShadowProperties() const;
863
864   /**
865    * @brief Sets the input underline's properties string.
866    *
867    * @note The string is stored to be recovered.
868    *
869    * @param[in] underlineProperties The underline's properties string.
870    */
871   void SetInputUnderlineProperties( const std::string& underlineProperties );
872
873   /**
874    * @brief Retrieves the input underline's properties string.
875    *
876    * @return The underline's properties string.
877    */
878   const std::string& GetInputUnderlineProperties() const;
879
880   /**
881    * @brief Sets the input emboss's properties string.
882    *
883    * @note The string is stored to be recovered.
884    *
885    * @param[in] embossProperties The emboss's properties string.
886    */
887   void SetInputEmbossProperties( const std::string& embossProperties );
888
889   /**
890    * @brief Retrieves the input emboss's properties string.
891    *
892    * @return The emboss's properties string.
893    */
894   const std::string& GetInputEmbossProperties() const;
895
896   /**
897    * @brief Sets input the outline's properties string.
898    *
899    * @note The string is stored to be recovered.
900    *
901    * @param[in] outlineProperties The outline's properties string.
902    */
903   void SetInputOutlineProperties( const std::string& outlineProperties );
904
905   /**
906    * @brief Retrieves the input outline's properties string.
907    *
908    * @return The outline's properties string.
909    */
910   const std::string& GetInputOutlineProperties() const;
911
912 public: // Queries & retrieves.
913
914   /**
915    * @brief Return the layout engine.
916    *
917    * @return A reference to the layout engine.
918    */
919   Layout::Engine& GetLayoutEngine();
920
921   /**
922    * @brief Return a view of the text.
923    *
924    * @return A reference to the view.
925    */
926   View& GetView();
927
928   /**
929    * @copydoc Control::GetNaturalSize()
930    */
931   Vector3 GetNaturalSize();
932
933   /**
934    * @copydoc Control::GetHeightForWidth()
935    */
936   float GetHeightForWidth( float width );
937
938   /**
939    * @brief Retrieves the text's number of lines for a given width.
940    * @param[in] width The width of the text's area.
941    * @ return The number of lines.
942    */
943   int GetLineCount( float width );
944
945   /**
946    * @brief Retrieves the text's model.
947    *
948    * @return A pointer to the text's model.
949    */
950   const ModelInterface* const GetTextModel() const;
951
952   /**
953    * @brief Used to get scrolled distance by user input
954    *
955    * @return Distance from last scroll offset to new scroll offset
956    */
957   float GetScrollAmountByUserInput();
958
959   /**
960    * @brief Get latest scroll amount, control size and layout size
961    *
962    * This method is used to get information of control's scroll
963    * @param[out] scrollPosition The current scrolled position
964    * @param[out] controlHeight The size of a UI control
965    * @param[out] layoutHeight The size of a bounding box to layout text within.
966    *
967    * @return Whether the text scroll position is changed or not after last update.
968    */
969   bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
970
971   /**
972    * @brief Used to set the hidden input option
973    */
974   void SetHiddenInputOption( const Property::Map& options );
975
976   /**
977    * @brief Used to get the hidden input option
978    */
979   void GetHiddenInputOption( Property::Map& options );
980
981 public: // Relayout.
982
983   /**
984    * @brief Triggers a relayout which updates View (if necessary).
985    *
986    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
987    * @param[in] size A the size of a bounding box to layout text within.
988    *
989    * @return Whether the text model or decorations were updated.
990    */
991   UpdateTextType Relayout( const Size& size );
992
993   /**
994    * @brief Request a relayout using the ControlInterface.
995    */
996   void RequestRelayout();
997
998 public: // Input style change signals.
999
1000   /**
1001    * @return Whether the queue of input style changed signals is empty.
1002    */
1003   bool IsInputStyleChangedSignalsQueueEmpty();
1004
1005   /**
1006    * @brief Process all pending input style changed signals.
1007    *
1008    * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1009    * text controls. Text controls may send signals to state the input style has changed.
1010    */
1011   void ProcessInputStyleChangedSignals();
1012
1013 public: // Text-input Event Queuing.
1014
1015   /**
1016    * @brief Called by editable UI controls when keyboard focus is gained.
1017    */
1018   void KeyboardFocusGainEvent();
1019
1020   /**
1021    * @brief Called by editable UI controls when focus is lost.
1022    */
1023   void KeyboardFocusLostEvent();
1024
1025   /**
1026    * @brief Called by editable UI controls when key events are received.
1027    *
1028    * @param[in] event The key event.
1029    * @param[in] type Used to distinguish between regular key events and IMF events.
1030    */
1031   bool KeyEvent( const Dali::KeyEvent& event );
1032
1033   /**
1034    * @brief Called by editable UI controls when a tap gesture occurs.
1035    * @param[in] tapCount The number of taps.
1036    * @param[in] x The x position relative to the top-left of the parent control.
1037    * @param[in] y The y position relative to the top-left of the parent control.
1038    */
1039   void TapEvent( unsigned int tapCount, float x, float y );
1040
1041   /**
1042    * @brief Called by editable UI controls when a pan gesture occurs.
1043    *
1044    * @param[in] state The state of the gesture.
1045    * @param[in] displacement This distance panned since the last pan gesture.
1046    */
1047   void PanEvent( Gesture::State state, const Vector2& displacement );
1048
1049   /**
1050    * @brief Called by editable UI controls when a long press gesture occurs.
1051    *
1052    * @param[in] state The state of the gesture.
1053    * @param[in] x The x position relative to the top-left of the parent control.
1054    * @param[in] y The y position relative to the top-left of the parent control.
1055    */
1056   void LongPressEvent( Gesture::State state, float x, float y );
1057
1058   /**
1059    * @brief Event received from IMF manager
1060    *
1061    * @param[in] imfManager The IMF manager.
1062    * @param[in] imfEvent The event received.
1063    * @return A data struture indicating if update is needed, cursor position and current text.
1064    */
1065   ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
1066
1067   /**
1068    * @brief Event from Clipboard notifying an Item has been selected for pasting
1069    */
1070   void PasteClipboardItemEvent();
1071
1072 protected: // Inherit from Text::Decorator::ControllerInterface.
1073
1074   /**
1075    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1076    */
1077   virtual void GetTargetSize( Vector2& targetSize );
1078
1079   /**
1080    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1081    */
1082   virtual void AddDecoration( Actor& actor, bool needsClipping );
1083
1084   /**
1085    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1086    */
1087   virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1088
1089 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1090
1091   /**
1092    * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1093    */
1094   virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1095
1096 protected: // Inherit from HiddenText.
1097
1098   /**
1099    * @brief Invoked from HiddenText when showing time of the last character was expired
1100    */
1101   virtual void DisplayTimeExpired();
1102
1103 private: // Update.
1104
1105   /**
1106    * @brief Called by editable UI controls when key events are received.
1107    *
1108    * @param[in] text The text to insert.
1109    * @param[in] type Used to distinguish between regular key events and IMF events.
1110    */
1111   void InsertText( const std::string& text, InsertType type );
1112
1113   /**
1114    * @brief Paste given string into Text model
1115    * @param[in] stringToPaste this string will be inserted into the text model
1116    */
1117   void PasteText( const std::string& stringToPaste );
1118
1119   /**
1120    * @brief Remove a given number of characters
1121    *
1122    * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1123    * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1124    * style when pre-edit text is removed.
1125    *
1126    * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1127    * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1128    * @param[in] type Whether to update the input style.
1129    * @return True if the remove was successful.
1130    */
1131   bool RemoveText( int cursorOffset,
1132                    int numberOfCharacters,
1133                    UpdateInputStyleType type  );
1134
1135   /**
1136    * @brief Checks if text is selected and if so removes it.
1137    * @return true if text was removed
1138    */
1139   bool RemoveSelectedText();
1140
1141 private: // Relayout.
1142
1143   /**
1144    * @brief Lays-out the text.
1145    *
1146    * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1147    *
1148    * @param[in] size A the size of a bounding box to layout text within.
1149    * @param[in] operations The layout operations which need to be done.
1150    * @param[out] layoutSize The size of the laid-out text.
1151    */
1152   bool DoRelayout( const Size& size,
1153                    OperationsMask operations,
1154                    Size& layoutSize );
1155
1156   /**
1157    * @brief Calulates the vertical offset to align the text inside the bounding box.
1158    *
1159    * @param[in] size The size of the bounding box.
1160    */
1161   void CalculateVerticalOffset( const Size& size );
1162
1163 private: // Events.
1164
1165   /**
1166    * @brief Process queued events which modify the model.
1167    */
1168   void ProcessModifyEvents();
1169
1170   /**
1171    * @brief Used to process an event queued from SetText()
1172    */
1173   void TextReplacedEvent();
1174
1175   /**
1176    * @brief Used to process an event queued from key events etc.
1177    */
1178   void TextInsertedEvent();
1179
1180   /**
1181    * @brief Used to process an event queued from backspace key etc.
1182    */
1183   void TextDeletedEvent();
1184
1185   /**
1186    * @brief Creates a selection event.
1187    *
1188    * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1189    *
1190    * @param[in] x The x position relative to the top-left of the parent control.
1191    * @param[in] y The y position relative to the top-left of the parent control.
1192    * @param[in] selectAll Whether the whole text is selected.
1193    */
1194   void SelectEvent( float x, float y, bool selectAll );
1195
1196   /**
1197    * @brief Helper to KeyEvent() to handle the backspace case.
1198    *
1199    * @return True if a character was deleted.
1200    */
1201   bool BackspaceKeyEvent();
1202
1203 private: // Helpers.
1204
1205   /**
1206    * @brief Used to remove the text included the placeholder text.
1207    */
1208   void ResetText();
1209
1210   /**
1211    * @brief Helper to show the place holder text..
1212    */
1213   void ShowPlaceholderText();
1214
1215   /**
1216    * @brief Helper to clear font-specific data (only).
1217    */
1218   void ClearFontData();
1219
1220   /**
1221    * @brief Helper to clear text's style data.
1222    */
1223   void ClearStyleData();
1224
1225   /**
1226    * @brief Used to reset the cursor position after setting a new text.
1227    *
1228    * @param[in] cursorIndex Where to place the cursor.
1229    */
1230   void ResetCursorPosition( CharacterIndex cursorIndex );
1231
1232   /**
1233    * @brief Used to reset the scroll position after setting a new text.
1234    */
1235   void ResetScrollPosition();
1236
1237 private: // Private contructors & copy operator.
1238
1239   /**
1240    * @brief Private constructor.
1241    */
1242   Controller();
1243
1244   /**
1245    * @brief Private constructor.
1246    */
1247   Controller( ControlInterface* controlInterface );
1248
1249   /**
1250    * @brief Private constructor.
1251    */
1252   Controller( ControlInterface* controlInterface,
1253               EditableControlInterface* editableControlInterface );
1254
1255   // Undefined
1256   Controller( const Controller& handle );
1257
1258   // Undefined
1259   Controller& operator=( const Controller& handle );
1260
1261 protected: // Destructor.
1262
1263   /**
1264    * @brief A reference counted object may only be deleted by calling Unreference().
1265    */
1266   virtual ~Controller();
1267
1268 private:
1269
1270   struct Impl;
1271   Impl* mImpl;
1272 };
1273
1274 } // namespace Text
1275
1276 } // namespace Toolkit
1277
1278 } // namespace Dali
1279
1280 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H