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