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