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