Merge "bug fixed : Characters are truncated when HorizontalAlignment.End in Multi...
[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::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
1308   mController->SetLayoutDirection( layoutDirection );
1309
1310   // Forward input events to controller
1311   EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
1312   GetTapGestureDetector().SetMaximumTapsRequired( 2 );
1313
1314   self.TouchSignal().Connect( this, &TextField::OnTouched );
1315
1316   // Set BoundingBox to stage size if not already set.
1317   Rect<int> boundingBox;
1318   mDecorator->GetBoundingBox( boundingBox );
1319
1320   if( boundingBox.IsEmpty() )
1321   {
1322     Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
1323     mDecorator->SetBoundingBox( Rect<int>( 0.0f, 0.0f, stageSize.width, stageSize.height ) );
1324   }
1325
1326   // Flip vertically the 'left' selection handle
1327   mDecorator->FlipHandleVertically( LEFT_SELECTION_HANDLE, true );
1328
1329   // Fill-parent area by default
1330   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
1331   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
1332   self.OnStageSignal().Connect( this, &TextField::OnStageConnect );
1333
1334   DevelControl::SetInputMethodContext( *this, mInputMethodContext );
1335
1336   if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy )
1337   {
1338     EnableClipping();
1339   }
1340 }
1341
1342 void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
1343 {
1344   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n");
1345
1346   switch ( change )
1347   {
1348     case StyleChange::DEFAULT_FONT_CHANGE:
1349     {
1350       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
1351       const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
1352       // Property system did not set the font so should update it.
1353       mController->UpdateAfterFontChange( newFont );
1354       RelayoutRequest();
1355       break;
1356     }
1357
1358     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
1359     {
1360       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
1361       RelayoutRequest();
1362       break;
1363     }
1364     case StyleChange::THEME_CHANGE:
1365     {
1366       // Nothing to do, let control base class handle this
1367       break;
1368     }
1369   }
1370
1371   // Up call to Control
1372   Control::OnStyleChange( styleManager, change );
1373 }
1374
1375 Vector3 TextField::GetNaturalSize()
1376 {
1377   Extents padding;
1378   padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1379
1380   Vector3 naturalSize = mController->GetNaturalSize();
1381   naturalSize.width += ( padding.start + padding.end );
1382   naturalSize.height += ( padding.top + padding.bottom );
1383
1384   return naturalSize;
1385 }
1386
1387 float TextField::GetHeightForWidth( float width )
1388 {
1389   Extents padding;
1390   padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1391   return mController->GetHeightForWidth( width ) + padding.top + padding.bottom;
1392 }
1393
1394 void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
1395 {
1396   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
1397
1398   Actor self = Self();
1399
1400   Extents padding;
1401   padding = self.GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1402
1403   Vector2 contentSize( size.x - ( padding.start + padding.end ), size.y - ( padding.top + padding.bottom ) );
1404
1405   // Support Right-To-Left of padding
1406   Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
1407   if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
1408   {
1409     std::swap( padding.start, padding.end );
1410   }
1411
1412   if( mStencil )
1413   {
1414     mStencil.SetPosition( padding.start, padding.top );
1415   }
1416   if( mActiveLayer )
1417   {
1418     mActiveLayer.SetPosition( padding.start, padding.top );
1419   }
1420
1421   const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize, layoutDirection );
1422
1423   if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
1424       !mRenderer )
1425   {
1426     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnRelayout %p Displaying new contents\n", mController.Get() );
1427
1428     if( mDecorator &&
1429         ( Text::Controller::NONE_UPDATED != ( Text::Controller::DECORATOR_UPDATED & updateTextType ) ) )
1430     {
1431       mDecorator->Relayout( size );
1432     }
1433
1434     if( !mRenderer )
1435     {
1436       mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
1437     }
1438
1439     RenderText( updateTextType );
1440
1441   }
1442
1443   // The text-field emits signals when the input style changes. These changes of style are
1444   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1445   // can't be emitted during the size negotiation as the callbacks may update the UI.
1446   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1447   if( !mController->IsInputStyleChangedSignalsQueueEmpty() )
1448   {
1449     if( Adaptor::IsAvailable() )
1450     {
1451       Adaptor& adaptor = Adaptor::Get();
1452
1453       if( NULL == mIdleCallback )
1454       {
1455         // @note: The callback manager takes the ownership of the callback object.
1456         mIdleCallback = MakeCallback( this, &TextField::OnIdleSignal );
1457         adaptor.AddIdle( mIdleCallback, false );
1458       }
1459     }
1460   }
1461 }
1462
1463 void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
1464 {
1465   Actor renderableActor;
1466
1467   if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
1468   {
1469     if( mRenderer )
1470     {
1471       Dali::Toolkit::TextField handle = Dali::Toolkit::TextField( GetOwner() );
1472
1473       renderableActor = mRenderer->Render( mController->GetView(),
1474                                            handle,
1475                                            Property::INVALID_INDEX, // Animatable property not supported
1476                                            mAlignmentOffset,
1477                                            DepthIndex::CONTENT );
1478     }
1479
1480     if( renderableActor != mRenderableActor )
1481     {
1482       UnparentAndReset( mRenderableActor );
1483       mRenderableActor = renderableActor;
1484     }
1485   }
1486
1487   if( mRenderableActor )
1488   {
1489     const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
1490
1491     if( mStencil )
1492     {
1493       mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y );
1494     }
1495     else
1496     {
1497       Extents padding;
1498       padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1499
1500       // Support Right-To-Left of padding
1501       Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
1502       if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
1503       {
1504         std::swap( padding.start, padding.end );
1505       }
1506
1507       mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset + padding.start, scrollOffset.y + padding.top );
1508     }
1509
1510
1511     // Make sure the actors are parented correctly with/without clipping
1512     Actor self = mStencil ? mStencil : Self();
1513
1514     for( std::vector<Actor>::iterator it = mClippingDecorationActors.begin(),
1515            endIt = mClippingDecorationActors.end();
1516          it != endIt;
1517          ++it )
1518     {
1519       self.Add( *it );
1520       it->LowerToBottom();
1521     }
1522     mClippingDecorationActors.clear();
1523
1524     self.Add( mRenderableActor );
1525   }
1526 }
1527
1528 void TextField::OnKeyInputFocusGained()
1529 {
1530   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
1531   if ( mInputMethodContext )
1532   {
1533     mInputMethodContext.ApplyOptions( mInputMethodOptions );
1534
1535     mInputMethodContext.StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
1536
1537     mInputMethodContext.EventReceivedSignal().Connect( this, &TextField::OnInputMethodContextEvent );
1538
1539     // Notify that the text editing start.
1540     mInputMethodContext.Activate();
1541
1542     // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated.
1543     mInputMethodContext.SetRestoreAfterFocusLost( true );
1544   }
1545   ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1546
1547   if ( notifier )
1548   {
1549     notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
1550   }
1551
1552   mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event
1553
1554   EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
1555 }
1556
1557 void TextField::OnKeyInputFocusLost()
1558 {
1559   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get() );
1560   if ( mInputMethodContext )
1561   {
1562     mInputMethodContext.StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged );
1563     // The text editing is finished. Therefore the inputMethodContext don't have restore activation.
1564     mInputMethodContext.SetRestoreAfterFocusLost( false );
1565
1566     // Notify that the text editing finish.
1567     mInputMethodContext.Deactivate();
1568
1569     mInputMethodContext.EventReceivedSignal().Disconnect( this, &TextField::OnInputMethodContextEvent );
1570   }
1571   ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
1572
1573   if ( notifier )
1574   {
1575     notifier.ContentSelectedSignal().Disconnect( this, &TextField::OnClipboardTextSelected );
1576   }
1577
1578   mController->KeyboardFocusLostEvent();
1579
1580   EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
1581 }
1582
1583 void TextField::OnTap( const TapGesture& gesture )
1584 {
1585   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get() );
1586   if ( mInputMethodContext )
1587   {
1588     mInputMethodContext.Activate();
1589   }
1590   // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
1591   Extents padding;
1592   padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1593   mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
1594
1595   SetKeyInputFocus();
1596 }
1597
1598 void TextField::OnPan( const PanGesture& gesture )
1599 {
1600   mController->PanEvent( gesture.state, gesture.displacement );
1601 }
1602
1603 void TextField::OnLongPress( const LongPressGesture& gesture )
1604 {
1605   if ( mInputMethodContext )
1606   {
1607     mInputMethodContext.Activate();
1608   }
1609   Extents padding;
1610   padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
1611   mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
1612
1613   SetKeyInputFocus();
1614 }
1615
1616 bool TextField::OnKeyEvent( const KeyEvent& event )
1617 {
1618   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
1619
1620   if( Dali::DALI_KEY_ESCAPE == event.keyCode && mController->ShouldClearFocusOnEscape() )
1621   {
1622     // Make sure ClearKeyInputFocus when only key is up
1623     if( event.state == KeyEvent::Up )
1624     {
1625       ClearKeyInputFocus();
1626     }
1627
1628     return true;
1629   }
1630   else if( Dali::DevelKey::DALI_KEY_RETURN == event.keyCode )
1631   {
1632     // Do nothing when enter is comming.
1633     return false;
1634   }
1635
1636   return mController->KeyEvent( event );
1637 }
1638
1639 void TextField::RequestTextRelayout()
1640 {
1641   RelayoutRequest();
1642 }
1643
1644 void TextField::TextChanged()
1645 {
1646   Dali::Toolkit::TextField handle( GetOwner() );
1647   mTextChangedSignal.Emit( handle );
1648 }
1649
1650 void TextField::MaxLengthReached()
1651 {
1652   Dali::Toolkit::TextField handle( GetOwner() );
1653   mMaxLengthReachedSignal.Emit( handle );
1654 }
1655
1656 void TextField::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
1657 {
1658   Dali::Toolkit::TextField handle( GetOwner() );
1659
1660   Toolkit::TextField::InputStyle::Mask fieldInputStyleMask = Toolkit::TextField::InputStyle::NONE;
1661
1662   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_COLOR ) )
1663   {
1664     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::COLOR );
1665   }
1666   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_FAMILY ) )
1667   {
1668     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_FAMILY );
1669   }
1670   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_POINT_SIZE ) )
1671   {
1672     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::POINT_SIZE );
1673   }
1674   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_WEIGHT ) )
1675   {
1676     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE );
1677   }
1678   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_WIDTH ) )
1679   {
1680     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE );
1681   }
1682   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_FONT_SLANT ) )
1683   {
1684     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::FONT_STYLE );
1685   }
1686   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_UNDERLINE ) )
1687   {
1688     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::UNDERLINE );
1689   }
1690   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_SHADOW ) )
1691   {
1692     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::SHADOW );
1693   }
1694   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_EMBOSS ) )
1695   {
1696     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::EMBOSS );
1697   }
1698   if( InputStyle::NONE != static_cast<InputStyle::Mask>( inputStyleMask & InputStyle::INPUT_OUTLINE ) )
1699   {
1700     fieldInputStyleMask = static_cast<Toolkit::TextField::InputStyle::Mask>( fieldInputStyleMask | Toolkit::TextField::InputStyle::OUTLINE );
1701   }
1702
1703   mInputStyleChangedSignal.Emit( handle, fieldInputStyleMask );
1704 }
1705
1706 void TextField::AddDecoration( Actor& actor, bool needsClipping )
1707 {
1708   if( actor )
1709   {
1710     if( needsClipping )
1711     {
1712       mClippingDecorationActors.push_back( actor );
1713     }
1714     else
1715     {
1716       actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1717       actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1718       Self().Add( actor );
1719       mActiveLayer = actor;
1720     }
1721   }
1722 }
1723
1724 void TextField::OnStageConnect( Dali::Actor actor )
1725 {
1726   if ( mHasBeenStaged )
1727   {
1728     RenderText( static_cast<Text::Controller::UpdateTextType>( Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED ) );
1729   }
1730   else
1731   {
1732     mHasBeenStaged = true;
1733   }
1734 }
1735
1736 InputMethodContext::CallbackData TextField::OnInputMethodContextEvent( Dali::InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent )
1737 {
1738   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnInputMethodContextEvent %p eventName %d\n", mController.Get(), inputMethodContextEvent.eventName );
1739   return mController->OnInputMethodContextEvent( inputMethodContext, inputMethodContextEvent );
1740 }
1741
1742 void TextField::GetHandleImagePropertyValue(  Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType )
1743 {
1744   if( mDecorator )
1745   {
1746     ResourceImage image = ResourceImage::DownCast( mDecorator->GetHandleImage( handleType, handleImageType ) );
1747
1748     if ( image )
1749     {
1750       Property::Map map;
1751       Scripting::CreatePropertyMap( image, map );
1752       value = map;
1753     }
1754   }
1755 }
1756
1757 void TextField::EnableClipping()
1758 {
1759   if( !mStencil )
1760   {
1761     // Creates an extra control to be used as stencil buffer.
1762     mStencil = Control::New();
1763     mStencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1764     mStencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
1765
1766     // Creates a background visual. Even if the color is transparent it updates the stencil.
1767     mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND,
1768                           Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR ).
1769                           Add( ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT ) );
1770
1771     // Enable the clipping property.
1772     mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
1773     mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
1774
1775     Self().Add( mStencil );
1776   }
1777 }
1778
1779 void TextField::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
1780 {
1781   mController->PasteClipboardItemEvent();
1782 }
1783
1784 void TextField::KeyboardStatusChanged(bool keyboardShown)
1785 {
1786   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown );
1787
1788   // Just hide the grab handle when keyboard is hidden.
1789   if (!keyboardShown )
1790   {
1791     mController->KeyboardFocusLostEvent();
1792   }
1793   else
1794   {
1795     mController->KeyboardFocusGainEvent(); // Initially called by OnKeyInputFocusGained
1796   }
1797 }
1798
1799 void TextField::OnStageConnection( int depth )
1800 {
1801   // Sets the depth to the visuals inside the text's decorator.
1802   mDecorator->SetTextDepth( depth );
1803
1804   // The depth of the text renderer is set in the RenderText() called from OnRelayout().
1805
1806   // Call the Control::OnStageConnection() to set the depth of the background.
1807   Control::OnStageConnection( depth );
1808 }
1809
1810 bool TextField::OnTouched( Actor actor, const TouchData& touch )
1811 {
1812   return true;
1813 }
1814
1815 void TextField::OnIdleSignal()
1816 {
1817   // Emits the change of input style signals.
1818   mController->ProcessInputStyleChangedSignals();
1819
1820   // Set the pointer to null as the callback manager deletes the callback after execute it.
1821   mIdleCallback = NULL;
1822 }
1823
1824 TextField::TextField()
1825 : Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
1826   mIdleCallback( NULL ),
1827   mAlignmentOffset( 0.f ),
1828   mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
1829   mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ),
1830   mHasBeenStaged( false )
1831 {
1832 }
1833
1834 TextField::~TextField()
1835 {
1836   UnparentAndReset( mStencil );
1837
1838   if( ( NULL != mIdleCallback ) && Adaptor::IsAvailable() )
1839   {
1840     Adaptor::Get().RemoveIdle( mIdleCallback );
1841   }
1842 }
1843
1844 } // namespace Internal
1845
1846 } // namespace Toolkit
1847
1848 } // namespace Dali