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