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