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