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