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