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