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