APIs for text editor.
[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 Replaces any text previously set.
178    *
179    * @note This will be converted into UTF-32 when stored in the text model.
180    * @param[in] text A string of UTF-8 characters.
181    */
182   void SetText( const std::string& text );
183
184   /**
185    * @brief Retrieve any text previously set.
186    *
187    * @return A string of UTF-8 characters.
188    */
189   void GetText( std::string& text ) const;
190
191   /**
192    * @brief Remove a given number of characters
193    *
194    * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
195    * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
196    * style when pre-edit text is removed.
197    *
198    * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
199    * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
200    * @param[in] type Whether to update the input style.
201    * @return True if the remove was successful.
202    */
203   bool RemoveText( int cursorOffset,
204                    int numberOfCharacters,
205                    UpdateInputStyleType type  );
206
207   /**
208    * @brief Retrieve the current cursor position.
209    *
210    * @return The cursor position.
211    */
212   unsigned int GetLogicalCursorPosition() const;
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    * @brief Query the alignment offset.
712    *
713    * @return The alignmnet offset.
714    */
715   const Vector2& GetAlignmentOffset() const;
716
717   /**
718    * @copydoc Control::GetNaturalSize()
719    */
720   Vector3 GetNaturalSize();
721
722   /**
723    * @copydoc Control::GetHeightForWidth()
724    */
725   float GetHeightForWidth( float width );
726
727   /**
728    * @brief Triggers a relayout which updates View (if necessary).
729    *
730    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
731    * @param[in] size A the size of a bounding box to layout text within.
732    * @return True if the text model or decorations were updated.
733    */
734   bool Relayout( const Size& size );
735
736   /**
737    * @brief Process queued events which modify the model.
738    */
739   void ProcessModifyEvents();
740
741   /**
742    * @brief Used to remove placeholder text.
743    */
744   void ResetText();
745
746   /**
747    * @brief Used to reset the cursor position after setting a new text.
748    *
749    * @param[in] cursorIndex Where to place the cursor.
750    */
751   void ResetCursorPosition( CharacterIndex cursorIndex );
752
753   /**
754    * @brief Used to reset the scroll position after setting a new text.
755    */
756   void ResetScrollPosition();
757
758   /**
759    * @brief Used to process an event queued from SetText()
760    */
761   void TextReplacedEvent();
762
763   /**
764    * @brief Used to process an event queued from key events etc.
765    */
766   void TextInsertedEvent();
767
768   /**
769    * @brief Used to process an event queued from backspace key etc.
770    */
771   void TextDeletedEvent();
772
773   /**
774    * @brief Lays-out the text.
775    *
776    * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
777    *
778    * @param[in] size A the size of a bounding box to layout text within.
779    * @param[in] operations The layout operations which need to be done.
780    * @param[out] layoutSize The size of the laid-out text.
781    */
782   bool DoRelayout( const Size& size,
783                    OperationsMask operations,
784                    Size& layoutSize );
785
786   /**
787    * @brief Whether to enable the multi-line layout.
788    *
789    * @param[in] enable \e true enables the multi-line (by default)
790    */
791   void SetMultiLineEnabled( bool enable );
792
793   /**
794    * @return Whether the multi-line layout is enabled.
795    */
796   bool IsMultiLineEnabled() const;
797
798   /**
799    * @copydoc Dali::Toolkit::Text::LayoutEngine::SetHorizontalAlignment()
800    */
801   void SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment );
802
803   /**
804    * @copydoc Dali::Toolkit::Text::LayoutEngine::GetHorizontalAlignment()
805    */
806   LayoutEngine::HorizontalAlignment GetHorizontalAlignment() const;
807
808   /**
809    * @copydoc Dali::Toolkit::Text::LayoutEngine::SetVerticalAlignment()
810    */
811   void SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment );
812
813   /**
814    * @copydoc Dali::Toolkit::Text::LayoutEngine::GetVerticalAlignment()
815    */
816   LayoutEngine::VerticalAlignment GetVerticalAlignment() const;
817
818   /**
819    * @brief Calulates the alignment of the whole text inside the bounding box.
820    *
821    * @param[in] size The size of the bounding box.
822    */
823   void CalculateTextAlignment( const Size& size );
824
825   /**
826    * @brief Return the layout engine.
827    *
828    * @return A reference to the layout engine.
829    */
830   LayoutEngine& GetLayoutEngine();
831
832   /**
833    * @brief Return a view of the text.
834    *
835    * @return A reference to the view.
836    */
837   View& GetView();
838
839   // Text-input Event Queuing
840
841   /**
842    * @brief Called by editable UI controls when keyboard focus is gained.
843    */
844   void KeyboardFocusGainEvent();
845
846   /**
847    * @brief Called by editable UI controls when focus is lost.
848    */
849   void KeyboardFocusLostEvent();
850
851   /**
852    * @brief Called by editable UI controls when key events are received.
853    *
854    * @param[in] event The key event.
855    * @param[in] type Used to distinguish between regular key events and IMF events.
856    */
857   bool KeyEvent( const Dali::KeyEvent& event );
858
859   /**
860    * @brief Called by editable UI controls when key events are received.
861    *
862    * @param[in] text The text to insert.
863    * @param[in] type Used to distinguish between regular key events and IMF events.
864    */
865   void InsertText( const std::string& text, InsertType type );
866
867   /**
868    * @brief Checks if text is selected and if so removes it.
869    * @return true if text was removed
870    */
871   bool RemoveSelectedText();
872
873   /**
874    * @brief Called by editable UI controls when a tap gesture occurs.
875    * @param[in] tapCount The number of taps.
876    * @param[in] x The x position relative to the top-left of the parent control.
877    * @param[in] y The y position relative to the top-left of the parent control.
878    */
879   void TapEvent( unsigned int tapCount, float x, float y );
880
881   /**
882    * @brief Called by editable UI controls when a pan gesture occurs.
883    *
884    * @param[in] state The state of the gesture.
885    * @param[in] displacement This distance panned since the last pan gesture.
886    */
887   void PanEvent( Gesture::State state, const Vector2& displacement );
888
889   /**
890    * @brief Called by editable UI controls when a long press gesture occurs.
891    *
892    * @param[in] state The state of the gesture.
893    * @param[in] x The x position relative to the top-left of the parent control.
894    * @param[in] y The y position relative to the top-left of the parent control.
895    */
896   void LongPressEvent( Gesture::State state, float x, float y );
897
898   /**
899    * @brief Creates a selection event.
900    *
901    * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.
902    *
903    * @param[in] x The x position relative to the top-left of the parent control.
904    * @param[in] y The y position relative to the top-left of the parent control.
905    * @param[in] selectAll Whether the whole text is selected.
906    */
907   void SelectEvent( float x, float y, bool selectAll );
908
909   /**
910    * @brief Event received from IMF manager
911    *
912    * @param[in] imfManager The IMF manager.
913    * @param[in] imfEvent The event received.
914    * @return A data struture indicating if update is needed, cursor position and current text.
915    */
916   ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
917
918   /**
919    * @brief Paste given string into Text model
920    * @param[in] stringToPaste this string will be inserted into the text model
921    */
922   void PasteText( const std::string& stringToPaste );
923
924   /**
925    * @brief Event from Clipboard notifying an Item has been selected for pasting
926    */
927   void PasteClipboardItemEvent();
928
929   /**
930    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
931    */
932   virtual void GetTargetSize( Vector2& targetSize );
933
934   /**
935    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
936    */
937   virtual void AddDecoration( Actor& actor, bool needsClipping );
938
939   /**
940    * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
941    */
942   virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
943
944   /**
945    * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
946    */
947   virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
948
949 protected:
950
951   /**
952    * @brief A reference counted object may only be deleted by calling Unreference().
953    */
954   virtual ~Controller();
955
956 private:
957
958   /**
959    * @brief Helper to KeyEvent() to handle the backspace case.
960    *
961    * @return True if a character was deleted.
962    */
963   bool BackspaceKeyEvent();
964
965   /**
966    * @brief Helper to notify IMF manager with surrounding text & cursor changes.
967    */
968   void NotifyImfManager();
969
970   /**
971    * @brief Helper to clear font-specific data.
972    */
973   void ShowPlaceholderText();
974
975   /**
976    * @brief Helper to clear font-specific data (only).
977    */
978   void ClearFontData();
979
980   /**
981    * @brief Helper to clear text's style data.
982    */
983   void ClearStyleData();
984
985   /**
986    * @brief Private constructor.
987    */
988   Controller( ControlInterface& controlInterface );
989
990   // Undefined
991   Controller( const Controller& handle );
992
993   // Undefined
994   Controller& operator=( const Controller& handle );
995
996 private:
997
998   struct Impl;
999   Impl* mImpl;
1000 };
1001
1002 } // namespace Text
1003
1004 } // namespace Toolkit
1005
1006 } // namespace Dali
1007
1008 #endif // __DALI_TOOLKIT_TEXT_CONTROLLER_H__