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