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