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