Merge branch 'master' into tizen
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-input / text-input-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali-toolkit/public-api/controls/control-impl.h>
22 #include <dali-toolkit/public-api/controls/text-input/text-input.h>
23 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
24 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
25 #include <dali-toolkit/internal/controls/text-input/text-input-popup-impl.h>
26
27 #include <dali/public-api/common/dali-vector.h>
28 #include <dali/public-api/adaptor-framework/common/imf-manager.h>
29 #include <dali/public-api/geometry/mesh.h>
30
31 namespace Dali
32 {
33
34 namespace Toolkit
35 {
36
37 namespace Internal
38 {
39
40 class TextInput;
41 class TextView;
42
43 typedef IntrusivePtr<TextInput> TextInputPtr;
44
45 class TextInput : public Control
46 {
47 public:
48
49   /**
50    * Create a new TextInput
51    * @return instrusive ptr to a TextInput
52    */
53   static Dali::Toolkit::TextInput New();
54
55   /**
56    * @copydoc Toolkit::TextInput::GetText
57    */
58   std::string GetText() const;
59
60   /**
61    * @copydoc Toolkit::TextInput::GetMarkupText()
62    */
63   std::string GetMarkupText() const;
64
65   /**
66    * @copydoc Toolkit::TextInput::SetPlaceholderText
67    */
68   void SetPlaceholderText( const std::string& placeHolderText );
69
70   /**
71    * @copydoc Toolkit::TextInput::SetPlaceholderText
72    */
73   std::string GetPlaceholderText();
74
75   /**
76    * @copydoc Toolkit::TextInput::SetInitialText
77    */
78   void SetInitialText(const std::string& initialText);
79
80   /**
81    *  set the text to be displayed in text-input, will overwrite any existing text.
82    *  can be used to clear the text-input by passing an empty string.
83    *  @param [in] initialText text to be initially displayed
84    */
85   void SetText(const std::string& initialText);
86
87   /**
88    * @copydoc Toolkit::TextInput::SetMaxCharacterLength
89    */
90   void SetMaxCharacterLength(std::size_t maxChars);
91
92   /**
93    * @copydoc Toolkit::TextInput::SetNumberOfLinesLimit
94    */
95   void SetNumberOfLinesLimit(std::size_t maxLines);
96
97   /**
98    * @copydoc Toolkit::TextInput::GetNumberOfLinesLimit
99    */
100   std::size_t GetNumberOfLinesLimit() const;
101
102   /**
103    * @copydoc Toolkit::TextInput::GetFont
104    */
105   Font GetFont() const;
106
107   /**
108    * @copydoc Toolkit::TextInput::SetFont
109    */
110   void SetFont(Font font);
111
112   /**
113    * @copydoc Toolkit::TextInput::InputStartedSignal()
114    */
115   Toolkit::TextInput::InputSignalV2& InputStartedSignal();
116
117   /**
118    * @copydoc Toolkit::TextInput::InputFinishedSignal()
119    */
120   Toolkit::TextInput::InputSignalV2& InputFinishedSignal();
121
122   /**
123    * @copydoc Toolkit::TextInput::CutAndPasteToolBarDisplayedSignal()
124    */
125   Toolkit::TextInput::InputSignalV2& CutAndPasteToolBarDisplayedSignal();
126
127   /**
128    * @copydoc Toolkit::TextInput::StyleChangedSignal()
129    */
130   Toolkit::TextInput::StyleChangedSignalV2& StyleChangedSignal();
131
132   /**
133    * @copydoc Toolkit::TextInput::TextModifiedSignal()
134    */
135   Toolkit::TextInput::TextModifiedSignalType& TextModifiedSignal();
136
137   /**
138    * @copydoc Toolkit::TextInput::MaxInputCharactersReachedSignal()
139    */
140   Toolkit::TextInput::MaxInputCharactersReachedSignalV2& MaxInputCharactersReachedSignal();
141
142   /**
143    * @copydoc Toolkit::TextInput::InputTextExceedBoundariesSignal()
144    */
145   Toolkit::TextInput::InputTextExceedBoundariesSignalV2& InputTextExceedBoundariesSignal();
146
147   /**
148    * Connects a callback function with the object's signals.
149    * @param[in] object The object providing the signal.
150    * @param[in] tracker Used to disconnect the signal.
151    * @param[in] signalName The signal to connect to.
152    * @param[in] functor A newly allocated FunctorDelegate.
153    * @return True if the signal was connected.
154    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
155    */
156   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
157
158   /**
159    * @see Toolkit::TextInput::SetEditMode(bool editMode)
160    * @see Toolkit::TextInput::SetEditMode(bool editMode, const Vector2& touchPoint)
161    *
162    * @param[in] editMode true or false to indicate editMode on or off.
163    * @param[in] setCursorOnTouchPoint Whether to use the touch point to set the cursor position.
164    * @param[in] touchPoint A position in actor coordinates within the text-input.
165    */
166   void SetEditable(bool editMode, bool setCursorOnTouchPoint, const Vector2& touchPoint = Vector2::ZERO);
167
168   /**
169    * @copydoc Toolkit::TextInput::GetEditMode
170    */
171   bool IsEditable() const;
172
173   /**
174    * @copydoc Toolkit::TextInput::SetTextSelectable
175    */
176   void SetTextSelectable(bool textSelectable = true);
177
178   /**
179    * @copydoc Toolkit::TextInput::IsTextSelectable
180    */
181   bool IsTextSelectable() const;
182
183   /**
184    * @copydoc Toolkit::TextInput::IsTextSelected
185    */
186   bool IsTextSelected() const;
187
188   /**
189    * @copydoc Toolkit::TextInput::DeSelectText
190    */
191   void DeSelectText();
192
193   /**
194    * @copydoc Toolkit::TextInput::SetEditOnTouch
195    */
196   void SetEditOnTouch(bool editOnTouch);
197
198   /**
199    * @copydoc Toolkit::TextInput::IsEditOnTouch
200    */
201   bool IsEditOnTouch() const;
202
203   /**
204    * @copydoc Toolkit::TextInput::SetGrabHandleImage
205    */
206   void SetGrabHandleImage(Dali::Image image);
207
208   /**
209    * @copydoc Toolkit::TextInput::SetCursorImage
210    */
211   void SetCursorImage(Dali::Image image, const Vector4& border );
212
213   /**
214    * @copydoc Toolkit::TextInput::GetSelectionHandleSize
215    */
216   Vector3 GetSelectionHandleSize();
217
218   /**
219    * @copydoc Toolkit::TextInput::SetRTLCursorImage
220    */
221   void SetRTLCursorImage(Dali::Image image, const Vector4& border );
222
223   /**
224    * @copydoc Toolkit::TextInput::EnableGrabHandle
225    */
226   void EnableGrabHandle(bool toggle);
227
228   /**
229    * @copydoc Toolkit::TextInput::IsGrabHandleEnabled
230    */
231   bool IsGrabHandleEnabled();
232
233   /**
234    * @copydoc Toolkit::TextInput::EnableSelectionHandleFlip
235    */
236   void EnableSelectionHandleFlip( bool toggle );
237
238   /**
239    * @copydoc Toolkit::TextInput::IsSelectionHandleFlipEnabled
240    */
241   bool IsSelectionHandleFlipEnabled();
242
243   /**
244    * @copydoc Toolkit::TextInput::SetSelectionHandleFlipMargin
245    */
246   void SetSelectionHandleFlipMargin( const Vector4& margin );
247
248   /**
249    * @copydoc Toolkit::TextInput::SetBoundingRectangle
250    */
251   void SetBoundingRectangle( const Rect<float>& boundingRectangle );
252
253   /**
254    * @copydoc Toolkit::TextInput::GetBoundingRectangle
255    */
256   const Rect<float> GetBoundingRectangle() const;
257
258   /**
259    * @copydoc Toolkit::TextInput::GetSelectionHandleFlipMargin
260    */
261   const Vector4& GetSelectionHandleFlipMargin();
262
263   /**
264    * @copydoc Toolkit::TextInput::SetTextColor
265    */
266   void SetTextColor( const Vector4& color );
267
268   /**
269    * @copydoc Toolkit::TextInput::SetActiveStyle
270    */
271   void SetActiveStyle( const TextStyle& style, const TextStyle::Mask mask );
272
273   /**
274    * @copydoc Toolkit::TextInput::ApplyStyle
275    */
276   void ApplyStyle( const TextStyle& style, const TextStyle::Mask mask );
277
278   /**
279    * @copydoc Toolkit::TextInput::ApplyStyleToAll
280    */
281   void ApplyStyleToAll( const TextStyle& style, const TextStyle::Mask mask );
282
283   /**
284    * @copydoc Toolkit::TextInput::GetStyleAtCursor
285    */
286   TextStyle GetStyleAtCursor() const;
287
288   /**
289    * Retrieves the character style for the given position.
290    * @param[in] position The character position which style is required.
291    * @return The style for the given position.
292    */
293   TextStyle GetStyleAt( std::size_t position ) const;
294
295   /**
296    * @copydoc Toolkit::TextInput::SetTextAlignment()
297    */
298   void SetTextAlignment( Toolkit::Alignment::Type align );
299
300   /**
301    * @copydoc Toolkit::TextInput::SetTextLineJustification()
302    */
303   void SetTextLineJustification( Toolkit::TextView::LineJustification justification );
304
305   /**
306    * @copydoc Toolkit::TextInput::SetFadeBoundary()
307    */
308   void SetFadeBoundary( const Toolkit::TextView::FadeBoundary& fadeBoundary );
309
310   /**
311    * @copydoc Toolkit::TextInput::GetFadeBoundary()
312    */
313   const Toolkit::TextView::FadeBoundary& GetFadeBoundary() const;
314
315   /**
316    * @copydoc Toolkit::TextInput::GetTextAlignment()
317    */
318   Toolkit::Alignment::Type GetTextAlignment() const;
319
320   /**
321    * @copydoc Toolkit::TextInput::SetMultilinePolicy()
322    */
323   void SetMultilinePolicy( Toolkit::TextView::MultilinePolicy policy );
324
325   /**
326    * @copydoc Toolkit::TextInput::GetMultilinePolicy()
327    */
328   Toolkit::TextView::MultilinePolicy GetMultilinePolicy() const;
329
330   /**
331    * @copydoc Toolkit::TextInput::SetWidthExceedPolicy()
332    */
333   void SetWidthExceedPolicy( Toolkit::TextView::ExceedPolicy policy );
334
335   /**
336    * @copydoc Toolkit::TextInput::GetWidthExceedPolicy()
337    */
338   Toolkit::TextView::ExceedPolicy GetWidthExceedPolicy() const;
339
340   /**
341    * @copydoc Toolkit::TextInput::SetHeightExceedPolicy()
342    */
343   void SetHeightExceedPolicy( Toolkit::TextView::ExceedPolicy policy );
344
345   /**
346    * @copydoc Toolkit::TextInput::GetHeightExceedPolicy()
347    */
348   Toolkit::TextView::ExceedPolicy GetHeightExceedPolicy() const;
349
350   /**
351    * @copydoc Toolkit::TextInput::SetExceedEnabled()
352    */
353   void SetExceedEnabled( bool enable );
354
355   /**
356    * @copydoc Toolkit::TextInput::GetExceedEnabled()
357    */
358   bool GetExceedEnabled() const;
359
360   /**
361    * @copydoc Toolkit::TextInput::SetBackground
362    */
363   void SetBackground(Dali::Image image );
364
365   /**
366    * @copydoc Toolkit::TextInput::SetNumberOfLines
367    */
368   void SetNumberOfLines(std::size_t lines);
369
370   /**
371    * @copydoc Toolkit::TextInput::GetNumberOfLines
372    */
373   std::size_t GetNumberOfLines();
374
375   /**
376    * @copydoc Toolkit::TextInput::GetNumberOfCharacters
377    */
378   std::size_t GetNumberOfCharacters() const;
379
380 private:
381
382   /**
383    * structure to hold each highlight box needed for text selection
384    */
385   struct HighlightBox
386   {
387     Vector3 size;                         ///< size of the highlight box
388     Vector3 position;                     ///< position of highlight box
389     ImageActor highlightBoxActor;         ///< as actor that is the highlight box
390   };
391
392   /**
393    * structure to hold each character in displayed string and its position from the left
394    */
395   struct CharPositions
396   {
397     char character;   ///< todo change to UTF to aid multi-language support
398     Vector3 position;
399     Vector2 size;
400   };
401
402   /**
403    * structure to hold coordinates of each quad, which will make up the mesh.
404    */
405   struct QuadCoordinates
406   {
407     /**
408      * Default constructor
409      */
410     QuadCoordinates()
411     {
412     }
413
414     /**
415      * Constructor
416      * @param[in] x1 left co-ordinate
417      * @param[in] y1 top co-ordinate
418      * @param[in] x2 right co-ordinate
419      * @param[in] y2 bottom co-ordinate
420      */
421     QuadCoordinates(float x1, float y1, float x2, float y2)
422     : min(x1, y1),
423       max(x2, y2)
424     {
425     }
426
427     Vector2 min;                          ///< top-left (minimum) position of quad
428     Vector2 max;                          ///< bottom-right (maximum) position of quad
429   };
430
431   typedef std::vector<QuadCoordinates> QuadContainer;
432
433   /**
434    * structure for information required to build the highlight mesh
435    */
436   struct HighlightInfo
437   {
438     /**
439      * Adds a Quad (2D rectangular sub-selection)
440      * @param[in] x1 left co-ordinate
441      * @param[in] y1 top co-ordinate
442      * @param[in] x2 right co-ordinate
443      * @param[in] y2 bottom co-ordinate
444      */
445     void AddQuad( float x1, float y1, float x2, float y2 );
446
447     /**
448      * Clamps all quads to fit within a min -> max 2D boundary.
449      */
450     void Clamp2D(const Vector2& min, const Vector2& max);
451
452     QuadContainer mQuadList;                                 ///< List of quads (sub-selections that form to create complete selection)
453   };
454
455   /**
456    * Holds requested selection start and end points for highlighted text.
457    */
458   struct SelectionParameters
459   {
460     SelectionParameters( size_t start, size_t end )
461     : mStartOfSelection( start ), mEndOfSelection( end )
462     {
463
464     }
465
466     size_t mStartOfSelection;
467     size_t mEndOfSelection;
468   };
469
470   enum State
471   {
472     StateEdit,
473     StateDraggingHandle
474   };
475
476   enum SelectionHandleId
477   {
478     HandleOne,   ///< Selection handle one which is on the left
479     HandleTwo    ///< Selection handle two which is on the right
480   };
481
482   /**
483    * Two different behaviours are needed to convert a touch point into a character index.
484    * When a tap is received and the touch point doesn't hit any character, the final character selected might
485    * be different than the one selected if the event is a pan.
486    * i.e. If a tap is received and the touch point doesn't hit any character the expected position of the cursor
487    * would be the end or the beginning of a line. However, this behaviour would be weird while panning.
488    */
489   enum TouchToIndex
490   {
491     TapMode,  ///< Touch point to character index conversion mode used for Tap events.
492     DragMode  ///< Touch point to character index conversion mode used for Pan events.
493   };
494
495   /**
496    * Used to set the direction when find the next visible character.
497    */
498   enum FindVisibleCharacterDirection
499   {
500     Left,  ///< Find visible characters on the left.
501     Right, ///< Find visible characters on the right.
502     ByEnd  ///< Start finding visible characters by the end.
503   };
504
505   /**
506    *
507    */
508   virtual bool OnTouchEvent(const TouchEvent& event);
509
510   /**
511    * From CustomActorImpl; called after the Text Input actor is touched
512    * @param[in] event The KeyEvent event.
513    * @return True if the event should be consumed.
514    */
515   virtual bool OnKeyEvent(const KeyEvent& event);
516
517   /**
518    * From CustomActorImpl; called when this actor gains keyboard focus.
519    */
520   virtual void OnKeyInputFocusGained();
521
522   /**
523    * From CustomActorImpl; called when this actor loses keyboard focus.
524    */
525   virtual void OnKeyInputFocusLost();
526
527   /**
528    * From Control; called whenever the control is added to the stage.
529    */
530   virtual void OnControlStageConnection();
531
532 private: // From Control
533
534   /**
535    * Creation of the layer that is used by top level active parts of the TextInput like handles
536    */
537   void CreateActiveLayer();
538
539   /**
540    * @copydoc Control::OnInitialize()
541    */
542   virtual void OnInitialize();
543
544   /**
545    * @copydoc Control::OnControlSizeSet()
546    */
547   virtual void OnControlSizeSet(const Vector3& targetSize);
548
549   /**
550    * @copydoc Control::OnRelaidOut()
551    */
552   virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
553
554   /**
555    * Retrieves the text-input's natural size by calling TextView::GetNaturalSize().
556    *
557    * @return The natural size.
558    */
559   virtual Vector3 GetNaturalSize();
560
561   /**
562    * Retrieves the text-input's \e height for a given \e width by calling TextView::GetHeightForWidth().
563    *
564    * @param[in] width The given \e width.
565    *
566    * @return The \e height for the given \e width.
567    */
568   virtual float GetHeightForWidth( float width );
569
570 protected:
571
572   /**
573    * Construct a new TextInput.
574    */
575   TextInput();
576
577   /**
578    * A reference counted object may only be deleted by calling Unreference()
579    */
580   virtual ~TextInput();
581
582 private:
583
584   // Undefined
585   TextInput(const TextInput&);
586
587   // Undefined
588   TextInput& operator=(const TextInput& rhs);
589
590   /**
591     * Callback when a handle is panned/moved, either selection handles or grab handle
592     * @param actor Handle of the selection or grab handle.
593     * @param gesture Data structure with the parameters of the gesture.
594     */
595    void OnHandlePan(Actor actor, PanGesture gesture);
596
597    /**
598     * Callback for touch down on Grab handle
599     * @param[in] actor touched
600     * @param[in] touch touch event
601     */
602    bool OnPressDown(Dali::Actor actor, const TouchEvent& touch);
603
604    /**
605     * Callback for touch down on Selection handle one
606     * @param[in] actor touched
607     * @param[in] touch touch event, used to determine if down or up event
608     */
609    bool OnHandleOneTouched(Dali::Actor actor, const TouchEvent& touch);
610
611    /**
612     * Callback for touch down on Selection handle two
613     * @param[in] actor touched
614     * @param[in] touch touch event, used to determine if down or up event
615     */
616    bool OnHandleTwoTouched(Dali::Actor actor, const TouchEvent& touch);
617
618    /**
619     * Callback for tap on TextInput
620     * @param[in] actor
621     * @param[in] tap touch event
622     */
623    void OnTextTap(Dali::Actor actor, Dali::TapGesture tap);
624
625    /**
626     * Callback for double tap on TextInput
627     * @param[in] actor
628     * @param[in] tap touch event
629     */
630    void OnDoubleTap(Dali::Actor actor, Dali::TapGesture tap);
631
632     /**
633      * Callback for long press on TextInput
634      * @param[in] actor
635      * @param[in] longPress long press event
636      */
637    void OnLongPress(Dali::Actor actor, Dali::LongPressGesture longPress);
638
639    /**
640     * Callback for the ClipboardEventNotifier when text is selected in the clipboard window.
641     * @param[in] notifier The Clipboard Event Notifier.
642     */
643    void OnClipboardTextSelected( ClipboardEventNotifier& notifier );
644
645    /**
646     * Callback for when a button is pressed in popup panel
647     * @param[in] button handle to the button pressed.
648     */
649    bool OnPopupButtonPressed( Toolkit::Button button );
650
651    /**
652     * Callback when handle timer ticks.
653     *
654     * Cursor should become visible/invisible to simulate blinking.
655     *
656     * @return True if the timer should be keep running.
657     */
658    bool OnCursorBlinkTimerTick();
659
660    /**
661     * Invoked upon popup Hide animation completing.
662     * @note Only called for animating hide, not called for instantaneous (animate = false)
663     * @param[in] popup The popup which was hidden.
664     */
665    void OnPopupHideFinished(TextInputPopup& popup);
666
667    /**
668     * Called in OnKeyEvent to handle key down events.
669     * @param[in] event The KeyEvent event.
670     * @return True if the event should be consumed.
671     */
672    bool OnKeyDownEvent(const KeyEvent& event);
673
674    /**
675     * Called in OnKeyEvent to handle key up events.
676     * @param[in] event The KeyEvent event.
677     * @return True if the event should be consumed.
678     */
679    bool OnKeyUpEvent(const KeyEvent& event);
680
681    /**
682     * Callback called when the text-view is scrolled.
683     *
684     * Updates the selection and grab handles, and the highlighted text.
685     *
686     * @param[in] textView Handle of the text-view.
687     * @param[in] scrollPosition The difference with the previous scroll position.
688     */
689    void OnTextViewScrolled( Toolkit::TextView textView, Vector2 scrollPosition );
690
691    /**
692     * Scrolls the text-view to make the cursor visible.
693     *
694     * @param[in] cursorPosition The actual cursor position in actor coordinates.
695     */
696    void ScrollTextViewToMakeCursorVisible( const Vector3& cursorPosition );
697
698    /**
699     * Creates and starts a timer to scroll the text when handles are close to the edges of the text-input.
700     *
701     * It only starts the timer if it's already created.
702     */
703    void StartScrollTimer();
704
705    /**
706     * Stops the timer used to scroll the text.
707     */
708    void StopScrollTimer();
709
710    /**
711     * Callback called by the timer used to scroll the text.
712     *
713     * It calculates and sets a new scroll position.
714     */
715    bool OnScrollTimerTick();
716
717 public:  // Public to allow internal testing.
718
719   /**
720    * Register for touch events
721    */
722   void SetUpTouchEvents();
723
724   /**
725    * Sets up TextView Actor
726    */
727   void CreateTextViewActor();
728
729   /**
730    * Set Styled Text for text input.
731    * @param[in] styleText The new styled text for the text input.
732    */
733   void SetText( const MarkupProcessor::StyledTextArray& styleText );
734
735   /**
736    * Start a timer to signal cursor to blink.
737    */
738   void StartCursorBlinkTimer();
739
740   /**
741    * Stop the timer signalling the cursor to blink.
742    */
743   void StopCursorBlinkTimer();
744
745   /**
746    * Starts input, setting focus and showing keyboard..
747    */
748   void StartEditMode();
749
750   /**
751    * Called when End of input and focus no longer required, keyboard is hidden.
752    */
753   void EndEditMode();
754
755   /**
756    * Applies a style to the current pre-edit / predicted word to show it is being edited.
757    * @param[in] preEditStartPosition position in text array that the predicted word starts at
758    * @param[in] preEditStringLength used to calculate how many characters need their style changed.
759    */
760   void ApplyPreEditStyle( std::size_t preEditStartPosition, std::size_t preEditStringLength );
761
762   /**
763    * Restores style to value before applying Pre-Edit style.
764    */
765   void RemovePreEditStyle();
766
767   /**
768    * Event received from IMF manager
769    * @return ImfCallbackData data struture undicating if update is needed, cursor position and current text
770    */
771   ImfManager::ImfCallbackData ImfEventReceived( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& test );
772
773   /**
774    * Called when the OnKey event is a Pre-edit string
775    * @param[in] keyString String received in Pre-edit
776    * @param[in] cursorOffset the cursor offset from where the pre-edit word starts
777    * @return bool true if preedit reset is required.
778    */
779   bool PreEditReceived( const std::string& keyString, std::size_t cursorOffset  );
780
781  /**
782   * Called when the OnKey event is a Commit string
783   * @param[in] keyString String received in Comment
784   * @return update flag to trigger cursor update of TextInput only when needed.
785   */
786   bool CommitReceived( const std::string& keyString );
787
788   /**
789    * Deletes Pre-edit string
790    * By default it doesn't update the character's size and position table, which is a costly
791    * operation. As in many cases deletion and insertion (InsertAt) of text
792    * occurs in the same action i.e. preedit/commit. It makes sense to
793    * delete without updating, and then insert with updating.
794    *
795    * @return The number of characters to be deleted.
796    */
797   std::size_t DeletePreEdit();
798
799   /**
800    * Reset all pre-edit flag and signal IMF keyboard that the current pre-edit word has been comitted.
801    * This may be due to the cursor being moved by user or reached the max character limit.
802    * @param[in] preserveCursorPosition Set true to keep cursor in current position, eg. touch event caused cursor to move.
803    */
804   void PreEditReset( bool preserveCursorPosition );
805
806   /**
807    * Called after cursor position needs updating.
808    * Redraws cursor and notifies VirtualKeyboard
809    */
810   void CursorUpdate();
811
812   /**
813    * Delete highlighted characters
814    * @param[in] inheritStyle Whether style from previous character in the string should be inherited.
815    */
816   void DeleteHighlightedText( bool inheritStyle );
817
818   /*
819    * Delete range of characters
820    * @param[in] start position of characters to delete
821    * @param[in] ncharacters number of characters to delete
822    */
823   void DeleteRange(std::size_t start, std::size_t ncharacters);
824
825   /**
826    * Delete character at current cursor position and redisplay
827    * @param[in] positionToDelete position of character to delete
828    */
829   void DeleteCharacter( std::size_t positionToDelete );
830
831   /**
832    * Add or replaces characters to currently displayed string at cursor position
833    * By default it doesn't update the character's size and position table, which is a costly
834    * operation. As in many cases deletion and insertion (InsertAt) of text
835    * occurs in the same action i.e. preedit/commit. It makes sense to
836    * delete without updating, and then insert with updating.
837    * @param[in] newText string to add to TextInput display string.
838    * @param[in] insertionPosition position to insert at.
839    * @param[in] numberOfCharactersToReplace The number of characters to replace.
840    * @return number of characters to offset the cursor by.
841    */
842   std::size_t InsertAt( const Text& newText, const std::size_t insertionPosition, const std::size_t numberOfCharactersToReplace );
843
844   /**
845    * Creates a cursor from the supplied image
846    * @param[in] cursorImage the image to be used for the cursor.
847    * @param[in] border the nine patch border corresponding to the supplied image.
848    * @return the image actor to be used as the cursor.
849    */
850   ImageActor CreateCursor( Image cursorImage, const Vector4& border );
851
852   /**
853    * Moves cursor to the right
854    * param[in] reverse if true then cursor moves in the reverse direction (to the left)
855    * param[in] places number of character cursor should move.
856    */
857   void AdvanceCursor(bool reverse = false, std::size_t places = 1);
858
859   /**
860    * Draw a cursor / caret at position where new text should appear
861    * @param[in] nthChar the position along the text string in which new text should appear.
862    */
863   void DrawCursor(const std::size_t nthChar = 0);
864
865   /**
866    * Sets cursor visibility
867    * This sets visibility of the cursor. Which is comprised of 2
868    * cursors. The conventional cursor, and the alternate (RTL) cursor,
869    * which only appears when the cursor is at a character that can have
870    * a character appended to different visual positions depending on whether that
871    * character to be appended is RTL or LTR.
872    * @param[in] visible true - enable visibility for cursor, false - disable visiblity for cursor
873    */
874   void SetCursorVisibility( bool visible );
875
876   /**
877    * Sets alternate cursor enable state
878    * @see SetCursorVisibility
879    * alternate cursor will only be visible if both SetCursorVisiblity
880    * and cursor enabled have been set to true.
881    */
882   void SetAltCursorEnabled( bool enabled );
883
884   /**
885    * Create the grab handle that positions the cursor
886    * @param[in] image to be used for grab handle
887    *
888    */
889   void CreateGrabHandle(Image image=Image());
890
891   /**
892    * Create Grab area to be used by Grab Handle
893    */
894   void CreateGrabArea( Actor& parent);
895
896   /**
897    * Move grab handle to the required character position
898    *
899    * @param[in] displacement Displacement of the grab handle in actor coordinates.
900    *
901    * @return The new actual position the handle has been set to.
902    */
903   Vector3 MoveGrabHandle( const Vector2& displacement );
904
905   /**
906    * Show or hide the grab handle without baking the visibility flag.
907    * Used when the Grab handle needs to be invisible due to text-view scrolling making it out of view
908    *
909    * @param[in] visible bool flag to set as true is grab handle should be shown, else false to hide.
910    */
911   void ShowGrabHandle( bool visible );
912
913   /**
914    * Show or hide the grab handle and bake the visibility flag.
915    * Used when the state of text-input changes to a state which the grabhandle is not required. E.g. Selection mode starts or edit mode ends.
916    * Calls ShowGrabHandle.
917    *
918    * @param[in] visible bool flag to set as true is grab handle should be shown, else false to hide.
919    */
920   void ShowGrabHandleAndSetVisibility( bool visible );
921
922   /* Boundary Property Notifications when handle exceed bounding box*/
923
924   /**
925    * PropertyNotification Callback when left boundary exceeded so handle can be flipped.
926    * @param[in] source PropertyNotification
927    */
928   void OnLeftBoundaryExceeded( PropertyNotification& source );
929   /**
930    * PropertyNotification Callback when within left boundary so handle can be flipped back.
931    * @param[in] source PropertyNotification
932    */
933   void OnReturnToLeftBoundary( PropertyNotification& source );
934   /**
935    * PropertyNotification Callback when right boundary exceeded so handle can be flipped.
936    * @param[in] source PropertyNotification
937    */
938   void OnRightBoundaryExceeded( PropertyNotification& source );
939   /**
940    * * PropertyNotification Callback when within right boundary so handle can be flipped back.
941    * @param[in] source PropertyNotification
942    */
943   void OnReturnToRightBoundary( PropertyNotification& source );
944
945   /**
946    * PropertyNotification Callbacks for hiding handle one when it exceeds boundary.
947    * @param[in] source PropertyNotification
948    */
949   void OnHandleOneLeavesBoundary( PropertyNotification& source );
950   /**
951    * PropertyNotification Callbacks for showing hidden handle one when returns within boundary
952    * @param[in] source PropertyNotification
953    */
954   void OnHandleOneWithinBoundary( PropertyNotification& source );
955   /**
956    * PropertyNotification Callbacks for hiding handle two it  when exceeds boundary.
957    * @param[in] source PropertyNotification
958    */
959   void OnHandleTwoLeavesBoundary( PropertyNotification& source );
960   /**
961    * PropertyNotification Callbacks for showing hidden handle two when returns within boundary
962    * * @param[in] source PropertyNotification
963    */
964   void OnHandleTwoWithinBoundary( PropertyNotification& source );
965
966   /**
967    * Set up property notifications on the position of the handles to facilitate flipping and hiding when at screen boundary.
968    */
969   void SetUpHandlePropertyNotifications();
970
971   /**
972    * Create the selection handles that bound text to be selected for copy/cut.
973    * @param[in] start initial position of start selection handle.
974    * @param[in] end initial position of end selection handle.
975    * @param[in] handleOneImage (optional) to be used for selection handle
976    * @param[in] handleTwoImage (optional) to be used for selection handle
977    */
978   void CreateSelectionHandles( std::size_t start = 0, std::size_t end = std::numeric_limits<std::size_t>::max(), Dali::Image handleOneImage = Dali::Image(),  Dali::Image handleTwoImage = Dali::Image() );
979
980   /**
981    * Move the selection handles to required positions in text.
982    *
983    * @param[in] handleId the handle to position
984    * @param[in] displacement Displacement of the selection handle in actor coordinates.
985    *
986    * @return The new actual position the handle has been set to.
987    */
988   Vector3 MoveSelectionHandle(SelectionHandleId handleId, const Vector2& displacement);
989
990   /**
991    * Calculate and position the specified selection handle the given index position
992    *
993    * @param[in] handleId the handle to position
994    */
995   void SetSelectionHandlePosition(SelectionHandleId handleId);
996
997   /**
998    * Gets the visual position of a logical position.
999    * @note This is preferred over directly accessing the Map, as it resolves visual
1000    * positions outside of the character map range.
1001    * @param[in] logicalPosition The logical position
1002    * @return Visual position is returned.
1003    */
1004   std::size_t GetVisualPosition(std::size_t logicalPosition) const;
1005
1006   /**
1007    * Gets a table of the visual text positions which has a flag
1008    * for each Character. The flag is either true (character selected)
1009    * or false (character deselected)
1010    * @note startSelection can be greater or less than endSelection
1011    *
1012    * @param[in,out] selectedVisualText The vector to be resized and populated with the selected flags
1013    * @param[in] startSelection The start selection point for the text
1014    * @param[in] endSelection The end selection point for the text
1015    */
1016   void GetVisualTextSelection(std::vector<bool>& selectedVisualText, std::size_t startSelection, std::size_t endSelection);
1017
1018   /**
1019    *  Iterates between selection handles and computes the info required to build the highlight mesh
1020    */
1021   HighlightInfo CalculateHighlightInfo();
1022
1023   /**
1024    * Calculates new Mesh data so highlight moves with selection handles.
1025    */
1026   void UpdateHighlight();
1027
1028   /**
1029    * Removes popup, and its options.
1030    */
1031   void ClearPopup();
1032
1033   /**
1034    * Adds a popup option.
1035    * @note Creates popup frame if not already created.
1036    * @param[in] name The unique name for this option.
1037    * @param[in] caption The caption (label) for this option
1038    * @param[in] icon the image icon to be displayed for this option
1039    * @param[in] finalOption Flag to indicate that this is the final option.
1040    * (set to true on the last option you add)
1041    */
1042   void AddPopupOption(const std::string& name, const std::string& caption, const Image icon, bool finalOption = false);
1043
1044   /**
1045    * Sets popup position
1046    * @param[in] position The actual position for this popup.
1047    */
1048   void SetPopupPosition(const Vector3& position);
1049
1050   /**
1051    * Hides the popup
1052    * @param[in] animate (optional) whether to animate popup to hide state over time (i.e. tween).
1053    * @param[in] signalFinished (optional) whether to perform an animation finish operation after the hide animation completes. Requires animate to be true.
1054    */
1055   void HidePopup( bool animate = true, bool signalFinished = true );
1056
1057   /**
1058    * Shows the popup
1059    * @param[in] animate (optional) whether to animate popup to show state over time (i.e. tween).
1060    */
1061   void ShowPopup(bool animate = true);
1062
1063   /**
1064    * Shows the cut-copy-paste popup
1065    */
1066   void ShowPopupCutCopyPaste();
1067
1068   /**
1069    * Setup the selection popup and clipboard if relevant so the correct options are shown when ShowPopup is called.
1070    */
1071   void SetUpPopUpSelection();
1072
1073   /**
1074    * Return the logical index containing the character position closest to the source.
1075    * Used for positioning the grab handle at characters when dragged along.
1076    * Two different behaviours are needed in case the source point doesn't actually touch a
1077    * character. @see TouchToIndex.
1078    * @param[in] source float to match against
1079    * @param[out] closestIndex index to the vector of character's size and position.
1080    * @return \e true if the source point is actually inside the geometry provided by TextView.
1081    */
1082   bool ReturnClosestIndex(const Vector2& source, std::size_t& closestIndex );
1083
1084   /**
1085    * Returns the X-position of the current line justification
1086    * (relative to left of text-view container)
1087    * @return X position for line justification
1088    */
1089   float GetLineJustificationPosition() const;
1090
1091   /**
1092    * Currently the cursor is positioned at the previous characters position plus it's width.
1093    * If the previous character is on a different line then this function returns the correct position.
1094    * @param[in] characterPosition the character position index that the cursor should be at
1095    * @return position of cursor/handle
1096    */
1097   Vector3 PositionCursorAfterWordWrap( std::size_t characterPosition ) const;
1098
1099
1100   /**
1101    * Return a vector which is the actual position for the given character position
1102    * The character position is where a cursor would be position for that character.
1103    * @param[in] characterPosition the logical (input) position in the 'string' of characters.
1104    *
1105    * @return Vector3 the actual x,y,z position
1106    */
1107   Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition ) const;
1108
1109   /**
1110    * Return a vector which is the actual position for the given character position
1111    * The character position is where a cursor would be positioned for that character to be inserted.
1112    * An additional alternatePosition is also set in circumstances where the possible writing
1113    * of characters would be in the opposite direction.
1114    * e.g. "HelloشقشلاهؤEnglish"
1115    *            |     |
1116    *            *     +
1117    * [*] - Primary actual position for cursor i.e. continuing writing LTR (English)
1118    * [+] - Alternate actual position for cursor i.e. writing RTL (Arabic)
1119    *
1120    * @param[in] characterPosition the logical (input) position in the 'string' of characters.
1121    * @param[out] directionRTL Whether the actual x,y,z position is after LTR (false) or RTL (true) text.
1122    * @param[out] alternatePosition the actual x,y,z position of the cursor if user types
1123    * in alternate direction to current flow of text.
1124    * @param[out] alternatePositionValid whether this alternate position is valid.
1125    * @return Vector3 the actual x,y,z position
1126    */
1127   Vector3 GetActualPositionFromCharacterPosition(std::size_t characterPosition, bool& directionRTL, Vector3& alternatePosition, bool& alternatePositionValid ) const;
1128
1129   /**
1130    * Retrieve the character position of the first character on the row of text
1131    * that this character resides on.
1132    * @param[in] logicalPosition the position in the 'string' of characters.
1133    * @return logical character position of start of row.
1134    */
1135   std::size_t GetRowStartFromCharacterPosition(std::size_t logicalPosition) const;
1136
1137   /**
1138    * Retrieve the dimensions of this row of text that the character resides on.
1139    * @param[in] characterPosition the position in the 'string' of characters.
1140    * @return The size of the rectangle representing this row
1141    */
1142   Size GetRowRectFromCharacterPosition(std::size_t characterPosition) const;
1143
1144   /**
1145    * Retrieve the dimensions (and min-max) of this row of text that the character resides on.
1146    * @param[in] characterPosition the position in the 'string' of characters.
1147    * @param[out] min the top-left position of the rectangle representing this row
1148    * @param[out] max the bottom-right position of the rectangle representing this row
1149    * @return The size of the rectangle representing this row (max - min)
1150    */
1151   Size GetRowRectFromCharacterPosition(std::size_t characterPosition, Vector2& min, Vector2& max) const;
1152
1153   /**
1154    * Checks if the provided touchedActor was this text-input
1155    * @param[in] touchedActor the touched actor that will be checked against this text-input
1156    * @return true if the touchActor was the text-input or one of its children
1157    */
1158   bool WasTouchedCheck( const Actor& touchedActor ) const;
1159
1160   /**
1161    * Connect to the stage touch event
1162    */
1163   void StartMonitoringStageForTouch();
1164
1165   /**
1166    * Disconnect from the stage touch event
1167    */
1168   void EndMonitoringStageForTouch();
1169
1170   /**
1171    * Callback for when the screen is touched, this will be connected when selection starts and disconnected when it ends.
1172    * @param[in] event The touch event
1173    */
1174   void OnStageTouched(const TouchEvent& event);
1175
1176
1177   /**
1178    * Select the text between the given values
1179    * @param[in] start position within array to start selection
1180    * @param[in] end position within array to end selection
1181    */
1182   void SelectText(std::size_t start, std::size_t end);
1183
1184   /**
1185    * Gets selected text and returns it as a StyleText vector
1186    * @return StyledText vector that is selected.
1187    */
1188   MarkupProcessor::StyledTextArray GetSelectedText();
1189
1190   /**
1191    * Applies the given style to all text, selected or not selected.
1192    * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
1193    */
1194   void ApplyStyleToRange(const TextStyle& style, const TextStyle::Mask mask, const std::size_t begin, const std::size_t end);
1195
1196   /**
1197    * Callback for when the keyboard status changes
1198    * @param[in]  keyboardShown  Whether the keyboard has just been shown or not.
1199    */
1200   void KeyboardStatusChanged(bool keyboardShown);
1201
1202   /**
1203    * Hide highlight shown between selection handles.
1204    */
1205   void RemoveHighlight();
1206
1207   /**
1208    * Highlights text that has been selected
1209    */
1210   void CreateHighlight();
1211
1212   /**
1213    * Copies selected text to clipboard
1214    * @return bool true if copy was successful.
1215    */
1216   bool CopySelectedTextToClipboard();
1217
1218   /**
1219    * Pastes the given text to currently displayed string at the current cursor position
1220    * @param[in] text Text to be pasted
1221    */
1222   void PasteText( const Text& text );
1223
1224   /**
1225    * Sets the direction of the text if it is empty.
1226    */
1227   void SetTextDirection();
1228
1229   /**
1230    * Updates the line height accordingly with the current text input style.
1231    */
1232   void UpdateLineHeight();
1233
1234   /**
1235    * Finds a visible character.
1236    *
1237    * The \e direction parameters specifies from where to start to look for a visible character. \e Left means start by characters in lower
1238    * positions than \e cursorPosition, \e Right means start by characters in greater positions than \e cursorPosition and \e ByEnd starts
1239    * by the last characters.
1240    *
1241    * If \e Left or \e Right is provided and any character is found, then looks in the other direction.
1242    *
1243    * @param[in] direction Direction used to find a visible character.
1244    * @param[in] cursorPosition Starting position.
1245    *
1246    * @return The found visible character.
1247    */
1248   std::size_t FindVisibleCharacter( const FindVisibleCharacterDirection direction , const std::size_t cursorPosition ) const;
1249
1250   /**
1251    * @copydoc SetSortModifier()
1252    */
1253   void SetSortModifier( float depthOffset );
1254
1255   /**
1256    * @copydoc SetSnapshotModeEnabled()
1257    */
1258   void SetSnapshotModeEnabled( bool enable );
1259
1260   /**
1261    * @copydoc IsSnapshotModeEnabled()
1262    */
1263   bool IsSnapshotModeEnabled() const;
1264
1265   /**
1266    * @copydoc SetScrollEnabled()
1267    */
1268   void SetScrollEnabled( bool enable );
1269
1270   /**
1271    * @copydoc IsScrollEnabled()
1272    */
1273   bool IsScrollEnabled() const;
1274
1275   /**
1276    * @copydoc SetScrollPosition()
1277    */
1278   void SetScrollPosition( const Vector2& position );
1279
1280   /**
1281    * @copydoc GetScrollPosition()
1282    */
1283   Vector2 GetScrollPosition() const;
1284
1285   /**
1286    * @brief Sets whether markup processing should be carried out.
1287    *
1288    * @param[in] enable whether markup processing is carried out or not.
1289    */
1290   void SetMarkupProcessingEnabled( bool enable );
1291
1292   /**
1293    * @brief Returns whether markup processing is enabled or not
1294    *
1295    * @return true is markup processing is enabled
1296    */
1297   bool IsMarkupProcessingEnabled() const;
1298
1299   /**
1300    * Insert or replaces the given text in the given position. It checks if the text exceeds the maximum allowed number of characters
1301    * and if it fits in the text-input's boundaries.
1302    *
1303    * @param[in] text Text to be inserted.
1304    * @param[in] position Position where the text is inserted.
1305    * @param[in] numberOfCharactersToReplace The number of characters to replace.
1306    * @param[out] textExceedsMaximunNumberOfCharacters The number of characters that have been inserted.
1307    * @param[out] textExceedsBoundary Whether the inserted text has exceeded the boundaries of the text-input.
1308    *
1309    * @return The number of characters that have been inserted.
1310    */
1311   std::size_t DoInsertAt( const Text& text, std::size_t position, std::size_t numberOfCharactersToReplace, bool& textExceedsMaximunNumberOfCharacters, bool& textExceedsBoundary );
1312
1313   /**
1314    *  Retrieve Text-view's layout info.
1315    */
1316   void GetTextLayoutInfo();
1317
1318   /**
1319    * Emits the style changed signal.
1320    */
1321   void EmitStyleChangedSignal();
1322
1323   /**
1324    * Emit signal when text is modified.
1325    */
1326   void EmitTextModified();
1327
1328   /**
1329    * Emits max input characters reached signal.
1330    */
1331   void EmitMaxInputCharactersReachedSignal();
1332
1333   /**
1334    * Emits a signal when the input text exceeds the boundaries of the text-input.
1335    */
1336   void EmitInputTextExceedsBoundariesSignal();
1337
1338 private:
1339
1340   State mState;                                 ///< Current State of Text input.
1341   MarkupProcessor::StyledTextArray mStyledText; ///< String currently displayed by TextView with style info.
1342   TextStyle mInputStyle;                        ///< Stores the current input style.
1343   float     mLineHeight;                        ///< Stores the current line height accordingly with the input style.
1344   Toolkit::TextView mDisplayedTextView;         ///< Actor which actually display text
1345
1346   MarkupProcessor::StyledTextArray mStyledPlaceHolderText; ///< Text used as place holder with style info.
1347
1348   std::size_t mMaxStringLength;                 ///< Max number of characters for string
1349   std::size_t mNumberOflinesLimit;              ///< Limit on the number of lines this TextInput will display.
1350
1351   ImageActor mCursor;                           ///< Cursor overlayed on Text to show where new text will be inserted
1352   ImageActor mCursorRTL;                        ///< Right To Left Cursor overlayed on Text (where new RTL text would be inserted)
1353   Animation mCursorAnimation;                   ///< animator for cursor blinking.
1354   std::size_t mCursorPosition;                  ///< position along string cursor is at.
1355   Timer mCursorBlinkTimer;                      ///< Timer to signal cursor to blink
1356
1357   Layer mActiveLayer;                           ///< Layer for active handles and alike that ensures they are above all else.
1358
1359   Image mGrabHandleImage;                       ///< image to be used for grab handle
1360   ImageActor mGrabHandle;                       ///< Handle used to move cursor for editing
1361
1362   Actor mGrabArea;                              ///< invisible actor that receives pans events for the grab handle.
1363   PanGestureDetector  mPanGestureDetector;      ///< Pan gesture for handles
1364   TapGestureDetector mTapDetector;              ///< used to start editing
1365   TapGestureDetector mDoubleTapDetector;        ///< double tap detector
1366
1367   Vector3 mActualGrabHandlePosition;            ///< actual position of grab handle, this might not be snapped to a character
1368
1369   LongPressGestureDetector mLongPressDetector;  ///< Gesture to start selection
1370
1371   /*Selection handles*/
1372   Image mSelectionHandleOneImage;               ///< image used for selection handle one
1373   Image mSelectionHandleOneImagePressed;        ///< image used for selection handle one pressed state
1374   Image mSelectionHandleTwoImage;               ///< image used for selection handle two
1375   Image mSelectionHandleTwoImagePressed;        ///< image used for selection handle two pressed state
1376
1377   bool mIsSelectionHandleOneFlipped:1;          ///< Flag to know whether the handle one is flipped or not.
1378   bool mIsSelectionHandleTwoFlipped:1;          ///< Flag to know whether the handle two is flipped or not.
1379   Vector3 mSelectionHandleOneOffset;            ///< Handle One's Offset
1380   Vector3 mSelectionHandleTwoOffset;            ///< Handle Two's Offset
1381   Vector3 mSelectionHandleOneActualPosition;    ///< Actual x y position of handle
1382   Vector3 mSelectionHandleTwoActualPosition;    ///< Actual x y position of handle
1383   std::size_t mSelectionHandleOnePosition;      ///< Position of handle along the string of text
1384   std::size_t mSelectionHandleTwoPosition;      ///< Position of handle along the string of text
1385   ImageActor mSelectionHandleOne;               ///< First selection handle used for selecting text to cut&paste
1386   ImageActor mSelectionHandleTwo;               ///< Second selection handle used for selecting text to cut&paste
1387   Actor mHandleOneGrabArea;                     ///< invisible actor that receives pans events for the selection handle.
1388   Actor mHandleTwoGrabArea;                     ///< invisible actor that receives pans events for the selection handle.
1389
1390   Mesh              mHighlightMesh;             ///< Mesh Data for highlight
1391   MeshActor         mHighlightMeshActor;        ///< Mesh Actor to display highlight
1392   MeshData          mMeshData;                  ///< Container to hold meshData for highlight
1393   Material          mCustomMaterial;            ///< Custom material used for highlight
1394   HighlightInfo     mNewHighlightInfo;          ///< Geometry info to create highlight.
1395
1396   Text mPreEditString;                          ///< Holds current input string prior to it being committed.
1397   std::size_t mPreEditStartPosition;            ///< Cursor position for start of pre-edit string
1398   std::size_t mPreEditLength;                   ///< Cursor position for length of current pre-edit string after purging characters that do not fit.
1399   std::size_t mNumberOfSurroundingCharactersDeleted; ///< Stores the number of surrounding characters deleted.
1400   unsigned long mTouchStartTime;                ///< Touch Start time (time in ms when down press began)
1401
1402   Toolkit::TextView::TextLayoutInfo                                 mTextLayoutInfo; ///< It contains a table layout info per character sorted by the character's visual index (retrieved from TextView),
1403                                                                                      ///< a reorder map that stores each character's visual (output) index according to its logical (input) index,
1404                                                                                      ///< a reorder map that stores each character's logical (input) index according to its visual (output) index,
1405                                                                                      ///< the text size after layout and the scroll offset.
1406
1407   MarkupProcessor::StyledTextArray mCurrentCopySelecton;                                              ///< Array to store copied text.
1408   TextInputPopup mPopUpPanel;                                                                         ///< Panel to house cut and paste, select all buttons.
1409
1410   Timer mScrollTimer;
1411   Vector2 mScrollDisplacement;
1412   Vector3 mCurrentHandlePosition;
1413   SelectionHandleId mCurrentSelectionId;
1414   Vector3 mCurrentSelectionHandlePosition;
1415   SelectionParameters mRequestedSelection;
1416   Vector4 mSelectionHandleFlipMargin;
1417   Vector4 mBoundingRectangleWorldCoordinates;
1418
1419   Clipboard mClipboard;                  ///< Handle to clipboard
1420
1421   bool mOverrideAutomaticAlignment:1;    ///< Whether to override the alignment automatically set by the text content (e.g. european LTR or arabic RTL)
1422   bool mCursorRTLEnabled:1;              ///< Enable state of Alternate RTL Cursor (need to keep track of this as it's not always enabled)
1423   bool mClosestCursorPositionEOL:1;      ///< closest cursor position is end of line.
1424   bool mCursorBlinkStatus:1;             ///< \e true shows the cursor, \e false hiddes it.
1425
1426   bool mCursorVisibility:1;              ///< Visibility status of Cursor
1427   bool mGrabHandleVisibility:1;          ///< Visibility status of the grab handle.
1428
1429   bool mIsCursorInScrollArea:1;          ///< Whether the cursor is inside the boundaries of the text-input.
1430   bool mIsGrabHandleInScrollArea:1;      ///< Whether the grab handle is inside the boundaries of the text-input.
1431
1432   bool mEditModeActive:1;                ///< true to indicate TextInput is in edit mode.
1433   bool mEditOnTouch:1;                   ///< true indicates edit mode starts by touching/tapping the TextInput
1434   bool mTextSelection:1;                 ///< true indicates text selection is enabled.
1435   bool mExceedEnabled:1;                 ///< Whether text-input editing text beyond its boundary is enabled or not. By default is enabled.
1436   bool mGrabHandleEnabled:1;             ///< Flag to enable the grab handle instead of the default magnifier.
1437   bool mIsSelectionHandleFlipEnabled:1;  ///< Flag to enable the selection handle flip
1438
1439   bool mPreEditFlag:1;                   ///< Flag to indicate if key string received is still in pre-edit mode (Ecore IMF keyboard)
1440   bool mIgnoreCommitFlag:1;              ///< Flag to indicate if the commit string should be ignored, maybe due to a keyboard reset.
1441   bool mIgnoreFirstCommitFlag:1;         ///< Whether to ignore the first commit.
1442   bool mSelectingText:1;                 ///< Ignore surrounding text as selecting text
1443
1444   bool mPreserveCursorPosition:1;        ///< Indicates that the commit message is from a reset and does not require the cursor to be moved
1445
1446   bool mSelectTextOnCommit:1;
1447
1448   bool mUnderlinedPriorToPreEdit:1;      ///< As predictive text adds underline style this flag enables us to revert back or keep underline.
1449
1450   bool mCommitByKeyInput:1;              ///< Set if a commit is done by key input rather than automatically (usually when a space bar or enter is pressed).
1451
1452   bool mPlaceHolderSet:1;                ///< Whether the place holder text is set.
1453   bool mMarkUpEnabled:1;                 ///< enable to scan for mark-up
1454
1455   Toolkit::TextInput::InputSignalV2                      mInputStartedSignalV2;              ///< Signal emitted when input starts
1456   Toolkit::TextInput::InputSignalV2                      mInputFinishedSignalV2;             ///< Signal emitted when input ends
1457   Toolkit::TextInput::StyleChangedSignalV2               mStyleChangedSignalV2;              ///< Signal emitted when style changes.
1458   Toolkit::TextInput::TextModifiedSignalType             mTextModifiedSignal;                ///< Signal emitted when text modified.
1459   Toolkit::TextInput::MaxInputCharactersReachedSignalV2  mMaxInputCharactersReachedSignalV2; ///< Signal emitted when max input characters is reached.
1460   Toolkit::TextInput::InputSignalV2                      mCutAndPasteToolBarDisplayedV2;     ///< Signal emitted when toolbar displayed
1461   Toolkit::TextInput::InputTextExceedBoundariesSignalV2  mInputTextExceedBoundariesSignalV2; ///< Signal emitted when input text exceeds the boundaries of the text-input.
1462 };
1463
1464 } // namespace Internal
1465
1466 // Helpers for public-api forwarding methods
1467
1468 inline Toolkit::Internal::TextInput& GetImpl(Toolkit::TextInput& textInput)
1469 {
1470   DALI_ASSERT_ALWAYS(textInput);
1471
1472   Dali::RefObject& handle = textInput.GetImplementation();
1473
1474   return static_cast<Toolkit::Internal::TextInput&>(handle);
1475 }
1476
1477 inline const Toolkit::Internal::TextInput& GetImpl(const Toolkit::TextInput& textInput)
1478 {
1479   DALI_ASSERT_ALWAYS(textInput);
1480
1481   const Dali::RefObject& handle = textInput.GetImplementation();
1482
1483   return static_cast<const Toolkit::Internal::TextInput&>(handle);
1484 }
1485
1486 } // namespace Toolkit
1487
1488 } // namespace Dali
1489
1490 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_H__