Revert "[Tizen] Disable indicator"
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / windows / input-method-context-impl-win.cpp
1 /*\r
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  * http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  *\r
16  */\r
17 \r
18 // CLASS HEADER\r
19 #include <dali/internal/input/windows/input-method-context-impl-win.h>\r
20 \r
21 // EXTERNAL INCLUDES\r
22 //#include <Ecore_IMF.h>\r
23 //#include <Ecore_Input.h>\r
24 #include <dali/public-api/events/key-event.h>\r
25 #include <dali/public-api/adaptor-framework/key.h>\r
26 #include <dali/public-api/object/type-registry.h>\r
27 #include <dali/integration-api/debug.h>\r
28 \r
29 // INTERNAL INCLUDES\r
30 #include <dali/integration-api/adaptor.h>\r
31 #include <dali/internal/adaptor/common/adaptor-impl.h>\r
32 #include <dali/internal/system/common/locale-utils.h>\r
33 #include <dali/internal/system/common/singleton-service-impl.h>\r
34 #include <dali/internal/input/common/virtual-keyboard-impl.h>\r
35 #include <dali/internal/input/common/key-impl.h>\r
36 // Ecore is littered with C style cast\r
37 #pragma GCC diagnostic push\r
38 #pragma GCC diagnostic ignored "-Wold-style-cast"\r
39 //#include <dali/internal/input/tizen-wayland/ecore-virtual-keyboard.h>\r
40 \r
41 namespace Dali\r
42 {\r
43 \r
44 namespace Internal\r
45 {\r
46 \r
47 namespace Adaptor\r
48 {\r
49 \r
50 namespace\r
51 {\r
52 #if defined(DEBUG_ENABLED)\r
53 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT");\r
54 #endif\r
55 \r
56 // Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.\r
57 size_t Utf8SequenceLength(const unsigned char leadByte)\r
58 {\r
59   size_t length = 0;\r
60 \r
61   if ((leadByte & 0x80) == 0 )          //ASCII character (lead bit zero)\r
62   {\r
63     length = 1;\r
64   }\r
65   else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx\r
66   {\r
67     length = 2;\r
68   }\r
69   else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx\r
70   {\r
71     length = 3;\r
72   }\r
73   else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx\r
74   {\r
75     length = 4;\r
76   }\r
77 \r
78   return length;\r
79 }\r
80 //\r
81 //// Static function calls used by ecore 'c' style callback registration\r
82 //void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info )\r
83 //{\r
84 //  if ( data )\r
85 //  {\r
86 //    InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data );\r
87 //    inputMethodContext->CommitReceived( data, imfContext, event_info );\r
88 //  }\r
89 //}\r
90 //\r
91 //void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info )\r
92 //{\r
93 //  if ( data )\r
94 //  {\r
95 //    InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data );\r
96 //    inputMethodContext->PreEditChanged( data, imfContext, event_info );\r
97 //  }\r
98 //}\r
99 //\r
100 //Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )\r
101 //{\r
102 //  if ( data )\r
103 //  {\r
104 //    InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data );\r
105 //    return inputMethodContext->RetrieveSurrounding( data, imfContext, text, cursorPosition );\r
106 //  }\r
107 //  else\r
108 //  {\r
109 //    return false;\r
110 //  }\r
111 //}\r
112 //\r
113 ///**\r
114 // * Called when an InputMethodContext delete surrounding event is received.\r
115 // * Here we tell the application that it should delete a certain range.\r
116 // */\r
117 //void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )\r
118 //{\r
119 //  if ( data )\r
120 //  {\r
121 //    InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data );\r
122 //    inputMethodContext->DeleteSurrounding( data, imfContext, event_info );\r
123 //  }\r
124 //}\r
125 \r
126 } // unnamed namespace\r
127 \r
128 InputMethodContextPtr InputMethodContextWin::New()\r
129 {\r
130   InputMethodContextPtr manager;\r
131 \r
132   if ( Adaptor::IsAvailable() )\r
133   {\r
134     // Create instance and register singleton only if the adaptor is available\r
135     Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );\r
136     Any nativeWindow = adaptorImpl.GetNativeWindowHandle();\r
137 \r
138     // The Ecore_X_Window needs to use the InputMethodContext.\r
139     // Only when the render surface is window, we can get the Ecore_X_Window.\r
140     Ecore_X_Window ecoreXwin( AnyCast<Ecore_X_Window>(nativeWindow) );\r
141     if (ecoreXwin)\r
142     {\r
143       // If we fail to get Ecore_X_Window, we can't use the InputMethodContext correctly.\r
144       // Thus you have to call "ecore_imf_context_client_window_set" somewhere.\r
145       // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().\r
146 \r
147       manager = new InputMethodContextWin( ecoreXwin );\r
148     }\r
149     else\r
150     {\r
151       DALI_LOG_ERROR("Failed to get native window handle\n");\r
152     }\r
153   }\r
154 \r
155   return manager;\r
156 }\r
157 \r
158 void InputMethodContextWin::Finalize()\r
159 {\r
160   //DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Finalize\n" );\r
161   //VirtualKeyboard::DisconnectCallbacks( mIMFContext );\r
162   //DisconnectCallbacks();\r
163   //DeleteContext();\r
164 }\r
165 \r
166 InputMethodContextWin::InputMethodContextWin( Ecore_X_Window ecoreXwin )\r
167 //: mIMFContext(),\r
168 :  mEcoreXwin( ecoreXwin ),\r
169   mIMFCursorPosition( 0 ),\r
170   mSurroundingText(),\r
171   mRestoreAfterFocusLost( false ),\r
172   mIdleCallbackConnected( false )\r
173 {\r
174   //ecore_imf_init();\r
175 }\r
176 \r
177 InputMethodContextWin::~InputMethodContextWin()\r
178 {\r
179   Finalize();\r
180   //ecore_imf_shutdown();\r
181 }\r
182 \r
183 void InputMethodContextWin::Initialize()\r
184 {\r
185   CreateContext( mEcoreXwin );\r
186   ConnectCallbacks();\r
187   //VirtualKeyboard::ConnectCallbacks( mIMFContext );\r
188 }\r
189 \r
190 void InputMethodContextWin::CreateContext( Ecore_X_Window ecoreXwin )\r
191 {\r
192   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CreateContext\n" );\r
193 \r
194   //const char *contextId = ecore_imf_context_default_id_get();\r
195   //if( contextId )\r
196   //{\r
197   //  mIMFContext = ecore_imf_context_add( contextId );\r
198 \r
199   //  if( mIMFContext )\r
200   //  {\r
201   //    if( ecoreXwin )\r
202   //    {\r
203   //      ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast<void*>( ecoreXwin ) );\r
204   //    }\r
205   //  }\r
206   //  else\r
207   //  {\r
208   //    DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n");\r
209   //  }\r
210   //}\r
211   //else\r
212   //{\r
213   //  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n");\r
214   //}\r
215 }\r
216 \r
217 void InputMethodContextWin::DeleteContext()\r
218 {\r
219   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteContext\n" );\r
220 \r
221   //if ( mIMFContext )\r
222   //{\r
223   //  ecore_imf_context_del( mIMFContext );\r
224   //  mIMFContext = NULL;\r
225   //}\r
226 }\r
227 \r
228 // Callbacks for predicitive text support.\r
229 void InputMethodContextWin::ConnectCallbacks()\r
230 {\r
231   //if ( mIMFContext )\r
232   //{\r
233   //  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::ConnectCallbacks\n" );\r
234 \r
235   //  ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED,    PreEdit,    this );\r
236   //  ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT,             Commit,     this );\r
237   //  ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );\r
238 \r
239   //  ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);\r
240   //}\r
241 }\r
242 \r
243 void InputMethodContextWin::DisconnectCallbacks()\r
244 {\r
245   //if ( mIMFContext )\r
246   //{\r
247   //  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DisconnectCallbacks\n" );\r
248 \r
249   //  ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED,    PreEdit );\r
250   //  ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT,             Commit );\r
251   //  ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );\r
252 \r
253   //  // We do not need to unset the retrieve surrounding callback.\r
254   //}\r
255 }\r
256 \r
257 void InputMethodContextWin::Activate()\r
258 {\r
259   // Reset mIdleCallbackConnected\r
260   mIdleCallbackConnected = false;\r
261 \r
262   //if ( mIMFContext )\r
263   //{\r
264   //  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Activate\n" );\r
265 \r
266   //  ecore_imf_context_focus_in( mIMFContext );\r
267 \r
268   //  // emit keyboard activated signal\r
269   //  Dali::InputMethodContext handle( this );\r
270   //  mActivatedSignal.Emit( handle );\r
271   //}\r
272 }\r
273 \r
274 void InputMethodContextWin::Deactivate()\r
275 {\r
276   //if( mIMFContext )\r
277   //{\r
278   //  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Deactivate\n" );\r
279 \r
280   //  Reset();\r
281   //  ecore_imf_context_focus_out( mIMFContext );\r
282   //}\r
283 \r
284   // Reset mIdleCallbackConnected\r
285   mIdleCallbackConnected = false;\r
286 }\r
287 \r
288 void InputMethodContextWin::Reset()\r
289 {\r
290   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Reset\n" );\r
291 \r
292   //if ( mIMFContext )\r
293   //{\r
294   //  ecore_imf_context_reset( mIMFContext );\r
295   //}\r
296 }\r
297 \r
298 ImfContext* InputMethodContextWin::GetContext()\r
299 {\r
300   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetContext\n" );\r
301 \r
302   //return mIMFContext;\r
303   return NULL;\r
304 }\r
305 \r
306 bool InputMethodContextWin::RestoreAfterFocusLost() const\r
307 {\r
308   return mRestoreAfterFocusLost;\r
309 }\r
310 \r
311 void InputMethodContextWin::SetRestoreAfterFocusLost( bool toggle )\r
312 {\r
313   mRestoreAfterFocusLost = toggle;\r
314 }\r
315 \r
316 /**\r
317  * Called when an InputMethodContext Pre-Edit changed event is received.\r
318  * We are still predicting what the user is typing.  The latest string is what the InputMethodContext module thinks\r
319  * the user wants to type.\r
320  */\r
321 void InputMethodContextWin::PreEditChanged( void*, ImfContext* imfContext, void* event_info )\r
322 {\r
323   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::PreEditChanged\n" );\r
324 //  auto context = reinterpret_cast<Ecore_IMF_Context*>(imfContext);\r
325 //\r
326 //  char* preEditString( NULL );\r
327 //  int cursorPosition( 0 );\r
328 //  Eina_List* attrs = NULL;\r
329 //  Eina_List* l = NULL;\r
330 //\r
331 //  Ecore_IMF_Preedit_Attr* attr;\r
332 //\r
333 //  // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.\r
334 //  // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.\r
335 //  ecore_imf_context_preedit_string_with_attributes_get( context, &preEditString, &attrs, &cursorPosition );\r
336 //\r
337 //  if ( attrs )\r
338 //  {\r
339 //    // iterate through the list of attributes getting the type, start and end position.\r
340 //    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) ) ))\r
341 //    {\r
342 //#ifdef DALI_PROFILE_UBUNTU\r
343 //      if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF)\r
344 //#else // DALI_PROFILE_UBUNTU\r
345 //      if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF)\r
346 //#endif // DALI_PROFILE_UBUNTU\r
347 //      {\r
348 //        // 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.\r
349 //\r
350 //        size_t visualCharacterIndex = 0;\r
351 //        size_t byteIndex = 0;\r
352 //\r
353 //        // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).\r
354 //        const char leadByte = preEditString[byteIndex];\r
355 //        while( leadByte != '\0' )\r
356 //        {\r
357 //          // attr->end_index is provided as a byte position not character and we need to know the character position.\r
358 //          const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.\r
359 //          if ( byteIndex == attr->end_index )\r
360 //          {\r
361 //            cursorPosition = visualCharacterIndex;\r
362 //            break;\r
363 //            // end loop as found cursor position that matches byte position\r
364 //          }\r
365 //          else\r
366 //          {\r
367 //            byteIndex += currentSequenceLength; // jump to next character\r
368 //            visualCharacterIndex++;  // increment character count so we know our position for when we get a match\r
369 //          }\r
370 //\r
371 //          DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString ));\r
372 //        }\r
373 //      }\r
374 //    }\r
375 //  }\r
376 \r
377   //if ( Dali::Adaptor::IsAvailable() )\r
378   //{\r
379   //  Dali::InputMethodContext handle( this );\r
380   //  Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::PRE_EDIT, preEditString, cursorPosition, 0 );\r
381   //  Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );\r
382 \r
383   //  if( callbackData.update )\r
384   //  {\r
385   //    mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );\r
386 \r
387   //    NotifyCursorPosition();\r
388   //  }\r
389 \r
390   //  if( callbackData.preeditResetRequired )\r
391   //  {\r
392   //    Reset();\r
393   //  }\r
394   //}\r
395   //free( preEditString );\r
396 }\r
397 \r
398 void InputMethodContextWin::CommitReceived( void*, ImfContext* imfContext, void* event_info )\r
399 {\r
400   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CommitReceived\n" );\r
401 \r
402   if ( Dali::Adaptor::IsAvailable() )\r
403   {\r
404     const std::string keyString( static_cast<char*>( event_info ) );\r
405 \r
406     Dali::InputMethodContext handle( this );\r
407     Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::COMMIT, keyString, 0, 0 );\r
408     Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );\r
409 \r
410     if( callbackData.update )\r
411     {\r
412       mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );\r
413 \r
414       NotifyCursorPosition();\r
415     }\r
416   }\r
417 }\r
418 \r
419 /**\r
420  * Called when an InputMethodContext retrieve surround event is received.\r
421  * Here the InputMethodContext module wishes to know the string we are working with and where within the string the cursor is\r
422  * We need to signal the application to tell us this information.\r
423  */\r
424 bool InputMethodContextWin::RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition )\r
425 {\r
426   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::RetrieveSurrounding\n" );\r
427 \r
428   Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0 );\r
429   Dali::InputMethodContext handle( this );\r
430   Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );\r
431 \r
432   if( callbackData.update )\r
433   {\r
434     if( text )\r
435     {\r
436       *text = strdup( callbackData.currentText.c_str() );\r
437     }\r
438 \r
439     if( cursorPosition )\r
440     {\r
441       mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );\r
442       *cursorPosition = mIMFCursorPosition;\r
443     }\r
444   }\r
445 \r
446   //return EINA_TRUE;\r
447   return true;\r
448 }\r
449 \r
450 /**\r
451  * Called when an InputMethodContext delete surrounding event is received.\r
452  * Here we tell the application that it should delete a certain range.\r
453  */\r
454 void InputMethodContextWin::DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info )\r
455 {\r
456   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteSurrounding\n" );\r
457 \r
458   //if( Dali::Adaptor::IsAvailable() )\r
459   //{\r
460   //  Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>( event_info );\r
461 \r
462   //  Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::DELETE_SURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );\r
463   //  Dali::InputMethodContext handle( this );\r
464   //  Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );\r
465 \r
466   //  if( callbackData.update )\r
467   //  {\r
468   //    mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );\r
469 \r
470   //    NotifyCursorPosition();\r
471   //  }\r
472   //}\r
473 }\r
474 \r
475 void InputMethodContextWin::NotifyCursorPosition()\r
476 {\r
477   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::NotifyCursorPosition\n" );\r
478 \r
479   //if( mIMFContext )\r
480   //{\r
481   //  ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );\r
482   //}\r
483 }\r
484 \r
485 void InputMethodContextWin::SetCursorPosition( unsigned int cursorPosition )\r
486 {\r
487   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetCursorPosition\n" );\r
488 \r
489   mIMFCursorPosition = static_cast<int>( cursorPosition );\r
490 }\r
491 \r
492 unsigned int InputMethodContextWin::GetCursorPosition() const\r
493 {\r
494   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetCursorPosition\n" );\r
495 \r
496   return static_cast<unsigned int>( mIMFCursorPosition );\r
497 }\r
498 \r
499 void InputMethodContextWin::SetSurroundingText( const std::string& text )\r
500 {\r
501   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetSurroundingText\n" );\r
502 \r
503   mSurroundingText = text;\r
504 }\r
505 \r
506 const std::string& InputMethodContextWin::GetSurroundingText() const\r
507 {\r
508   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetSurroundingText\n" );\r
509 \r
510   return mSurroundingText;\r
511 }\r
512 \r
513 void InputMethodContextWin::NotifyTextInputMultiLine( bool multiLine )\r
514 {\r
515 }\r
516 \r
517 Dali::InputMethodContext::TextDirection InputMethodContextWin::GetTextDirection()\r
518 {\r
519   Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LeftToRight );\r
520 \r
521     //if ( mIMFContext )\r
522     //{\r
523     //  char* locale( NULL );\r
524     //  ecore_imf_context_input_panel_language_locale_get( mIMFContext, &locale );\r
525 \r
526     //  if ( locale )\r
527     //  {\r
528     //    direction = static_cast< Dali::InputMethodContext::TextDirection >( Locale::GetDirection( std::string( locale ) ) );\r
529     //    free( locale );\r
530     //  }\r
531     //}\r
532 \r
533   return direction;\r
534 }\r
535 \r
536 Rect<int> InputMethodContextWin::GetInputMethodArea()\r
537 {\r
538   int xPos, yPos, width, height;\r
539 \r
540   width = height = xPos = yPos = 0;\r
541 \r
542   //if( mIMFContext )\r
543   //{\r
544   //  ecore_imf_context_input_panel_geometry_get( mIMFContext, &xPos, &yPos, &width, &height );\r
545   //}\r
546   //else\r
547   //{\r
548   //  DALI_LOG_WARNING("VKB Unable to get InputMethodContext Context so GetSize unavailable\n");\r
549   //}\r
550 \r
551   return Rect<int>(xPos,yPos,width,height);\r
552 }\r
553 \r
554 void InputMethodContextWin::ApplyOptions( const InputMethodOptions& options )\r
555 {\r
556   using namespace Dali::InputMethod::Category;\r
557 \r
558   int index;\r
559 \r
560   //if (mIMFContext == NULL)\r
561   //{\r
562   //  DALI_LOG_WARNING("VKB Unable to excute ApplyOptions with Null ImfContext\n");\r
563   //  return;\r
564   //}\r
565 \r
566   if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )\r
567   {\r
568   }\r
569   if ( mOptions.CompareAndSet(BUTTON_ACTION, options, index) )\r
570   {\r
571   }\r
572   if ( mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index) )\r
573   {\r
574   }\r
575   if ( mOptions.CompareAndSet(VARIATION, options, index) )\r
576   {\r
577   }\r
578 }\r
579 \r
580 void InputMethodContextWin::SetInputPanelData( const std::string& data )\r
581 {\r
582   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelData\n" );\r
583 \r
584   //if( mIMFContext )\r
585   //{\r
586   //  int length = data.length();\r
587   //  ecore_imf_context_input_panel_imdata_set( mIMFContext, data.c_str(), length );\r
588   //}\r
589 }\r
590 \r
591 void InputMethodContextWin::GetInputPanelData( std::string& data )\r
592 {\r
593   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelData\n" );\r
594 \r
595   //if( mIMFContext )\r
596   //{\r
597   //  int length = 4096; // The max length is 4096 bytes\r
598   //  Dali::Vector< char > buffer;\r
599   //  buffer.Resize( length );\r
600   //  ecore_imf_context_input_panel_imdata_get( mIMFContext, &buffer[0], &length );\r
601   //  data = std::string( buffer.Begin(), buffer.End() );\r
602   //}\r
603 }\r
604 \r
605 Dali::InputMethodContext::State InputMethodContextWin::GetInputPanelState()\r
606 {\r
607   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelState\n" );\r
608 \r
609   //if( mIMFContext )\r
610   //{\r
611   //  int value;\r
612   //  value = ecore_imf_context_input_panel_state_get( mIMFContext );\r
613 \r
614   //  switch (value)\r
615   //  {\r
616   //    case ECORE_IMF_INPUT_PANEL_STATE_SHOW:\r
617   //    {\r
618   //      return Dali::InputMethodContext::SHOW;\r
619   //      break;\r
620   //    }\r
621 \r
622   //    case ECORE_IMF_INPUT_PANEL_STATE_HIDE:\r
623   //    {\r
624   //      return Dali::InputMethodContext::HIDE;\r
625   //      break;\r
626   //    }\r
627 \r
628   //    case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:\r
629   //    {\r
630   //      return Dali::InputMethodContext::WILL_SHOW;\r
631   //      break;\r
632   //    }\r
633 \r
634   //    default:\r
635   //    {\r
636   //      return Dali::InputMethodContext::DEFAULT;\r
637   //    }\r
638   //  }\r
639   //}\r
640   return Dali::InputMethodContext::DEFAULT;\r
641 }\r
642 \r
643 void InputMethodContextWin::SetReturnKeyState( bool visible )\r
644 {\r
645   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetReturnKeyState\n" );\r
646 \r
647   //if( mIMFContext )\r
648   //{\r
649   //  ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible );\r
650   //}\r
651 }\r
652 \r
653 void InputMethodContextWin::AutoEnableInputPanel( bool enabled )\r
654 {\r
655   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::AutoEnableInputPanel\n" );\r
656 \r
657   //if( mIMFContext )\r
658   //{\r
659   //  ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled );\r
660   //}\r
661 }\r
662 \r
663 void InputMethodContextWin::ShowInputPanel()\r
664 {\r
665   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::ShowInputPanel\n" );\r
666 \r
667   //if( mIMFContext )\r
668   //{\r
669   //  ecore_imf_context_input_panel_show( mIMFContext );\r
670   //}\r
671 }\r
672 \r
673 void InputMethodContextWin::HideInputPanel()\r
674 {\r
675   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::HideInputPanel\n" );\r
676 \r
677   //if( mIMFContext )\r
678   //{\r
679   //  ecore_imf_context_input_panel_hide( mIMFContext );\r
680   //}\r
681 }\r
682 \r
683 Dali::InputMethodContext::KeyboardType InputMethodContextWin::GetKeyboardType()\r
684 {\r
685   return Dali::InputMethodContext::KeyboardType::SOFTWARE_KEYBOARD;\r
686 }\r
687 \r
688 std::string InputMethodContextWin::GetInputPanelLocale()\r
689 {\r
690   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelLocale\n" );\r
691 \r
692   std::string locale = "";\r
693 \r
694   //if( mIMFContext )\r
695   //{\r
696   //  char* value = NULL;\r
697   //  ecore_imf_context_input_panel_language_locale_get( mIMFContext, &value );\r
698 \r
699   //  if( value )\r
700   //  {\r
701   //    std::string valueCopy( value );\r
702   //    locale = valueCopy;\r
703 \r
704   //    // The locale string retrieved must be freed with free().\r
705   //    free( value );\r
706   //  }\r
707   //}\r
708   return locale;\r
709 }\r
710 \r
711 bool InputMethodContextWin::FilterEventKey( const Dali::KeyEvent& keyEvent )\r
712 {\r
713   bool eventHandled( false );\r
714 \r
715   // If a device key then skip ecore_imf_context_filter_event.\r
716   if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ))\r
717   {\r
718     //check whether it's key down or key up event\r
719     if ( keyEvent.state == KeyEvent::Down )\r
720     {\r
721       eventHandled = ProcessEventKeyDown( keyEvent );\r
722     }\r
723     else if ( keyEvent.state == KeyEvent::Up )\r
724     {\r
725       eventHandled = ProcessEventKeyUp( keyEvent );\r
726     }\r
727   }\r
728 \r
729   return eventHandled;\r
730 }\r
731 \r
732 bool InputMethodContextWin::ProcessEventKeyDown( const KeyEvent& keyEvent )\r
733 {\r
734   bool eventHandled( false );\r
735 //  if ( mIMFContext )\r
736 //  {\r
737 //    // We're consuming key down event so we have to pass to InputMethodContext so that it can parse it as well.\r
738 //    Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;\r
739 //    ecoreKeyDownEvent.keyname = keyEvent.keyPressedName.c_str();\r
740 //    ecoreKeyDownEvent.key = keyEvent.keyPressedName.c_str();\r
741 //    ecoreKeyDownEvent.string = keyEvent.keyPressed.c_str();\r
742 //    ecoreKeyDownEvent.compose = keyEvent.GetCompose().c_str();\r
743 //    ecoreKeyDownEvent.timestamp = keyEvent.time;\r
744 //    ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );\r
745 //    ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );\r
746 //#ifdef ECORE_IMF_1_13\r
747 //    ecoreKeyDownEvent.dev_name  = "";\r
748 //    ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;\r
749 //    ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;\r
750 //#endif // ECORE_IMF_1_13\r
751 //\r
752 //    // If the device is IME and the focused key is the direction keys, then we should send a key event to move a key cursor.\r
753 //    if ((keyEvent.GetDeviceName() == "ime") && ((!strncmp(keyEvent.keyPressedName.c_str(), "Left", 4)) ||\r
754 //                                   (!strncmp(keyEvent.keyPressedName.c_str(), "Right", 5)) ||\r
755 //                                   (!strncmp(keyEvent.keyPressedName.c_str(), "Up", 2)) ||\r
756 //                                   (!strncmp(keyEvent.keyPressedName.c_str(), "Down", 4))))\r
757 //    {\r
758 //      eventHandled = 0;\r
759 //    }\r
760 //    else\r
761 //    {\r
762 //      eventHandled = ecore_imf_context_filter_event(mIMFContext,\r
763 //                                                    ECORE_IMF_EVENT_KEY_DOWN,\r
764 //                                                    (Ecore_IMF_Event *) &ecoreKeyDownEvent);\r
765 //    }\r
766 //\r
767 //    // If the event has not been handled by InputMethodContext then check if we should reset our IMFcontext\r
768 //    if (!eventHandled)\r
769 //    {\r
770 //      if (!strcmp(keyEvent.keyPressedName.c_str(), "Escape") ||\r
771 //          !strcmp(keyEvent.keyPressedName.c_str(), "Return") ||\r
772 //          !strcmp(keyEvent.keyPressedName.c_str(), "KP_Enter"))\r
773 //      {\r
774 //        ecore_imf_context_reset(mIMFContext);\r
775 //      }\r
776 //    }\r
777 //  }\r
778   return eventHandled;\r
779 }\r
780 \r
781 bool InputMethodContextWin::ProcessEventKeyUp( const KeyEvent& keyEvent )\r
782 {\r
783   bool eventHandled( false );\r
784 //  if( mIMFContext )\r
785 //  {\r
786 //    // We're consuming key up event so we have to pass to InputMethodContext so that it can parse it as well.\r
787 //    Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;\r
788 //    ecoreKeyUpEvent.keyname = keyEvent.keyPressedName.c_str();\r
789 //    ecoreKeyUpEvent.key = keyEvent.keyPressedName.c_str();\r
790 //    ecoreKeyUpEvent.string = keyEvent.keyPressed.c_str();\r
791 //    ecoreKeyUpEvent.compose = keyEvent.GetCompose().c_str();\r
792 //    ecoreKeyUpEvent.timestamp = keyEvent.time;\r
793 //    ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );\r
794 //    ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );\r
795 //#ifdef ECORE_IMF_1_13\r
796 //    ecoreKeyUpEvent.dev_name  = "";\r
797 //#endif // ECORE_IMF_1_13\r
798 //\r
799 //    eventHandled = ecore_imf_context_filter_event(mIMFContext,\r
800 //                                                  ECORE_IMF_EVENT_KEY_UP,\r
801 //                                                  (Ecore_IMF_Event *) &ecoreKeyUpEvent);\r
802 //  }\r
803   return eventHandled;\r
804 }\r
805 \r
806 //Ecore_IMF_Keyboard_Modifiers InputMethodContextWin::EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier )\r
807 //{\r
808 //  unsigned int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE );  // If no other matches returns NONE.\r
809 //\r
810 //  if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT )  // enums from ecore_input/Ecore_Input.h\r
811 //  {\r
812 //    modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT;  // enums from ecore_imf/ecore_imf.h\r
813 //  }\r
814 //\r
815 //  if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )\r
816 //  {\r
817 //    modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;\r
818 //  }\r
819 //\r
820 //  if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )\r
821 //  {\r
822 //    modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;\r
823 //  }\r
824 //\r
825 //  if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )\r
826 //  {\r
827 //    modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;\r
828 //  }\r
829 //\r
830 //  if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )\r
831 //  {\r
832 //    modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;\r
833 //  }\r
834 //\r
835 //  return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );\r
836 //}\r
837 //\r
838 //Ecore_IMF_Keyboard_Locks InputMethodContextWin::EcoreInputModifierToEcoreIMFLock( unsigned int modifier )\r
839 //{\r
840 //    unsigned int lock( ECORE_IMF_KEYBOARD_LOCK_NONE ); // If no other matches, returns NONE.\r
841 //\r
842 //    if( modifier & ECORE_EVENT_LOCK_NUM )\r
843 //    {\r
844 //      lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active.\r
845 //    }\r
846 //\r
847 //    if( modifier & ECORE_EVENT_LOCK_CAPS )\r
848 //    {\r
849 //      lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active.\r
850 //    }\r
851 //\r
852 //    if( modifier & ECORE_EVENT_LOCK_SCROLL )\r
853 //    {\r
854 //      lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active.\r
855 //    }\r
856 //\r
857 //    return static_cast<Ecore_IMF_Keyboard_Locks>( lock );\r
858 //}\r
859 \r
860 } // Adaptor\r
861 \r
862 } // Internal\r
863 \r
864 } // Dali\r
865 \r
866 #pragma GCC diagnostic pop\r