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