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