Renaming of enum values for coding standards compliance.
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / windows / input-method-context-impl-win.cpp
index 16df1a5..a26c90a 100755 (executable)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
 \r
 // EXTERNAL INCLUDES\r
 #include <dali/public-api/events/key-event.h>\r
-#include <dali/public-api/adaptor-framework/key.h>\r
 #include <dali/public-api/object/type-registry.h>\r
+#include <dali/devel-api/common/singleton-service.h>\r
 #include <dali/integration-api/debug.h>\r
 \r
 // INTERNAL INCLUDES\r
-#include <dali/integration-api/adaptor.h>\r
+#include <dali/public-api/adaptor-framework/key.h>\r
+#include <dali/integration-api/adaptor-framework/adaptor.h>\r
 #include <dali/internal/adaptor/common/adaptor-impl.h>\r
-#include <dali/internal/system/common/locale-utils.h>\r
-#include <dali/internal/system/common/singleton-service-impl.h>\r
-#include <dali/internal/input/common/virtual-keyboard-impl.h>\r
 #include <dali/internal/input/common/key-impl.h>\r
+#include <dali/internal/input/common/virtual-keyboard-impl.h>\r
+#include <dali/internal/system/common/locale-utils.h>\r
 \r
 namespace Dali\r
 {\r
@@ -41,27 +41,20 @@ namespace Internal
 namespace Adaptor\r
 {\r
 \r
-InputMethodContextPtr InputMethodContextWin::New()\r
+namespace\r
+{\r
+#if defined(DEBUG_ENABLED)\r
+Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT" );\r
+#endif\r
+}\r
+\r
+InputMethodContextPtr InputMethodContextWin::New( Dali::Actor actor )\r
 {\r
   InputMethodContextPtr manager;\r
 \r
-  if ( Adaptor::IsAvailable() )\r
+  if ( actor && Adaptor::IsAvailable() )\r
   {\r
-    // Create instance and register singleton only if the adaptor is available\r
-    Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );\r
-    Any nativeWindow = adaptorImpl.GetNativeWindowHandle();\r
-\r
-    // The Win_Window_Handle needs to use the InputMethodContext.\r
-    // Only when the render surface is window, we can get the Win_Window_Handle.\r
-    WinWindowHandle winWindow( AnyCast<WinWindowHandle>(nativeWindow) );\r
-    if ( winWindow )\r
-    {\r
-      manager = new InputMethodContextWin( winWindow );\r
-    }\r
-    else\r
-    {\r
-      DALI_LOG_ERROR("Failed to get native window handle\n");\r
-    }\r
+    manager = new InputMethodContextWin( actor );\r
   }\r
 \r
   return manager;\r
@@ -71,13 +64,15 @@ void InputMethodContextWin::Finalize()
 {\r
 }\r
 \r
-InputMethodContextWin::InputMethodContextWin( WinWindowHandle winWindow )\r
-: mWin32Window( winWindow ),\r
+InputMethodContextWin::InputMethodContextWin( Dali::Actor actor )\r
+: mWin32Window( 0 ),\r
   mIMFCursorPosition( 0 ),\r
   mSurroundingText(),\r
   mRestoreAfterFocusLost( false ),\r
   mIdleCallbackConnected( false )\r
 {\r
+\r
+  actor.OnSceneSignal().Connect( this, &InputMethodContextWin::OnStaged );\r
 }\r
 \r
 InputMethodContextWin::~InputMethodContextWin()\r
@@ -148,18 +143,18 @@ void InputMethodContextWin::SetRestoreAfterFocusLost( bool toggle )
  * We are still predicting what the user is typing.  The latest string is what the InputMethodContext module thinks\r
  * the user wants to type.\r
  */\r
-void InputMethodContextWin::PreEditChanged( void*, ImfContext* imfContext, void* event_info )\r
+void InputMethodContextWin::PreEditChanged( void*, ImfContext* imfContext, void* eventInfo )\r
 {\r
   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::PreEditChanged\n" );\r
 }\r
 \r
-void InputMethodContextWin::CommitReceived( void*, ImfContext* imfContext, void* event_info )\r
+void InputMethodContextWin::CommitReceived( void*, ImfContext* imfContext, void* eventInfo )\r
 {\r
   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CommitReceived\n" );\r
 \r
   if ( Dali::Adaptor::IsAvailable() )\r
   {\r
-    const std::string keyString( static_cast<char*>( event_info ) );\r
+    const std::string keyString( static_cast<char*>( eventInfo ) );\r
 \r
     Dali::InputMethodContext handle( this );\r
     Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::COMMIT, keyString, 0, 0 );\r
@@ -208,7 +203,7 @@ bool InputMethodContextWin::RetrieveSurrounding( void* data, ImfContext* imfCont
  * Called when an InputMethodContext delete surrounding event is received.\r
  * Here we tell the application that it should delete a certain range.\r
  */\r
-void InputMethodContextWin::DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info )\r
+void InputMethodContextWin::DeleteSurrounding( void* data, ImfContext* imfContext, void* eventInfo )\r
 {\r
   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteSurrounding\n" );\r
 }\r
@@ -252,7 +247,7 @@ void InputMethodContextWin::NotifyTextInputMultiLine( bool multiLine )
 \r
 Dali::InputMethodContext::TextDirection InputMethodContextWin::GetTextDirection()\r
 {\r
-  Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LeftToRight );\r
+  Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LEFT_TO_RIGHT );\r
 \r
   return direction;\r
 }\r
@@ -335,18 +330,23 @@ std::string InputMethodContextWin::GetInputPanelLocale()
   return locale;\r
 }\r
 \r
+void InputMethodContextWin::SetContentMIMETypes( const std::string& mimeTypes )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetContentMIMETypes\n" );\r
+}\r
+\r
 bool InputMethodContextWin::FilterEventKey( const Dali::KeyEvent& keyEvent )\r
 {\r
   bool eventHandled( false );\r
 \r
-  if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ))\r
+  if ( ! KeyLookup::IsDeviceButton( keyEvent.GetKeyName().c_str() ))\r
   {\r
     //check whether it's key down or key up event\r
-    if ( keyEvent.state == KeyEvent::Down )\r
+    if ( keyEvent.GetState() == Dali::KeyEvent::DOWN )\r
     {\r
       eventHandled = ProcessEventKeyDown( keyEvent );\r
     }\r
-    else if ( keyEvent.state == KeyEvent::Up )\r
+    else if ( keyEvent.GetState() == Dali::KeyEvent::UP )\r
     {\r
       eventHandled = ProcessEventKeyUp( keyEvent );\r
     }\r
@@ -355,18 +355,54 @@ bool InputMethodContextWin::FilterEventKey( const Dali::KeyEvent& keyEvent )
   return eventHandled;\r
 }\r
 \r
-bool InputMethodContextWin::ProcessEventKeyDown( const KeyEvent& keyEvent )\r
+void InputMethodContextWin::SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelLanguage\n" );\r
+}\r
+\r
+Dali::InputMethodContext::InputPanelLanguage InputMethodContextWin::GetInputPanelLanguage() const\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelLanguage\n" );\r
+  return Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC;\r
+}\r
+\r
+void InputMethodContextWin::SetInputPanelPosition( unsigned int x, unsigned int y )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelPosition\n" );\r
+}\r
+\r
+void InputMethodContextWin::GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetPreeditStyle\n" );\r
+  attrs = mPreeditAttrs;\r
+}\r
+\r
+bool InputMethodContextWin::ProcessEventKeyDown( const Dali::KeyEvent& keyEvent )\r
 {\r
   bool eventHandled( false );\r
   return eventHandled;\r
 }\r
 \r
-bool InputMethodContextWin::ProcessEventKeyUp( const KeyEvent& keyEvent )\r
+bool InputMethodContextWin::ProcessEventKeyUp( const Dali::KeyEvent& keyEvent )\r
 {\r
   bool eventHandled( false );\r
   return eventHandled;\r
 }\r
 \r
+void InputMethodContextWin::OnStaged( Dali::Actor actor )\r
+{\r
+  WinWindowHandle winWindow( AnyCast< WinWindowHandle >( Dali::Integration::SceneHolder::Get( actor ).GetNativeHandle() ) );\r
+\r
+  if( mWin32Window != winWindow )\r
+  {\r
+    mWin32Window = winWindow;\r
+\r
+    // Reset\r
+    Finalize();\r
+    Initialize();\r
+  }\r
+}\r
+\r
 } // Adaptor\r
 \r
 } // Internal\r