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