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