support match align for system language direciton
[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 Sets input type to password
425    *
426    * @note The string is displayed hidden character
427    *
428    * @param[in] passwordInput True if password input is enabled.
429    */
430   void SetInputModePassword( bool passwordInput );
431
432   /**
433    * @brief Returns whether the input mode type is set as password.
434    *
435    * @return True if input mode type is password
436    */
437   bool IsInputModePassword();
438
439   /**
440    * @brief Sets the action when there is a double tap event on top of a text area with no text.
441    *
442    * @param[in] action The action to do.
443    */
444   void SetNoTextDoubleTapAction( NoTextTap::Action action );
445
446   /**
447    * @brief Retrieves the action when there is a double tap event on top of a text area with no text.
448    *
449    * @return The action to do.
450    */
451   NoTextTap::Action GetNoTextDoubleTapAction() const;
452
453   /**
454    * @briefSets the action when there is a long press event on top of a text area with no text.
455    *
456    * @param[in] action The action to do.
457    */
458   void SetNoTextLongPressAction( NoTextTap::Action action );
459
460   /**
461    * @brief Retrieves the action when there is a long press event on top of a text area with no text.
462    *
463    * @return The action to do.
464    */
465   NoTextTap::Action GetNoTextLongPressAction() const;
466
467   /**
468    * @brief Query if Underline settings were provided by string or map
469    * @return bool true if set by string
470    */
471   bool IsUnderlineSetByString();
472
473   /**
474    * Set method underline setting were set by
475    * @param[in] bool, true if set by string
476    */
477   void UnderlineSetByString( bool setByString );
478
479   /**
480    * @brief Query if shadow settings were provided by string or map
481    * @return bool true if set by string
482    */
483   bool IsShadowSetByString();
484
485   /**
486    * Set method shadow setting were set by
487    * @param[in] bool, true if set by string
488    */
489   void ShadowSetByString( bool setByString );
490
491   /**
492    * @brief Query if outline settings were provided by string or map
493    * @return bool true if set by string
494    */
495   bool IsOutlineSetByString();
496
497   /**
498    * Set method outline setting were set by
499    * @param[in] bool, true if set by string
500    */
501   void OutlineSetByString( bool setByString );
502
503   /**
504    * @brief Query if font style settings were provided by string or map
505    * @return bool true if set by string
506    */
507   bool IsFontStyleSetByString();
508
509   /**
510    * Set method font style setting were set by
511    * @param[in] bool, true if set by string
512    */
513   void FontStyleSetByString( bool setByString );
514
515 public: // Update.
516
517   /**
518    * @brief Replaces any text previously set.
519    *
520    * @note This will be converted into UTF-32 when stored in the text model.
521    * @param[in] text A string of UTF-8 characters.
522    */
523   void SetText( const std::string& text );
524
525   /**
526    * @brief Retrieve any text previously set.
527    *
528    * @param[out] text A string of UTF-8 characters.
529    */
530   void GetText( std::string& text ) const;
531
532   /**
533    * @brief Replaces any placeholder text previously set.
534    *
535    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
536    * @param[in] text A string of UTF-8 characters.
537    */
538   void SetPlaceholderText( PlaceholderType type, const std::string& text );
539
540   /**
541    * @brief Retrieve any placeholder text previously set.
542    *
543    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
544    * @param[out] A string of UTF-8 characters.
545    */
546   void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
547
548   /**
549    * @ brief Update the text after a font change
550    * @param[in] newDefaultFont The new font to change to
551    */
552   void UpdateAfterFontChange( const std::string& newDefaultFont );
553
554 public: // Default style & Input style
555
556   /**
557    * @brief Set the default font family.
558    *
559    * @param[in] defaultFontFamily The default font family.
560    */
561   void SetDefaultFontFamily( const std::string& defaultFontFamily );
562
563   /**
564    * @brief Retrieve the default font family.
565    *
566    * @return The default font family.
567    */
568   const std::string& GetDefaultFontFamily() const;
569
570   /**
571    * @brief Sets the placeholder text font family.
572    * @param[in] placeholderTextFontFamily The placeholder text font family.
573    */
574   void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
575
576   /**
577    * @brief Retrieves the placeholder text font family.
578    *
579    * @return The placeholder text font family
580    */
581   const std::string& GetPlaceholderFontFamily() const;
582
583   /**
584    * @brief Sets the default font weight.
585    *
586    * @param[in] weight The font weight.
587    */
588   void SetDefaultFontWeight( FontWeight weight );
589
590   /**
591    * @brief Whether the font's weight has been defined.
592    */
593   bool IsDefaultFontWeightDefined() const;
594
595   /**
596    * @brief Retrieves the default font weight.
597    *
598    * @return The default font weight.
599    */
600   FontWeight GetDefaultFontWeight() const;
601
602   /**
603    * @brief Sets the placeholder text font weight.
604    *
605    * @param[in] weight The font weight
606    */
607   void SetPlaceholderTextFontWeight( FontWeight weight );
608
609   /**
610    * @brief Whether the font's weight has been defined.
611    *
612    * @return True if the placeholder text font weight is defined
613    */
614   bool IsPlaceholderTextFontWeightDefined() const;
615
616   /**
617    * @brief Retrieves the placeholder text font weight.
618    *
619    * @return The placeholder text font weight
620    */
621   FontWeight GetPlaceholderTextFontWeight() const;
622
623   /**
624    * @brief Sets the default font width.
625    *
626    * @param[in] width The font width.
627    */
628   void SetDefaultFontWidth( FontWidth width );
629
630   /**
631    * @brief Whether the font's width has been defined.
632    */
633   bool IsDefaultFontWidthDefined() const;
634
635   /**
636    * @brief Retrieves the default font width.
637    *
638    * @return The default font width.
639    */
640   FontWidth GetDefaultFontWidth() const;
641
642   /**
643    * @brief Sets the placeholder text font width.
644    *
645    * @param[in] width The font width
646    */
647   void SetPlaceholderTextFontWidth( FontWidth width );
648
649   /**
650    * @brief Whether the font's width has been defined.
651    *
652    * @return True if the placeholder text font width is defined
653    */
654   bool IsPlaceholderTextFontWidthDefined() const;
655
656   /**
657    * @brief Retrieves the placeholder text font width.
658    *
659    * @return The placeholder text font width
660    */
661   FontWidth GetPlaceholderTextFontWidth() const;
662
663   /**
664    * @brief Sets the default font slant.
665    *
666    * @param[in] slant The font slant.
667    */
668   void SetDefaultFontSlant( FontSlant slant );
669
670   /**
671    * @brief Whether the font's slant has been defined.
672    */
673   bool IsDefaultFontSlantDefined() const;
674
675   /**
676    * @brief Retrieves the default font slant.
677    *
678    * @return The default font slant.
679    */
680   FontSlant GetDefaultFontSlant() const;
681
682   /**
683    * @brief Sets the placeholder text font slant.
684    *
685    * @param[in] slant The font slant
686    */
687   void SetPlaceholderTextFontSlant( FontSlant slant );
688
689   /**
690    * @brief Whether the font's slant has been defined.
691    *
692    * @return True if the placeholder text font slant is defined
693    */
694   bool IsPlaceholderTextFontSlantDefined() const;
695
696   /**
697    * @brief Retrieves the placeholder text font slant.
698    *
699    * @return The placeholder text font slant
700    */
701   FontSlant GetPlaceholderTextFontSlant() const;
702
703   /**
704    * @brief Set the default font size.
705    *
706    * @param[in] fontSize The default font size
707    * @param[in] type The font size type is point size or pixel size
708    */
709   void SetDefaultFontSize( float fontSize, FontSizeType type );
710
711   /**
712    * @brief Retrieve the default point size.
713    *
714    * @param[in] type The font size type
715    * @return The default point size.
716    */
717   float GetDefaultFontSize( FontSizeType type ) const;
718
719   /**
720    * @brief Sets the Placeholder text font size.
721    * @param[in] fontSize The placeholder text font size
722    * @param[in] type The font size type is point size or pixel size
723    */
724   void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
725
726   /**
727    * @brief Retrieves the Placeholder text font size.
728    * @param[in] type The font size type
729    * @return The placeholder font size
730    */
731   float GetPlaceholderTextFontSize( FontSizeType type ) const;
732
733   /**
734    * @brief Sets the text's default color.
735    *
736    * @param color The default color.
737    */
738   void SetDefaultColor( const Vector4& color );
739
740   /**
741    * @brief Retrieves the text's default color.
742    *
743    * @return The default color.
744    */
745   const Vector4& GetDefaultColor() const;
746
747   /**
748    * @brief Set the text color
749    *
750    * @param textColor The text color
751    */
752   void SetPlaceholderTextColor( const Vector4& textColor );
753
754   /**
755    * @brief Retrieve the text color
756    *
757    * @return The text color
758    */
759   const Vector4& GetPlaceholderTextColor() const;
760
761   /**
762    * @brief Set the shadow offset.
763    *
764    * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
765    */
766   void SetShadowOffset( const Vector2& shadowOffset );
767
768   /**
769    * @brief Retrieve the shadow offset.
770    *
771    * @return The shadow offset.
772    */
773   const Vector2& GetShadowOffset() const;
774
775   /**
776    * @brief Set the shadow color.
777    *
778    * @param[in] shadowColor The shadow color.
779    */
780   void SetShadowColor( const Vector4& shadowColor );
781
782   /**
783    * @brief Retrieve the shadow color.
784    *
785    * @return The shadow color.
786    */
787   const Vector4& GetShadowColor() const;
788
789   /**
790    * @brief Set the shadow blur radius.
791    *
792    * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
793    */
794   void SetShadowBlurRadius( const float& shadowBlurRadius );
795
796   /**
797    * @brief Retrieve the shadow blur radius.
798    *
799    * @return The shadow blur radius.
800    */
801   const float& GetShadowBlurRadius() const;
802
803   /**
804    * @brief Set the underline color.
805    *
806    * @param[in] color color of underline.
807    */
808   void SetUnderlineColor( const Vector4& color );
809
810   /**
811    * @brief Retrieve the underline color.
812    *
813    * @return The underline color.
814    */
815   const Vector4& GetUnderlineColor() const;
816
817   /**
818    * @brief Set the underline enabled flag.
819    *
820    * @param[in] enabled The underline enabled flag.
821    */
822   void SetUnderlineEnabled( bool enabled );
823
824   /**
825    * @brief Returns whether the text is underlined or not.
826    *
827    * @return The underline state.
828    */
829   bool IsUnderlineEnabled() const;
830
831   /**
832    * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
833    *
834    * @param[in] height The height in pixels of the underline
835    */
836   void SetUnderlineHeight( float height );
837
838   /**
839    * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
840    *
841    * @return The height of the underline, or 0 if height is not overrided.
842    */
843   float GetUnderlineHeight() const;
844
845   /**
846    * @brief Set the outline color.
847    *
848    * @param[in] color color of outline.
849    */
850   void SetOutlineColor( const Vector4& color );
851
852   /**
853    * @brief Retrieve the outline color.
854    *
855    * @return The outline color.
856    */
857   const Vector4& GetOutlineColor() const;
858
859   /**
860    * @brief Set the outline width
861    *
862    * @param[in] width The width in pixels of the outline, 0 indicates no outline
863    */
864   void SetOutlineWidth( unsigned int width );
865
866   /**
867    * @brief Retrieves the width of an outline
868    *
869    * @return The width of the outline.
870    */
871   unsigned int GetOutlineWidth() const;
872
873   /**
874    * @brief Set the background color.
875    *
876    * @param[in] color color of background.
877    */
878   void SetBackgroundColor( const Vector4& color );
879
880   /**
881    * @brief Retrieve the background color.
882    *
883    * @return The background color.
884    */
885   const Vector4& GetBackgroundColor() const;
886
887   /**
888    * @brief Set the background enabled flag.
889    *
890    * @param[in] enabled The background enabled flag.
891    */
892   void SetBackgroundEnabled( bool enabled );
893
894   /**
895    * @brief Returns whether to enable text background or not.
896    *
897    * @return Whether text background is enabled.
898    */
899   bool IsBackgroundEnabled() const;
900
901   /**
902    * @brief Sets the emboss's properties string.
903    *
904    * @note The string is stored to be recovered.
905    *
906    * @param[in] embossProperties The emboss's properties string.
907    */
908   void SetDefaultEmbossProperties( const std::string& embossProperties );
909
910   /**
911    * @brief Retrieves the emboss's properties string.
912    *
913    * @return The emboss's properties string.
914    */
915   const std::string& GetDefaultEmbossProperties() const;
916
917   /**
918    * @brief Sets the outline's properties string.
919    *
920    * @note The string is stored to be recovered.
921    *
922    * @param[in] outlineProperties The outline's properties string.
923    */
924   void SetDefaultOutlineProperties( const std::string& outlineProperties );
925
926   /**
927    * @brief Retrieves the outline's properties string.
928    *
929    * @return The outline's properties string.
930    */
931   const std::string& GetDefaultOutlineProperties() const;
932
933   /**
934    * @brief Sets the default line spacing.
935    *
936    * @param[in] lineSpacing The line spacing.
937    *
938    * @return True if lineSpacing has been updated, false otherwise
939    */
940   bool SetDefaultLineSpacing( float lineSpacing );
941
942   /**
943    * @brief Retrieves the default line spacing.
944    *
945    * @return The line spacing.
946    */
947   float GetDefaultLineSpacing() const;
948
949   /**
950    * @brief Sets the input text's color.
951    *
952    * @param[in] color The input text's color.
953    */
954   void SetInputColor( const Vector4& color );
955
956   /**
957    * @brief Retrieves the input text's color.
958    *
959    * @return The input text's color.
960    */
961   const Vector4& GetInputColor() const;
962
963   /**
964    * @brief Sets the input text's font family name.
965    *
966    * @param[in] fontFamily The text's font family name.
967    */
968   void SetInputFontFamily( const std::string& fontFamily );
969
970   /**
971    * @brief Retrieves the input text's font family name.
972    *
973    * @return The input text's font family name.
974    */
975   const std::string& GetInputFontFamily() const;
976
977   /**
978    * @brief Sets the input font's weight.
979    *
980    * @param[in] weight The input font's weight.
981    */
982   void SetInputFontWeight( FontWeight weight );
983
984   /**
985    * @return Whether the font's weight has been defined.
986    */
987   bool IsInputFontWeightDefined() const;
988
989   /**
990    * @brief Retrieves the input font's weight.
991    *
992    * @return The input font's weight.
993    */
994   FontWeight GetInputFontWeight() const;
995
996   /**
997    * @brief Sets the input font's width.
998    *
999    * @param[in] width The input font's width.
1000    */
1001   void SetInputFontWidth( FontWidth width );
1002
1003   /**
1004    * @return Whether the font's width has been defined.
1005    */
1006   bool IsInputFontWidthDefined() const;
1007
1008   /**
1009    * @brief Retrieves the input font's width.
1010    *
1011    * @return The input font's width.
1012    */
1013   FontWidth GetInputFontWidth() const;
1014
1015   /**
1016    * @brief Sets the input font's slant.
1017    *
1018    * @param[in] slant The input font's slant.
1019    */
1020   void SetInputFontSlant( FontSlant slant );
1021
1022   /**
1023    * @return Whether the font's slant has been defined.
1024    */
1025   bool IsInputFontSlantDefined() const;
1026
1027   /**
1028    * @brief Retrieves the input font's slant.
1029    *
1030    * @return The input font's slant.
1031    */
1032   FontSlant GetInputFontSlant() const;
1033
1034   /**
1035    * @brief Sets the input font's point size.
1036    *
1037    * @param[in] size The input font's point size.
1038    */
1039   void SetInputFontPointSize( float size );
1040
1041   /**
1042    * @brief Retrieves the input font's point size.
1043    *
1044    * @return The input font's point size.
1045    */
1046   float GetInputFontPointSize() const;
1047
1048   /**
1049    * @brief Sets the input line spacing.
1050    *
1051    * @param[in] lineSpacing The line spacing.
1052    */
1053   void SetInputLineSpacing( float lineSpacing );
1054
1055   /**
1056    * @brief Retrieves the input line spacing.
1057    *
1058    * @return The line spacing.
1059    */
1060   float GetInputLineSpacing() const;
1061
1062   /**
1063    * @brief Sets the input shadow's properties string.
1064    *
1065    * @note The string is stored to be recovered.
1066    *
1067    * @param[in] shadowProperties The shadow's properties string.
1068    */
1069   void SetInputShadowProperties( const std::string& shadowProperties );
1070
1071   /**
1072    * @brief Retrieves the input shadow's properties string.
1073    *
1074    * @return The shadow's properties string.
1075    */
1076   const std::string& GetInputShadowProperties() const;
1077
1078   /**
1079    * @brief Sets the input underline's properties string.
1080    *
1081    * @note The string is stored to be recovered.
1082    *
1083    * @param[in] underlineProperties The underline's properties string.
1084    */
1085   void SetInputUnderlineProperties( const std::string& underlineProperties );
1086
1087   /**
1088    * @brief Retrieves the input underline's properties string.
1089    *
1090    * @return The underline's properties string.
1091    */
1092   const std::string& GetInputUnderlineProperties() const;
1093
1094   /**
1095    * @brief Sets the input emboss's properties string.
1096    *
1097    * @note The string is stored to be recovered.
1098    *
1099    * @param[in] embossProperties The emboss's properties string.
1100    */
1101   void SetInputEmbossProperties( const std::string& embossProperties );
1102
1103   /**
1104    * @brief Retrieves the input emboss's properties string.
1105    *
1106    * @return The emboss's properties string.
1107    */
1108   const std::string& GetInputEmbossProperties() const;
1109
1110   /**
1111    * @brief Sets input the outline's properties string.
1112    *
1113    * @note The string is stored to be recovered.
1114    *
1115    * @param[in] outlineProperties The outline's properties string.
1116    */
1117   void SetInputOutlineProperties( const std::string& outlineProperties );
1118
1119   /**
1120    * @brief Retrieves the input outline's properties string.
1121    *
1122    * @return The outline's properties string.
1123    */
1124   const std::string& GetInputOutlineProperties() const;
1125
1126   /**
1127    * @brief Set the control's interface.
1128    *
1129    * @param[in] controlInterface The control's interface.
1130    */
1131   void SetControlInterface( ControlInterface* controlInterface );
1132
1133 public: // Queries & retrieves.
1134
1135   /**
1136    * @brief Return the layout engine.
1137    *
1138    * @return A reference to the layout engine.
1139    */
1140   Layout::Engine& GetLayoutEngine();
1141
1142   /**
1143    * @brief Return a view of the text.
1144    *
1145    * @return A reference to the view.
1146    */
1147   View& GetView();
1148
1149   /**
1150    * @copydoc Control::GetNaturalSize()
1151    */
1152   Vector3 GetNaturalSize();
1153
1154   /**
1155    * @copydoc Control::GetHeightForWidth()
1156    */
1157   float GetHeightForWidth( float width );
1158
1159   /**
1160    * @brief Retrieves the text's number of lines for a given width.
1161    * @param[in] width The width of the text's area.
1162    * @ return The number of lines.
1163    */
1164   int GetLineCount( float width );
1165
1166   /**
1167    * @brief Retrieves the text's model.
1168    *
1169    * @return A pointer to the text's model.
1170    */
1171   const ModelInterface* const GetTextModel() const;
1172
1173   /**
1174    * @brief Used to get scrolled distance by user input
1175    *
1176    * @return Distance from last scroll offset to new scroll offset
1177    */
1178   float GetScrollAmountByUserInput();
1179
1180   /**
1181    * @brief Get latest scroll amount, control size and layout size
1182    *
1183    * This method is used to get information of control's scroll
1184    * @param[out] scrollPosition The current scrolled position
1185    * @param[out] controlHeight The size of a UI control
1186    * @param[out] layoutHeight The size of a bounding box to layout text within.
1187    *
1188    * @return Whether the text scroll position is changed or not after last update.
1189    */
1190   bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight );
1191
1192   /**
1193    * @brief Used to set the hidden input option
1194    */
1195   void SetHiddenInputOption( const Property::Map& options );
1196
1197   /**
1198    * @brief Used to get the hidden input option
1199    */
1200   void GetHiddenInputOption( Property::Map& options );
1201
1202   /**
1203    * @brief Sets the Placeholder Properties.
1204    *
1205    * @param[in] map The placeholder property map
1206    */
1207   void SetPlaceholderProperty( const Property::Map& map );
1208
1209   /**
1210    * @brief Retrieves the Placeholder Property map.
1211    *
1212    * @param[out] map The property map
1213    */
1214   void GetPlaceholderProperty( Property::Map& map );
1215
1216   /**
1217    * @brief Checks text direction.
1218    * @return The text direction.
1219    */
1220   Toolkit::DevelText::TextDirection::Type GetTextDirection();
1221
1222   /**
1223    * @brief Retrieves vertical line alignment
1224    * @return The vertical line alignment
1225    */
1226   Toolkit::DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
1227
1228   /**
1229    * @brief Sets vertical line alignment
1230    * @param[in] alignment The vertical line alignment for the text
1231    */
1232   void SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlignment::Type alignment );
1233
1234   /**
1235    * @brief Retrieves ignoreSpaceAfterText value from model
1236    * @return The value of ignoreSpaceAfterText
1237    */
1238   bool IsIgnoreSpacesAfterText() const;
1239
1240   /**
1241    * @brief Sets ignoreSpaceAfterText value to model
1242    * @param[in] ignore The value of ignoreSpacesAfterText for the text
1243    */
1244   void SetIgnoreSpacesAfterText( bool ignore );
1245
1246   /**
1247    * @brief Retrieves matchSystemLanguageDirection value from model
1248    * @return The value of matchSystemLanguageDirection
1249    */
1250   bool IsMatchSystemLanguageDirection() const;
1251
1252   /**
1253    * @brief Sets matchSystemLanguageDirection value to model
1254    * @param[in] match The value of matchSystemLanguageDirection for the text
1255    */
1256   void SetMatchSystemLanguageDirection( bool match );
1257
1258 public: // Relayout.
1259
1260   /**
1261    * @brief Triggers a relayout which updates View (if necessary).
1262    *
1263    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
1264    * @param[in] size A the size of a bounding box to layout text within.
1265    * @param[in] layoutDirection The direction of the system language.
1266    *
1267    * @return Whether the text model or decorations were updated.
1268    */
1269   UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT );
1270
1271   /**
1272    * @brief Request a relayout using the ControlInterface.
1273    */
1274   void RequestRelayout();
1275
1276 public: // Input style change signals.
1277
1278   /**
1279    * @return Whether the queue of input style changed signals is empty.
1280    */
1281   bool IsInputStyleChangedSignalsQueueEmpty();
1282
1283   /**
1284    * @brief Process all pending input style changed signals.
1285    *
1286    * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the
1287    * text controls. Text controls may send signals to state the input style has changed.
1288    */
1289   void ProcessInputStyleChangedSignals();
1290
1291 public: // Text-input Event Queuing.
1292
1293   /**
1294    * @brief Called by editable UI controls when keyboard focus is gained.
1295    */
1296   void KeyboardFocusGainEvent();
1297
1298   /**
1299    * @brief Called by editable UI controls when focus is lost.
1300    */
1301   void KeyboardFocusLostEvent();
1302
1303   /**
1304    * @brief Called by editable UI controls when key events are received.
1305    *
1306    * @param[in] event The key event.
1307    * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1308    */
1309   bool KeyEvent( const Dali::KeyEvent& event );
1310
1311   /**
1312    * @brief Called by editable UI controls when a tap gesture occurs.
1313    * @param[in] tapCount The number of taps.
1314    * @param[in] x The x position relative to the top-left of the parent control.
1315    * @param[in] y The y position relative to the top-left of the parent control.
1316    */
1317   void TapEvent( unsigned int tapCount, float x, float y );
1318
1319   /**
1320    * @brief Called by editable UI controls when a pan gesture occurs.
1321    *
1322    * @param[in] state The state of the gesture.
1323    * @param[in] displacement This distance panned since the last pan gesture.
1324    */
1325   void PanEvent( Gesture::State state, const Vector2& displacement );
1326
1327   /**
1328    * @brief Called by editable UI controls when a long press gesture occurs.
1329    *
1330    * @param[in] state The state of the gesture.
1331    * @param[in] x The x position relative to the top-left of the parent control.
1332    * @param[in] y The y position relative to the top-left of the parent control.
1333    */
1334   void LongPressEvent( Gesture::State state, float x, float y );
1335
1336   /**
1337    * @brief Event received from input method context
1338    *
1339    * @param[in] inputMethodContext The input method context.
1340    * @param[in] inputMethodContextEvent The event received.
1341    * @return A data struture indicating if update is needed, cursor position and current text.
1342    */
1343   InputMethodContext::CallbackData OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent );
1344
1345   /**
1346    * @brief Event from Clipboard notifying an Item has been selected for pasting
1347    */
1348   void PasteClipboardItemEvent();
1349
1350   /**
1351    * @brief Return true when text control should clear key input focus when escape key is pressed.
1352    *
1353    * @return Whether text control should clear key input focus or not when escape key is pressed.
1354    */
1355   bool ShouldClearFocusOnEscape() const;
1356
1357 protected: // Inherit from Text::Decorator::ControllerInterface.
1358
1359   /**
1360    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
1361    */
1362   virtual void GetTargetSize( Vector2& targetSize );
1363
1364   /**
1365    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
1366    */
1367   virtual void AddDecoration( Actor& actor, bool needsClipping );
1368
1369   /**
1370    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
1371    */
1372   virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
1373
1374 protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
1375
1376   /**
1377    * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
1378    */
1379   virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
1380
1381 protected: // Inherit from HiddenText.
1382
1383   /**
1384    * @brief Invoked from HiddenText when showing time of the last character was expired
1385    */
1386   virtual void DisplayTimeExpired();
1387
1388 private: // Update.
1389
1390   /**
1391    * @brief Called by editable UI controls when key events are received.
1392    *
1393    * @param[in] text The text to insert.
1394    * @param[in] type Used to distinguish between regular key events and InputMethodContext events.
1395    */
1396   void InsertText( const std::string& text, InsertType type );
1397
1398   /**
1399    * @brief Paste given string into Text model
1400    * @param[in] stringToPaste this string will be inserted into the text model
1401    */
1402   void PasteText( const std::string& stringToPaste );
1403
1404   /**
1405    * @brief Remove a given number of characters
1406    *
1407    * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
1408    * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
1409    * style when pre-edit text is removed.
1410    *
1411    * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
1412    * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
1413    * @param[in] type Whether to update the input style.
1414    * @return True if the remove was successful.
1415    */
1416   bool RemoveText( int cursorOffset,
1417                    int numberOfCharacters,
1418                    UpdateInputStyleType type  );
1419
1420   /**
1421    * @brief Checks if text is selected and if so removes it.
1422    * @return true if text was removed
1423    */
1424   bool RemoveSelectedText();
1425
1426 private: // Relayout.
1427
1428   /**
1429    * @brief Lays-out the text.
1430    *
1431    * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
1432    *
1433    * @param[in] size A the size of a bounding box to layout text within.
1434    * @param[in] operations The layout operations which need to be done.
1435    * @param[out] layoutSize The size of the laid-out text.
1436    */
1437   bool DoRelayout( const Size& size,
1438                    OperationsMask operations,
1439                    Size& layoutSize );
1440
1441   /**
1442    * @brief Calulates the vertical offset to align the text inside the bounding box.
1443    *
1444    * @param[in] size The size of the bounding box.
1445    */
1446   void CalculateVerticalOffset( const Size& size );
1447
1448 private: // Events.
1449
1450   /**
1451    * @brief Process queued events which modify the model.
1452    */
1453   void ProcessModifyEvents();
1454
1455   /**
1456    * @brief Used to process an event queued from SetText()
1457    */
1458   void TextReplacedEvent();
1459
1460   /**
1461    * @brief Used to process an event queued from key events etc.
1462    */
1463   void TextInsertedEvent();
1464
1465   /**
1466    * @brief Used to process an event queued from backspace key etc.
1467    */
1468   void TextDeletedEvent();
1469
1470   /**
1471    * @brief Creates a selection event.
1472    *
1473    * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
1474    *
1475    * @param[in] x The x position relative to the top-left of the parent control.
1476    * @param[in] y The y position relative to the top-left of the parent control.
1477    * @param[in] selectAll Whether the whole text is selected.
1478    */
1479   void SelectEvent( float x, float y, bool selectAll );
1480
1481   /**
1482    * @brief Helper to KeyEvent() to handle the backspace or delete key case.
1483    *
1484    * @param[in] keyCode The keycode for the key pressed
1485    * @return True if a character was deleted.
1486    */
1487   bool DeleteEvent( int keyCode );
1488
1489 private: // Helpers.
1490
1491   /**
1492    * @brief Used to remove the text included the placeholder text.
1493    */
1494   void ResetText();
1495
1496   /**
1497    * @brief Helper to show the place holder text..
1498    */
1499   void ShowPlaceholderText();
1500
1501   /**
1502    * @brief Helper to clear font-specific data (only).
1503    */
1504   void ClearFontData();
1505
1506   /**
1507    * @brief Helper to clear text's style data.
1508    */
1509   void ClearStyleData();
1510
1511   /**
1512    * @brief Used to reset the cursor position after setting a new text.
1513    *
1514    * @param[in] cursorIndex Where to place the cursor.
1515    */
1516   void ResetCursorPosition( CharacterIndex cursorIndex );
1517
1518   /**
1519    * @brief Used to reset the scroll position after setting a new text.
1520    */
1521   void ResetScrollPosition();
1522
1523 private: // Private contructors & copy operator.
1524
1525   /**
1526    * @brief Private constructor.
1527    */
1528   Controller();
1529
1530   /**
1531    * @brief Private constructor.
1532    */
1533   Controller( ControlInterface* controlInterface );
1534
1535   /**
1536    * @brief Private constructor.
1537    */
1538   Controller( ControlInterface* controlInterface,
1539               EditableControlInterface* editableControlInterface );
1540
1541   // Undefined
1542   Controller( const Controller& handle );
1543
1544   // Undefined
1545   Controller& operator=( const Controller& handle );
1546
1547 protected: // Destructor.
1548
1549   /**
1550    * @brief A reference counted object may only be deleted by calling Unreference().
1551    */
1552   virtual ~Controller();
1553
1554 public:
1555
1556   struct Impl; ///< Made public for testing purposes
1557
1558 private:
1559
1560   Impl* mImpl;
1561 };
1562
1563 } // namespace Text
1564
1565 } // namespace Toolkit
1566
1567 } // namespace Dali
1568
1569 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_H