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