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