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