2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 // Ecore is littered with C style cast
20 #pragma GCC diagnostic push
21 #pragma GCC diagnostic ignored "-Wold-style-cast"
22 #include <imf-manager-impl.h>
25 #include <dali/public-api/events/key-event.h>
26 #include <dali/public-api/object/type-registry.h>
27 #include <dali/integration-api/debug.h>
30 #include <input-method-devel.h>
32 #include <locale-utils.h>
33 #include <window-render-surface.h>
34 #include <adaptor-impl.h>
35 #include <singleton-service-impl.h>
37 #define TOKEN_STRING(x) #x
39 Ecore_IMF_Input_Panel_Layout panelLayoutMap[] =
41 ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL,
42 ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER,
43 ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL,
44 ECORE_IMF_INPUT_PANEL_LAYOUT_URL,
45 ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER,
46 ECORE_IMF_INPUT_PANEL_LAYOUT_IP,
47 ECORE_IMF_INPUT_PANEL_LAYOUT_MONTH,
48 ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY,
49 ECORE_IMF_INPUT_PANEL_LAYOUT_HEX,
50 ECORE_IMF_INPUT_PANEL_LAYOUT_TERMINAL,
51 ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD,
52 ECORE_IMF_INPUT_PANEL_LAYOUT_DATETIME,
53 ECORE_IMF_INPUT_PANEL_LAYOUT_EMOTICON,
54 ECORE_IMF_INPUT_PANEL_LAYOUT_VOICE
57 Ecore_IMF_Autocapital_Type autoCapitalMap[] =
59 ECORE_IMF_AUTOCAPITAL_TYPE_NONE,
60 ECORE_IMF_AUTOCAPITAL_TYPE_WORD,
61 ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE,
62 ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER,
65 Ecore_IMF_Input_Panel_Return_Key_Type returnKeyTypeMap[] =
67 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT,
68 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE,
69 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO,
70 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN,
71 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN,
72 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT,
73 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH,
74 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND,
75 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN
89 #if defined(DEBUG_ENABLED)
90 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_IMF_MANAGER");
93 // Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
94 size_t Utf8SequenceLength(const unsigned char leadByte)
98 if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
102 else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
106 else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
110 else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
118 // Static function calls used by ecore 'c' style callback registration
119 void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
123 ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
124 imfManager->CommitReceived( data, imfContext, event_info );
128 void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
132 ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
133 imfManager->PreEditChanged( data, imfContext, event_info );
137 Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
141 ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
142 return imfManager->RetrieveSurrounding( data, imfContext, text, cursorPosition );
150 void InputPanelStateChangeCallback( void* data, Ecore_IMF_Context* context, int value )
156 ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
159 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
161 imfManager->StatusChangedSignal().Emit( true );
165 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
167 imfManager->StatusChangedSignal().Emit( false );
171 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
180 void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value )
186 ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
187 // Emit the signal that the language has changed
188 imfManager->LanguageChangedSignal().Emit();
191 void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value )
197 ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
198 // Emit signal that the keyboard is resized
199 imfManager->ResizedSignal().Emit();
202 void InputPanelKeyboardTypeChangedCallback( void *data, Ecore_IMF_Context *context, int value )
209 ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
212 case ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE:
214 // Emit Signal that the keyboard type is changed to Software Keyboard
215 imfManager->KeyboardTypeChangedSignal().Emit( Dali::ImfManager::KeyboardType::SOFTWARE_KEYBOARD );
218 case ECORE_IMF_INPUT_PANEL_HW_KEYBOARD_MODE:
220 // Emit Signal that the keyboard type is changed to Hardware Keyboard
221 imfManager->KeyboardTypeChangedSignal().Emit( Dali::ImfManager::KeyboardType::HARDWARE_KEYBOARD );
228 * Called when an IMF delete surrounding event is received.
229 * Here we tell the application that it should delete a certain range.
231 void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
235 ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
236 imfManager->DeleteSurrounding( data, imfContext, event_info );
241 * Called when the input method sends a private command.
243 void PrivateCommand( void *data, Ecore_IMF_Context *imfContext, void *event_info )
247 ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
248 imfManager->SendPrivateCommand( data, imfContext, event_info );
254 return ImfManager::Get();
257 TypeRegistration IMF_MANAGER_TYPE( typeid(Dali::ImfManager), typeid(Dali::BaseHandle), Create );
259 } // unnamed namespace
261 bool ImfManager::IsAvailable()
263 bool available( false );
265 Dali::SingletonService service( SingletonService::Get() );
268 available = service.GetSingleton( typeid( Dali::ImfManager ) );
274 Dali::ImfManager ImfManager::Get()
276 Dali::ImfManager manager;
278 Dali::SingletonService service( SingletonService::Get() );
281 // Check whether the singleton is already created
282 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::ImfManager ) );
285 // If so, downcast the handle
286 manager = Dali::ImfManager( dynamic_cast< ImfManager* >( handle.GetObjectPtr() ) );
288 else if ( Adaptor::IsAvailable() )
290 // Create instance and register singleton only if the adaptor is available
292 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
293 Any nativeWindow = adaptorImpl.GetNativeWindowHandle();
295 // The Ecore_Wl_Window needs to use the ImfManager.
296 // Only when the render surface is window, we can get the Ecore_Wl_Window.
297 Ecore_Wl_Window *ecoreWwin( AnyCast< Ecore_Wl_Window* >( nativeWindow ) );
300 // If we fail to get Ecore_Wl_Window, we can't use the ImfManager correctly.
301 // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
302 // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
304 manager = Dali::ImfManager( new ImfManager( ecoreWwin ) );
305 service.Register( typeid( manager ), manager );
309 DALI_LOG_ERROR("Failed to get native window handle\n");
317 ImfManager::ImfManager( Ecore_Wl_Window *ecoreWlwin )
319 mIMFCursorPosition( 0 ),
321 mRestoreAfterFocusLost( false ),
322 mIdleCallbackConnected( false )
325 CreateContext( ecoreWlwin );
330 ImfManager::~ImfManager()
332 DisconnectCallbacks();
335 ecore_imf_shutdown();
339 void ImfManager::CreateContext( Ecore_Wl_Window *ecoreWlwin )
341 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CreateContext\n" );
343 const char *contextId = ecore_imf_context_default_id_get();
346 mIMFContext = ecore_imf_context_add( contextId );
352 ecore_imf_context_client_window_set( mIMFContext,
353 reinterpret_cast<void*>( ecore_wl_window_id_get(ecoreWlwin)) );
358 DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
363 DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
367 void ImfManager::DeleteContext()
369 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteContext\n" );
373 ecore_imf_context_del( mIMFContext );
378 // Callbacks for predicitive text support.
379 void ImfManager::ConnectCallbacks()
383 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::ConnectCallbacks\n" );
385 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
386 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
387 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
388 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand, this );
390 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, this );
391 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, this );
392 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, this );
393 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, InputPanelKeyboardTypeChangedCallback, this );
395 ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);
399 void ImfManager::DisconnectCallbacks()
403 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DisconnectCallbacks\n" );
405 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
406 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
407 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
408 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand );
410 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback );
411 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback );
412 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback );
413 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, InputPanelKeyboardTypeChangedCallback );
415 // We do not need to unset the retrieve surrounding callback.
419 void ImfManager::Activate()
421 // Reset mIdleCallbackConnected
422 mIdleCallbackConnected = false;
426 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Activate\n" );
428 ecore_imf_context_focus_in( mIMFContext );
430 // emit keyboard activated signal
431 Dali::ImfManager handle( this );
432 mActivatedSignal.Emit( handle );
436 void ImfManager::Deactivate()
440 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Deactivate\n" );
443 ecore_imf_context_focus_out( mIMFContext );
446 // Reset mIdleCallbackConnected
447 mIdleCallbackConnected = false;
450 void ImfManager::Reset()
452 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Reset\n" );
456 ecore_imf_context_reset( mIMFContext );
460 Ecore_IMF_Context* ImfManager::GetContext()
462 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetContext\n" );
467 bool ImfManager::RestoreAfterFocusLost() const
469 return mRestoreAfterFocusLost;
472 void ImfManager::SetRestoreAfterFocusLost( bool toggle )
474 mRestoreAfterFocusLost = toggle;
478 * Called when an IMF Pre-Edit changed event is received.
479 * We are still predicting what the user is typing. The latest string is what the IMF module thinks
480 * the user wants to type.
482 void ImfManager::PreEditChanged( void*, Ecore_IMF_Context* imfContext, void* event_info )
484 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::PreEditChanged\n" );
486 char* preEditString( NULL );
487 int cursorPosition( 0 );
488 Eina_List* attrs = NULL;
491 Ecore_IMF_Preedit_Attr* attr;
493 // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
494 // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
495 ecore_imf_context_preedit_string_with_attributes_get( imfContext, &preEditString, &attrs, &cursorPosition );
499 // iterate through the list of attributes getting the type, start and end position.
500 for ( l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
502 #ifdef DALI_PROFILE_UBUNTU
503 if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF)
504 #else // DALI_PROFILE_UBUNTU
505 if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF)
506 #endif // DALI_PROFILE_UBUNTU
508 // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages.
510 size_t visualCharacterIndex = 0;
511 size_t byteIndex = 0;
513 // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
514 const char leadByte = preEditString[byteIndex];
515 while( leadByte != '\0' )
517 // attr->end_index is provided as a byte position not character and we need to know the character position.
518 const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
519 if ( byteIndex == attr->end_index )
521 cursorPosition = visualCharacterIndex;
523 // end loop as found cursor position that matches byte position
527 byteIndex += currentSequenceLength; // jump to next character
528 visualCharacterIndex++; // increment character count so we know our position for when we get a match
531 DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString ));
537 if ( Dali::Adaptor::IsAvailable() )
539 Dali::ImfManager handle( this );
540 Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::PREEDIT, preEditString, cursorPosition, 0 );
541 Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
543 if ( callbackData.update )
545 SetCursorPosition( callbackData.cursorPosition );
546 SetSurroundingText( callbackData.currentText );
548 NotifyCursorPosition();
551 if ( callbackData.preeditResetRequired )
556 free( preEditString );
559 void ImfManager::CommitReceived( void*, Ecore_IMF_Context* imfContext, void* event_info )
561 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CommitReceived\n" );
563 if ( Dali::Adaptor::IsAvailable() )
565 const std::string keyString( static_cast<char*>( event_info ) );
567 Dali::ImfManager handle( this );
568 Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::COMMIT, keyString, 0, 0 );
569 Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
571 if( callbackData.update )
573 SetCursorPosition( callbackData.cursorPosition );
574 SetSurroundingText( callbackData.currentText );
576 NotifyCursorPosition();
582 * Called when an IMF retrieve surround event is received.
583 * Here the IMF module wishes to know the string we are working with and where within the string the cursor is
584 * We need to signal the application to tell us this information.
586 Eina_Bool ImfManager::RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition )
588 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::RetrieveSurrounding\n" );
590 Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::GETSURROUNDING, std::string(), 0, 0 );
591 Dali::ImfManager handle( this );
592 mEventSignal.Emit( handle, imfData );
596 *text = strdup( mSurroundingText.c_str() );
601 *cursorPosition = mIMFCursorPosition;
608 * Called when an IMF delete surrounding event is received.
609 * Here we tell the application that it should delete a certain range.
611 void ImfManager::DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info )
613 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteSurrounding\n" );
615 if( Dali::Adaptor::IsAvailable() )
617 Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>( event_info );
619 Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::DELETESURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );
620 Dali::ImfManager handle( this );
621 mEventSignal.Emit( handle, imfData );
626 * Called when the input method sends a private command.
628 void ImfManager::SendPrivateCommand( void* data, Ecore_IMF_Context* imfContext, void* event_info )
630 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SendPrivateCommand\n" );
632 if( Dali::Adaptor::IsAvailable() )
634 const char* privateCommandSendEvent = static_cast<const char*>( event_info );
636 Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::PRIVATECOMMAND, privateCommandSendEvent, 0, 0 );
637 Dali::ImfManager handle( this );
638 mEventSignal.Emit( handle, imfData );
642 void ImfManager::NotifyCursorPosition()
644 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::NotifyCursorPosition\n" );
648 ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
652 void ImfManager::SetCursorPosition( unsigned int cursorPosition )
654 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetCursorPosition\n" );
656 mIMFCursorPosition = static_cast<int>( cursorPosition );
659 unsigned int ImfManager::GetCursorPosition() const
661 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetCursorPosition\n" );
663 return static_cast<unsigned int>( mIMFCursorPosition );
666 void ImfManager::SetSurroundingText( const std::string& text )
668 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetSurroundingText\n" );
670 mSurroundingText = text;
673 const std::string& ImfManager::GetSurroundingText() const
675 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetSurroundingText\n" );
677 return mSurroundingText;
680 void ImfManager::NotifyTextInputMultiLine( bool multiLine )
682 Ecore_IMF_Input_Hints currentHint = ecore_imf_context_input_hint_get(mIMFContext);
683 ecore_imf_context_input_hint_set( mIMFContext,
684 static_cast< Ecore_IMF_Input_Hints >( multiLine ?
685 (currentHint | ECORE_IMF_INPUT_HINT_MULTILINE) :
686 (currentHint & ~ECORE_IMF_INPUT_HINT_MULTILINE)));
689 Dali::ImfManager::TextDirection ImfManager::GetTextDirection()
691 Dali::ImfManager::TextDirection direction ( Dali::ImfManager::LeftToRight );
693 if ( ImfManager::IsAvailable() /* We do not want to create an instance of ImfManager */ )
697 char* locale( NULL );
698 ecore_imf_context_input_panel_language_locale_get( mIMFContext, &locale );
702 direction = Locale::GetTextDirection( std::string( locale ) );
710 Rect<int> ImfManager::GetInputMethodArea()
712 int xPos, yPos, width, height;
714 width = height = xPos = yPos = 0;
718 ecore_imf_context_input_panel_geometry_get( mIMFContext, &xPos, &yPos, &width, &height );
722 DALI_LOG_WARNING("VKB Unable to get IMF Context so GetSize unavailable\n");
723 // return 0 as real size unknown.
726 return Rect<int>(xPos,yPos,width,height);
729 void ImfManager::ApplyOptions( const InputMethodOptions& options )
731 using namespace Dali::InputMethod::Category;
735 if (mIMFContext == NULL)
737 DALI_LOG_WARNING("VKB Unable to excute ApplyOptions with Null ImfContext\n");
741 if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )
743 ecore_imf_context_input_panel_layout_set( mIMFContext, panelLayoutMap[index] );
745 if ( mOptions.CompareAndSet(AUTO_CAPITALISE, options, index) )
747 ecore_imf_context_autocapital_type_set( mIMFContext, autoCapitalMap[index] );
749 if ( mOptions.CompareAndSet(ACTION_BUTTON_TITLE, options, index) )
751 ecore_imf_context_input_panel_return_key_type_set( mIMFContext, returnKeyTypeMap[index] );
753 if ( mOptions.CompareAndSet(VARIATION, options, index) )
755 ecore_imf_context_input_panel_layout_variation_set( mIMFContext, index );
759 void ImfManager::SetInputPanelUserData( const std::string& data )
761 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetInputPanelUserData\n" );
765 int length = data.length();
766 ecore_imf_context_input_panel_imdata_set( mIMFContext, data.c_str(), length );
770 void ImfManager::GetInputPanelUserData( std::string& data )
772 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelUserData\n" );
777 char* buffer = reinterpret_cast< char* >( calloc ( 1, length * sizeof ( char ) ) );
780 ecore_imf_context_input_panel_imdata_get( mIMFContext, buffer, &length );
787 Dali::ImfManager::State ImfManager::GetInputPanelState()
789 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelState\n" );
794 value = ecore_imf_context_input_panel_state_get( mIMFContext );
798 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
800 return Dali::ImfManager::SHOW;
804 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
806 return Dali::ImfManager::HIDE;
810 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
812 return Dali::ImfManager::WILL_SHOW;
818 return Dali::ImfManager::DEFAULT;
822 return Dali::ImfManager::DEFAULT;
825 void ImfManager::SetReturnKeyState( bool visible )
827 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetReturnKeyState\n" );
831 ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible );
835 void ImfManager::AutoEnableInputPanel( bool enabled )
837 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::AutoEnableInputPanel\n" );
841 ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled );
845 void ImfManager::ShowInputPanel()
847 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::ShowInputPanel\n" );
851 ecore_imf_context_input_panel_show( mIMFContext );
855 void ImfManager::HideInputPanel()
857 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::HideInputPanel\n" );
861 ecore_imf_context_input_panel_hide( mIMFContext );
865 Dali::ImfManager::KeyboardType ImfManager::GetKeyboardType()
867 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetKeyboardType\n" );
869 #ifdef OVER_TIZEN_VERSION_4
873 value = ecore_imf_context_keyboard_mode_get( mIMFContext );
877 case ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE:
879 return Dali::ImfManager::SOFTWARE_KEYBOARD;
882 case ECORE_IMF_INPUT_PANEL_HW_KEYBOARD_MODE:
884 return Dali::ImfManager::HARDWARE_KEYBOARD;
889 #endif // OVER_TIZEN_VERSION_4
890 return Dali::ImfManager::KeyboardType::SOFTWARE_KEYBOARD;
893 std::string ImfManager::GetInputPanelLocale()
895 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelLocale\n" );
897 std::string locale = "";
902 ecore_imf_context_input_panel_language_locale_get( mIMFContext, &value );
906 std::string valueCopy( value );
909 // The locale string retrieved must be freed with free().
922 #pragma GCC diagnostic pop