Merge "Don't count '\r' in text-field" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-field-impl.cpp
1 /*
2  * Copyright (c) 2017 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 <cstring>
23 #include <dali/public-api/adaptor-framework/key.h>
24 #include <dali/devel-api/adaptor-framework/key-devel.h>
25 #include <dali/public-api/common/stage.h>
26 #include <dali/public-api/images/resource-image.h>
27 #include <dali/devel-api/object/property-helper-devel.h>
28 #include <dali/devel-api/actors/actor-devel.h>
29 #include <dali/public-api/object/type-registry-helper.h>
30 #include <dali/integration-api/adaptors/adaptor.h>
31 #include <dali/integration-api/debug.h>
32
33 // INTERNAL INCLUDES
34 #include <dali-toolkit/public-api/text/rendering-backend.h>
35 #include <dali-toolkit/public-api/text/text-enumerations.h>
36 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
37 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
38 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
39 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
40 #include <dali-toolkit/public-api/visuals/visual-properties.h>
41 #include <dali-toolkit/internal/text/text-enumerations-impl.h>
42 #include <dali-toolkit/internal/text/rendering/text-backend.h>
43 #include <dali-toolkit/internal/text/text-effects-style.h>
44 #include <dali-toolkit/internal/text/text-font-style.h>
45 #include <dali-toolkit/internal/text/text-view.h>
46 #include <dali-toolkit/internal/styling/style-manager-impl.h>
47
48 using namespace Dali::Toolkit::Text;
49
50 namespace Dali
51 {
52
53 namespace Toolkit
54 {
55
56 namespace Internal
57 {
58
59 namespace // unnamed namespace
60 {
61
62 #if defined(DEBUG_ENABLED)
63   Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
64 #endif
65
66   const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
67 } // unnamed namespace
68
69 namespace
70 {
71 // Type registration
72 BaseHandle Create()
73 {
74   return Toolkit::TextField::New();
75 }
76
77 // Setup properties, signals and actions using the type-registry.
78 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextField, Toolkit::Control, Create );
79
80 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "renderingBackend",                     INTEGER,   RENDERING_BACKEND                    )
81 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text",                                 STRING,    TEXT                                 )
82 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderText",                      STRING,    PLACEHOLDER_TEXT                     )
83 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderTextFocused",               STRING,    PLACEHOLDER_TEXT_FOCUSED             )
84 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "fontFamily",                           STRING,    FONT_FAMILY                          )
85 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "fontStyle",                            MAP,       FONT_STYLE                           )
86 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "pointSize",                            FLOAT,     POINT_SIZE                           )
87 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "maxLength",                            INTEGER,   MAX_LENGTH                           )
88 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "exceedPolicy",                         INTEGER,   EXCEED_POLICY                        )
89 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "horizontalAlignment",                  STRING,    HORIZONTAL_ALIGNMENT                 )
90 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "verticalAlignment",                    STRING,    VERTICAL_ALIGNMENT                   )
91 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "textColor",                            VECTOR4,   TEXT_COLOR                           )
92 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderTextColor",                 VECTOR4,   PLACEHOLDER_TEXT_COLOR               )
93 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadowOffset",                         VECTOR2,   SHADOW_OFFSET                        )
94 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadowColor",                          VECTOR4,   SHADOW_COLOR                         )
95 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "primaryCursorColor",                   VECTOR4,   PRIMARY_CURSOR_COLOR                 )
96 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "secondaryCursorColor",                 VECTOR4,   SECONDARY_CURSOR_COLOR               )
97 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableCursorBlink",                    BOOLEAN,   ENABLE_CURSOR_BLINK                  )
98 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursorBlinkInterval",                  FLOAT,     CURSOR_BLINK_INTERVAL                )
99 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursorBlinkDuration",                  FLOAT,     CURSOR_BLINK_DURATION                )
100 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "cursorWidth",                          INTEGER,   CURSOR_WIDTH                         )
101 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grabHandleImage",                      STRING,    GRAB_HANDLE_IMAGE                    )
102 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "grabHandlePressedImage",               STRING,    GRAB_HANDLE_PRESSED_IMAGE            )
103 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scrollThreshold",                      FLOAT,     SCROLL_THRESHOLD                     )
104 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "scrollSpeed",                          FLOAT,     SCROLL_SPEED                         )
105 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleImageLeft",             MAP,       SELECTION_HANDLE_IMAGE_LEFT          )
106 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleImageRight",            MAP,       SELECTION_HANDLE_IMAGE_RIGHT         )
107 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandlePressedImageLeft",      MAP,       SELECTION_HANDLE_PRESSED_IMAGE_LEFT  )
108 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandlePressedImageRight",     MAP,       SELECTION_HANDLE_PRESSED_IMAGE_RIGHT )
109 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleMarkerImageLeft",       MAP,       SELECTION_HANDLE_MARKER_IMAGE_LEFT   )
110 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHandleMarkerImageRight",      MAP,       SELECTION_HANDLE_MARKER_IMAGE_RIGHT  )
111 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selectionHighlightColor",              VECTOR4,   SELECTION_HIGHLIGHT_COLOR            )
112 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "decorationBoundingBox",                RECTANGLE, DECORATION_BOUNDING_BOX              )
113 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputMethodSettings",                  MAP,       INPUT_METHOD_SETTINGS                )
114 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputColor",                           VECTOR4,   INPUT_COLOR                          )
115 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableMarkup",                         BOOLEAN,   ENABLE_MARKUP                        )
116 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputFontFamily",                      STRING,    INPUT_FONT_FAMILY                    )
117 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputFontStyle",                       MAP,       INPUT_FONT_STYLE                     )
118 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputPointSize",                       FLOAT,     INPUT_POINT_SIZE                     )
119 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "underline",                            MAP,       UNDERLINE                            )
120 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputUnderline",                       MAP,       INPUT_UNDERLINE                      )
121 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadow",                               MAP,       SHADOW                               )
122 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputShadow",                          MAP,       INPUT_SHADOW                         )
123 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "emboss",                               MAP,       EMBOSS                               )
124 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputEmboss",                          MAP,       INPUT_EMBOSS                         )
125 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "outline",                              MAP,       OUTLINE                              )
126 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "inputOutline",                         MAP,       INPUT_OUTLINE                        )
127 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "hiddenInputSettings",                  MAP,       HIDDEN_INPUT_SETTINGS                )
128 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "pixelSize",                            FLOAT,     PIXEL_SIZE                           )
129 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableSelection",                      BOOLEAN,   ENABLE_SELECTION                     )
130 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder",                          MAP,       PLACEHOLDER                          )
131 DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "ellipsis",                             BOOLEAN,   ELLIPSIS                             )
132 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableShiftSelection",           BOOLEAN,   ENABLE_SHIFT_SELECTION               )
133
134 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged",        SIGNAL_TEXT_CHANGED )
135 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached",   SIGNAL_MAX_LENGTH_REACHED )
136 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "inputStyleChanged",  SIGNAL_INPUT_STYLE_CHANGED )
137
138 DALI_TYPE_REGISTRATION_END()
139
140 } // namespace
141
142 Toolkit::TextField TextField::New()
143 {
144   // Create the implementation, temporarily owned by this handle on stack
145   IntrusivePtr< TextField > impl = new TextField();
146
147   // Pass ownership to CustomActor handle
148   Toolkit::TextField handle( *impl );
149
150   // Second-phase init of the implementation
151   // This can only be done after the CustomActor connection has been made...
152   impl->Initialize();
153
154   return handle;
155 }
156
157 void TextField::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
158 {
159   Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
160
161   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField SetProperty\n");
162
163
164   if( textField )
165   {
166     TextField& impl( GetImpl( textField ) );
167
168     switch( index )
169     {
170       case Toolkit::TextField::Property::RENDERING_BACKEND:
171       {
172         int backend = value.Get< int >();
173         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p RENDERING_BACKEND %d\n", impl.mController.Get(), backend );
174
175 #ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING
176         if( Text::RENDERING_VECTOR_BASED == backend )
177         {
178           backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
179         }
180 #endif
181         if( impl.mRenderingBackend != backend )
182         {
183           impl.mRenderingBackend = backend;
184           impl.mRenderer.Reset();
185
186           if( impl.mController )
187           {
188             // When using the vector-based rendering, the size of the GLyphs are different
189             TextAbstraction::GlyphType glyphType = (Text::RENDERING_VECTOR_BASED == impl.mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
190             impl.mController->SetGlyphType( glyphType );
191           }
192         }
193         break;
194       }
195       case Toolkit::TextField::Property::TEXT:
196       {
197         if( impl.mController )
198         {
199           const std::string& text = value.Get< std::string >();
200           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str() );
201
202           impl.mController->SetText( text );
203         }
204         break;
205       }
206       case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
207       {
208         if( impl.mController )
209         {
210           const std::string& text = value.Get< std::string >();
211           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
212
213           impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
214         }
215         break;
216       }
217       case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
218       {
219         if( impl.mController )
220         {
221           const std::string& text = value.Get< std::string >();
222           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str() );
223
224           impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
225         }
226         break;
227       }
228       case Toolkit::TextField::Property::FONT_FAMILY:
229       {
230         if( impl.mController )
231         {
232           const std::string& fontFamily = value.Get< std::string >();
233           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
234           impl.mController->SetDefaultFontFamily( fontFamily );
235         }
236         break;
237       }
238       case Toolkit::TextField::Property::FONT_STYLE:
239       {
240         SetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
241         break;
242       }
243       case Toolkit::TextField::Property::POINT_SIZE:
244       {
245         if( impl.mController )
246         {
247           const float pointSize = value.Get< float >();
248           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize );
249
250           if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE ), pointSize ) )
251           {
252             impl.mController->SetDefaultFontSize( pointSize, Text::Controller::POINT_SIZE );
253           }
254         }
255         break;
256       }
257       case Toolkit::TextField::Property::MAX_LENGTH:
258       {
259         if( impl.mController )
260         {
261           const int max = value.Get< int >();
262           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p MAX_LENGTH %d\n", impl.mController.Get(), max );
263
264           impl.mController->SetMaximumNumberOfCharacters( max );
265         }
266         break;
267       }
268       case Toolkit::TextField::Property::EXCEED_POLICY:
269       {
270         impl.mExceedPolicy = value.Get<int>();
271
272         if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == impl.mExceedPolicy )
273         {
274           impl.EnableClipping();
275         }
276         else
277         {
278           UnparentAndReset( impl.mStencil );
279         }
280         impl.RequestTextRelayout();
281         break;
282       }
283       case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
284       {
285         if( impl.mController )
286         {
287           Text::HorizontalAlignment::Type alignment( static_cast< Text::HorizontalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set
288           if( GetHorizontalAlignmentEnumeration( value, alignment ) )
289           {
290             DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %d\n", impl.mController.Get(), alignment );
291             impl.mController->SetHorizontalAlignment( alignment );
292           }
293         }
294         break;
295       }
296       case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
297       {
298         if( impl.mController )
299         {
300           Toolkit::Text::VerticalAlignment::Type alignment( static_cast< Text::VerticalAlignment::Type >( -1 ) ); // Set to invalid value to ensure a valid mode does get set
301           if( GetVerticalAlignmentEnumeration( value, alignment ) )
302           {
303             impl.mController->SetVerticalAlignment( alignment );
304             DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment );
305           }
306         }
307         break;
308       }
309       case Toolkit::TextField::Property::TEXT_COLOR:
310       {
311         if( impl.mController )
312         {
313           const Vector4& textColor = value.Get< Vector4 >();
314           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 );
315
316           if( impl.mController->GetDefaultColor() != textColor )
317           {
318             impl.mController->SetDefaultColor( textColor );
319             impl.mController->SetInputColor( textColor );
320             impl.mRenderer.Reset();
321           }
322         }
323         break;
324       }
325       case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
326       {
327         if( impl.mController )
328         {
329           const Vector4& textColor = value.Get< Vector4 >();
330           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 );
331
332           if( impl.mController->GetPlaceholderTextColor() != textColor )
333           {
334             impl.mController->SetPlaceholderTextColor( textColor );
335             impl.mRenderer.Reset();
336           }
337         }
338         break;
339       }
340       case Toolkit::TextField::Property::SHADOW_OFFSET:
341       {
342         if( impl.mController )
343         {
344           const Vector2& shadowOffset = value.Get< Vector2 >();
345           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_OFFSET %f,%f\n", impl.mController.Get(), shadowOffset.x, shadowOffset.y );
346
347           if ( impl.mController->GetShadowOffset() != shadowOffset )
348           {
349             impl.mController->SetShadowOffset( shadowOffset );
350             impl.mRenderer.Reset();
351           }
352         }
353         break;
354       }
355       case Toolkit::TextField::Property::SHADOW_COLOR:
356       {
357         if( impl.mController )
358         {
359           const Vector4& shadowColor = value.Get< Vector4 >();
360           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 );
361
362           if ( impl.mController->GetShadowColor() != shadowColor )
363           {
364             impl.mController->SetShadowColor( shadowColor );
365             impl.mRenderer.Reset();
366           }
367         }
368         break;
369       }
370       case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
371       {
372         if( impl.mDecorator )
373         {
374           const Vector4& color = value.Get< Vector4 >();
375           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 );
376
377           impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
378           impl.RequestTextRelayout();
379         }
380         break;
381       }
382       case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
383       {
384         if( impl.mDecorator )
385         {
386           const Vector4& color = value.Get< Vector4 >();
387           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 );
388
389           impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
390           impl.RequestTextRelayout();
391         }
392         break;
393       }
394       case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
395       {
396         if( impl.mController )
397         {
398           const bool enable = value.Get< bool >();
399           DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p ENABLE_CURSOR_BLINK %d\n", impl.mController.Get(), enable );
400
401           impl.mController->SetEnableCursorBlink( enable );
402           impl.RequestTextRelayout();
403         }
404         break;
405       }
406       case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
407       {
408         if( impl.mDecorator )
409         {
410           const float interval = value.Get< float >();
411           DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_INTERVAL %f\n", impl.mController.Get(), interval );
412
413           impl.mDecorator->SetCursorBlinkInterval( interval );
414         }
415         break;
416       }
417       case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
418       {
419         if( impl.mDecorator )
420         {
421           const float duration = value.Get< float >();
422           DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_BLINK_DURATION %f\n", impl.mController.Get(), duration );
423
424           impl.mDecorator->SetCursorBlinkDuration( duration );
425         }
426         break;
427       }
428       case Toolkit::TextField::Property::CURSOR_WIDTH:
429       {
430         if( impl.mDecorator )
431         {
432           const int width = value.Get< int >();
433           DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p CURSOR_WIDTH %d\n", impl.mController.Get(), width );
434
435           impl.mDecorator->SetCursorWidth( width );
436           impl.mController->GetLayoutEngine().SetCursorWidth( width );
437         }
438         break;
439       }
440       case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
441       {
442         const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
443         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
444
445         if( impl.mDecorator )
446         {
447           impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, image );
448           impl.RequestTextRelayout();
449         }
450         break;
451       }
452       case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
453       {
454         const ResourceImage image = ResourceImage::New( value.Get< std::string >() );
455         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p GRAB_HANDLE_PRESSED_IMAGE %s\n", impl.mController.Get(), image.GetUrl().c_str() );
456
457         if( impl.mDecorator )
458         {
459           impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, image );
460           impl.RequestTextRelayout();
461         }
462         break;
463       }
464       case Toolkit::TextField::Property::SCROLL_THRESHOLD:
465       {
466         const float threshold = value.Get< float >();
467         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_THRESHOLD %f\n", impl.mController.Get(), threshold );
468
469         if( impl.mDecorator )
470         {
471           impl.mDecorator->SetScrollThreshold( threshold );
472         }
473         break;
474       }
475       case Toolkit::TextField::Property::SCROLL_SPEED:
476       {
477         const float speed = value.Get< float >();
478         DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField %p SCROLL_SPEED %f\n", impl.mController.Get(), speed );
479
480         if( impl.mDecorator )
481         {
482           impl.mDecorator->SetScrollSpeed( speed );
483         }
484         break;
485       }
486       case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
487       {
488         const Image image = Scripting::NewImage( value );
489
490         if( impl.mDecorator && image )
491         {
492           impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
493           impl.RequestTextRelayout();
494         }
495         break;
496       }
497       case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
498       {
499         const Image image = Scripting::NewImage( value );
500
501         if( impl.mDecorator && image )
502         {
503           impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image );
504           impl.RequestTextRelayout();
505         }
506         break;
507       }
508       case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
509       {
510         const Image image = Scripting::NewImage( value );
511
512         if( impl.mDecorator && image )
513         {
514           impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
515           impl.RequestTextRelayout();
516         }
517         break;
518       }
519       case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
520       {
521         const Image image = Scripting::NewImage( value );
522
523         if( impl.mDecorator && image )
524         {
525           impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image );
526           impl.RequestTextRelayout();
527         }
528         break;
529       }
530       case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
531       {
532         const Image image = Scripting::NewImage( value );
533
534         if( impl.mDecorator && image )
535         {
536           impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
537           impl.RequestTextRelayout();
538         }
539         break;
540       }
541       case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
542       {
543         const Image image = Scripting::NewImage( value );
544
545         if( impl.mDecorator && image )
546         {
547           impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED, image );
548           impl.RequestTextRelayout();
549         }
550         break;
551       }
552       case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
553       {
554         const Vector4 color = value.Get< Vector4 >();
555         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 );
556
557         if( impl.mDecorator )
558         {
559           impl.mDecorator->SetHighlightColor( color );
560           impl.RequestTextRelayout();
561         }
562         break;
563       }
564       case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
565       {
566         if( impl.mDecorator )
567         {
568           const Rect<int> box = value.Get< Rect<int> >();
569           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 );
570
571           impl.mDecorator->SetBoundingBox( box );
572           impl.RequestTextRelayout();
573         }
574         break;
575       }
576       case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
577       {
578         const Property::Map* map = value.GetMap();
579         if (map)
580         {
581           impl.mInputMethodOptions.ApplyProperty( *map );
582         }
583         impl.mController->SetInputModePassword( impl.mInputMethodOptions.IsPassword() );
584
585         Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl();
586         if (control == textField)
587         {
588           impl.mImfManager.ApplyOptions( impl.mInputMethodOptions );
589         }
590         break;
591       }
592       case Toolkit::TextField::Property::INPUT_COLOR:
593       {
594         if( impl.mController )
595         {
596           const Vector4 inputColor = value.Get< Vector4 >();
597           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a );
598
599           impl.mController->SetInputColor( inputColor );
600         }
601         break;
602       }
603       case Toolkit::TextField::Property::ENABLE_MARKUP:
604       {
605         if( impl.mController )
606         {
607           const bool enableMarkup = value.Get<bool>();
608           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_MARKUP %d\n", impl.mController.Get(), enableMarkup );
609
610           impl.mController->SetMarkupProcessorEnabled( enableMarkup );
611         }
612         break;
613       }
614       case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
615       {
616         if( impl.mController )
617         {
618           const std::string& fontFamily = value.Get< std::string >();
619           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
620           impl.mController->SetInputFontFamily( fontFamily );
621         }
622         break;
623       }
624       case Toolkit::TextField::Property::INPUT_FONT_STYLE:
625       {
626         SetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
627         break;
628       }
629       case Toolkit::TextField::Property::INPUT_POINT_SIZE:
630       {
631         if( impl.mController )
632         {
633           const float pointSize = value.Get< float >();
634           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_POINT_SIZE %f\n", impl.mController.Get(), pointSize );
635           impl.mController->SetInputFontPointSize( pointSize );
636         }
637         break;
638       }
639       case Toolkit::TextField::Property::UNDERLINE:
640       {
641         const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
642         if( update )
643         {
644           impl.mRenderer.Reset();
645         }
646         break;
647       }
648       case Toolkit::TextField::Property::INPUT_UNDERLINE:
649       {
650         const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
651         if( update )
652         {
653           impl.mRenderer.Reset();
654         }
655         break;
656       }
657       case Toolkit::TextField::Property::SHADOW:
658       {
659         const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
660         if( update )
661         {
662           impl.mRenderer.Reset();
663         }
664         break;
665       }
666       case Toolkit::TextField::Property::INPUT_SHADOW:
667       {
668         const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
669         if( update )
670         {
671           impl.mRenderer.Reset();
672         }
673         break;
674       }
675       case Toolkit::TextField::Property::EMBOSS:
676       {
677         const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
678         if( update )
679         {
680           impl.mRenderer.Reset();
681         }
682         break;
683       }
684       case Toolkit::TextField::Property::INPUT_EMBOSS:
685       {
686         const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
687         if( update )
688         {
689           impl.mRenderer.Reset();
690         }
691         break;
692       }
693       case Toolkit::TextField::Property::OUTLINE:
694       {
695         const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
696         if( update )
697         {
698           impl.mRenderer.Reset();
699         }
700         break;
701       }
702       case Toolkit::TextField::Property::INPUT_OUTLINE:
703       {
704         const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
705         if( update )
706         {
707           impl.mRenderer.Reset();
708         }
709         break;
710       }
711       case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
712       {
713         const Property::Map* map = value.GetMap();
714         if (map)
715         {
716           impl.mController->SetHiddenInputOption(*map);
717         }
718         break;
719       }
720       case Toolkit::TextField::Property::PIXEL_SIZE:
721       {
722         if( impl.mController )
723         {
724           const float pixelSize = value.Get< float >();
725           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PIXEL_SIZE %f\n", impl.mController.Get(), pixelSize );
726
727           if( !Equals( impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) )
728           {
729             impl.mController->SetDefaultFontSize( pixelSize, Text::Controller::PIXEL_SIZE );
730           }
731         }
732         break;
733       }
734       case Toolkit::TextField::Property::ENABLE_SELECTION:
735       {
736         if( impl.mController )
737         {
738           const bool enableSelection = value.Get< bool >();
739            DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection );
740           impl.mController->SetSelectionEnabled( enableSelection );
741         }
742         break;
743       }
744       case Toolkit::TextField::Property::PLACEHOLDER:
745       {
746         const Property::Map* map = value.GetMap();
747         if( map )
748         {
749           impl.mController->SetPlaceholderProperty( *map );
750         }
751         break;
752       }
753       case Toolkit::TextField::Property::ELLIPSIS:
754       {
755         if( impl.mController )
756         {
757           const bool ellipsis = value.Get<bool>();
758           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis );
759
760           impl.mController->SetTextElideEnabled( ellipsis );
761         }
762         break;
763       }
764       case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
765       {
766         if( impl.mController )
767         {
768           const bool shiftSelection = value.Get<bool>();
769           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_SHIFT_SELECTION %d\n", impl.mController.Get(), shiftSelection );
770
771           impl.mController->SetShiftSelectionEnabled( shiftSelection );
772         }
773         break;
774       }
775     } // switch
776   } // textfield
777 }
778
779 Property::Value TextField::GetProperty( BaseObject* object, Property::Index index )
780 {
781   Property::Value value;
782
783   Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
784
785   if( textField )
786   {
787     TextField& impl( GetImpl( textField ) );
788
789     switch( index )
790     {
791       case Toolkit::TextField::Property::RENDERING_BACKEND:
792       {
793         value = impl.mRenderingBackend;
794         break;
795       }
796       case Toolkit::TextField::Property::TEXT:
797       {
798         if( impl.mController )
799         {
800           std::string text;
801           impl.mController->GetText( text );
802           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p returning text: %s\n", impl.mController.Get(), text.c_str() );
803           value = text;
804         }
805         break;
806       }
807       case Toolkit::TextField::Property::PLACEHOLDER_TEXT:
808       {
809         if( impl.mController )
810         {
811           std::string text;
812           impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
813           value = text;
814         }
815         break;
816       }
817       case Toolkit::TextField::Property::PLACEHOLDER_TEXT_FOCUSED:
818       {
819         if( impl.mController )
820         {
821           std::string text;
822           impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
823           value = text;
824         }
825         break;
826       }
827       case Toolkit::TextField::Property::FONT_FAMILY:
828       {
829         if( impl.mController )
830         {
831           value = impl.mController->GetDefaultFontFamily();
832         }
833         break;
834       }
835       case Toolkit::TextField::Property::FONT_STYLE:
836       {
837         GetFontStyleProperty( impl.mController, value, Text::FontStyle::DEFAULT );
838         break;
839       }
840       case Toolkit::TextField::Property::POINT_SIZE:
841       {
842         if( impl.mController )
843         {
844           value = impl.mController->GetDefaultFontSize( Text::Controller::POINT_SIZE );
845         }
846         break;
847       }
848       case Toolkit::TextField::Property::MAX_LENGTH:
849       {
850         if( impl.mController )
851         {
852           value = impl.mController->GetMaximumNumberOfCharacters();
853         }
854         break;
855       }
856       case Toolkit::TextField::Property::EXCEED_POLICY:
857       {
858         value = impl.mExceedPolicy;
859         break;
860       }
861       case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
862       {
863         if( impl.mController )
864         {
865           const char* name = Text::GetHorizontalAlignmentString( impl.mController->GetHorizontalAlignment() );
866
867           if ( name )
868           {
869             value = std::string( name );
870           }
871         }
872         break;
873       }
874       case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
875       {
876         if( impl.mController )
877         {
878           const char* name = Text::GetVerticalAlignmentString( impl.mController->GetVerticalAlignment() );
879
880           if( name )
881           {
882             value = std::string( name );
883           }
884         }
885         break;
886       }
887       case Toolkit::TextField::Property::TEXT_COLOR:
888       {
889         if ( impl.mController )
890         {
891           value = impl.mController->GetDefaultColor();
892         }
893         break;
894       }
895       case Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR:
896       {
897         if ( impl.mController )
898         {
899           value = impl.mController->GetPlaceholderTextColor();
900         }
901         break;
902       }
903       case Toolkit::TextField::Property::SHADOW_OFFSET:
904       {
905         if ( impl.mController )
906         {
907           value = impl.mController->GetShadowOffset();
908         }
909         break;
910       }
911       case Toolkit::TextField::Property::SHADOW_COLOR:
912       {
913         if ( impl.mController )
914         {
915           value = impl.mController->GetShadowColor();
916         }
917         break;
918       }
919       case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
920       {
921         if( impl.mDecorator )
922         {
923           value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
924         }
925         break;
926       }
927       case Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR:
928       {
929         if( impl.mDecorator )
930         {
931           value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
932         }
933         break;
934       }
935       case Toolkit::TextField::Property::ENABLE_CURSOR_BLINK:
936       {
937         value = impl.mController->GetEnableCursorBlink();
938         break;
939       }
940       case Toolkit::TextField::Property::CURSOR_BLINK_INTERVAL:
941       {
942         if( impl.mDecorator )
943         {
944           value = impl.mDecorator->GetCursorBlinkInterval();
945         }
946         break;
947       }
948       case Toolkit::TextField::Property::CURSOR_BLINK_DURATION:
949       {
950         if( impl.mDecorator )
951         {
952           value = impl.mDecorator->GetCursorBlinkDuration();
953         }
954         break;
955       }
956       case Toolkit::TextField::Property::CURSOR_WIDTH:
957       {
958         if( impl.mDecorator )
959         {
960           value = impl.mDecorator->GetCursorWidth();
961         }
962         break;
963       }
964       case Toolkit::TextField::Property::GRAB_HANDLE_IMAGE:
965       {
966         if( impl.mDecorator )
967         {
968           ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ) );
969           if( image )
970           {
971             value = image.GetUrl();
972           }
973         }
974         break;
975       }
976       case Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE:
977       {
978         if( impl.mDecorator )
979         {
980           ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ) );
981           if( image )
982           {
983             value = image.GetUrl();
984           }
985         }
986         break;
987       }
988       case Toolkit::TextField::Property::SCROLL_THRESHOLD:
989       {
990         if( impl.mDecorator )
991         {
992           value = impl.mDecorator->GetScrollThreshold();
993         }
994         break;
995       }
996       case Toolkit::TextField::Property::SCROLL_SPEED:
997       {
998         if( impl.mDecorator )
999         {
1000           value = impl.mDecorator->GetScrollSpeed();
1001         }
1002         break;
1003       }
1004       case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT:
1005       {
1006         impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED );
1007         break;
1008       }
1009       case Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT:
1010       {
1011         impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED ) ;
1012         break;
1013       }
1014       case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT:
1015       {
1016         impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
1017         break;
1018       }
1019       case Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT:
1020       {
1021         impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED );
1022         break;
1023       }
1024       case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT:
1025       {
1026         impl.GetHandleImagePropertyValue( value, LEFT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
1027         break;
1028       }
1029       case Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT:
1030       {
1031         impl.GetHandleImagePropertyValue( value, RIGHT_SELECTION_HANDLE_MARKER, HANDLE_IMAGE_RELEASED );
1032         break;
1033       }
1034       case Toolkit::TextField::Property::SELECTION_HIGHLIGHT_COLOR:
1035       {
1036         if( impl.mDecorator )
1037         {
1038           value = impl.mDecorator->GetHighlightColor();
1039         }
1040         break;
1041       }
1042       case Toolkit::TextField::Property::DECORATION_BOUNDING_BOX:
1043       {
1044         if( impl.mDecorator )
1045         {
1046           Rect<int> boundingBox;
1047           impl.mDecorator->GetBoundingBox( boundingBox );
1048           value = boundingBox;
1049         }
1050         break;
1051       }
1052       case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS:
1053       {
1054         Property::Map map;
1055         impl.mInputMethodOptions.RetrieveProperty( map );
1056         value = map;
1057         break;
1058       }
1059       case Toolkit::TextField::Property::INPUT_COLOR:
1060       {
1061         if( impl.mController )
1062         {
1063           value = impl.mController->GetInputColor();
1064         }
1065         break;
1066       }
1067       case Toolkit::TextField::Property::ENABLE_MARKUP:
1068       {
1069         if( impl.mController )
1070         {
1071           value = impl.mController->IsMarkupProcessorEnabled();
1072         }
1073         break;
1074       }
1075       case Toolkit::TextField::Property::INPUT_FONT_FAMILY:
1076       {
1077         if( impl.mController )
1078         {
1079           value = impl.mController->GetInputFontFamily();
1080         }
1081         break;
1082       }
1083       case Toolkit::TextField::Property::INPUT_FONT_STYLE:
1084       {
1085         GetFontStyleProperty( impl.mController, value, Text::FontStyle::INPUT );
1086         break;
1087       }
1088       case Toolkit::TextField::Property::INPUT_POINT_SIZE:
1089       {
1090         if( impl.mController )
1091         {
1092           value = impl.mController->GetInputFontPointSize();
1093         }
1094         break;
1095       }
1096       case Toolkit::TextField::Property::UNDERLINE:
1097       {
1098         GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
1099         break;
1100       }
1101       case Toolkit::TextField::Property::INPUT_UNDERLINE:
1102       {
1103         GetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
1104         break;
1105       }
1106       case Toolkit::TextField::Property::SHADOW:
1107       {
1108         GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
1109         break;
1110       }
1111       case Toolkit::TextField::Property::INPUT_SHADOW:
1112       {
1113         GetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT );
1114         break;
1115       }
1116       case Toolkit::TextField::Property::EMBOSS:
1117       {
1118         GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
1119         break;
1120       }
1121       case Toolkit::TextField::Property::INPUT_EMBOSS:
1122       {
1123         GetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT );
1124         break;
1125       }
1126       case Toolkit::TextField::Property::OUTLINE:
1127       {
1128         GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
1129         break;
1130       }
1131       case Toolkit::TextField::Property::INPUT_OUTLINE:
1132       {
1133         GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT );
1134         break;
1135       }
1136       case Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS:
1137       {
1138         Property::Map map;
1139         impl.mController->GetHiddenInputOption(map);
1140         value = map;
1141         break;
1142       }
1143       case Toolkit::TextField::Property::PIXEL_SIZE:
1144       {
1145         if( impl.mController )
1146         {
1147           value = impl.mController->GetDefaultFontSize( Text::Controller::PIXEL_SIZE );
1148         }
1149         break;
1150       }
1151       case Toolkit::TextField::Property::ENABLE_SELECTION:
1152       {
1153         if( impl.mController )
1154         {
1155           value = impl.mController->IsSelectionEnabled();
1156         }
1157         break;
1158       }
1159       case Toolkit::TextField::Property::PLACEHOLDER:
1160       {
1161         Property::Map map;
1162         impl.mController->GetPlaceholderProperty( map );
1163         value = map;
1164         break;
1165       }
1166       case Toolkit::TextField::Property::ELLIPSIS:
1167       {
1168         if( impl.mController )
1169         {
1170           value = impl.mController->IsTextElideEnabled();
1171         }
1172         break;
1173       }
1174       case Toolkit::DevelTextField::Property::ENABLE_SHIFT_SELECTION:
1175       {
1176         if( impl.mController )
1177         {
1178           value = impl.mController->IsShiftSelectionEnabled();
1179         }
1180         break;
1181       }
1182     } //switch
1183   }
1184
1185   return value;
1186 }
1187
1188 bool TextField::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
1189 {
1190   Dali::BaseHandle handle( object );
1191
1192   bool connected( true );
1193   Toolkit::TextField field = Toolkit::TextField::DownCast( handle );
1194
1195   if( 0 == strcmp( signalName.c_str(), SIGNAL_TEXT_CHANGED ) )
1196   {
1197     field.TextChangedSignal().Connect( tracker, functor );
1198   }
1199   else if( 0 == strcmp( signalName.c_str(), SIGNAL_MAX_LENGTH_REACHED ) )
1200   {
1201     field.MaxLengthReachedSignal().Connect( tracker, functor );
1202   }
1203   else if( 0 == strcmp( signalName.c_str(), SIGNAL_INPUT_STYLE_CHANGED ) )
1204   {
1205     field.InputStyleChangedSignal().Connect( tracker, functor );
1206   }
1207   else
1208   {
1209     // signalName does not match any signal
1210     connected = false;
1211   }
1212
1213   return connected;
1214 }
1215
1216 Toolkit::TextField::TextChangedSignalType& TextField::TextChangedSignal()
1217 {
1218   return mTextChangedSignal;
1219 }
1220
1221 Toolkit::TextField::MaxLengthReachedSignalType& TextField::MaxLengthReachedSignal()
1222 {
1223   return mMaxLengthReachedSignal;
1224 }
1225
1226 Toolkit::TextField::InputStyleChangedSignalType& TextField::InputStyleChangedSignal()
1227 {
1228   return mInputStyleChangedSignal;
1229 }
1230
1231 void TextField::OnInitialize()
1232 {
1233   Actor self = Self();
1234
1235   mController = Text::Controller::New( this, this );
1236
1237   // When using the vector-based rendering, the size of the GLyphs are different
1238   TextAbstraction::GlyphType glyphType = (Text::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
1239   mController->SetGlyphType( glyphType );
1240
1241   mDecorator = Text::Decorator::New( *mController,
1242                                      *mController );
1243
1244   mController->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX );
1245
1246   // Enables the text input.
1247   mController->EnableTextInput( mDecorator );
1248
1249   // Enables the horizontal scrolling after the text input has been enabled.
1250   mController->SetHorizontalScrollEnabled( true );
1251
1252   // Disables the vertical scrolling.
1253   mController->SetVerticalScrollEnabled( false );
1254
1255   // Disable the smooth handle panning.
1256   mController->SetSmoothHandlePanEnabled( false );
1257
1258   mController->SetNoTextDoubleTapAction( Controller::NoTextTap::HIGHLIGHT );
1259   mController->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT );
1260
1261   // Forward input events to controller
1262   EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
1263   GetTapGestureDetector().SetMaximumTapsRequired( 2 );
1264
1265   mImfManager = ImfManager::Get();
1266
1267   self.TouchSignal().Connect( this, &TextField::OnTouched );
1268
1269   // Set BoundingBox to stage size if not already set.
1270   Rect<int> boundingBox;
1271   mDecorator->GetBoundingBox( boundingBox );
1272
1273   if( boundingBox.IsEmpty() )
1274   {
1275     Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
1276     mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
1277   }
1278
1279   // Flip vertically the 'left' selection handle
1280   mDecorator->FlipHandleVertically( LEFT_SELECTION_HANDLE, true );
1281
1282   // Fill-parent area by default
1283   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
1284   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
1285   self.OnStageSignal().Connect( this, &TextField::OnStageConnect );
1286
1287   if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy )
1288   {
1289     EnableClipping();
1290   }
1291 }
1292
1293 void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
1294 {
1295   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n");
1296
1297   switch ( change )
1298   {
1299     case StyleChange::DEFAULT_FONT_CHANGE:
1300     {
1301       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
1302       const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
1303       // Property system did not set the font so should update it.
1304       mController->UpdateAfterFontChange( newFont );
1305       RelayoutRequest();
1306       break;
1307     }
1308
1309     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
1310     {
1311       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
1312       RelayoutRequest();
1313       break;
1314     }
1315     case StyleChange::THEME_CHANGE:
1316     {
1317       // Nothing to do, let control base class handle this
1318       break;
1319     }
1320   }
1321
1322   // Up call to Control
1323   Control::OnStyleChange( styleManager, change );
1324 }
1325
1326 Vector3 TextField::GetNaturalSize()
1327 {
1328   Extents padding;
1329   padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1330
1331   Vector3 naturalSize = mController->GetNaturalSize();
1332   naturalSize.width += ( padding.start + padding.end );
1333   naturalSize.height += ( padding.top + padding.bottom );
1334
1335   return naturalSize;
1336 }
1337
1338 float TextField::GetHeightForWidth( float width )
1339 {
1340   Extents padding;
1341   padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1342   return mController->GetHeightForWidth( width ) + padding.top + padding.bottom;
1343 }
1344
1345 void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
1346 {
1347   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
1348
1349   Actor self = Self();
1350
1351   Extents padding;
1352   padding = self.GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1353
1354   Vector2 contentSize( size.x - ( padding.start + padding.end ), size.y - ( padding.top + padding.bottom ) );
1355
1356   // Support Right-To-Left of padding
1357   Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
1358   if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
1359   {
1360     std::swap( padding.start, padding.end );
1361   }
1362
1363   if( mStencil )
1364   {
1365     mStencil.SetPosition( padding.start, padding.top );
1366   }
1367   if( mActiveLayer )
1368   {
1369     mActiveLayer.SetPosition( padding.start, padding.top );
1370   }
1371
1372   const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize );
1373
1374   if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
1375       !mRenderer )
1376   {
1377     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get() );
1378
1379     if( mDecorator &&
1380         ( Text::Controller::NONE_UPDATED != ( Text::Controller::DECORATOR_UPDATED & updateTextType ) ) )
1381     {
1382       mDecorator->Relayout( size );
1383     }
1384
1385     if( !mRenderer )
1386     {
1387       mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
1388     }
1389
1390     RenderText( updateTextType );
1391
1392   }
1393
1394   // The text-field emits signals when the input style changes. These changes of style are
1395   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1396   // can't be emitted during the size negotiation as the callbacks may update the UI.
1397   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1398   if( !mController->IsInputStyleChangedSignalsQueueEmpty() )
1399   {
1400     if( Adaptor::IsAvailable() )
1401     {
1402       Adaptor& adaptor = Adaptor::Get();
1403
1404       if( NULL == mIdleCallback )
1405       {
1406         // @note: The callback manager takes the ownership of the callback object.
1407         mIdleCallback = MakeCallback( this, &TextField::OnIdleSignal );
1408         adaptor.AddIdle( mIdleCallback );
1409       }
1410     }
1411   }
1412 }
1413
1414 void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
1415 {
1416   Actor renderableActor;
1417
1418   if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
1419   {
1420     if( mRenderer )
1421     {
1422       Dali::Toolkit::TextField handle = Dali::Toolkit::TextField( GetOwner() );
1423
1424       renderableActor = mRenderer->Render( mController->GetView(),
1425                                            handle,
1426                                            Property::INVALID_INDEX, // Animatable property not supported
1427                                            mAlignmentOffset,
1428                                            DepthIndex::CONTENT );
1429     }
1430
1431     if( renderableActor != mRenderableActor )
1432     {
1433       UnparentAndReset( mRenderableActor );
1434       mRenderableActor = renderableActor;
1435     }
1436   }
1437
1438   if( mRenderableActor )
1439   {
1440     const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
1441
1442     if( mStencil )
1443     {
1444       mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y );
1445     }
1446     else
1447     {
1448       Extents padding;
1449       padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1450
1451       // Support Right-To-Left of padding
1452       Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
1453       if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
1454       {
1455         std::swap( padding.start, padding.end );
1456       }
1457
1458       mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset + padding.start, scrollOffset.y + padding.top );
1459     }
1460
1461
1462     // Make sure the actors are parented correctly with/without clipping
1463     Actor self = mStencil ? mStencil : Self();
1464
1465     for( std::vector<Actor>::iterator it = mClippingDecorationActors.begin(),
1466            endIt = mClippingDecorationActors.end();
1467          it != endIt;
1468          ++it )
1469     {
1470       self.Add( *it );
1471       it->LowerToBottom();
1472     }
1473     mClippingDecorationActors.clear();
1474
1475     self.Add( mRenderableActor );
1476   }
1477 }
1478
1479 void TextField::OnKeyInputFocusGained()
1480 {
1481   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
1482
1483   mImfManager.ApplyOptions( mInputMethodOptions );
1484
1485   mImfManager.StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
1486
1487   mImfManager.EventReceivedSignal().Connect( this, &TextField::OnImfEvent );
1488
1489   // Notify that the text editing start.
1490   mImfManager.Activate();
1491
1492   // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated.
1493   mImfManager.SetRestoreAfterFocusLost( true );
1494
1495    ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1496
1497    if ( notifier )
1498    {
1499       notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
1500    }
1501
1502   mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
1503
1504   EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
1505 }
1506
1507 void TextField::OnKeyInputFocusLost()
1508 {
1509   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get() );
1510
1511   mImfManager.StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged );
1512   // The text editing is finished. Therefore the imf manager don't have restore activation.
1513   mImfManager.SetRestoreAfterFocusLost( false );
1514
1515   // Notify that the text editing finish.
1516   mImfManager.Deactivate();
1517
1518   mImfManager.EventReceivedSignal().Disconnect( this, &TextField::OnImfEvent );
1519
1520   ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1521
1522   if ( notifier )
1523   {
1524     notifier.ContentSelectedSignal().Disconnect( this, &TextField::OnClipboardTextSelected );
1525   }
1526
1527   mController->KeyboardFocusLostEvent();
1528
1529   EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
1530 }
1531
1532 void TextField::OnTap( const TapGesture& gesture )
1533 {
1534   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get() );
1535
1536   mImfManager.Activate();
1537
1538   // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
1539   Extents padding;
1540   padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1541   mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
1542
1543   SetKeyInputFocus();
1544 }
1545
1546 void TextField::OnPan( const PanGesture& gesture )
1547 {
1548   mController->PanEvent( gesture.state, gesture.displacement );
1549 }
1550
1551 void TextField::OnLongPress( const LongPressGesture& gesture )
1552 {
1553   mImfManager.Activate();
1554
1555   Extents padding;
1556   padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1557   mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
1558
1559   SetKeyInputFocus();
1560 }
1561
1562 bool TextField::OnKeyEvent( const KeyEvent& event )
1563 {
1564   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
1565
1566   if( Dali::DALI_KEY_ESCAPE == event.keyCode && mController->ShouldClearFocusOnEscape() )
1567   {
1568     // Make sure ClearKeyInputFocus when only key is up
1569     if( event.state == KeyEvent::Up )
1570     {
1571       ClearKeyInputFocus();
1572     }
1573
1574     return true;
1575   }
1576   else if( Dali::DevelKey::DALI_KEY_RETURN == event.keyCode )
1577   {
1578     // Do nothing when enter is comming.
1579     return false;
1580   }
1581
1582   return mController->KeyEvent( event );
1583 }
1584
1585 void TextField::RequestTextRelayout()
1586 {
1587   RelayoutRequest();
1588 }
1589
1590 void TextField::TextChanged()
1591 {
1592   Dali::Toolkit::TextField handle( GetOwner() );
1593   mTextChangedSignal.Emit( handle );
1594 }
1595
1596 void TextField::MaxLengthReached()
1597 {
1598   Dali::Toolkit::TextField handle( GetOwner() );
1599   mMaxLengthReachedSignal.Emit( handle );
1600 }
1601
1602 void TextField::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
1603 {
1604   Dali::Toolkit::TextField handle( GetOwner() );
1605
1606   Toolkit::TextField::InputStyle::Mask fieldInputStyleMask = Toolkit::TextField::InputStyle::NONE;
1607
1608   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_COLOR ) )
1609   {
1610     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::COLOR );
1611   }
1612   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_FAMILY ) )
1613   {
1614     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_FAMILY );
1615   }
1616   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_POINT_SIZE ) )
1617   {
1618     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::POINT_SIZE );
1619   }
1620   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_WEIGHT ) )
1621   {
1622     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE );
1623   }
1624   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_WIDTH ) )
1625   {
1626     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE );
1627   }
1628   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_SLANT ) )
1629   {
1630     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE );
1631   }
1632   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_UNDERLINE ) )
1633   {
1634     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::UNDERLINE );
1635   }
1636   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_SHADOW ) )
1637   {
1638     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::SHADOW );
1639   }
1640   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_EMBOSS ) )
1641   {
1642     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::EMBOSS );
1643   }
1644   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_OUTLINE ) )
1645   {
1646     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::OUTLINE );
1647   }
1648
1649   mInputStyleChangedSignal.Emit( handle, fieldInputStyleMask );
1650 }
1651
1652 void TextField::AddDecoration( Actor& actor, bool needsClipping )
1653 {
1654   if( actor )
1655   {
1656     if( needsClipping )
1657     {
1658       mClippingDecorationActors.push_back( actor );
1659     }
1660     else
1661     {
1662       actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1663       actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1664       Self().Add( actor );
1665       mActiveLayer = actor;
1666     }
1667   }
1668 }
1669
1670 void TextField::OnStageConnect( Dali::Actor actor )
1671 {
1672   if ( mHasBeenStaged )
1673   {
1674     RenderText( static_cast<Text::Controller::UpdateTextType>( Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED ) );
1675   }
1676   else
1677   {
1678     mHasBeenStaged = true;
1679   }
1680 }
1681
1682 ImfManager::ImfCallbackData TextField::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
1683 {
1684   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnImfEvent %p eventName %d\n", mController.Get(), imfEvent.eventName );
1685   return mController->OnImfEvent( imfManager, imfEvent );
1686 }
1687
1688 void TextField::GetHandleImagePropertyValue(  Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType )
1689 {
1690   if( mDecorator )
1691   {
1692     ResourceImage image = ResourceImage::DownCast( mDecorator->GetHandleImage( handleType, handleImageType ) );
1693
1694     if ( image )
1695     {
1696       Property::Map map;
1697       Scripting::CreatePropertyMap( image, map );
1698       value = map;
1699     }
1700   }
1701 }
1702
1703 void TextField::EnableClipping()
1704 {
1705   if( !mStencil )
1706   {
1707     // Creates an extra control to be used as stencil buffer.
1708     mStencil = Control::New();
1709     mStencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1710     mStencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
1711
1712     // Creates a background visual. Even if the color is transparent it updates the stencil.
1713     mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND,
1714                           Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR ).
1715                           Add( ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT ) );
1716
1717     // Enable the clipping property.
1718     mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
1719     mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1720
1721     Self().Add( mStencil );
1722   }
1723 }
1724
1725 void TextField::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
1726 {
1727   mController->PasteClipboardItemEvent();
1728 }
1729
1730 void TextField::KeyboardStatusChanged(bool keyboardShown)
1731 {
1732   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown );
1733
1734   // Just hide the grab handle when keyboard is hidden.
1735   if (!keyboardShown )
1736   {
1737     mController->KeyboardFocusLostEvent();
1738   }
1739   else
1740   {
1741     mController->KeyboardFocusGainEvent(); // Initially called by OnKeyInputFocusGained
1742   }
1743 }
1744
1745 void TextField::OnStageConnection( int depth )
1746 {
1747   // Sets the depth to the visuals inside the text's decorator.
1748   mDecorator->SetTextDepth( depth );
1749
1750   // The depth of the text renderer is set in the RenderText() called from OnRelayout().
1751
1752   // Call the Control::OnStageConnection() to set the depth of the background.
1753   Control::OnStageConnection( depth );
1754 }
1755
1756 bool TextField::OnTouched( Actor actor, const TouchData& touch )
1757 {
1758   return true;
1759 }
1760
1761 void TextField::OnIdleSignal()
1762 {
1763   // Emits the change of input style signals.
1764   mController->ProcessInputStyleChangedSignals();
1765
1766   // Set the pointer to null as the callback manager deletes the callback after execute it.
1767   mIdleCallback = NULL;
1768 }
1769
1770 TextField::TextField()
1771 : Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
1772   mIdleCallback( NULL ),
1773   mAlignmentOffset( 0.f ),
1774   mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
1775   mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ),
1776   mHasBeenStaged( false )
1777 {
1778 }
1779
1780 TextField::~TextField()
1781 {
1782   UnparentAndReset( mStencil );
1783
1784   if( ( NULL != mIdleCallback ) && Adaptor::IsAvailable() )
1785   {
1786     Adaptor::Get().RemoveIdle( mIdleCallback );
1787   }
1788 }
1789
1790 } // namespace Internal
1791
1792 } // namespace Toolkit
1793
1794 } // namespace Dali