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