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