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