/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <adaptor.h>
#include <window-render-surface.h>
#include <adaptor-impl.h>
+#include <locale-utils.h>
#include <singleton-service-impl.h>
#include <virtual-keyboard-impl.h>
+// Ecore is littered with C style cast
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#include "ecore-virtual-keyboard.h"
namespace Dali
}
}
-BaseHandle Create()
-{
- return ImfManager::Get();
-}
-
-TypeRegistration IMF_MANAGER_TYPE( typeid(Dali::ImfManager), typeid(Dali::BaseHandle), Create );
-
} // unnamed namespace
bool ImfManager::IsAvailable()
}
else
{
- DALI_LOG_ERROR("Failed to get native window handle");
+ DALI_LOG_ERROR("Failed to get native window handle\n");
}
}
}
}
else
{
- DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
+ DALI_LOG_INFO( gLogFilter, Debug::General, "IMF Unable to get IMF Context\n");
}
}
else
{
- DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
+ DALI_LOG_INFO( gLogFilter, Debug::General, "IMF Unable to get IMF Context\n");
}
}
if ( mIMFContext )
{
+ ecore_imf_context_del( mIMFContext );
mIMFContext = NULL;
}
}
Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::PREEDIT, preEditString, cursorPosition, 0 );
Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
- if ( callbackData.update )
+ if( callbackData.update )
{
- SetCursorPosition( callbackData.cursorPosition );
- SetSurroundingText( callbackData.currentText );
+ mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
NotifyCursorPosition();
}
- if ( callbackData.preeditResetRequired )
+ if( callbackData.preeditResetRequired )
{
Reset();
}
if( callbackData.update )
{
- SetCursorPosition( callbackData.cursorPosition );
- SetSurroundingText( callbackData.currentText );
+ mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
NotifyCursorPosition();
}
Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::GETSURROUNDING, std::string(), 0, 0 );
Dali::ImfManager handle( this );
- mEventSignal.Emit( handle, imfData );
+ Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfData );
- if( text )
+ if( callbackData.update )
{
- *text = strdup( mSurroundingText.c_str() );
- }
+ if( text )
+ {
+ *text = strdup( callbackData.currentText.c_str() );
+ }
- if( cursorPosition )
- {
- *cursorPosition = mIMFCursorPosition;
+ if( cursorPosition )
+ {
+ mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
+ *cursorPosition = mIMFCursorPosition;
+ }
}
return EINA_TRUE;
Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::DELETESURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );
Dali::ImfManager handle( this );
- mEventSignal.Emit( handle, imfData );
+ Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfData );
+
+ if( callbackData.update )
+ {
+ mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
+
+ NotifyCursorPosition();
+ }
}
}
return mSurroundingText;
}
+void ImfManager::NotifyTextInputMultiLine( bool multiLine )
+{
+}
+
+Dali::ImfManager::TextDirection ImfManager::GetTextDirection()
+{
+ Dali::ImfManager::TextDirection direction ( Dali::ImfManager::LeftToRight );
+
+ if ( ImfManager::IsAvailable() /* We do not want to create an instance of ImfManager */ )
+ {
+ if ( mIMFContext )
+ {
+ char* locale( NULL );
+ ecore_imf_context_input_panel_language_locale_get( mIMFContext, &locale );
+
+ if ( locale )
+ {
+ direction = static_cast< Dali::ImfManager::TextDirection >( Locale::GetDirection( std::string( locale ) ) );
+ free( locale );
+ }
+ }
+ }
+ return direction;
+}
+
+Rect<int> ImfManager::GetInputMethodArea()
+{
+ int xPos, yPos, width, height;
+
+ width = height = xPos = yPos = 0;
+
+ if( mIMFContext )
+ {
+ ecore_imf_context_input_panel_geometry_get( mIMFContext, &xPos, &yPos, &width, &height );
+ }
+ else
+ {
+ DALI_LOG_WARNING("VKB Unable to get IMF Context so GetSize unavailable\n");
+ }
+
+ return Rect<int>(xPos,yPos,width,height);
+}
+
+void ImfManager::ApplyOptions( const InputMethodOptions& options )
+{
+ using namespace Dali::InputMethod::Category;
+
+ int index;
+
+ if (mIMFContext == NULL)
+ {
+ DALI_LOG_WARNING("VKB Unable to excute ApplyOptions with Null ImfContext\n");
+ return;
+ }
+
+ if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )
+ {
+ }
+ if ( mOptions.CompareAndSet(AUTO_CAPITALISE, options, index) )
+ {
+ }
+ if ( mOptions.CompareAndSet(ACTION_BUTTON_TITLE, options, index) )
+ {
+ }
+ if ( mOptions.CompareAndSet(VARIATION, options, index) )
+ {
+ }
+}
+
+void ImfManager::SetInputPanelUserData( const std::string& data )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetInputPanelUserData\n" );
+
+ if( mIMFContext )
+ {
+ int length = data.length();
+ ecore_imf_context_input_panel_imdata_set( mIMFContext, &data, length );
+ }
+}
+
+void ImfManager::GetInputPanelUserData( std::string& data )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelUserData\n" );
+
+ if( mIMFContext )
+ {
+ int* length = NULL;
+ ecore_imf_context_input_panel_imdata_get( mIMFContext, &data, length );
+ }
+}
+
+Dali::ImfManager::State ImfManager::GetInputPanelState()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelState\n" );
+
+ if( mIMFContext )
+ {
+ int value;
+ value = ecore_imf_context_input_panel_state_get( mIMFContext );
+
+ switch (value)
+ {
+ case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
+ {
+ return Dali::ImfManager::SHOW;
+ break;
+ }
+
+ case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
+ {
+ return Dali::ImfManager::HIDE;
+ break;
+ }
+
+ case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
+ {
+ return Dali::ImfManager::WILL_SHOW;
+ break;
+ }
+
+ default:
+ {
+ return Dali::ImfManager::DEFAULT;
+ }
+ }
+ }
+ return Dali::ImfManager::DEFAULT;
+}
+
+void ImfManager::SetReturnKeyState( bool visible )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetReturnKeyState\n" );
+
+ if( mIMFContext )
+ {
+ ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible );
+ }
+}
+
+void ImfManager::AutoEnableInputPanel( bool enabled )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::AutoEnableInputPanel\n" );
+
+ if( mIMFContext )
+ {
+ ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled );
+ }
+}
+
+void ImfManager::ShowInputPanel()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::ShowInputPanel\n" );
+
+ if( mIMFContext )
+ {
+ ecore_imf_context_input_panel_show( mIMFContext );
+ }
+}
+
+void ImfManager::HideInputPanel()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::HideInputPanel\n" );
+
+ if( mIMFContext )
+ {
+ ecore_imf_context_input_panel_hide( mIMFContext );
+ }
+}
+
+Dali::ImfManager::KeyboardType ImfManager::GetKeyboardType()
+{
+ return Dali::ImfManager::KeyboardType::SOFTWARE_KEYBOARD;
+}
+
+std::string ImfManager::GetInputPanelLocale()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelLocale\n" );
+
+ std::string locale = "";
+
+ if( mIMFContext )
+ {
+ char* value = NULL;
+ ecore_imf_context_input_panel_language_locale_get( mIMFContext, &value );
+
+ if( value )
+ {
+ std::string valueCopy( value );
+ locale = valueCopy;
+
+ // The locale string retrieved must be freed with free().
+ free( value );
+ }
+ }
+ return locale;
+}
+
} // Adaptor
} // Internal
} // Dali
+
+#pragma GCC diagnostic pop