[Tizen] Fix imfmanager issue and add an imfmanager sample
[platform/core/csapi/nui.git] / Tizen.NUI / src / public / ImfManager.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 using System;
17 using System.Runtime.InteropServices;
18
19 namespace Tizen.NUI
20 {
21     /// <summary>
22     /// Specifically manages the ecore input method framework which enables the virtual or hardware keyboards.
23     /// </summary>
24     public class ImfManager : BaseHandle
25     {
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27
28         internal ImfManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicManualPINVOKE.ImfManager_SWIGUpcast(cPtr), cMemoryOwn)
29         {
30             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
31         }
32
33         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImfManager obj)
34         {
35             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
36         }
37
38         protected override void Dispose(DisposeTypes type)
39         {
40             if (disposed)
41             {
42                 return;
43             }
44
45             if (type == DisposeTypes.Explicit)
46             {
47                 //Called by User
48                 //Release your own managed resources here.
49                 //You should release all of your own disposable objects here.
50
51             }
52
53             //Release your own unmanaged resources here.
54             //You should not access any managed member here except static instance.
55             //because the execution order of Finalizes is non-deterministic.
56
57             if (_imfKeyboardTypeChangedEventCallback != null)
58             {
59                 KeyboardTypeChangedSignal().Disconnect(_imfKeyboardTypeChangedEventCallback);
60             }
61
62             if (_imfManagerLanguageChangedEventCallback != null)
63             {
64                 LanguageChangedSignal().Disconnect(_imfManagerLanguageChangedEventCallback);
65             }
66
67             if (_imfManagerResizedEventCallback != null)
68             {
69                 ResizedSignal().Disconnect(_imfManagerResizedEventCallback);
70             }
71
72             if (_imfManagerStatusChangedEventCallback != null)
73             {
74                 StatusChangedSignal().Disconnect(_imfManagerStatusChangedEventCallback);
75             }
76
77             if (_imfManagerEventReceivedEventCallback != null)
78             {
79                 EventReceivedSignal().Disconnect(_imfManagerEventReceivedEventCallback);
80             }
81
82             if (_imfManagerActivatedEventCallback != null)
83             {
84                 ActivatedSignal().Disconnect(_imfManagerActivatedEventCallback);
85             }
86
87             if (swigCPtr.Handle != global::System.IntPtr.Zero)
88             {
89                 if (swigCMemOwn)
90                 {
91                     swigCMemOwn = false;
92                     NDalicManualPINVOKE.delete_ImfManager(swigCPtr);
93                 }
94                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
95             }
96
97             base.Dispose(type);
98         }
99
100         /// <summary>
101         /// This structure is used to pass on data from the IMF regarding predictive text.
102         /// </summary>
103         public class ImfEventData : global::System.IDisposable
104         {
105             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
106             protected bool swigCMemOwn;
107
108             internal ImfEventData(global::System.IntPtr cPtr, bool cMemoryOwn)
109             {
110                 swigCMemOwn = cMemoryOwn;
111                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
112             }
113
114             internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImfEventData obj)
115             {
116                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
117             }
118
119             //A Flag to check who called Dispose(). (By User or DisposeQueue)
120             private bool isDisposeQueued = false;
121             //A Flat to check if it is already disposed.
122             protected bool disposed = false;
123
124
125             ~ImfEventData()
126             {
127                 if (!isDisposeQueued)
128                 {
129                     isDisposeQueued = true;
130                     DisposeQueue.Instance.Add(this);
131                 }
132             }
133
134             /// <summary>
135             /// Dispose pattern
136             /// </summary>
137             public void Dispose()
138             {
139                 //Throw excpetion if Dispose() is called in separate thread.
140                 if (!Window.IsInstalled())
141                 {
142                     throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
143                 }
144
145                 if (isDisposeQueued)
146                 {
147                     Dispose(DisposeTypes.Implicit);
148                 }
149                 else
150                 {
151                     Dispose(DisposeTypes.Explicit);
152                     System.GC.SuppressFinalize(this);
153                 }
154             }
155
156             protected virtual void Dispose(DisposeTypes type)
157             {
158                 if (disposed)
159                 {
160                     return;
161                 }
162
163                 if (type == DisposeTypes.Explicit)
164                 {
165                     //Called by User
166                     //Release your own managed resources here.
167                     //You should release all of your own disposable objects here.
168
169                 }
170
171                 //Release your own unmanaged resources here.
172                 //You should not access any managed member here except static instance.
173                 //because the execution order of Finalizes is non-deterministic.
174
175                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
176                 {
177                     if (swigCMemOwn)
178                     {
179                         swigCMemOwn = false;
180                         NDalicManualPINVOKE.delete_ImfManager_ImfEventData(swigCPtr);
181                     }
182                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
183                 }
184
185                 disposed = true;
186             }
187
188             internal static ImfEventData GetImfEventDataFromPtr(global::System.IntPtr cPtr)
189             {
190                 ImfEventData ret = new ImfEventData(cPtr, false);
191                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192                 return ret;
193             }
194
195             /// <summary>
196             /// Default Constructor
197             /// </summary>
198             public ImfEventData() : this(NDalicManualPINVOKE.new_ImfManager_ImfEventData__SWIG_0(), true)
199             {
200                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201             }
202
203             /// <summary>
204             /// Constructor
205             /// </summary>
206             /// <param name="aEventName">The name of the event from the IMF.</param>
207             /// <param name="aPredictiveString">The pre-edit or commit string.</param>
208             /// <param name="aCursorOffset">Start position from the current cursor position to start deleting characters.</param>
209             /// <param name="aNumberOfChars">The number of characters to delete from the cursorOffset.</param>
210             public ImfEventData(ImfManager.ImfEvent aEventName, string aPredictiveString, int aCursorOffset, int aNumberOfChars) : this(NDalicManualPINVOKE.new_ImfManager_ImfEventData__SWIG_1((int)aEventName, aPredictiveString, aCursorOffset, aNumberOfChars), true)
211             {
212                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213             }
214
215             /// <summary>
216             /// The pre-edit or commit string.
217             /// </summary>
218             public string PredictiveString
219             {
220                 set
221                 {
222                     NDalicManualPINVOKE.ImfManager_ImfEventData_predictiveString_set(swigCPtr, value);
223                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224                 }
225                 get
226                 {
227                     string ret = NDalicManualPINVOKE.ImfManager_ImfEventData_predictiveString_get(swigCPtr);
228                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229                     return ret;
230                 }
231             }
232
233             /// <summary>
234             /// The name of the event from the IMF.
235             /// </summary>
236             public ImfManager.ImfEvent EventName
237             {
238                 set
239                 {
240                     NDalicManualPINVOKE.ImfManager_ImfEventData_eventName_set(swigCPtr, (int)value);
241                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242                 }
243                 get
244                 {
245                     ImfManager.ImfEvent ret = (ImfManager.ImfEvent)NDalicManualPINVOKE.ImfManager_ImfEventData_eventName_get(swigCPtr);
246                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247                     return ret;
248                 }
249             }
250
251             /// <summary>
252             /// Start position from the current cursor position to start deleting characters.
253             /// </summary>
254             public int CursorOffset
255             {
256                 set
257                 {
258                     NDalicManualPINVOKE.ImfManager_ImfEventData_cursorOffset_set(swigCPtr, value);
259                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
260                 }
261                 get
262                 {
263                     int ret = NDalicManualPINVOKE.ImfManager_ImfEventData_cursorOffset_get(swigCPtr);
264                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265                     return ret;
266                 }
267             }
268
269             /// <summary>
270             /// Number of characters to delete from the cursorOffset.
271             /// </summary>
272             public int NumberOfChars
273             {
274                 set
275                 {
276                     NDalicManualPINVOKE.ImfManager_ImfEventData_numberOfChars_set(swigCPtr, value);
277                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
278                 }
279                 get
280                 {
281                     int ret = NDalicManualPINVOKE.ImfManager_ImfEventData_numberOfChars_get(swigCPtr);
282                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283                     return ret;
284                 }
285             }
286
287         }
288
289         /// <summary>
290         /// Data required by IMF from the callback.
291         /// </summary>
292         public class ImfCallbackData : global::System.IDisposable
293         {
294             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
295             protected bool swigCMemOwn;
296
297             internal IntPtr GetImfCallbackDataPtr()
298             {
299                 return (IntPtr)swigCPtr;
300             }
301
302             internal ImfCallbackData(global::System.IntPtr cPtr, bool cMemoryOwn)
303             {
304                 swigCMemOwn = cMemoryOwn;
305                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
306             }
307
308             internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImfCallbackData obj)
309             {
310                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
311             }
312
313             //A Flag to check who called Dispose(). (By User or DisposeQueue)
314             private bool isDisposeQueued = false;
315             //A Flat to check if it is already disposed.
316             protected bool disposed = false;
317
318
319             ~ImfCallbackData()
320             {
321                 if (!isDisposeQueued)
322                 {
323                     isDisposeQueued = true;
324                     DisposeQueue.Instance.Add(this);
325                 }
326             }
327
328             /// <summary>
329             /// Dispose pattern
330             /// </summary>
331             public void Dispose()
332             {
333                 //Throw excpetion if Dispose() is called in separate thread.
334                 if (!Window.IsInstalled())
335                 {
336                     throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
337                 }
338
339                 if (isDisposeQueued)
340                 {
341                     Dispose(DisposeTypes.Implicit);
342                 }
343                 else
344                 {
345                     Dispose(DisposeTypes.Explicit);
346                     System.GC.SuppressFinalize(this);
347                 }
348             }
349
350             protected virtual void Dispose(DisposeTypes type)
351             {
352                 if (disposed)
353                 {
354                     return;
355                 }
356
357                 if (type == DisposeTypes.Explicit)
358                 {
359                     //Called by User
360                     //Release your own managed resources here.
361                     //You should release all of your own disposable objects here.
362
363                 }
364
365                 //Release your own unmanaged resources here.
366                 //You should not access any managed member here except static instance.
367                 //because the execution order of Finalizes is non-deterministic.
368
369                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
370                 {
371                     if (swigCMemOwn)
372                     {
373                         swigCMemOwn = false;
374                         NDalicManualPINVOKE.delete_ImfManager_ImfCallbackData(swigCPtr);
375                     }
376                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
377                 }
378
379                 disposed = true;
380             }
381
382             internal static ImfCallbackData GetImfCallbackDataFromPtr(global::System.IntPtr cPtr)
383             {
384                 ImfCallbackData ret = new ImfCallbackData(cPtr, false);
385                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
386                 return ret;
387             }
388
389             /// <summary>
390             /// Default Constructor
391             /// </summary>
392             public ImfCallbackData() : this(NDalicManualPINVOKE.new_ImfManager_ImfCallbackData__SWIG_0(), true)
393             {
394                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
395             }
396
397             /// <summary>
398             /// Constructor
399             /// </summary>
400             /// <param name="aUpdate">True if cursor position needs to be updated.</param>
401             /// <param name="aCursorPosition">New position of cursor.</param>
402             /// <param name="aCurrentText">Current text string.</param>
403             /// <param name="aPreeditResetRequired">Flag if preedit reset is required.</param>
404             public ImfCallbackData(bool aUpdate, int aCursorPosition, string aCurrentText, bool aPreeditResetRequired) : this(NDalicManualPINVOKE.new_ImfManager_ImfCallbackData__SWIG_1(aUpdate, aCursorPosition, aCurrentText, aPreeditResetRequired), true)
405             {
406                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
407             }
408
409             /// <summary>
410             /// Current text string.
411             /// </summary>
412             public string CurrentText
413             {
414                 set
415                 {
416                     NDalicManualPINVOKE.ImfManager_ImfCallbackData_currentText_set(swigCPtr, value);
417                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418                 }
419                 get
420                 {
421                     string ret = NDalicManualPINVOKE.ImfManager_ImfCallbackData_currentText_get(swigCPtr);
422                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
423                     return ret;
424                 }
425             }
426
427             /// <summary>
428             /// Current text string.
429             /// </summary>
430             public int CursorPosition
431             {
432                 set
433                 {
434                     NDalicManualPINVOKE.ImfManager_ImfCallbackData_cursorPosition_set(swigCPtr, value);
435                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436                 }
437                 get
438                 {
439                     int ret = NDalicManualPINVOKE.ImfManager_ImfCallbackData_cursorPosition_get(swigCPtr);
440                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
441                     return ret;
442                 }
443             }
444
445             /// <summary>
446             /// If cursor position needs to be updated.
447             /// </summary>
448             public bool Update
449             {
450                 set
451                 {
452                     NDalicManualPINVOKE.ImfManager_ImfCallbackData_update_set(swigCPtr, value);
453                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
454                 }
455                 get
456                 {
457                     bool ret = NDalicManualPINVOKE.ImfManager_ImfCallbackData_update_get(swigCPtr);
458                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
459                     return ret;
460                 }
461             }
462
463             /// <summary>
464             /// Flag if preedit reset is required.
465             /// </summary>
466             public bool PreeditResetRequired
467             {
468                 set
469                 {
470                     NDalicManualPINVOKE.ImfManager_ImfCallbackData_preeditResetRequired_set(swigCPtr, value);
471                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
472                 }
473                 get
474                 {
475                     bool ret = NDalicManualPINVOKE.ImfManager_ImfCallbackData_preeditResetRequired_get(swigCPtr);
476                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
477                     return ret;
478                 }
479             }
480
481         }
482
483         /// <summary>
484         /// Retrieve a handle to the instance of ImfManager.
485         /// </summary>
486         /// <returns>A handle to the ImfManager.</returns>
487         public static ImfManager Get()
488         {
489             ImfManager ret = new ImfManager(NDalicManualPINVOKE.ImfManager_Get(), true);
490             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
491             return ret;
492         }
493
494         /// <summary>
495         /// Activate the IMF.<br/>
496         /// It means that the text editing is started at somewhere.<br/>
497         /// If the H/W keyboard isn't connected then it will show the virtual keyboard.
498         /// </summary>
499         public void Activate()
500         {
501             NDalicManualPINVOKE.ImfManager_Activate(swigCPtr);
502             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
503         }
504
505         /// <summary>
506         /// Deactivate the IMF.<br/>
507         /// It means that the text editing is finished at somewhere.
508         /// </summary>
509         public void Deactivate()
510         {
511             NDalicManualPINVOKE.ImfManager_Deactivate(swigCPtr);
512             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
513         }
514
515         /// <summary>
516         /// Get the restoration status, which controls if the keyboard is restored after the focus lost then regained.<br/>
517         /// If true then keyboard will be restored (activated) after focus is regained.
518         /// </summary>
519         /// <returns>Restoration status.</returns>
520         public bool RestoreAfterFocusLost()
521         {
522             bool ret = NDalicManualPINVOKE.ImfManager_RestoreAfterFocusLost(swigCPtr);
523             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
524             return ret;
525         }
526
527         /// <summary>
528         /// Set status whether the IMF has to restore the keyboard after losing focus.
529         /// </summary>
530         /// <param name="toggle">True means that keyboard should be restored after focus lost and regained.</param>
531         public void SetRestoreAfterFocusLost(bool toggle)
532         {
533             NDalicManualPINVOKE.ImfManager_SetRestoreAfterFocusLost(swigCPtr, toggle);
534             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
535         }
536
537         /// <summary>
538         /// Send message reset the pred-edit state / imf module.
539         /// </summary>
540         public new void Reset()
541         {
542             NDalicManualPINVOKE.ImfManager_Reset(swigCPtr);
543             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
544         }
545
546         /// <summary>
547         /// Notifies IMF context that the cursor position has changed, required for features like auto-capitalisation.
548         /// </summary>
549         public void NotifyCursorPosition()
550         {
551             NDalicManualPINVOKE.ImfManager_NotifyCursorPosition(swigCPtr);
552             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
553         }
554
555         /// <summary>
556         /// Sets cursor position stored in VirtualKeyboard, this is required by the IMF context.
557         /// </summary>
558         /// <param name="cursorPosition">Position of cursor.</param>
559         public void SetCursorPosition(uint cursorPosition)
560         {
561             NDalicManualPINVOKE.ImfManager_SetCursorPosition(swigCPtr, cursorPosition);
562             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
563         }
564
565         /// <summary>
566         /// Gets cursor position stored in VirtualKeyboard, this is required by the IMF context.
567         /// </summary>
568         /// <returns>Current position of cursor</returns>
569         public uint GetCursorPosition()
570         {
571             uint ret = NDalicManualPINVOKE.ImfManager_GetCursorPosition(swigCPtr);
572             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
573             return ret;
574         }
575
576         /// <summary>
577         /// Method to store the string required by the IMF, this is used to provide predictive word suggestions.
578         /// </summary>
579         /// <param name="text">The text string surrounding the current cursor point.</param>
580         public void SetSurroundingText(string text)
581         {
582             NDalicManualPINVOKE.ImfManager_SetSurroundingText(swigCPtr, text);
583             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584         }
585
586         /// <summary>
587         /// Gets current text string set within the IMF manager, this is used to offer predictive suggestions.
588         /// </summary>
589         /// <returns>Surrounding text.</returns>
590         public string GetSurroundingText()
591         {
592             string ret = NDalicManualPINVOKE.ImfManager_GetSurroundingText(swigCPtr);
593             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
594             return ret;
595         }
596
597         /// <summary>
598         /// Notifies IMF context that text input is set to multi line or not.
599         /// </summary>
600         /// <param name="multiLine">True if multiline text input is used.</param>
601         public void NotifyTextInputMultiLine(bool multiLine)
602         {
603             NDalicManualPINVOKE.ImfManager_NotifyTextInputMultiLine(swigCPtr, multiLine);
604             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
605         }
606
607         /// <summary>
608         /// Returns text direction of the keyboard's current input language.
609         /// </summary>
610         /// <returns>The direction of the text.</returns>
611         public ImfManager.TextDirection GetTextDirection()
612         {
613             ImfManager.TextDirection ret = (ImfManager.TextDirection)NDalicManualPINVOKE.ImfManager_GetTextDirection(swigCPtr);
614             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
615             return ret;
616         }
617
618         /// <summary>
619         /// Provides size and position of keyboard.<br/>
620         /// Position is relative to whether keyboard is visible or not.<br/>
621         /// If keyboard is not visible then position will be off the screen.<br/>
622         /// If keyboard is not being shown when this method is called the keyboard is partially setup (IMFContext) to get<br/>
623         /// the values then taken down.  So ideally GetInputMethodArea() should be called after Show().
624         /// </summary>
625         /// <returns>Rectangle which is keyboard panel x, y, width, height</returns>
626         public Rectangle GetInputMethodArea()
627         {
628             Rectangle ret = new Rectangle(NDalicManualPINVOKE.ImfManager_GetInputMethodArea(swigCPtr), true);
629             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
630             return ret;
631         }
632
633         internal void ApplyOptions(InputMethodOptions options)
634         {
635             NDalicManualPINVOKE.ImfManager_ApplyOptions(swigCPtr, InputMethodOptions.getCPtr(options));
636             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
637         }
638
639         /// <summary>
640         /// Sets up the input-panel specific data.
641         /// </summary>
642         /// <param name="text">The specific data to be set to the input panel.</param>
643         public void SetInputPanelUserData(string text)
644         {
645             NDalicManualPINVOKE.ImfManager_SetInputPanelUserData(swigCPtr, text);
646             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
647         }
648
649         /// <summary>
650         /// Gets the specific data of the current active input panel.
651         /// </summary>
652         /// <param name="text">The specific data to be got from the input panel.</param>
653         public void GetInputPanelUserData(out string text)
654         {
655             NDalicManualPINVOKE.ImfManager_GetInputPanelUserData(swigCPtr, out text);
656             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
657         }
658
659         /// <summary>
660         /// Gets the state of the current active input panel.
661         /// </summary>
662         /// <returns>The state of the input panel.</returns>
663         public ImfManager.State GetInputPanelState()
664         {
665             ImfManager.State ret = (ImfManager.State)NDalicManualPINVOKE.ImfManager_GetInputPanelState(swigCPtr);
666             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
667             return ret;
668         }
669
670         /// <summary>
671         /// Sets the return key on the input panel to be visible or invisible.<br/>
672         /// The default is true.
673         /// </summary>
674         /// <param name="visible">True if the return key is visible(enabled), false otherwise.</param>
675         public void SetReturnKeyState(bool visible)
676         {
677             NDalicManualPINVOKE.ImfManager_SetReturnKeyState(swigCPtr, visible);
678             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
679         }
680
681         /// <summary>
682         /// Enable to show the input panel automatically when focused.
683         /// </summary>
684         /// <param name="enabled">If true, the input panel will be shown when focused.</param>
685         public void AutoEnableInputPanel(bool enabled)
686         {
687             NDalicManualPINVOKE.ImfManager_AutoEnableInputPanel(swigCPtr, enabled);
688             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
689         }
690
691         /// <summary>
692         /// Shows the input panel.
693         /// </summary>
694         public void ShowInputPanel()
695         {
696             NDalicManualPINVOKE.ImfManager_ShowInputPanel(swigCPtr);
697             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
698         }
699
700         /// <summary>
701         /// Hides the input panel.
702         /// </summary>
703         public void HideInputPanel()
704         {
705             NDalicManualPINVOKE.ImfManager_HideInputPanel(swigCPtr);
706             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707         }
708
709         /// <summary>
710         /// Gets the keyboard type.<br/>
711         /// The default keyboard type is SoftwareKeyboard.
712         /// </summary>
713         /// <returns>The keyboard type</returns>
714         public ImfManager.KeyboardType GetKeyboardType()
715         {
716             ImfManager.KeyboardType ret = (ImfManager.KeyboardType)NDalicManualPINVOKE.ImfManager_GetKeyboardType(swigCPtr);
717             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
718             return ret;
719         }
720
721         /// <summary>
722         /// Gets the current language locale of the input panel.<br/>
723         /// Ex) en_US, en_GB, en_PH, fr_FR, ...
724         /// </summary>
725         /// <returns>The current language locale of the input panel.</returns>
726         public string GetInputPanelLocale()
727         {
728             string ret = NDalicManualPINVOKE.ImfManager_GetInputPanelLocale(swigCPtr);
729             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
730             return ret;
731         }
732
733         /// <summary>
734         /// Constructor
735         /// </summary>
736         public ImfManager() : this(NDalicManualPINVOKE.new_ImfManager(), true)
737         {
738             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
739         }
740
741         internal static ImfManager GetImfManagerFromPtr(global::System.IntPtr cPtr)
742         {
743             ImfManager ret = new ImfManager(cPtr, false);
744             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
745             return ret;
746         }
747
748         /// <summary>
749         /// ImfManager activated event arguments.
750         /// </summary>
751         public class ImfManagerActivatedEventArgs : EventArgs
752         {
753             public ImfManager ImfManager
754             {
755                 get;
756                 set;
757             }
758         }
759
760         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
761         private delegate void ImfManagerActivatedEventCallbackType(global::System.IntPtr data);
762         private ImfManagerActivatedEventCallbackType _imfManagerActivatedEventCallback;
763
764         private event EventHandler<ImfManagerActivatedEventArgs> _imfManagerActivatedEventHandler;
765
766         /// <summary>
767         /// ImfManager activated.
768         /// </summary>
769         public event EventHandler<ImfManagerActivatedEventArgs> ImfManagerActivated
770         {
771             add
772             {
773                 if (_imfManagerActivatedEventHandler == null)
774                 {
775                     _imfManagerActivatedEventCallback = OnImfManagerActivated;
776                     ActivatedSignal().Connect(_imfManagerActivatedEventCallback);
777                 }
778
779                 _imfManagerActivatedEventHandler += value;
780             }
781             remove
782             {
783                 _imfManagerActivatedEventHandler -= value;
784
785                 if (_imfManagerActivatedEventHandler == null && _imfManagerActivatedEventCallback != null)
786                 {
787                     ActivatedSignal().Disconnect(_imfManagerActivatedEventCallback);
788                 }
789             }
790         }
791
792         private void OnImfManagerActivated(global::System.IntPtr data)
793         {
794             ImfManagerActivatedEventArgs e = new ImfManagerActivatedEventArgs();
795
796             e.ImfManager = ImfManager.GetImfManagerFromPtr(data);
797
798             if (_imfManagerActivatedEventHandler != null)
799             {
800                 _imfManagerActivatedEventHandler(this, e);
801             }
802         }
803
804         internal ActivatedSignalType ActivatedSignal()
805         {
806             ActivatedSignalType ret = new ActivatedSignalType(NDalicManualPINVOKE.ImfManager_ActivatedSignal(swigCPtr), false);
807             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
808             return ret;
809         }
810
811         /// <summary>
812         /// ImfManager event received event arguments.
813         /// </summary>
814         public class ImfManagerEventReceivedEventArgs : EventArgs
815         {
816             public ImfManager ImfManager
817             {
818                 get;
819                 set;
820             }
821
822             public ImfEventData ImfEventData
823             {
824                 get;
825                 set;
826             }
827         }
828
829         private delegate global::System.IntPtr ImfManagerEventReceivedEventCallbackType(global::System.IntPtr imfManager, global::System.IntPtr imfEventData);
830         private ImfManagerEventReceivedEventCallbackType _imfManagerEventReceivedEventCallback;
831
832         private event EventHandlerWithReturnType<object, ImfManagerEventReceivedEventArgs, ImfCallbackData> _imfManagerEventReceivedEventHandler;
833         /// <summary>
834         /// ImfManager event received.
835         /// </summary>
836         public event EventHandlerWithReturnType<object, ImfManagerEventReceivedEventArgs, ImfCallbackData> ImfManagerEventReceived
837         {
838             add
839             {
840                 if (_imfManagerEventReceivedEventHandler == null)
841                 {
842                     _imfManagerEventReceivedEventCallback = OnImfManagerEventReceived;
843                     EventReceivedSignal().Connect(_imfManagerEventReceivedEventCallback);
844                 }
845
846                 _imfManagerEventReceivedEventHandler += value;
847             }
848             remove
849             {
850                 _imfManagerEventReceivedEventHandler -= value;
851
852                 if (_imfManagerEventReceivedEventHandler == null && _imfManagerEventReceivedEventCallback != null)
853                 {
854                     EventReceivedSignal().Disconnect(_imfManagerEventReceivedEventCallback);
855                 }
856             }
857         }
858
859         private global::System.IntPtr OnImfManagerEventReceived(global::System.IntPtr imfManager, global::System.IntPtr imfEventData)
860         {
861             ImfCallbackData imfCallbackData = null;
862
863             ImfManagerEventReceivedEventArgs e = new ImfManagerEventReceivedEventArgs();
864
865             e.ImfManager = ImfManager.GetImfManagerFromPtr(imfManager);
866             e.ImfEventData = ImfEventData.GetImfEventDataFromPtr(imfEventData);
867
868             if (_imfManagerEventReceivedEventHandler != null)
869             {
870                 imfCallbackData = _imfManagerEventReceivedEventHandler(this, e);
871             }
872             if (imfCallbackData != null)
873             {
874                 return imfCallbackData.GetImfCallbackDataPtr();
875             }
876             else
877             {
878                 return new ImfCallbackData().GetImfCallbackDataPtr();
879             }
880         }
881
882         internal ImfEventSignalType EventReceivedSignal()
883         {
884             ImfEventSignalType ret = new ImfEventSignalType(NDalicManualPINVOKE.ImfManager_EventReceivedSignal(swigCPtr), false);
885             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
886             return ret;
887         }
888
889         /// <summary>
890         /// ImfManager status changed event arguments.
891         /// </summary>
892         public class ImfManagerStatusChangedEventArgs : EventArgs
893         {
894             public bool StatusChanged
895             {
896                 get;
897                 set;
898             }
899         }
900
901         private delegate void ImfManagerStatusChangedEventCallbackType(bool statusChanged);
902         private ImfManagerStatusChangedEventCallbackType _imfManagerStatusChangedEventCallback;
903
904         private event EventHandler<ImfManagerStatusChangedEventArgs> _imfManagerStatusChangedEventHandler;
905         /// <summary>
906         /// ImfManager status changed.
907         /// </summary>
908         public event EventHandler<ImfManagerStatusChangedEventArgs> ImfManagerStatusChanged
909         {
910             add
911             {
912                 if (_imfManagerStatusChangedEventHandler == null)
913                 {
914                     _imfManagerStatusChangedEventCallback = OnImfManagerStatusChanged;
915                     StatusChangedSignal().Connect(_imfManagerStatusChangedEventCallback);
916                 }
917
918                 _imfManagerStatusChangedEventHandler += value;
919             }
920             remove
921             {
922                 _imfManagerStatusChangedEventHandler -= value;
923
924                 if (_imfManagerStatusChangedEventHandler == null && _imfManagerStatusChangedEventCallback != null)
925                 {
926                     StatusChangedSignal().Disconnect(_imfManagerStatusChangedEventCallback);
927                 }
928             }
929         }
930
931         private void OnImfManagerStatusChanged(bool statusChanged)
932         {
933             ImfManagerStatusChangedEventArgs e = new ImfManagerStatusChangedEventArgs();
934
935             e.StatusChanged = statusChanged;
936
937             if (_imfManagerStatusChangedEventHandler != null)
938             {
939                 _imfManagerStatusChangedEventHandler(this, e);
940             }
941         }
942
943         internal StatusSignalType StatusChangedSignal()
944         {
945             StatusSignalType ret = new StatusSignalType(NDalicManualPINVOKE.ImfManager_StatusChangedSignal(swigCPtr), false);
946             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
947             return ret;
948         }
949
950         private delegate void ImfManagerResizedEventCallbackType();
951         private ImfManagerResizedEventCallbackType _imfManagerResizedEventCallback;
952
953         private event EventHandler _imfManagerResizedEventHandler;
954         /// <summary>
955         /// ImfManager resized.
956         /// </summary>
957         public event EventHandler ImfManagerResized
958         {
959             add
960             {
961                 if (_imfManagerResizedEventHandler == null)
962                 {
963                     _imfManagerResizedEventCallback = OnImfManagerResized;
964                     ResizedSignal().Connect(_imfManagerResizedEventCallback);
965                 }
966
967                 _imfManagerResizedEventHandler += value;
968             }
969             remove
970             {
971                 _imfManagerResizedEventHandler -= value;
972
973                 if (_imfManagerResizedEventHandler == null && _imfManagerResizedEventCallback != null)
974                 {
975                     ResizedSignal().Disconnect(_imfManagerResizedEventCallback);
976                 }
977             }
978         }
979
980         private void OnImfManagerResized()
981         {
982             if (_imfManagerResizedEventHandler != null)
983             {
984                 _imfManagerResizedEventHandler(this, null);
985             }
986         }
987
988         internal ImfVoidSignalType ResizedSignal()
989         {
990             ImfVoidSignalType ret = new ImfVoidSignalType(NDalicManualPINVOKE.ImfManager_ResizedSignal(swigCPtr), true);
991             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
992             return ret;
993         }
994
995         private delegate void ImfManagerLanguageChangedEventCallbackType();
996         private ImfManagerLanguageChangedEventCallbackType _imfManagerLanguageChangedEventCallback;
997
998         private event EventHandler _imfManagerLanguageChangedEventHandler;
999         /// <summary>
1000         /// ImfManager language changed.
1001         /// </summary>
1002         public event EventHandler ImfManagerLanguageChanged
1003         {
1004             add
1005             {
1006                 if (_imfManagerLanguageChangedEventHandler == null)
1007                 {
1008                     _imfManagerLanguageChangedEventCallback = OnImfManagerLanguageChanged;
1009                     LanguageChangedSignal().Connect(_imfManagerLanguageChangedEventCallback);
1010                 }
1011
1012                 _imfManagerLanguageChangedEventHandler += value;
1013             }
1014             remove
1015             {
1016                 _imfManagerLanguageChangedEventHandler -= value;
1017
1018                 if (_imfManagerLanguageChangedEventHandler == null && _imfManagerLanguageChangedEventCallback != null)
1019                 {
1020                     LanguageChangedSignal().Disconnect(_imfManagerLanguageChangedEventCallback);
1021                 }
1022             }
1023         }
1024
1025         private void OnImfManagerLanguageChanged()
1026         {
1027             if (_imfManagerLanguageChangedEventHandler != null)
1028             {
1029                 _imfManagerLanguageChangedEventHandler(this, null);
1030             }
1031         }
1032
1033         internal ImfVoidSignalType LanguageChangedSignal()
1034         {
1035             ImfVoidSignalType ret = new ImfVoidSignalType(NDalicManualPINVOKE.ImfManager_LanguageChangedSignal(swigCPtr), true);
1036             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1037             return ret;
1038         }
1039
1040         /// <summary>
1041         /// ImfManager keyboard type changed event arguments.
1042         /// </summary>
1043         public class ImfKeyboardTypeChangedEventArgs : EventArgs
1044         {
1045             public KeyboardType KeyboardType
1046             {
1047                 get;
1048                 set;
1049             }
1050         }
1051
1052         private delegate void ImfKeyboardTypeChangedEventCallbackType(KeyboardType type);
1053         private ImfKeyboardTypeChangedEventCallbackType _imfKeyboardTypeChangedEventCallback;
1054
1055         private event EventHandler<ImfKeyboardTypeChangedEventArgs> _imfKeyboardTypeChangedEventHandler;
1056         /// <summary>
1057         /// ImfManager keyboard type changed.
1058         /// </summary>
1059         public event EventHandler<ImfKeyboardTypeChangedEventArgs> ImfKeyboardTypeChanged
1060         {
1061             add
1062             {
1063                 if (_imfKeyboardTypeChangedEventHandler == null)
1064                 {
1065                     _imfKeyboardTypeChangedEventCallback = OnImfKeyboardTypeChanged;
1066                     KeyboardTypeChangedSignal().Connect(_imfKeyboardTypeChangedEventCallback);
1067                 }
1068
1069                 _imfKeyboardTypeChangedEventHandler += value;
1070             }
1071             remove
1072             {
1073                 _imfKeyboardTypeChangedEventHandler -= value;
1074
1075                 if (_imfKeyboardTypeChangedEventHandler == null && _imfKeyboardTypeChangedEventCallback != null)
1076                 {
1077                     KeyboardTypeChangedSignal().Disconnect(_imfKeyboardTypeChangedEventCallback);
1078                 }
1079             }
1080         }
1081
1082         private void OnImfKeyboardTypeChanged(KeyboardType type)
1083         {
1084             ImfKeyboardTypeChangedEventArgs e = new ImfKeyboardTypeChangedEventArgs();
1085
1086             e.KeyboardType = type;
1087
1088             if (_imfKeyboardTypeChangedEventHandler != null)
1089             {
1090                 _imfKeyboardTypeChangedEventHandler(this, e);
1091             }
1092         }
1093
1094         internal KeyboardTypeSignalType KeyboardTypeChangedSignal()
1095         {
1096             KeyboardTypeSignalType ret = new KeyboardTypeSignalType(NDalicManualPINVOKE.ImfManager_KeyboardTypeChangedSignal(swigCPtr), false);
1097             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1098             return ret;
1099         }
1100
1101         /// <summary>
1102         /// The direction of text.
1103         /// </summary>
1104         public enum TextDirection
1105         {
1106             /// <summary>
1107             /// Left to right.
1108             /// </summary>
1109             LeftToRight,
1110             /// <summary>
1111             /// Right to left.
1112             /// </summary>
1113             RightToLeft
1114         }
1115
1116         /// <summary>
1117         /// Events that are generated by the IMF.
1118         /// </summary>
1119         public enum ImfEvent
1120         {
1121             /// <summary>
1122             /// No event.
1123             /// </summary>
1124             Void,
1125             /// <summary>
1126             /// Pre-Edit changed.
1127             /// </summary>
1128             Preedit,
1129             /// <summary>
1130             /// Commit recieved.
1131             /// </summary>
1132             Commit,
1133             /// <summary>
1134             /// Event to delete a range of characters from the string.
1135             /// </summary>
1136             DeleteSurrounding,
1137             /// <summary>
1138             /// Event to query string and cursor position.
1139             /// </summary>
1140             GetSurrounding,
1141             /// <summary>
1142             /// Private command sent from the input panel.
1143             /// </summary>
1144             PrivateCommand
1145         }
1146
1147         /// <summary>
1148         /// Enumeration for state of the input panel.
1149         /// </summary>
1150         public enum State
1151         {
1152             /// <summary>
1153             /// Unknown state.
1154             /// </summary>
1155             Default = 0,
1156             /// <summary>
1157             /// Input panel is shown.
1158             /// </summary>
1159             Show,
1160             /// <summary>
1161             /// Input panel is hidden.
1162             /// </summary>
1163             Hide,
1164             /// <summary>
1165             /// Input panel in process of being shown.
1166             /// </summary>
1167             WillShow
1168         }
1169
1170         /// <summary>
1171         /// Enumeration for the type of Keyboard.
1172         /// </summary>
1173         public enum KeyboardType
1174         {
1175             /// <summary>
1176             /// Software keyboard (Virtual keyboard) is default.
1177             /// </summary>
1178             SoftwareKeyboard,
1179             /// <summary>
1180             /// Hardware keyboard.
1181             /// </summary>
1182             HardwareKeyboard
1183         }
1184     }
1185 }