[dali_1.1.40] Merge branch 'devel/master'
[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) 2015 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/text-control-interface.h>
30
31 namespace Dali
32 {
33
34 namespace Toolkit
35 {
36
37 namespace Text
38 {
39
40 class Controller;
41 class View;
42
43 typedef IntrusivePtr<Controller> ControllerPtr;
44 typedef Dali::Toolkit::Text::ControlInterface ControlInterface;
45
46 /**
47  * @brief Different placeholder-text can be shown when the control is active/inactive.
48  */
49 enum PlaceholderType
50 {
51   PLACEHOLDER_TYPE_ACTIVE,
52   PLACEHOLDER_TYPE_INACTIVE,
53 };
54
55 /**
56  * @brief A Text Controller is used by UI Controls which display text.
57  *
58  * It manipulates the Logical & Visual text models on behalf of the UI Controls.
59  * It provides a view of the text that can be used by rendering back-ends.
60  *
61  * For selectable/editable UI controls, the controller handles input events from the UI control
62  * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
63  *
64  * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
65  */
66 class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface
67 {
68 public:
69
70   /**
71    * @brief Text related operations to be done in the relayout process.
72    */
73   enum OperationsMask
74   {
75     NO_OPERATION       = 0x0000,
76     CONVERT_TO_UTF32   = 0x0001,
77     GET_SCRIPTS        = 0x0002,
78     VALIDATE_FONTS     = 0x0004,
79     GET_LINE_BREAKS    = 0x0008,
80     GET_WORD_BREAKS    = 0x0010,
81     BIDI_INFO          = 0x0020,
82     SHAPE_TEXT         = 0x0040,
83     GET_GLYPH_METRICS  = 0x0080,
84     LAYOUT             = 0x0100,
85     UPDATE_ACTUAL_SIZE = 0x0200,
86     REORDER            = 0x0400,
87     ALIGN              = 0x0800,
88     COLOR              = 0x1000,
89     UPDATE_DIRECTION   = 0x2000,
90     ALL_OPERATIONS     = 0xFFFF
91   };
92
93   /**
94    * @brief Used to distinguish between regular key events and IMF events
95    */
96   enum InsertType
97   {
98     COMMIT,
99     PRE_EDIT
100   };
101
102   /**
103    * @brief Used to specify whether to update the input style.
104    */
105   enum UpdateInputStyleType
106   {
107     UPDATE_INPUT_STYLE,
108     DONT_UPDATE_INPUT_STYLE
109   };
110
111   /**
112    * @brief Create a new instance of a Controller.
113    *
114    * @param[in] controlInterface An interface used to request a text relayout.
115    * @return A pointer to a new Controller.
116    */
117   static ControllerPtr New( ControlInterface& controlInterface );
118
119   /**
120    * @brief Called to enable text input.
121    *
122    * @note Selectable or editable controls should call this once after Controller::New().
123    * @param[in] decorator Used to create cursor, selection handle decorations etc.
124    */
125   void EnableTextInput( DecoratorPtr decorator );
126
127   /**
128    * @brief Used to switch between bitmap & vector based glyphs
129    *
130    * @param[in] glyphType The type of glyph; note that metrics for bitmap & vector based glyphs are different.
131    */
132   void SetGlyphType( TextAbstraction::GlyphType glyphType );
133
134   /**
135    * @brief Enables/disables the mark-up processor.
136    *
137    * By default is disabled.
138    *
139    * @param[in] enable Whether to enable the mark-up processor.
140    */
141   void SetMarkupProcessorEnabled( bool enable );
142
143   /**
144    * @brief Retrieves whether the mark-up processor is enabled.
145    *
146    * By default is disabled.
147    *
148    * @return @e true if the mark-up processor is enabled, otherwise returns @e false.
149    */
150   bool IsMarkupProcessorEnabled() const;
151
152   /**
153    * @brief Enables/disables the auto text scrolling
154    *
155    * By default is disabled.
156    *
157    * @param[in] enable Whether to enable the auto scrolling
158    */
159   void SetAutoScrollEnabled( bool enable );
160
161   /**
162    * @brief Retrieves whether auto text scrolling is enabled.
163    *
164    * By default is disabled.
165    *
166    * @return @e true if auto scrolling is enabled, otherwise returns @e false.
167    */
168   bool IsAutoScrollEnabled() const;
169
170   /**
171    * @brief Get direction of the text from the first line of text,
172    * @return bool rtl (right to left) is true
173    */
174   CharacterDirection GetAutoScrollDirection() const;
175
176   /**
177    * @brief Get the alignment offset of the first line of text.
178    *
179    * @return The alignment offset.
180    */
181   float GetAutoScrollLineAlignment() const;
182
183   /**
184    * @brief Replaces any text previously set.
185    *
186    * @note This will be converted into UTF-32 when stored in the text model.
187    * @param[in] text A string of UTF-8 characters.
188    */
189   void SetText( const std::string& text );
190
191   /**
192    * @brief Retrieve any text previously set.
193    *
194    * @param[out] text A string of UTF-8 characters.
195    */
196   void GetText( std::string& text ) const;
197
198   /**
199    * @brief Remove a given number of characters
200    *
201    * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
202    * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
203    * style when pre-edit text is removed.
204    *
205    * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
206    * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
207    * @param[in] type Whether to update the input style.
208    * @return True if the remove was successful.
209    */
210   bool RemoveText( int cursorOffset,
211                    int numberOfCharacters,
212                    UpdateInputStyleType type  );
213
214   /**
215    * @brief Replaces any placeholder text previously set.
216    *
217    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
218    * @param[in] text A string of UTF-8 characters.
219    */
220   void SetPlaceholderText( PlaceholderType type, const std::string& text );
221
222   /**
223    * @brief Retrieve any placeholder text previously set.
224    *
225    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
226    * @param[out] A string of UTF-8 characters.
227    */
228   void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
229
230   /**
231    * @brief Sets the maximum number of characters that can be inserted into the TextModel
232    *
233    * @param[in] maxCharacters maximum number of characters to be accepted
234    */
235   void SetMaximumNumberOfCharacters( Length maxCharacters );
236
237   /**
238    * @brief Sets the maximum number of characters that can be inserted into the TextModel
239    *
240    * @param[in] maxCharacters maximum number of characters to be accepted
241    */
242   int GetMaximumNumberOfCharacters();
243
244   /**
245    * @brief Set the default font family.
246    *
247    * @param[in] defaultFontFamily The default font family.
248    */
249   void SetDefaultFontFamily( const std::string& defaultFontFamily );
250
251   /**
252    * @brief Retrieve the default font family.
253    *
254    * @return The default font family.
255    */
256   const std::string& GetDefaultFontFamily() const;
257
258   /**
259    * @brief Sets the font's style string.
260    *
261    * @note The style set may be changed by the underlying font system. The string is stored to be recovered.
262    *
263    * @param[in] style The font's style string.
264    */
265   void SetDefaultFontStyle( const std::string& style );
266
267   /**
268    * @brief Retrieves the font's style.
269    *
270    * @return The font's style.
271    */
272   const std::string& GetDefaultFontStyle() const;
273
274   /**
275    * @brief Sets the default font weight.
276    *
277    * @param[in] weight The font weight.
278    */
279   void SetDefaultFontWeight( FontWeight weight );
280
281   /**
282    * @brief Retrieves the default font weight.
283    *
284    * @return The default font weight.
285    */
286   FontWeight GetDefaultFontWeight() const;
287
288   /**
289    * @brief Sets the default font width.
290    *
291    * @param[in] width The font width.
292    */
293   void SetDefaultFontWidth( FontWidth width );
294
295   /**
296    * @brief Retrieves the default font width.
297    *
298    * @return The default font width.
299    */
300   FontWidth GetDefaultFontWidth() const;
301
302   /**
303    * @brief Sets the default font slant.
304    *
305    * @param[in] slant The font slant.
306    */
307   void SetDefaultFontSlant( FontSlant slant );
308
309   /**
310    * @brief Retrieves the default font slant.
311    *
312    * @return The default font slant.
313    */
314   FontSlant GetDefaultFontSlant() const;
315
316   /**
317    * @brief Set the default point size.
318    *
319    * @param[in] pointSize The default point size.
320    */
321   void SetDefaultPointSize( float pointSize );
322
323   /**
324    * @brief Retrieve the default point size.
325    *
326    * @return The default point size.
327    */
328   float GetDefaultPointSize() const;
329
330   /**
331    * @ brief Update the text after a font change
332    * @param[in] newDefaultFont The new font to change to
333    */
334   void UpdateAfterFontChange( const std::string& newDefaultFont );
335
336   /**
337    * @brief Set the text color
338    *
339    * @param textColor The text color
340    */
341   void SetTextColor( const Vector4& textColor );
342
343   /**
344    * @brief Retrieve the text color
345    *
346    * @return The text color
347    */
348   const Vector4& GetTextColor() const;
349
350   /**
351    * @brief Set the text color
352    *
353    * @param textColor The text color
354    */
355   void SetPlaceholderTextColor( const Vector4& textColor );
356
357   /**
358    * @brief Retrieve the text color
359    *
360    * @return The text color
361    */
362   const Vector4& GetPlaceholderTextColor() const;
363
364   /**
365    * @brief Set the shadow offset.
366    *
367    * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
368    */
369   void SetShadowOffset( const Vector2& shadowOffset );
370
371   /**
372    * @brief Retrieve the shadow offset.
373    *
374    * @return The shadow offset.
375    */
376   const Vector2& GetShadowOffset() const;
377
378   /**
379    * @brief Set the shadow color.
380    *
381    * @param[in] shadowColor The shadow color.
382    */
383   void SetShadowColor( const Vector4& shadowColor );
384
385   /**
386    * @brief Retrieve the shadow color.
387    *
388    * @return The shadow color.
389    */
390   const Vector4& GetShadowColor() const;
391
392   /**
393    * @brief Sets the shadow's properties string.
394    *
395    * @note The string is stored to be recovered.
396    *
397    * @param[in] shadowProperties The shadow's properties string.
398    */
399   void SetDefaultShadowProperties( const std::string& shadowProperties );
400
401   /**
402    * @brief Retrieves the shadow's properties string.
403    *
404    * @return The shadow's properties string.
405    */
406   const std::string& GetDefaultShadowProperties() const;
407
408   /**
409    * @brief Set the underline color.
410    *
411    * @param[in] color color of underline.
412    */
413   void SetUnderlineColor( const Vector4& color );
414
415   /**
416    * @brief Retrieve the underline color.
417    *
418    * @return The underline color.
419    */
420   const Vector4& GetUnderlineColor() const;
421
422   /**
423    * @brief Set the underline enabled flag.
424    *
425    * @param[in] enabled The underline enabled flag.
426    */
427   void SetUnderlineEnabled( bool enabled );
428
429   /**
430    * @brief Returns whether the text is underlined or not.
431    *
432    * @return The underline state.
433    */
434   bool IsUnderlineEnabled() const;
435
436   /**
437    * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
438    *
439    * @param[in] height The height in pixels of the underline
440    */
441   void SetUnderlineHeight( float height );
442
443   /**
444    * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
445    *
446    * @return The height of the underline, or 0 if height is not overrided.
447    */
448   float GetUnderlineHeight() const;
449
450   /**
451    * @brief Sets the underline's properties string.
452    *
453    * @note The string is stored to be recovered.
454    *
455    * @param[in] underlineProperties The underline's properties string.
456    */
457   void SetDefaultUnderlineProperties( const std::string& underlineProperties );
458
459   /**
460    * @brief Retrieves the underline's properties string.
461    *
462    * @return The underline's properties string.
463    */
464   const std::string& GetDefaultUnderlineProperties() const;
465
466   /**
467    * @brief Sets the emboss's properties string.
468    *
469    * @note The string is stored to be recovered.
470    *
471    * @param[in] embossProperties The emboss's properties string.
472    */
473   void SetDefaultEmbossProperties( const std::string& embossProperties );
474
475   /**
476    * @brief Retrieves the emboss's properties string.
477    *
478    * @return The emboss's properties string.
479    */
480   const std::string& GetDefaultEmbossProperties() const;
481
482   /**
483    * @brief Sets the outline's properties string.
484    *
485    * @note The string is stored to be recovered.
486    *
487    * @param[in] outlineProperties The outline's properties string.
488    */
489   void SetDefaultOutlineProperties( const std::string& outlineProperties );
490
491   /**
492    * @brief Retrieves the outline's properties string.
493    *
494    * @return The outline's properties string.
495    */
496   const std::string& GetDefaultOutlineProperties() const;
497
498   /**
499    * @brief Sets the default line spacing.
500    *
501    * @param[in] lineSpacing The line spacing.
502    */
503   void SetDefaultLineSpacing( float lineSpacing );
504
505   /**
506    * @brief Retrieves the default line spacing.
507    *
508    * @return The line spacing.
509    */
510   float GetDefaultLineSpacing() const;
511
512   /**
513    * @brief Sets the input text's color.
514    *
515    * @param[in] color The input text's color.
516    */
517   void SetInputColor( const Vector4& color );
518
519   /**
520    * @brief Retrieves the input text's color.
521    *
522    * @return The input text's color.
523    */
524   const Vector4& GetInputColor() const;
525
526   /**
527    * @brief Sets the input text's font family name.
528    *
529    * @param[in] fontFamily The text's font family name.
530    */
531   void SetInputFontFamily( const std::string& fontFamily );
532
533   /**
534    * @brief Retrieves the input text's font family name.
535    *
536    * @return The input text's font family name.
537    */
538   const std::string& GetInputFontFamily() const;
539
540   /**
541    * @brief Sets the input text's font style.
542    *
543    * @param[in] fontStyle The input text's font style.
544    */
545   void SetInputFontStyle( const std::string& fontStyle );
546
547   /**
548    * @brief Retrieves the input text's font style.
549    *
550    * @return The input text's font style.
551    */
552   const std::string& GetInputFontStyle() const;
553
554   /**
555    * @brief Sets the input font's weight.
556    *
557    * @param[in] weight The input font's weight.
558    */
559   void SetInputFontWeight( FontWeight weight );
560
561   /**
562    * @brief Retrieves the input font's weight.
563    *
564    * @return The input font's weight.
565    */
566   FontWeight GetInputFontWeight() const;
567
568   /**
569    * @brief Sets the input font's width.
570    *
571    * @param[in] width The input font's width.
572    */
573   void SetInputFontWidth( FontWidth width );
574
575   /**
576    * @brief Retrieves the input font's width.
577    *
578    * @return The input font's width.
579    */
580   FontWidth GetInputFontWidth() const;
581
582   /**
583    * @brief Sets the input font's slant.
584    *
585    * @param[in] slant The input font's slant.
586    */
587   void SetInputFontSlant( FontSlant slant );
588
589   /**
590    * @brief Retrieves the input font's slant.
591    *
592    * @return The input font's slant.
593    */
594   FontSlant GetInputFontSlant() const;
595
596   /**
597    * @brief Sets the input font's point size.
598    *
599    * @param[in] size The input font's point size.
600    */
601   void SetInputFontPointSize( float size );
602
603   /**
604    * @brief Retrieves the input font's point size.
605    *
606    * @return The input font's point size.
607    */
608   float GetInputFontPointSize() const;
609
610   /**
611    * @brief Sets the input line spacing.
612    *
613    * @param[in] lineSpacing The line spacing.
614    */
615   void SetInputLineSpacing( float lineSpacing );
616
617   /**
618    * @brief Retrieves the input line spacing.
619    *
620    * @return The line spacing.
621    */
622   float GetInputLineSpacing() const;
623
624   /**
625    * @brief Sets the input shadow's properties string.
626    *
627    * @note The string is stored to be recovered.
628    *
629    * @param[in] shadowProperties The shadow's properties string.
630    */
631   void SetInputShadowProperties( const std::string& shadowProperties );
632
633   /**
634    * @brief Retrieves the input shadow's properties string.
635    *
636    * @return The shadow's properties string.
637    */
638   const std::string& GetInputShadowProperties() const;
639
640   /**
641    * @brief Sets the input underline's properties string.
642    *
643    * @note The string is stored to be recovered.
644    *
645    * @param[in] underlineProperties The underline's properties string.
646    */
647   void SetInputUnderlineProperties( const std::string& underlineProperties );
648
649   /**
650    * @brief Retrieves the input underline's properties string.
651    *
652    * @return The underline's properties string.
653    */
654   const std::string& GetInputUnderlineProperties() const;
655
656   /**
657    * @brief Sets the input emboss's properties string.
658    *
659    * @note The string is stored to be recovered.
660    *
661    * @param[in] embossProperties The emboss's properties string.
662    */
663   void SetInputEmbossProperties( const std::string& embossProperties );
664
665   /**
666    * @brief Retrieves the input emboss's properties string.
667    *
668    * @return The emboss's properties string.
669    */
670   const std::string& GetInputEmbossProperties() const;
671
672   /**
673    * @brief Sets input the outline's properties string.
674    *
675    * @note The string is stored to be recovered.
676    *
677    * @param[in] outlineProperties The outline's properties string.
678    */
679   void SetInputOutlineProperties( const std::string& outlineProperties );
680
681   /**
682    * @brief Retrieves the input outline's properties string.
683    *
684    * @return The outline's properties string.
685    */
686   const std::string& GetInputOutlineProperties() const;
687
688   /**
689    * @brief Called to enable/disable cursor blink.
690    *
691    * @note Only editable controls should calls this.
692    * @param[in] enabled Whether the cursor should blink or not.
693    */
694   void SetEnableCursorBlink( bool enable );
695
696   /**
697    * @brief Query whether cursor blink is enabled.
698    *
699    * @return Whether the cursor should blink or not.
700    */
701   bool GetEnableCursorBlink() const;
702
703   /**
704    * @brief Query the current scroll position; the UI control is responsible for moving actors to this position.
705    *
706    * @return The scroll position.
707    */
708   const Vector2& GetScrollPosition() const;
709
710   /**
711    * @copydoc Control::GetNaturalSize()
712    */
713   Vector3 GetNaturalSize();
714
715   /**
716    * @copydoc Control::GetHeightForWidth()
717    */
718   float GetHeightForWidth( float width );
719
720   /**
721    * @brief Triggers a relayout which updates View (if necessary).
722    *
723    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
724    * @param[in] size A the size of a bounding box to layout text within.
725    * @return True if the text model or decorations were updated.
726    */
727   bool Relayout( const Size& size );
728
729   /**
730    * @brief Process queued events which modify the model.
731    */
732   void ProcessModifyEvents();
733
734   /**
735    * @brief Used to remove placeholder text.
736    */
737   void ResetText();
738
739   /**
740    * @brief Used to reset the cursor position after setting a new text.
741    *
742    * @param[in] cursorIndex Where to place the cursor.
743    */
744   void ResetCursorPosition( CharacterIndex cursorIndex );
745
746   /**
747    * @brief Used to reset the scroll position after setting a new text.
748    */
749   void ResetScrollPosition();
750
751   /**
752    * @brief Used to process an event queued from SetText()
753    */
754   void TextReplacedEvent();
755
756   /**
757    * @brief Used to process an event queued from key events etc.
758    */
759   void TextInsertedEvent();
760
761   /**
762    * @brief Used to process an event queued from backspace key etc.
763    */
764   void TextDeletedEvent();
765
766   /**
767    * @brief Lays-out the text.
768    *
769    * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
770    *
771    * @param[in] size A the size of a bounding box to layout text within.
772    * @param[in] operations The layout operations which need to be done.
773    * @param[out] layoutSize The size of the laid-out text.
774    */
775   bool DoRelayout( const Size& size,
776                    OperationsMask operations,
777                    Size& layoutSize );
778
779   /**
780    * @brief Whether to enable the multi-line layout.
781    *
782    * @param[in] enable \e true enables the multi-line (by default)
783    */
784   void SetMultiLineEnabled( bool enable );
785
786   /**
787    * @return Whether the multi-line layout is enabled.
788    */
789   bool IsMultiLineEnabled() const;
790
791   /**
792    * @copydoc Dali::Toolkit::Text::LayoutEngine::SetHorizontalAlignment()
793    */
794   void SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment );
795
796   /**
797    * @copydoc Dali::Toolkit::Text::LayoutEngine::GetHorizontalAlignment()
798    */
799   LayoutEngine::HorizontalAlignment GetHorizontalAlignment() const;
800
801   /**
802    * @copydoc Dali::Toolkit::Text::LayoutEngine::SetVerticalAlignment()
803    */
804   void SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment );
805
806   /**
807    * @copydoc Dali::Toolkit::Text::LayoutEngine::GetVerticalAlignment()
808    */
809   LayoutEngine::VerticalAlignment GetVerticalAlignment() const;
810
811   /**
812    * @brief Calulates the vertical offset to align the text inside the bounding box.
813    *
814    * @param[in] size The size of the bounding box.
815    */
816   void CalculateVerticalOffset( const Size& size );
817
818   /**
819    * @brief Return the layout engine.
820    *
821    * @return A reference to the layout engine.
822    */
823   LayoutEngine& GetLayoutEngine();
824
825   /**
826    * @brief Return a view of the text.
827    *
828    * @return A reference to the view.
829    */
830   View& GetView();
831
832   // Text-input Event Queuing
833
834   /**
835    * @brief Called by editable UI controls when keyboard focus is gained.
836    */
837   void KeyboardFocusGainEvent();
838
839   /**
840    * @brief Called by editable UI controls when focus is lost.
841    */
842   void KeyboardFocusLostEvent();
843
844   /**
845    * @brief Called by editable UI controls when key events are received.
846    *
847    * @param[in] event The key event.
848    * @param[in] type Used to distinguish between regular key events and IMF events.
849    */
850   bool KeyEvent( const Dali::KeyEvent& event );
851
852   /**
853    * @brief Called by editable UI controls when key events are received.
854    *
855    * @param[in] text The text to insert.
856    * @param[in] type Used to distinguish between regular key events and IMF events.
857    */
858   void InsertText( const std::string& text, InsertType type );
859
860   /**
861    * @brief Checks if text is selected and if so removes it.
862    * @return true if text was removed
863    */
864   bool RemoveSelectedText();
865
866   /**
867    * @brief Called by editable UI controls when a tap gesture occurs.
868    * @param[in] tapCount The number of taps.
869    * @param[in] x The x position relative to the top-left of the parent control.
870    * @param[in] y The y position relative to the top-left of the parent control.
871    */
872   void TapEvent( unsigned int tapCount, float x, float y );
873
874   /**
875    * @brief Called by editable UI controls when a pan gesture occurs.
876    *
877    * @param[in] state The state of the gesture.
878    * @param[in] displacement This distance panned since the last pan gesture.
879    */
880   void PanEvent( Gesture::State state, const Vector2& displacement );
881
882   /**
883    * @brief Called by editable UI controls when a long press gesture occurs.
884    *
885    * @param[in] state The state of the gesture.
886    * @param[in] x The x position relative to the top-left of the parent control.
887    * @param[in] y The y position relative to the top-left of the parent control.
888    */
889   void LongPressEvent( Gesture::State state, float x, float y );
890
891   /**
892    * @brief Creates a selection event.
893    *
894    * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
895    *
896    * @param[in] x The x position relative to the top-left of the parent control.
897    * @param[in] y The y position relative to the top-left of the parent control.
898    * @param[in] selectAll Whether the whole text is selected.
899    */
900   void SelectEvent( float x, float y, bool selectAll );
901
902   /**
903    * @brief Event received from IMF manager
904    *
905    * @param[in] imfManager The IMF manager.
906    * @param[in] imfEvent The event received.
907    * @return A data struture indicating if update is needed, cursor position and current text.
908    */
909   ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
910
911   /**
912    * @brief Paste given string into Text model
913    * @param[in] stringToPaste this string will be inserted into the text model
914    */
915   void PasteText( const std::string& stringToPaste );
916
917   /**
918    * @brief Event from Clipboard notifying an Item has been selected for pasting
919    */
920   void PasteClipboardItemEvent();
921
922   /**
923    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
924    */
925   virtual void GetTargetSize( Vector2& targetSize );
926
927   /**
928    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
929    */
930   virtual void AddDecoration( Actor& actor, bool needsClipping );
931
932   /**
933    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
934    */
935   virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
936
937   /**
938    * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
939    */
940   virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
941
942 protected:
943
944   /**
945    * @brief A reference counted object may only be deleted by calling Unreference().
946    */
947   virtual ~Controller();
948
949 private:
950
951   /**
952    * @brief Helper to KeyEvent() to handle the backspace case.
953    *
954    * @return True if a character was deleted.
955    */
956   bool BackspaceKeyEvent();
957
958   /**
959    * @brief Helper to clear font-specific data.
960    */
961   void ShowPlaceholderText();
962
963   /**
964    * @brief Helper to clear font-specific data (only).
965    */
966   void ClearFontData();
967
968   /**
969    * @brief Helper to clear text's style data.
970    */
971   void ClearStyleData();
972
973   /**
974    * @brief Private constructor.
975    */
976   Controller( ControlInterface& controlInterface );
977
978   // Undefined
979   Controller( const Controller& handle );
980
981   // Undefined
982   Controller& operator=( const Controller& handle );
983
984 private:
985
986   struct Impl;
987   Impl* mImpl;
988 };
989
990 } // namespace Text
991
992 } // namespace Toolkit
993
994 } // namespace Dali
995
996 #endif // __DALI_TOOLKIT_TEXT_CONTROLLER_H__