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