2 * Copyright(c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Runtime.InteropServices;
20 using System.ComponentModel;
25 /// Specifically manages the input method framework which enables the virtual or hardware keyboards.
27 /// <since_tizen> 3 </since_tizen>
28 [Obsolete("Please do not use! This will be deprecated! Please use InputMethodContext instead!")]
29 [EditorBrowsable(EditorBrowsableState.Never)]
30 public class ImfManager : BaseHandle
32 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
34 private ActivatedEventCallbackType _activatedEventCallback;
35 private EventReceivedEventCallbackType _eventReceivedEventCallback;
36 private StatusChangedEventCallbackType _statusChangedEventCallback;
37 private ResizedEventCallbackType _resizedEventCallback;
38 private LanguageChangedEventCallbackType _languageChangedEventCallback;
39 private KeyboardTypeChangedEventCallbackType _keyboardTypeChangedEventCallback;
44 /// <since_tizen> 5 </since_tizen>
45 public ImfManager() : this(NDalicManualPINVOKE.InputMethodContext_New(), true)
47 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
51 internal ImfManager(ImfManager imfManager) : this(NDalicManualPINVOKE.new_InputMethodContext__SWIG_1(ImfManager.getCPtr(imfManager)), true)
53 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
56 internal ImfManager(IntPtr cPtr, bool cMemoryOwn) : base(NDalicManualPINVOKE.InputMethodContext_SWIGUpcast(cPtr), cMemoryOwn)
58 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
61 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
62 private delegate void ActivatedEventCallbackType(IntPtr data);
63 private delegate IntPtr EventReceivedEventCallbackType(IntPtr imfManager, IntPtr imfEventData);
64 private delegate void StatusChangedEventCallbackType(bool statusChanged);
65 private delegate void ResizedEventCallbackType(int resized);
66 private delegate void LanguageChangedEventCallbackType(int languageChanged);
67 private delegate void KeyboardTypeChangedEventCallbackType(KeyboardType type);
70 /// ImfManager activated.
72 /// <since_tizen> 4 </since_tizen>
73 public event EventHandler<ActivatedEventArgs> Activated
77 if (_activatedEventHandler == null)
79 _activatedEventCallback = OnActivated;
80 ActivatedSignal().Connect(_activatedEventCallback);
83 _activatedEventHandler += value;
87 _activatedEventHandler -= value;
89 if (_activatedEventHandler == null && _activatedEventCallback != null)
91 ActivatedSignal().Disconnect(_activatedEventCallback);
97 /// ImfManager event received.
99 /// <since_tizen> 4 </since_tizen>
100 public event EventHandlerWithReturnType<object, EventReceivedEventArgs, ImfCallbackData> EventReceived
104 if (_eventReceivedEventHandler == null)
106 _eventReceivedEventCallback = OnEventReceived;
107 EventReceivedSignal().Connect(_eventReceivedEventCallback);
110 _eventReceivedEventHandler += value;
114 _eventReceivedEventHandler -= value;
116 if (_eventReceivedEventHandler == null && _eventReceivedEventCallback != null)
118 EventReceivedSignal().Disconnect(_eventReceivedEventCallback);
124 /// ImfManager status changed.
126 /// <since_tizen> 4 </since_tizen>
127 public event EventHandler<StatusChangedEventArgs> StatusChanged
131 if (_statusChangedEventHandler == null)
133 _statusChangedEventCallback = OnStatusChanged;
134 StatusChangedSignal().Connect(_statusChangedEventCallback);
137 _statusChangedEventHandler += value;
141 _statusChangedEventHandler -= value;
143 if (_statusChangedEventHandler == null && _statusChangedEventCallback != null)
145 StatusChangedSignal().Disconnect(_statusChangedEventCallback);
151 /// ImfManager resized.
153 /// <since_tizen> 4 </since_tizen>
154 public event EventHandler<ResizedEventArgs> Resized
158 if (_resizedEventHandler == null)
160 _resizedEventCallback = OnResized;
161 ResizedSignal().Connect(_resizedEventCallback);
164 _resizedEventHandler += value;
168 _resizedEventHandler -= value;
170 if (_resizedEventHandler == null && _resizedEventCallback != null)
172 ResizedSignal().Disconnect(_resizedEventCallback);
178 /// ImfManager language changed.
180 /// <since_tizen> 4 </since_tizen>
181 public event EventHandler<LanguageChangedEventArgs> LanguageChanged
185 if (_languageChangedEventHandler == null)
187 _languageChangedEventCallback = OnLanguageChanged;
188 LanguageChangedSignal().Connect(_languageChangedEventCallback);
191 _languageChangedEventHandler += value;
195 _languageChangedEventHandler -= value;
197 if (_languageChangedEventHandler == null && _languageChangedEventCallback != null)
199 LanguageChangedSignal().Disconnect(_languageChangedEventCallback);
205 /// ImfManager keyboard type changed.
207 /// <since_tizen> 4 </since_tizen>
208 public event EventHandler<KeyboardTypeChangedEventArgs> KeyboardTypeChanged
212 if (_keyboardTypeChangedEventHandler == null)
214 _keyboardTypeChangedEventCallback = OnKeyboardTypeChanged;
215 KeyboardTypeChangedSignal().Connect(_keyboardTypeChangedEventCallback);
218 _keyboardTypeChangedEventHandler += value;
222 _keyboardTypeChangedEventHandler -= value;
224 if (_keyboardTypeChangedEventHandler == null && _keyboardTypeChangedEventCallback != null)
226 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
231 private event EventHandler<ActivatedEventArgs> _activatedEventHandler;
232 private event EventHandlerWithReturnType<object, EventReceivedEventArgs, ImfCallbackData> _eventReceivedEventHandler;
233 private event EventHandler<StatusChangedEventArgs> _statusChangedEventHandler;
234 private event EventHandler<ResizedEventArgs> _resizedEventHandler;
235 private event EventHandler<LanguageChangedEventArgs> _languageChangedEventHandler;
236 private event EventHandler<KeyboardTypeChangedEventArgs> _keyboardTypeChangedEventHandler;
239 /// The direction of the text.
241 /// <since_tizen> 3 </since_tizen>
242 public enum TextDirection
255 /// Events that are generated by the IMF.
257 /// <since_tizen> 3 </since_tizen>
263 /// <since_tizen> 4 </since_tizen>
266 /// Pre-Edit changed.
268 /// <since_tizen> 4 </since_tizen>
273 /// <since_tizen> 4 </since_tizen>
276 /// An event to delete a range of characters from the string.
278 /// <since_tizen> 4 </since_tizen>
281 /// An event to query string and the cursor position.
283 /// <since_tizen> 4 </since_tizen>
286 /// Private command sent from the input panel.
288 /// <since_tizen> 4 </since_tizen>
293 /// Enumeration for the state of the input panel.
295 /// <since_tizen> 3 </since_tizen>
301 /// <since_tizen> 4 </since_tizen>
304 /// Input panel is shown.
306 /// <since_tizen> 4 </since_tizen>
309 /// Input panel is hidden.
311 /// <since_tizen> 4 </since_tizen>
314 /// Input panel in process of being shown.
316 /// <since_tizen> 4 </since_tizen>
321 /// Enumeration for the types of keyboard.
323 /// <since_tizen> 4 </since_tizen>
324 public enum KeyboardType
327 /// Software keyboard (virtual keyboard) is default.
329 /// <since_tizen> 4 </since_tizen>
332 /// Hardware keyboard.
334 /// <since_tizen> 4 </since_tizen>
339 /// Gets the singleton of the ImfManager object.
341 /// <since_tizen> 5 </since_tizen>
342 public static ImfManager Instance
346 return new ImfManager();
351 /// Retrieves a handle to the instance of the ImfManager.
353 /// <returns>A handle to the ImfManager.</returns>
354 /// <since_tizen> 3 </since_tizen>
355 public static ImfManager Get()
357 return new ImfManager();
361 /// Destroys the context of the IMF.<br/>
363 /// <since_tizen> 5 </since_tizen>
364 public void DestroyContext()
366 NDalicManualPINVOKE.InputMethodContext_Finalize(swigCPtr);
367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
371 /// Destroy the context of the IMF.<br/>
373 /// <since_tizen> 4 </since_tizen>
374 /// Please do not use! This will be deprecated, instead please USE Tizen.NUI.ImfManager.Instance.DestroyContext()!
375 #pragma warning disable 0465
376 [Obsolete("Please do not use! This will be deprecated! Please use ImfManager.Instance.DestroyContext() instead!")]
377 [EditorBrowsable(EditorBrowsableState.Never)]
378 public void Finalize()
382 #pragma warning restore 0465
385 /// Activates the IMF.<br/>
386 /// It means that the text editing is started somewhere.<br/>
387 /// If the hardware keyboard isn't connected, then it will show the virtual keyboard.
389 /// <since_tizen> 3 </since_tizen>
390 public void Activate()
392 NDalicManualPINVOKE.InputMethodContext_Activate(swigCPtr);
393 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
397 /// Deactivates the IMF.<br/>
398 /// It means that the text editing is finished somewhere.
400 /// <since_tizen> 3 </since_tizen>
401 public void Deactivate()
403 NDalicManualPINVOKE.InputMethodContext_Deactivate(swigCPtr);
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
408 /// Gets the restoration status which controls if the keyboard is restored after the focus is lost and then regained.<br/>
409 /// If true, then the keyboard will be restored (activated) after focus is regained.
411 /// <returns>The restoration status.</returns>
412 /// <since_tizen> 3 </since_tizen>
413 public bool RestoreAfterFocusLost()
415 bool ret = NDalicManualPINVOKE.InputMethodContext_RestoreAfterFocusLost(swigCPtr);
416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
421 /// Sets the status whether the IMF has to restore the keyboard after losing focus.
423 /// <param name="toggle">True means that keyboard should be restored after the focus is lost and regained.</param>
424 /// <since_tizen> 3 </since_tizen>
425 public void SetRestoreAfterFocusLost(bool toggle)
427 NDalicManualPINVOKE.InputMethodContext_SetRestoreAfterFocusLost(swigCPtr, toggle);
428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
432 /// Sends a message reset to the preedit state or the IMF module.
434 /// <since_tizen> 3 </since_tizen>
435 public new void Reset()
437 NDalicManualPINVOKE.InputMethodContext_Reset(swigCPtr);
438 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
442 /// Notifies the IMF context that the cursor position has changed, required for features like auto-capitalization.
444 /// <since_tizen> 3 </since_tizen>
445 public void NotifyCursorPosition()
447 NDalicManualPINVOKE.InputMethodContext_NotifyCursorPosition(swigCPtr);
448 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452 /// Sets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
454 /// <param name="cursorPosition">The position of the cursor.</param>
455 /// <since_tizen> 3 </since_tizen>
456 public void SetCursorPosition(uint cursorPosition)
458 NDalicManualPINVOKE.InputMethodContext_SetCursorPosition(swigCPtr, cursorPosition);
459 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
463 /// Gets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
465 /// <returns>The current position of the cursor.</returns>
466 /// <since_tizen> 3 </since_tizen>
467 public uint GetCursorPosition()
469 uint ret = NDalicManualPINVOKE.InputMethodContext_GetCursorPosition(swigCPtr);
470 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
475 /// A method to store the string required by the IMF, this is used to provide predictive word suggestions.
477 /// <param name="text">The text string surrounding the current cursor point.</param>
478 /// <since_tizen> 3 </since_tizen>
479 public void SetSurroundingText(string text)
481 NDalicManualPINVOKE.InputMethodContext_SetSurroundingText(swigCPtr, text);
482 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
486 /// Gets the current text string set within the IMF manager, this is used to offer predictive suggestions.
488 /// <returns>The surrounding text.</returns>
489 /// <since_tizen> 3 </since_tizen>
490 public string GetSurroundingText()
492 string ret = NDalicManualPINVOKE.InputMethodContext_GetSurroundingText(swigCPtr);
493 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
498 /// Notifies the IMF context that text input is set to multiline or not.
500 /// <param name="multiLine">True if multiline text input is used.</param>
501 /// <since_tizen> 3 </since_tizen>
502 public void NotifyTextInputMultiLine(bool multiLine)
504 NDalicManualPINVOKE.InputMethodContext_NotifyTextInputMultiLine(swigCPtr, multiLine);
505 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
509 /// Returns the text direction of the keyboard's current input language.
511 /// <returns>The direction of the text.</returns>
512 /// <since_tizen> 3 </since_tizen>
513 public ImfManager.TextDirection GetTextDirection()
515 ImfManager.TextDirection ret = (ImfManager.TextDirection)NDalicManualPINVOKE.InputMethodContext_GetTextDirection(swigCPtr);
516 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
521 /// Provides the size and the position of the keyboard.<br/>
522 /// The position is relative to whether the keyboard is visible or not.<br/>
523 /// If the keyboard is not visible, then the position will be off the screen.<br/>
524 /// If the keyboard is not being shown when this method is called, the keyboard is partially setup (IMFContext) to get/>
525 /// the values then taken down. So ideally, GetInputMethodArea() should be called after Show().
527 /// <returns>Rectangle which is keyboard panel x, y, width, height.</returns>
528 /// <since_tizen> 3 </since_tizen>
529 public Rectangle GetInputMethodArea()
531 Rectangle ret = new Rectangle(NDalicManualPINVOKE.InputMethodContext_GetInputMethodArea(swigCPtr), true);
532 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
537 /// Sets up the input-panel specific data.
539 /// <param name="text">The specific data to be set to the input panel.</param>
540 /// <since_tizen> 3 </since_tizen>
541 public void SetInputPanelUserData(string text)
543 NDalicManualPINVOKE.InputMethodContext_SetInputPanelUserData(swigCPtr, text);
544 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
548 /// Gets the specific data of the current active input panel.
550 /// <param name="text">The specific data to be received from the input panel.</param>
551 /// <since_tizen> 4 </since_tizen>
552 public void GetInputPanelUserData(out string text)
554 NDalicManualPINVOKE.InputMethodContext_GetInputPanelUserData(swigCPtr, out text);
555 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
559 /// Gets the state of the current active input panel.
561 /// <returns>The state of the input panel.</returns>
562 /// <since_tizen> 3 </since_tizen>
563 public ImfManager.State GetInputPanelState()
565 ImfManager.State ret = (ImfManager.State)NDalicManualPINVOKE.InputMethodContext_GetInputPanelState(swigCPtr);
566 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
571 /// Sets the return key on the input panel to be visible or invisible.<br/>
572 /// The default is true.
574 /// <param name="visible">True if the return key is visible (enabled), false otherwise.</param>
575 /// <since_tizen> 3 </since_tizen>
576 public void SetReturnKeyState(bool visible)
578 NDalicManualPINVOKE.InputMethodContext_SetReturnKeyState(swigCPtr, visible);
579 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
583 /// Enables to show the input panel automatically when focused.
585 /// <param name="enabled">If true, the input panel will be shown when focused.</param>
586 /// <since_tizen> 3 </since_tizen>
587 public void AutoEnableInputPanel(bool enabled)
589 NDalicManualPINVOKE.InputMethodContext_AutoEnableInputPanel(swigCPtr, enabled);
590 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
594 /// Shows the input panel.
596 /// <since_tizen> 3 </since_tizen>
597 public void ShowInputPanel()
599 NDalicManualPINVOKE.InputMethodContext_ShowInputPanel(swigCPtr);
600 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
604 /// Hides the input panel.
606 /// <since_tizen> 3 </since_tizen>
607 public void HideInputPanel()
609 NDalicManualPINVOKE.InputMethodContext_HideInputPanel(swigCPtr);
610 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614 /// Gets the keyboard type.<br/>
615 /// The default keyboard type is SoftwareKeyboard.
617 /// <returns>The keyboard type.</returns>
618 /// <since_tizen> 4 </since_tizen>
619 public ImfManager.KeyboardType GetKeyboardType()
621 ImfManager.KeyboardType ret = (ImfManager.KeyboardType)NDalicManualPINVOKE.InputMethodContext_GetKeyboardType(swigCPtr);
622 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
627 /// Gets the current language locale of the input panel.<br/>
628 /// For example, en_US, en_GB, en_PH, fr_FR, ...
630 /// <returns>The current language locale of the input panel.</returns>
631 /// <since_tizen> 4 </since_tizen>
632 public string GetInputPanelLocale()
634 string ret = NDalicManualPINVOKE.InputMethodContext_GetInputPanelLocale(swigCPtr);
635 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
639 internal ImfManager Assign(ImfManager imfManager)
641 ImfManager ret = new ImfManager(NDalicManualPINVOKE.InputMethodContext_Assign(swigCPtr, ImfManager.getCPtr(imfManager)), false);
642 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
646 internal static ImfManager DownCast(BaseHandle handle)
648 ImfManager ret = new ImfManager(NDalicManualPINVOKE.InputMethodContext_DownCast(BaseHandle.getCPtr(handle)), true);
649 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
653 internal void ApplyOptions(InputMethodOptions options)
655 NDalicManualPINVOKE.InputMethodContext_ApplyOptions(swigCPtr, InputMethodOptions.getCPtr(options));
656 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
659 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImfManager obj)
661 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
664 internal ActivatedSignalType ActivatedSignal()
666 ActivatedSignalType ret = new ActivatedSignalType(NDalicManualPINVOKE.InputMethodContext_ActivatedSignal(swigCPtr), false);
667 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
671 internal KeyboardEventSignalType EventReceivedSignal()
673 KeyboardEventSignalType ret = new KeyboardEventSignalType(NDalicManualPINVOKE.InputMethodContext_EventReceivedSignal(swigCPtr), false);
674 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678 internal StatusSignalType StatusChangedSignal()
680 StatusSignalType ret = new StatusSignalType(NDalicManualPINVOKE.InputMethodContext_StatusChangedSignal(swigCPtr), false);
681 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
685 internal KeyboardResizedSignalType ResizedSignal()
687 KeyboardResizedSignalType ret = new KeyboardResizedSignalType(NDalicManualPINVOKE.InputMethodContext_ResizedSignal(swigCPtr), false);
688 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
692 internal LanguageChangedSignalType LanguageChangedSignal()
694 LanguageChangedSignalType ret = new LanguageChangedSignalType(NDalicManualPINVOKE.InputMethodContext_LanguageChangedSignal(swigCPtr), false);
695 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699 internal KeyboardTypeSignalType KeyboardTypeChangedSignal()
701 KeyboardTypeSignalType ret = new KeyboardTypeSignalType(NDalicManualPINVOKE.InputMethodContext_KeyboardTypeChangedSignal(swigCPtr), false);
702 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
709 /// <param name="type">Dispose Type</param>
710 /// <since_tizen> 3 </since_tizen>
711 /// Please DO NOT use! This will be deprecated!
712 /// Dispose() method in Singletone classes (ex: FocusManager, StyleManager, VisualFactory, ImfManager, TtsPlayer, Window) is not required.
713 [EditorBrowsable(EditorBrowsableState.Never)]
714 protected override void Dispose(DisposeTypes type)
721 if (type == DisposeTypes.Explicit)
724 //Release your own managed resources here.
725 //You should release all of your own disposable objects here.
729 //Release your own unmanaged resources here.
730 //You should not access any managed member here except static instance.
731 //because the execution order of Finalizes is non-deterministic.
733 if (_keyboardTypeChangedEventCallback != null)
735 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
738 if (swigCPtr.Handle != global::System.IntPtr.Zero)
743 NDalicManualPINVOKE.delete_InputMethodContext(swigCPtr);
745 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
751 private void OnActivated(IntPtr data)
753 ActivatedEventArgs e = new ActivatedEventArgs();
757 e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(data) as ImfManager;
760 if (_activatedEventHandler != null)
762 _activatedEventHandler(this, e);
766 private IntPtr OnEventReceived(IntPtr imfManager, IntPtr imfEventData)
768 ImfCallbackData imfCallbackData = null;
770 EventReceivedEventArgs e = new EventReceivedEventArgs();
772 if (imfManager != null)
774 e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(imfManager) as ImfManager;
776 if (imfEventData != null)
778 e.ImfEventData = ImfEventData.GetImfEventDataFromPtr(imfEventData);
781 if (_eventReceivedEventHandler != null)
783 imfCallbackData = _eventReceivedEventHandler(this, e);
785 if (imfCallbackData != null)
787 return imfCallbackData.GetImfCallbackDataPtr();
791 return new ImfCallbackData().GetImfCallbackDataPtr();
795 private void OnStatusChanged(bool statusChanged)
797 StatusChangedEventArgs e = new StatusChangedEventArgs();
799 e.StatusChanged = statusChanged;
801 if (_statusChangedEventHandler != null)
803 _statusChangedEventHandler(this, e);
807 private void OnResized(int resized)
809 ResizedEventArgs e = new ResizedEventArgs();
812 if (_resizedEventHandler != null)
814 _resizedEventHandler(this, e);
818 private void OnLanguageChanged(int languageChanged)
820 LanguageChangedEventArgs e = new LanguageChangedEventArgs();
821 e.LanguageChanged = languageChanged;
823 if (_languageChangedEventHandler != null)
825 _languageChangedEventHandler(this, e);
829 private void OnKeyboardTypeChanged(KeyboardType type)
831 KeyboardTypeChangedEventArgs e = new KeyboardTypeChangedEventArgs();
833 e.KeyboardType = type;
835 if (_keyboardTypeChangedEventHandler != null)
837 _keyboardTypeChangedEventHandler(this, e);
842 /// This structure is used to pass on data from the IMF regarding predictive text.
844 /// <since_tizen> 3 </since_tizen>
845 public class ImfEventData : global::System.IDisposable
850 /// <since_tizen> 3 </since_tizen>
851 protected bool swigCMemOwn;
854 /// A Flat to check if it is already disposed.
856 /// <since_tizen> 3 </since_tizen>
857 protected bool disposed = false;
859 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
861 //A Flag to check who called Dispose(). (By User or DisposeQueue)
862 private bool isDisposeQueued = false;
865 /// The default constructor.
867 /// <since_tizen> 3 </since_tizen>
868 public ImfEventData() : this(NDalicManualPINVOKE.new_InputMethodContext_EventData__SWIG_0(), true)
870 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
876 /// <param name="aEventName">The name of the event from the IMF.</param>
877 /// <param name="aPredictiveString">The pre-edit or the commit string.</param>
878 /// <param name="aCursorOffset">Start the position from the current cursor position to start deleting characters.</param>
879 /// <param name="aNumberOfChars">The number of characters to delete from the cursorOffset.</param>
880 /// <since_tizen> 3 </since_tizen>
881 public ImfEventData(ImfManager.ImfEvent aEventName, string aPredictiveString, int aCursorOffset, int aNumberOfChars) : this(NDalicManualPINVOKE.new_InputMethodContext_EventData__SWIG_1((int)aEventName, aPredictiveString, aCursorOffset, aNumberOfChars), true)
883 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
886 internal ImfEventData(IntPtr cPtr, bool cMemoryOwn)
888 swigCMemOwn = cMemoryOwn;
889 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
895 /// <since_tizen> 3 </since_tizen>
898 if (!isDisposeQueued)
900 isDisposeQueued = true;
901 DisposeQueue.Instance.Add(this);
906 /// The pre-edit or the commit string.
908 /// <since_tizen> 4 </since_tizen>
909 public string PredictiveString
913 NDalicManualPINVOKE.InputMethodContext_EventData_predictiveString_set(swigCPtr, value);
914 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
918 string ret = NDalicManualPINVOKE.InputMethodContext_EventData_predictiveString_get(swigCPtr);
919 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
925 /// The name of the event from the IMF.
927 /// <since_tizen> 4 </since_tizen>
928 public ImfManager.ImfEvent EventName
932 NDalicManualPINVOKE.InputMethodContext_EventData_eventName_set(swigCPtr, (int)value);
933 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
937 ImfManager.ImfEvent ret = (ImfManager.ImfEvent)NDalicManualPINVOKE.InputMethodContext_EventData_eventName_get(swigCPtr);
938 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
944 /// The start position from the current cursor position to start deleting characters.
946 /// <since_tizen> 4 </since_tizen>
947 public int CursorOffset
951 NDalicManualPINVOKE.InputMethodContext_EventData_cursorOffset_set(swigCPtr, value);
952 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
956 int ret = NDalicManualPINVOKE.InputMethodContext_EventData_cursorOffset_get(swigCPtr);
957 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
963 /// The number of characters to delete from the cursorOffset.
965 /// <since_tizen> 4 </since_tizen>
966 public int NumberOfChars
970 NDalicManualPINVOKE.InputMethodContext_EventData_numberOfChars_set(swigCPtr, value);
971 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
975 int ret = NDalicManualPINVOKE.InputMethodContext_EventData_numberOfChars_get(swigCPtr);
976 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
982 /// The dispose pattern.
984 /// <since_tizen> 3 </since_tizen>
985 public void Dispose()
987 //Throw excpetion if Dispose() is called in separate thread.
988 if (!Window.IsInstalled())
990 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
995 Dispose(DisposeTypes.Implicit);
999 Dispose(DisposeTypes.Explicit);
1000 System.GC.SuppressFinalize(this);
1004 internal static ImfEventData GetImfEventDataFromPtr(IntPtr cPtr)
1006 ImfEventData ret = new ImfEventData(cPtr, false);
1007 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1011 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImfEventData obj)
1013 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1019 /// <since_tizen> 3 </since_tizen>
1020 protected virtual void Dispose(DisposeTypes type)
1027 if (type == DisposeTypes.Explicit)
1030 //Release your own managed resources here.
1031 //You should release all of your own disposable objects here.
1035 //Release your own unmanaged resources here.
1036 //You should not access any managed member here except static instance.
1037 //because the execution order of Finalizes is non-deterministic.
1039 if (swigCPtr.Handle != IntPtr.Zero)
1043 swigCMemOwn = false;
1044 NDalicManualPINVOKE.delete_InputMethodContext_EventData(swigCPtr);
1046 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1054 /// Data required by the IMF from the callback.
1056 /// <since_tizen> 3 </since_tizen>
1057 public class ImfCallbackData : global::System.IDisposable
1062 /// <since_tizen> 3 </since_tizen>
1063 protected bool swigCMemOwn;
1066 /// A Flat to check if it is already disposed.
1068 /// <since_tizen> 3 </since_tizen>
1069 protected bool disposed = false;
1071 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
1073 //A Flag to check who called Dispose(). (By User or DisposeQueue)
1074 private bool isDisposeQueued = false;
1077 /// The default constructor.
1079 /// <since_tizen> 3 </since_tizen>
1080 public ImfCallbackData() : this(NDalicManualPINVOKE.new_InputMethodContext_CallbackData__SWIG_0(), true)
1082 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1086 /// The constructor.
1088 /// <param name="aUpdate">True if the cursor position needs to be updated.</param>
1089 /// <param name="aCursorPosition">The new position of the cursor.</param>
1090 /// <param name="aCurrentText">The current text string.</param>
1091 /// <param name="aPreeditResetRequired">Flag if preedit reset is required.</param>
1092 /// <since_tizen> 3 </since_tizen>
1093 public ImfCallbackData(bool aUpdate, int aCursorPosition, string aCurrentText, bool aPreeditResetRequired) : this(NDalicManualPINVOKE.new_InputMethodContext_CallbackData__SWIG_1(aUpdate, aCursorPosition, aCurrentText, aPreeditResetRequired), true)
1095 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1098 internal ImfCallbackData(IntPtr cPtr, bool cMemoryOwn)
1100 swigCMemOwn = cMemoryOwn;
1101 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
1107 /// <since_tizen> 3 </since_tizen>
1110 if (!isDisposeQueued)
1112 isDisposeQueued = true;
1113 DisposeQueue.Instance.Add(this);
1118 /// The current text string.
1120 /// <since_tizen> 4 </since_tizen>
1121 public string CurrentText
1125 NDalicManualPINVOKE.InputMethodContext_CallbackData_currentText_set(swigCPtr, value);
1126 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1130 string ret = NDalicManualPINVOKE.InputMethodContext_CallbackData_currentText_get(swigCPtr);
1131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1137 /// The current text string.
1139 /// <since_tizen> 4 </since_tizen>
1140 public int CursorPosition
1144 NDalicManualPINVOKE.InputMethodContext_CallbackData_cursorPosition_set(swigCPtr, value);
1145 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1149 int ret = NDalicManualPINVOKE.InputMethodContext_CallbackData_cursorPosition_get(swigCPtr);
1150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1156 /// If the cursor position needs to be updated.
1158 /// <since_tizen> 4 </since_tizen>
1163 NDalicManualPINVOKE.InputMethodContext_CallbackData_update_set(swigCPtr, value);
1164 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1168 bool ret = NDalicManualPINVOKE.InputMethodContext_CallbackData_update_get(swigCPtr);
1169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1175 /// Flags if preedit reset is required.
1177 /// <since_tizen> 4 </since_tizen>
1178 public bool PreeditResetRequired
1182 NDalicManualPINVOKE.InputMethodContext_CallbackData_preeditResetRequired_set(swigCPtr, value);
1183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1187 bool ret = NDalicManualPINVOKE.InputMethodContext_CallbackData_preeditResetRequired_get(swigCPtr);
1188 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1194 /// The dispose pattern.
1196 /// <since_tizen> 3 </since_tizen>
1197 public void Dispose()
1199 //Throw excpetion if Dispose() is called in separate thread.
1200 if (!Window.IsInstalled())
1202 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
1205 if (isDisposeQueued)
1207 Dispose(DisposeTypes.Implicit);
1211 Dispose(DisposeTypes.Explicit);
1212 System.GC.SuppressFinalize(this);
1216 internal IntPtr GetImfCallbackDataPtr()
1218 return (IntPtr)swigCPtr;
1221 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImfCallbackData obj)
1223 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1226 internal static ImfCallbackData GetImfCallbackDataFromPtr(IntPtr cPtr)
1228 ImfCallbackData ret = new ImfCallbackData(cPtr, false);
1229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1236 /// <since_tizen> 3 </since_tizen>
1237 protected virtual void Dispose(DisposeTypes type)
1244 if (type == DisposeTypes.Explicit)
1247 //Release your own managed resources here.
1248 //You should release all of your own disposable objects here.
1252 //Release your own unmanaged resources here.
1253 //You should not access any managed member here except static instance.
1254 //because the execution order of Finalizes is non-deterministic.
1256 if (swigCPtr.Handle != IntPtr.Zero)
1260 swigCMemOwn = false;
1261 NDalicManualPINVOKE.delete_InputMethodContext_CallbackData(swigCPtr);
1263 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1271 /// ImfManager activated event arguments.
1273 /// <since_tizen> 4 </since_tizen>
1274 public class ActivatedEventArgs : EventArgs
1279 /// <since_tizen> 4 </since_tizen>
1280 public ImfManager ImfManager
1288 /// ImfManager event received event arguments.
1290 /// <since_tizen> 4 </since_tizen>
1291 public class EventReceivedEventArgs : EventArgs
1296 /// <since_tizen> 4 </since_tizen>
1297 public ImfManager ImfManager
1306 /// <since_tizen> 4 </since_tizen>
1307 public ImfEventData ImfEventData
1315 /// ImfManager status changed event arguments.
1317 /// <since_tizen> 4 </since_tizen>
1318 public class StatusChangedEventArgs : EventArgs
1321 /// ImfManager status
1323 /// <since_tizen> 4 </since_tizen>
1324 public bool StatusChanged
1332 /// ImfManager resized event.
1334 /// <since_tizen> 4 </since_tizen>
1335 public class ResizedEventArgs : EventArgs
1340 /// <since_tizen> 4 </since_tizen>
1349 /// ImfManager language changed event args.
1351 /// <since_tizen> 4 </since_tizen>
1352 public class LanguageChangedEventArgs : EventArgs
1355 /// language changed.
1357 /// <since_tizen> 4 </since_tizen>
1358 public int LanguageChanged
1366 /// ImfManager keyboard type changed event arguments.
1368 /// <since_tizen> 4 </since_tizen>
1369 public class KeyboardTypeChangedEventArgs : EventArgs
1372 /// ImfManager keyboard type
1374 /// <since_tizen> 4 </since_tizen>
1375 public KeyboardType KeyboardType