Merge "Internal UTC tests for popup with backing color fix" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-field-impl.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <string>
23 #include <iostream>
24 #include <cstring>
25 #include <dali/public-api/adaptor-framework/key.h>
26 #include <dali/public-api/common/stage.h>
27 #include <dali/public-api/images/resource-image.h>
28 #include <dali/public-api/object/type-registry.h>
29 #include <dali/devel-api/object/type-registry-helper.h>
30 #include <dali/devel-api/scripting/scripting.h>
31 #include <dali/devel-api/adaptor-framework/virtual-keyboard.h>
32 #include <dali/integration-api/debug.h>
33
34 // INTERNAL INCLUDES
35 #include <dali-toolkit/public-api/text/rendering-backend.h>
36 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
37 #include <dali-toolkit/internal/text/rendering/text-backend.h>
38 #include <dali-toolkit/internal/text/text-view.h>
39 #include <dali-toolkit/internal/styling/style-manager-impl.h>
40
41 using namespace Dali::Toolkit::Text;
42
43 namespace Dali
44 {
45
46 namespace Toolkit
47 {
48
49 namespace Internal
50 {
51
52 namespace // unnamed namespace
53 {
54
55 #if defined(DEBUG_ENABLED)
56   Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
57 #endif
58
59   const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
60
61 } // unnamed namespace
62
63 namespace
64 {
65
66 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
67 {
68   { "BEGIN",  Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN  },
69   { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
70   { "END",    Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END    },
71 };
72 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
73
74 const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
75 {
76   { "TOP",    Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP    },
77   { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
78   { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
79 };
80 const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
81
82 // Type registration
83 BaseHandle Create()
84 {
85   return Toolkit::TextField::New();
86 }
87
88 // Setup properties, signals and actions using the type-registry.
89 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
90
91 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "rendering-backend",                    INTEGER,   RENDERING_BACKEND                    )
92 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text",                                 STRING,    TEXT                                 )
93 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder-text",                     STRING,    PLACEHOLDER_TEXT                     )
94 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder-text-focused",             STRING,    PLACEHOLDER_TEXT_FOCUSED             )
95 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "font-family",                          STRING,    FONT_FAMILY                          )
96 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "font-style",                           STRING,    FONT_STYLE                           )
97 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "point-size",                           FLOAT,     POINT_SIZE                           )
98 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "max-length",                           INTEGER,   MAX_LENGTH                           )
99 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "exceed-policy",                        INTEGER,   EXCEED_POLICY                        )
100 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "horizontal-alignment",                 STRING,    HORIZONTAL_ALIGNMENT                 )
101 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "vertical-alignment",                   STRING,    VERTICAL_ALIGNMENT                   )
102 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text-color",                           VECTOR4,   TEXT_COLOR                           )
103 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder-text-color",               VECTOR4,   PLACEHOLDER_TEXT_COLOR               )
104 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow-offset",                        VECTOR2,   SHADOW_OFFSET                        )
105 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow-color",                         VECTOR4,   SHADOW_COLOR                         )
106 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "primary-cursor-color",                 VECTOR4,   PRIMARY_CURSOR_COLOR                 )
107 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "secondary-cursor-color",               VECTOR4,   SECONDARY_CURSOR_COLOR               )
108 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enable-cursor-blink",                  BOOLEAN,   ENABLE_CURSOR_BLINK                  )
109 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursor-blink-interval",                FLOAT,     CURSOR_BLINK_INTERVAL                )
110 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursor-blink-duration",                FLOAT,     CURSOR_BLINK_DURATION                )
111 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grab-handle-image",                    STRING,    GRAB_HANDLE_IMAGE                    )
112 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grab-handle-pressed-image",            STRING,    GRAB_HANDLE_PRESSED_IMAGE            )
113 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scroll-threshold",                     FLOAT,     SCROLL_THRESHOLD                     )
114 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scroll-speed",                         FLOAT,     SCROLL_SPEED                         )
115 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-image-left",          MAP,       SELECTION_HANDLE_IMAGE_LEFT          )
116 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-image-right",         MAP,       SELECTION_HANDLE_IMAGE_RIGHT         )
117 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-pressed-image-left",  MAP,       SELECTION_HANDLE_PRESSED_IMAGE_LEFT  )
118 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-pressed-image-right", MAP,       SELECTION_HANDLE_PRESSED_IMAGE_RIGHT )
119 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-marker-image-left",   MAP,       SELECTION_HANDLE_MARKER_IMAGE_LEFT   )
120 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-marker-image-right",  MAP,       SELECTION_HANDLE_MARKER_IMAGE_RIGHT  )
121 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-highlight-color",            VECTOR4,   SELECTION_HIGHLIGHT_COLOR            )
122 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "decoration-bounding-box",              RECTANGLE, DECORATION_BOUNDING_BOX              )
123 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "input-method-settings",                MAP,       INPUT_METHOD_SETTINGS                )
124
125 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "text-changed",       SIGNAL_TEXT_CHANGED )
126 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "max-length-reached", SIGNAL_MAX_LENGTH_REACHED )
127
128 DALI_TYPE_REGISTRATION_END()
129
130 } // namespace
131
132 Toolkit::TextField TextField::New()
133 {
134   // Create the implementation, temporarily owned by this handle on stack
135   IntrusivePtr< TextField > impl = new TextField();
136
137   // Pass ownership to CustomActor handle
138   Toolkit::TextField handle( *impl );
139
140   // Second-phase init of the implementation
141   // This can only be done after the CustomActor connection has been made...
142   impl->Initialize();
143
144   return handle;
145 }
146
147 void TextField::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
148 {
149   Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
150
151   if( textField )
152   {
153     TextField& impl( GetImpl( textField ) );
154
155     switch( index )
156     {
157       case Toolkit::TextField::Property::RENDERING_BACKEND:
158       {
159         int backend = value.Get< int >();
160         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend );
161
162         if( impl.mRenderingBackend != backend )
163         {
164           impl.mRenderingBackend = backend;
165           impl.mRenderer.Reset();
166           impl.RequestTextRelayout();
167         }
168         break;
169       }
170       case Toolkit::TextField::Property::TEXT:
171       {
172         if( impl.mController )
173         {
174           const std::string text = value.Get< std::string >();
175           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str() );
176
177           impl.mController->SetText( text );
178         }
179         break;
180       }
181       case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
182       {
183         if( impl.mController )
184         {
185           const std::string text = value.Get< std::string >();
186           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
187
188           impl.mController->SetPlaceholderText( PLACEHOLDER_TYPE_INACTIVE, text );
189         }
190         break;
191       }
192       case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
193       {
194         if( impl.mController )
195         {
196           const std::string text = value.Get< std::string >();
197           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str() );
198
199           impl.mController->SetPlaceholderText( PLACEHOLDER_TYPE_ACTIVE, text );
200         }
201         break;
202       }
203       case Toolkit::TextField::Property::FONT_FAMILY:
204       {
205         if( impl.mController )
206         {
207           const std::string fontFamily = value.Get< std::string >();
208           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
209
210           if( impl.mController->GetDefaultFontFamily() != fontFamily )
211           {
212             impl.mController->SetDefaultFontFamily( fontFamily );
213           }
214         }
215         break;
216       }
217       case Toolkit::TextField::Property::FONT_STYLE:
218       {
219         if( impl.mController )
220         {
221           const std::string fontStyle = value.Get< std::string >();
222           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_STYLE %s\n", impl.mController.Get(), fontStyle.c_str() );
223
224           if( impl.mController->GetDefaultFontStyle() != fontStyle )
225           {
226             impl.mController->SetDefaultFontStyle( fontStyle );
227           }
228         }
229         break;
230       }
231       case Toolkit::TextField::Property::POINT_SIZE:
232       {
233         if( impl.mController )
234         {
235           const float pointSize = value.Get< float >();
236           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_STYLE %f\n", impl.mController.Get(), pointSize );
237
238           if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) )
239           {
240             impl.mController->SetDefaultPointSize( pointSize );
241           }
242         }
243         break;
244       }
245       case Toolkit::TextField::Property::MAX_LENGTH:
246       {
247         if( impl.mController )
248         {
249           const int max = value.Get< int >();
250           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max );
251
252           impl.mController->SetMaximumNumberOfCharacters( max );
253         }
254         break;
255       }
256       case Toolkit::TextField::Property::EXCEED_POLICY:
257       {
258         // TODO
259         break;
260       }
261       case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
262       {
263         if( impl.mController )
264         {
265           const std::string alignStr = value.Get< std::string >();
266           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
267
268           LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
269           if( Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(),
270                                                                               HORIZONTAL_ALIGNMENT_STRING_TABLE,
271                                                                               HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
272                                                                               alignment ) )
273           {
274             impl.mController->SetHorizontalAlignment( alignment );
275           }
276         }
277         break;
278       }
279       case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
280       {
281         if( impl.mController )
282         {
283           const std::string alignStr = value.Get< std::string >();
284           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
285
286           LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
287           if( Scripting::GetEnumeration< LayoutEngine::VerticalAlignment >( alignStr.c_str(),
288                                                                             VERTICAL_ALIGNMENT_STRING_TABLE,
289                                                                             VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
290                                                                             alignment ) )
291           {
292             impl.mController->SetVerticalAlignment( alignment );
293           }
294         }
295         break;
296       }
297       case Toolkit::TextField::Property::TEXT_COLOR:
298       {
299         if( impl.mController )
300         {
301           const Vector4 textColor = value.Get< Vector4 >();
302           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
303
304           if( impl.mController->GetTextColor() != textColor )
305           {
306             impl.mController->SetTextColor( textColor );
307             impl.mRenderer.Reset();
308           }
309         }
310         break;
311       }
312       case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
313       {
314         if( impl.mController )
315         {
316           const Vector4 textColor = value.Get< Vector4 >();
317           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
318
319           if( impl.mController->GetPlaceholderTextColor() != textColor )
320           {
321             impl.mController->SetPlaceholderTextColor( textColor );
322             impl.mRenderer.Reset();
323           }
324         }
325         break;
326       }
327       case Toolkit::TextField::Property::SHADOW_OFFSET:
328       {
329         if( impl.mController )
330         {
331           const Vector2 shadowOffset = value.Get< Vector2 >();
332           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_OFFSET %f,%f\n", impl.mController.Get(), shadowOffset.x, shadowOffset.y );
333
334           if ( impl.mController->GetShadowOffset() != shadowOffset )
335           {
336             impl.mController->SetShadowOffset( shadowOffset );
337             impl.mRenderer.Reset();
338           }
339         }
340         break;
341       }
342       case Toolkit::TextField::Property::SHADOW_COLOR:
343       {
344         if( impl.mController )
345         {
346           const Vector4 shadowColor = value.Get< Vector4 >();
347           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_COLOR %f,%f,%f,%f\n", impl.mController.Get(), shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a );
348
349           if ( impl.mController->GetShadowColor() != shadowColor )
350           {
351             impl.mController->SetShadowColor( shadowColor );
352             impl.mRenderer.Reset();
353           }
354         }
355         break;
356       }
357       case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
358       {
359         if( impl.mDecorator )
360         {
361           const Vector4 color = value.Get< Vector4 >();
362           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
363
364           impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
365           impl.RequestTextRelayout();
366         }
367         break;
368       }
369       case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
370       {
371         if( impl.mDecorator )
372         {
373           const Vector4 color = value.Get< Vector4 >();
374           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
375
376           impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
377           impl.RequestTextRelayout();
378         }
379         break;
380       }
381       case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
382       {
383         if( impl.mController )
384         {
385           const bool enable = value.Get< bool >();
386           DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable );
387
388           impl.mController->SetEnableCursorBlink( enable );
389           impl.RequestTextRelayout();
390         }
391         break;
392       }
393       case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
394       {
395         if( impl.mDecorator )
396         {
397           const float interval = value.Get< float >();
398           DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval );
399
400           impl.mDecorator->SetCursorBlinkInterval( interval );
401         }
402         break;
403       }
404       case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
405       {
406         if( impl.mDecorator )
407         {
408           const float duration = value.Get< float >();
409           DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration );
410
411           impl.mDecorator->SetCursorBlinkDuration( duration );
412         }
413         break;
414       }
415       case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
416       {
417         const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
418         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
419
420         if( impl.mDecorator )
421         {
422           impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, image );
423           impl.RequestTextRelayout();
424         }
425         break;
426       }
427       case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
428       {
429         const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
430         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
431
432         if( impl.mDecorator )
433         {
434           impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, image );
435           impl.RequestTextRelayout();
436         }
437         break;
438       }
439       case Toolkit::TextField::Property::SCROLL_THRESHOLD:
440       {
441         const float threshold = value.Get< float >();
442         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold );
443
444         if( impl.mDecorator )
445         {
446           impl.mDecorator->SetScrollThreshold( threshold );
447         }
448         break;
449       }
450       case Toolkit::TextField::Property::SCROLL_SPEED:
451       {
452         const float speed = value.Get< float >();
453         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed );
454
455         if( impl.mDecorator )
456         {
457           impl.mDecorator->SetScrollSpeed( speed );
458         }
459         break;
460       }
461       case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
462       {
463         const Image image = Scripting::NewImage( value );
464
465         if( impl.mDecorator )
466         {
467           impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
468           impl.RequestTextRelayout();
469         }
470         break;
471       }
472       case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
473       {
474         const Image image = Scripting::NewImage( value );
475
476         if( impl.mDecorator )
477         {
478           impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
479           impl.RequestTextRelayout();
480         }
481         break;
482       }
483       case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
484       {
485         const Image image = Scripting::NewImage( value );
486
487         if( impl.mDecorator )
488         {
489           impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
490           impl.RequestTextRelayout();
491         }
492         break;
493       }
494       case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
495       {
496         const Image image = Scripting::NewImage( value );
497
498         if( impl.mDecorator )
499         {
500           impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
501           impl.RequestTextRelayout();
502         }
503         break;
504       }
505       case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
506       {
507         const Image image = Scripting::NewImage( value );
508         if( impl.mDecorator )
509         {
510           impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
511           impl.RequestTextRelayout();
512         }
513         break;
514       }
515       case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
516       {
517         const Image image = Scripting::NewImage( value );
518         if( impl.mDecorator )
519         {
520           impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
521           impl.RequestTextRelayout();
522         }
523         break;
524       }
525       case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
526       {
527         const Vector4 color = value.Get< Vector4 >();
528         DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTION_HIGHLIGHT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
529
530         if( impl.mDecorator )
531         {
532           impl.mDecorator->SetHighlightColor( color );
533           impl.RequestTextRelayout();
534         }
535         break;
536       }
537       case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
538       {
539         if( impl.mDecorator )
540         {
541           const Rect<int> box = value.Get< Rect<int> >();
542           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height );
543
544           impl.mDecorator->SetBoundingBox( box );
545           impl.RequestTextRelayout();
546         }
547         break;
548       }
549       case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
550       {
551         const Property::Map map = value.Get<Property::Map>();
552         VirtualKeyboard::ApplySettings( map );
553         break;
554       }
555     } // switch
556   } // textfield
557 }
558
559 Property::Value TextField::GetProperty( BaseObject* object, Property::Index index )
560 {
561   Property::Value value;
562
563   Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
564
565   if( textField )
566   {
567     TextField& impl( GetImpl( textField ) );
568
569     switch( index )
570     {
571       case Toolkit::TextField::Property::RENDERING_BACKEND:
572       {
573         value = impl.mRenderingBackend;
574         break;
575       }
576       case Toolkit::TextField::Property::TEXT:
577       {
578         if( impl.mController )
579         {
580           std::string text;
581           impl.mController->GetText( text );
582           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str() );
583           value = text;
584         }
585         break;
586       }
587       case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
588       {
589         if( impl.mController )
590         {
591           std::string text;
592           impl.mController->GetPlaceholderText( PLACEHOLDER_TYPE_INACTIVE, text );
593           value = text;
594         }
595         break;
596       }
597       case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
598       {
599         if( impl.mController )
600         {
601           std::string text;
602           impl.mController->GetPlaceholderText( PLACEHOLDER_TYPE_ACTIVE, text );
603           value = text;
604         }
605         break;
606       }
607       case Toolkit::TextField::Property::FONT_FAMILY:
608       {
609         if( impl.mController )
610         {
611           value = impl.mController->GetDefaultFontFamily();
612         }
613         break;
614       }
615       case Toolkit::TextField::Property::FONT_STYLE:
616       {
617         if( impl.mController )
618         {
619           value = impl.mController->GetDefaultFontStyle();
620         }
621         break;
622       }
623       case Toolkit::TextField::Property::POINT_SIZE:
624       {
625         if( impl.mController )
626         {
627           value = impl.mController->GetDefaultPointSize();
628         }
629         break;
630       }
631       case Toolkit::TextField::Property::MAX_LENGTH:
632       {
633         if( impl.mController )
634         {
635           value = impl.mController->GetMaximumNumberOfCharacters();
636         }
637         break;
638       }
639       case Toolkit::TextField::Property::EXCEED_POLICY:
640       {
641         value = impl.mExceedPolicy;
642         break;
643       }
644       case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
645       {
646         if( impl.mController )
647         {
648           const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
649                                                                                                                 HORIZONTAL_ALIGNMENT_STRING_TABLE,
650                                                                                                                 HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
651           if( name )
652           {
653             value = std::string( name );
654           }
655         }
656         break;
657       }
658       case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
659       {
660         if( impl.mController )
661         {
662           const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
663                                                                                                               VERTICAL_ALIGNMENT_STRING_TABLE,
664                                                                                                               VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
665           if( name )
666           {
667             value = std::string( name );
668           }
669         }
670         break;
671       }
672       case Toolkit::TextField::Property::TEXT_COLOR:
673       {
674         if ( impl.mController )
675         {
676           value = impl.mController->GetTextColor();
677         }
678         break;
679       }
680       case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
681       {
682         if ( impl.mController )
683         {
684           value = impl.mController->GetPlaceholderTextColor();
685         }
686         break;
687       }
688       case Toolkit::TextField::Property::SHADOW_OFFSET:
689       {
690         if ( impl.mController )
691         {
692           value = impl.mController->GetShadowOffset();
693         }
694         break;
695       }
696       case Toolkit::TextField::Property::SHADOW_COLOR:
697       {
698         if ( impl.mController )
699         {
700           value = impl.mController->GetShadowColor();
701         }
702         break;
703       }
704       case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
705       {
706         if( impl.mDecorator )
707         {
708           value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
709         }
710         break;
711       }
712       case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
713       {
714         if( impl.mDecorator )
715         {
716           value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
717         }
718         break;
719       }
720       case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
721       {
722         value = impl.mController->GetEnableCursorBlink();
723         break;
724       }
725       case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
726       {
727         if( impl.mDecorator )
728         {
729           value = impl.mDecorator->GetCursorBlinkInterval();
730         }
731         break;
732       }
733       case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
734       {
735         if( impl.mDecorator )
736         {
737           value = impl.mDecorator->GetCursorBlinkDuration();
738         }
739         break;
740       }
741       case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
742       {
743         if( impl.mDecorator )
744         {
745           ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ) );
746           if( image )
747           {
748             value = image.GetUrl();
749           }
750         }
751         break;
752       }
753       case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
754       {
755         if( impl.mDecorator )
756         {
757           ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ) );
758           if( image )
759           {
760             value = image.GetUrl();
761           }
762         }
763         break;
764       }
765       case Toolkit::TextField::Property::SCROLL_THRESHOLD:
766       {
767         if( impl.mDecorator )
768         {
769           value = impl.mDecorator->GetScrollThreshold();
770         }
771         break;
772       }
773       case Toolkit::TextField::Property::SCROLL_SPEED:
774       {
775         if( impl.mDecorator )
776         {
777           value = impl.mDecorator->GetScrollSpeed();
778         }
779         break;
780       }
781       case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
782       {
783         impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED );
784         break;
785       }
786       case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
787       {
788         impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED ) ;
789         break;
790       }
791       case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
792       {
793         impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
794         break;
795       }
796       case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
797       {
798         impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
799         break;
800       }
801       case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
802       {
803         impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
804         break;
805       }
806       case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
807       {
808         impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
809         break;
810       }
811       case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
812       {
813         if( impl.mDecorator )
814         {
815           value = impl.mDecorator->GetHighlightColor();
816         }
817         break;
818       }
819       case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
820       {
821         if( impl.mDecorator )
822         {
823           value = impl.mDecorator->GetBoundingBox();
824         }
825         break;
826       }
827       case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
828       {
829         break;
830       }
831     } //switch
832   }
833
834   return value;
835 }
836
837 bool TextField::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
838 {
839   Dali::BaseHandle handle( object );
840
841   bool connected( true );
842   Toolkit::TextField field = Toolkit::TextField::DownCast( handle );
843
844   if( 0 == strcmp( signalName.c_str(), SIGNAL_TEXT_CHANGED ) )
845   {
846     field.TextChangedSignal().Connect( tracker, functor );
847   }
848   else if( 0 == strcmp( signalName.c_str(), SIGNAL_MAX_LENGTH_REACHED ) )
849   {
850     field.MaxLengthReachedSignal().Connect( tracker, functor );
851   }
852   else
853   {
854     // signalName does not match any signal
855     connected = false;
856   }
857
858   return connected;
859 }
860
861 Toolkit::TextField::TextChangedSignalType& TextField::TextChangedSignal()
862 {
863   return mTextChangedSignal;
864 }
865
866 Toolkit::TextField::MaxLengthReachedSignalType& TextField::MaxLengthReachedSignal()
867 {
868   return mMaxLengthReachedSignal;
869 }
870
871 void TextField::OnInitialize()
872 {
873   Actor self = Self();
874
875   mController = Text::Controller::New( *this );
876
877   mDecorator = Text::Decorator::New( *mController,
878                                      *mController );
879
880   mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
881
882   mController->EnableTextInput( mDecorator );
883
884   // Forward input events to controller
885   EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan |Gesture::LongPress ) );
886   GetTapGestureDetector().SetMaximumTapsRequired( 2 );
887
888   self.TouchedSignal().Connect( this, &TextField::OnTouched );
889
890   // Set BoundingBox to stage size if not already set.
891   if ( mDecorator->GetBoundingBox().IsEmpty() )
892   {
893     Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
894     mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
895   }
896
897   // Fill-parent area by default
898   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
899   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
900   self.OnStageSignal().Connect( this, &TextField::OnStageConnect );
901 }
902
903 void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
904 {
905   GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
906 }
907
908 Vector3 TextField::GetNaturalSize()
909 {
910   return mController->GetNaturalSize();
911 }
912
913 float TextField::GetHeightForWidth( float width )
914 {
915   return mController->GetHeightForWidth( width );
916 }
917
918 void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
919 {
920   if( mController->Relayout( size ) ||
921       !mRenderer )
922   {
923     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get() );
924
925     if( mDecorator )
926     {
927       mDecorator->Relayout( size );
928     }
929
930     if( !mRenderer )
931     {
932       mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
933     }
934
935     EnableClipping( (Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy), size );
936     RenderText();
937   }
938 }
939
940 void TextField::RenderText()
941 {
942   Actor self = Self();
943   Actor renderableActor;
944   if( mRenderer )
945   {
946     renderableActor = mRenderer->Render( mController->GetView(), self.GetHierarchyDepth() );
947   }
948
949   if( renderableActor != mRenderableActor )
950   {
951     UnparentAndReset( mRenderableActor );
952     mRenderableActor = renderableActor;
953   }
954
955   if( mRenderableActor )
956   {
957     const Vector2 offset = mController->GetScrollPosition() + mController->GetAlignmentOffset();
958
959     mRenderableActor.SetPosition( offset.x, offset.y );
960
961     Actor clipRootActor;
962     if( mClipper )
963     {
964       clipRootActor = mClipper->GetRootActor();
965     }
966
967     for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
968            endIt = mClippingDecorationActors.end();
969          it != endIt;
970          ++it )
971     {
972       Actor actor = *it;
973
974       if( clipRootActor )
975       {
976         clipRootActor.Add( actor );
977       }
978       else
979       {
980         self.Add( actor );
981       }
982     }
983     mClippingDecorationActors.clear();
984
985     // Make sure the actor is parented correctly with/without clipping
986     if( clipRootActor )
987     {
988       clipRootActor.Add( mRenderableActor );
989     }
990     else
991     {
992       self.Add( mRenderableActor );
993     }
994   }
995 }
996
997 void TextField::OnKeyInputFocusGained()
998 {
999   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
1000
1001   VirtualKeyboard::StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
1002
1003   ImfManager imfManager = ImfManager::Get();
1004
1005   if ( imfManager )
1006   {
1007     imfManager.EventReceivedSignal().Connect( this, &TextField::OnImfEvent );
1008
1009     // Notify that the text editing start.
1010     imfManager.Activate();
1011
1012     // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated.
1013     imfManager.SetRestoreAfterFocusLost( true );
1014   }
1015
1016    ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1017
1018    if ( notifier )
1019    {
1020       notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
1021    }
1022
1023   mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
1024
1025   EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
1026 }
1027
1028 void TextField::OnKeyInputFocusLost()
1029 {
1030   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get() );
1031
1032   VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged );
1033
1034   ImfManager imfManager = ImfManager::Get();
1035   if ( imfManager )
1036   {
1037     // The text editing is finished. Therefore the imf manager don't have restore activation.
1038     imfManager.SetRestoreAfterFocusLost( false );
1039
1040     // Notify that the text editing finish.
1041     imfManager.Deactivate();
1042
1043     imfManager.EventReceivedSignal().Disconnect( this, &TextField::OnImfEvent );
1044   }
1045
1046   ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1047
1048   if ( notifier )
1049   {
1050     notifier.ContentSelectedSignal().Disconnect( this, &TextField::OnClipboardTextSelected );
1051   }
1052
1053   mController->KeyboardFocusLostEvent();
1054
1055   EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
1056 }
1057
1058 void TextField::OnTap( const TapGesture& gesture )
1059 {
1060   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get() );
1061
1062   // Show the keyboard if it was hidden.
1063   if (!VirtualKeyboard::IsVisible())
1064   {
1065     VirtualKeyboard::Show();
1066   }
1067
1068   // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
1069   mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
1070
1071   SetKeyInputFocus();
1072 }
1073
1074 void TextField::OnPan( const PanGesture& gesture )
1075 {
1076   mController->PanEvent( gesture.state, gesture.displacement );
1077 }
1078
1079 void TextField::OnLongPress( const LongPressGesture& gesture )
1080 {
1081   mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y );
1082 }
1083
1084 bool TextField::OnKeyEvent( const KeyEvent& event )
1085 {
1086   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
1087
1088   if( Dali::DALI_KEY_ESCAPE == event.keyCode ||
1089       "Return" == event.keyPressedName ) // Make a Dali key code for this
1090   {
1091     ClearKeyInputFocus();
1092     return true;
1093   }
1094
1095   return mController->KeyEvent( event );
1096 }
1097
1098 void TextField::AddDecoration( Actor& actor, bool needsClipping )
1099 {
1100   if( actor )
1101   {
1102     if( needsClipping )
1103     {
1104       mClippingDecorationActors.push_back( actor );
1105     }
1106     else
1107     {
1108       Self().Add( actor );
1109     }
1110   }
1111 }
1112
1113 void TextField::RequestTextRelayout()
1114 {
1115   RelayoutRequest();
1116 }
1117
1118 void TextField::TextChanged()
1119 {
1120   Dali::Toolkit::TextField handle( GetOwner() );
1121   mTextChangedSignal.Emit( handle );
1122 }
1123
1124 void TextField::OnStageConnect( Dali::Actor actor )
1125 {
1126   if ( mHasBeenStaged )
1127   {
1128     RenderText();
1129   }
1130   else
1131   {
1132     mHasBeenStaged = true;
1133   }
1134 }
1135
1136 void TextField::MaxLengthReached()
1137 {
1138   Dali::Toolkit::TextField handle( GetOwner() );
1139   mMaxLengthReachedSignal.Emit( handle );
1140 }
1141
1142 ImfManager::ImfCallbackData TextField::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
1143 {
1144   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnImfEvent %p eventName %d\n", mController.Get(), imfEvent.eventName );
1145   return mController->OnImfEvent( imfManager, imfEvent );
1146 }
1147
1148 void TextField::GetHandleImagePropertyValue(  Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType )
1149 {
1150   if( mDecorator )
1151   {
1152     ResourceImage image = ResourceImage::DownCast( mDecorator->GetHandleImage( handleType, handleImageType ) );
1153
1154     if ( image )
1155     {
1156       Property::Map map;
1157       Scripting::CreatePropertyMap( image, map );
1158       value = map;
1159     }
1160   }
1161 }
1162
1163 void TextField::EnableClipping( bool clipping, const Vector2& size )
1164 {
1165   if( clipping )
1166   {
1167     // Not worth to created clip actor if width or height is equal to zero.
1168     if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
1169     {
1170       if( !mClipper )
1171       {
1172         Actor self = Self();
1173
1174         mClipper = Clipper::New( size );
1175         self.Add( mClipper->GetRootActor() );
1176         self.Add( mClipper->GetImageActor() );
1177       }
1178       else if ( mClipper )
1179       {
1180         mClipper->Refresh( size );
1181       }
1182     }
1183   }
1184   else
1185   {
1186     // Note - this will automatically remove the root & image actors
1187     mClipper.Reset();
1188   }
1189 }
1190
1191 void TextField::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
1192 {
1193   mController->PasteClipboardItemEvent();
1194 }
1195
1196 void TextField::KeyboardStatusChanged(bool keyboardShown)
1197 {
1198   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown );
1199
1200   // Just hide the grab handle when keyboard is hidden.
1201   if (!keyboardShown )
1202   {
1203     mController->KeyboardFocusLostEvent();
1204   }
1205   else
1206   {
1207     mController->KeyboardFocusGainEvent(); // Initially called by OnKeyInputFocusGained
1208   }
1209 }
1210
1211 void TextField::OnStageConnection( int depth )
1212 {
1213   // Call the Control::OnStageConnection() to set the depth of the background.
1214   Control::OnStageConnection( depth );
1215
1216   // Sets the depth to the renderers inside the text's decorator.
1217   mDecorator->SetTextDepth( depth );
1218
1219   // The depth of the text renderer is set in the RenderText() called from OnRelayout().
1220 }
1221
1222 bool TextField::OnTouched( Actor actor, const TouchEvent& event )
1223 {
1224   return true;
1225 }
1226
1227 TextField::TextField()
1228 : Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
1229   mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
1230   mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ),
1231   mHasBeenStaged( false )
1232 {
1233 }
1234
1235 TextField::~TextField()
1236 {
1237   mClipper.Reset();
1238 }
1239
1240 } // namespace Internal
1241
1242 } // namespace Toolkit
1243
1244 } // namespace Dali