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