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