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