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(Interop.InputMethodContext.InputMethodContext_New(), true)
47 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
51 internal ImfManager(ImfManager imfManager) : this(Interop.InputMethodContext.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(Interop.InputMethodContext.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 [EditorBrowsable(EditorBrowsableState.Never)]
209 public event EventHandler<KeyboardTypeChangedEventArgs> KeyboardTypeChanged
213 if (_keyboardTypeChangedEventHandler == null)
215 _keyboardTypeChangedEventCallback = OnKeyboardTypeChanged;
216 KeyboardTypeChangedSignal().Connect(_keyboardTypeChangedEventCallback);
219 _keyboardTypeChangedEventHandler += value;
223 _keyboardTypeChangedEventHandler -= value;
225 if (_keyboardTypeChangedEventHandler == null && _keyboardTypeChangedEventCallback != null)
227 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
232 private event EventHandler<ActivatedEventArgs> _activatedEventHandler;
233 private event EventHandlerWithReturnType<object, EventReceivedEventArgs, ImfCallbackData> _eventReceivedEventHandler;
234 private event EventHandler<StatusChangedEventArgs> _statusChangedEventHandler;
235 private event EventHandler<ResizedEventArgs> _resizedEventHandler;
236 private event EventHandler<LanguageChangedEventArgs> _languageChangedEventHandler;
237 private event EventHandler<KeyboardTypeChangedEventArgs> _keyboardTypeChangedEventHandler;
240 /// The direction of the text.
242 /// <since_tizen> 3 </since_tizen>
243 public enum TextDirection
256 /// Events that are generated by the IMF.
258 /// <since_tizen> 3 </since_tizen>
264 /// <since_tizen> 4 </since_tizen>
267 /// Pre-Edit changed.
269 /// <since_tizen> 4 </since_tizen>
274 /// <since_tizen> 4 </since_tizen>
277 /// An event to delete a range of characters from the string.
279 /// <since_tizen> 4 </since_tizen>
282 /// An event to query string and the cursor position.
284 /// <since_tizen> 4 </since_tizen>
287 /// Private command sent from the input panel.
289 /// <since_tizen> 4 </since_tizen>
294 /// Enumeration for the state of the input panel.
296 /// <since_tizen> 3 </since_tizen>
302 /// <since_tizen> 4 </since_tizen>
305 /// Input panel is shown.
307 /// <since_tizen> 4 </since_tizen>
310 /// Input panel is hidden.
312 /// <since_tizen> 4 </since_tizen>
315 /// Input panel in process of being shown.
317 /// <since_tizen> 4 </since_tizen>
322 /// Enumeration for the types of keyboard.
324 /// <since_tizen> 4 </since_tizen>
325 public enum KeyboardType
328 /// Software keyboard (virtual keyboard) is default.
330 /// <since_tizen> 4 </since_tizen>
333 /// Hardware keyboard.
335 /// <since_tizen> 4 </since_tizen>
340 /// Gets the singleton of the ImfManager object.
342 /// <since_tizen> 5 </since_tizen>
343 public static ImfManager Instance
347 return new ImfManager();
352 /// Retrieves a handle to the instance of the ImfManager.
354 /// <returns>A handle to the ImfManager.</returns>
355 /// <since_tizen> 3 </since_tizen>
356 public static ImfManager Get()
358 return new ImfManager();
362 /// Destroys the context of the IMF.<br/>
364 /// <since_tizen> 5 </since_tizen>
365 public void DestroyContext()
367 Interop.InputMethodContext.InputMethodContext_Finalize(swigCPtr);
368 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
372 /// Destroy the context of the IMF.<br/>
374 /// <since_tizen> 4 </since_tizen>
375 /// Please do not use! This will be deprecated, instead please USE Tizen.NUI.ImfManager.Instance.DestroyContext()!
376 #pragma warning disable 0465
377 [Obsolete("Please do not use! This will be deprecated! Please use ImfManager.Instance.DestroyContext() instead!")]
378 [EditorBrowsable(EditorBrowsableState.Never)]
379 public void Finalize()
383 #pragma warning restore 0465
386 /// Activates the IMF.<br/>
387 /// It means that the text editing is started somewhere.<br/>
388 /// If the hardware keyboard isn't connected, then it will show the virtual keyboard.
390 /// <since_tizen> 3 </since_tizen>
391 public void Activate()
393 Interop.InputMethodContext.InputMethodContext_Activate(swigCPtr);
394 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
398 /// Deactivates the IMF.<br/>
399 /// It means that the text editing is finished somewhere.
401 /// <since_tizen> 3 </since_tizen>
402 public void Deactivate()
404 Interop.InputMethodContext.InputMethodContext_Deactivate(swigCPtr);
405 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
409 /// Gets the restoration status which controls if the keyboard is restored after the focus is lost and then regained.<br/>
410 /// If true, then the keyboard will be restored (activated) after focus is regained.
412 /// <returns>The restoration status.</returns>
413 /// <since_tizen> 3 </since_tizen>
414 public bool RestoreAfterFocusLost()
416 bool ret = Interop.InputMethodContext.InputMethodContext_RestoreAfterFocusLost(swigCPtr);
417 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
422 /// Sets the status whether the IMF has to restore the keyboard after losing focus.
424 /// <param name="toggle">True means that keyboard should be restored after the focus is lost and regained.</param>
425 /// <since_tizen> 3 </since_tizen>
426 public void SetRestoreAfterFocusLost(bool toggle)
428 Interop.InputMethodContext.InputMethodContext_SetRestoreAfterFocusLost(swigCPtr, toggle);
429 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
433 /// Sends a message reset to the preedit state or the IMF module.
435 /// <since_tizen> 3 </since_tizen>
436 public new void Reset()
438 Interop.InputMethodContext.InputMethodContext_Reset(swigCPtr);
439 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
443 /// Notifies the IMF context that the cursor position has changed, required for features like auto-capitalization.
445 /// <since_tizen> 3 </since_tizen>
446 public void NotifyCursorPosition()
448 Interop.InputMethodContext.InputMethodContext_NotifyCursorPosition(swigCPtr);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453 /// Sets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
455 /// <param name="cursorPosition">The position of the cursor.</param>
456 /// <since_tizen> 3 </since_tizen>
457 public void SetCursorPosition(uint cursorPosition)
459 Interop.InputMethodContext.InputMethodContext_SetCursorPosition(swigCPtr, cursorPosition);
460 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
464 /// Gets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
466 /// <returns>The current position of the cursor.</returns>
467 /// <since_tizen> 3 </since_tizen>
468 public uint GetCursorPosition()
470 uint ret = Interop.InputMethodContext.InputMethodContext_GetCursorPosition(swigCPtr);
471 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 /// A method to store the string required by the IMF, this is used to provide predictive word suggestions.
478 /// <param name="text">The text string surrounding the current cursor point.</param>
479 /// <since_tizen> 3 </since_tizen>
480 public void SetSurroundingText(string text)
482 Interop.InputMethodContext.InputMethodContext_SetSurroundingText(swigCPtr, text);
483 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
487 /// Gets the current text string set within the IMF manager, this is used to offer predictive suggestions.
489 /// <returns>The surrounding text.</returns>
490 /// <since_tizen> 3 </since_tizen>
491 public string GetSurroundingText()
493 string ret = Interop.InputMethodContext.InputMethodContext_GetSurroundingText(swigCPtr);
494 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
499 /// Notifies the IMF context that text input is set to multiline or not.
501 /// <param name="multiLine">True if multiline text input is used.</param>
502 /// <since_tizen> 3 </since_tizen>
503 public void NotifyTextInputMultiLine(bool multiLine)
505 Interop.InputMethodContext.InputMethodContext_NotifyTextInputMultiLine(swigCPtr, multiLine);
506 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
510 /// Returns the text direction of the keyboard's current input language.
512 /// <returns>The direction of the text.</returns>
513 /// <since_tizen> 3 </since_tizen>
514 public ImfManager.TextDirection GetTextDirection()
516 ImfManager.TextDirection ret = (ImfManager.TextDirection)Interop.InputMethodContext.InputMethodContext_GetTextDirection(swigCPtr);
517 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
522 /// Provides the size and the position of the keyboard.<br/>
523 /// The position is relative to whether the keyboard is visible or not.<br/>
524 /// If the keyboard is not visible, then the position will be off the screen.<br/>
525 /// If the keyboard is not being shown when this method is called, the keyboard is partially setup (IMFContext) to get/>
526 /// the values then taken down. So ideally, GetInputMethodArea() should be called after Show().
528 /// <returns>Rectangle which is keyboard panel x, y, width, height.</returns>
529 /// <since_tizen> 3 </since_tizen>
530 public Rectangle GetInputMethodArea()
532 Rectangle ret = new Rectangle(Interop.InputMethodContext.InputMethodContext_GetInputMethodArea(swigCPtr), true);
533 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
538 /// Sets up the input-panel specific data.
540 /// <param name="text">The specific data to be set to the input panel.</param>
541 /// <since_tizen> 3 </since_tizen>
542 public void SetInputPanelUserData(string text)
544 Interop.InputMethodContext.InputMethodContext_SetInputPanelUserData(swigCPtr, text);
545 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
549 /// Gets the specific data of the current active input panel.
551 /// <param name="text">The specific data to be received from the input panel.</param>
552 /// <since_tizen> 4 </since_tizen>
553 public void GetInputPanelUserData(out string text)
555 Interop.InputMethodContext.InputMethodContext_GetInputPanelUserData(swigCPtr, out text);
556 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
560 /// Gets the state of the current active input panel.
562 /// <returns>The state of the input panel.</returns>
563 /// <since_tizen> 3 </since_tizen>
564 public ImfManager.State GetInputPanelState()
566 ImfManager.State ret = (ImfManager.State)Interop.InputMethodContext.InputMethodContext_GetInputPanelState(swigCPtr);
567 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
572 /// Sets the return key on the input panel to be visible or invisible.<br/>
573 /// The default is true.
575 /// <param name="visible">True if the return key is visible (enabled), false otherwise.</param>
576 /// <since_tizen> 3 </since_tizen>
577 public void SetReturnKeyState(bool visible)
579 Interop.InputMethodContext.InputMethodContext_SetReturnKeyState(swigCPtr, visible);
580 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584 /// Enables to show the input panel automatically when focused.
586 /// <param name="enabled">If true, the input panel will be shown when focused.</param>
587 /// <since_tizen> 3 </since_tizen>
588 public void AutoEnableInputPanel(bool enabled)
590 Interop.InputMethodContext.InputMethodContext_AutoEnableInputPanel(swigCPtr, enabled);
591 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 /// Shows the input panel.
597 /// <since_tizen> 3 </since_tizen>
598 public void ShowInputPanel()
600 Interop.InputMethodContext.InputMethodContext_ShowInputPanel(swigCPtr);
601 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
605 /// Hides the input panel.
607 /// <since_tizen> 3 </since_tizen>
608 public void HideInputPanel()
610 Interop.InputMethodContext.InputMethodContext_HideInputPanel(swigCPtr);
611 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
615 /// Gets the keyboard type.<br/>
616 /// The default keyboard type is SoftwareKeyboard.
618 /// <returns>The keyboard type.</returns>
619 /// <since_tizen> 4 </since_tizen>
620 public ImfManager.KeyboardType GetKeyboardType()
622 ImfManager.KeyboardType ret = (ImfManager.KeyboardType)Interop.InputMethodContext.InputMethodContext_GetKeyboardType(swigCPtr);
623 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 /// Gets the current language locale of the input panel.<br/>
629 /// For example, en_US, en_GB, en_PH, fr_FR, ...
631 /// <returns>The current language locale of the input panel.</returns>
632 /// <since_tizen> 4 </since_tizen>
633 public string GetInputPanelLocale()
635 string ret = Interop.InputMethodContext.InputMethodContext_GetInputPanelLocale(swigCPtr);
636 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
640 internal ImfManager Assign(ImfManager imfManager)
642 ImfManager ret = new ImfManager(Interop.InputMethodContext.InputMethodContext_Assign(swigCPtr, ImfManager.getCPtr(imfManager)), false);
643 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
647 internal static ImfManager DownCast(BaseHandle handle)
649 ImfManager ret = new ImfManager(Interop.InputMethodContext.InputMethodContext_DownCast(BaseHandle.getCPtr(handle)), true);
650 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
654 internal void ApplyOptions(InputMethodOptions options)
656 Interop.InputMethodContext.InputMethodContext_ApplyOptions(swigCPtr, InputMethodOptions.getCPtr(options));
657 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
660 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImfManager obj)
662 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
665 internal ActivatedSignalType ActivatedSignal()
667 ActivatedSignalType ret = new ActivatedSignalType(Interop.InputMethodContext.InputMethodContext_ActivatedSignal(swigCPtr), false);
668 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
672 internal KeyboardEventSignalType EventReceivedSignal()
674 KeyboardEventSignalType ret = new KeyboardEventSignalType(Interop.InputMethodContext.InputMethodContext_EventReceivedSignal(swigCPtr), false);
675 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
679 internal StatusSignalType StatusChangedSignal()
681 StatusSignalType ret = new StatusSignalType(Interop.InputMethodContext.InputMethodContext_StatusChangedSignal(swigCPtr), false);
682 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
686 internal KeyboardResizedSignalType ResizedSignal()
688 KeyboardResizedSignalType ret = new KeyboardResizedSignalType(Interop.InputMethodContext.InputMethodContext_ResizedSignal(swigCPtr), false);
689 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
693 internal LanguageChangedSignalType LanguageChangedSignal()
695 LanguageChangedSignalType ret = new LanguageChangedSignalType(Interop.InputMethodContext.InputMethodContext_LanguageChangedSignal(swigCPtr), false);
696 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
700 internal KeyboardTypeSignalType KeyboardTypeChangedSignal()
702 KeyboardTypeSignalType ret = new KeyboardTypeSignalType(Interop.InputMethodContext.InputMethodContext_KeyboardTypeChangedSignal(swigCPtr), false);
703 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708 /// You can override it to clean-up your own resources.
710 /// <param name="type">Dispose Type</param>
711 /// <since_tizen> 3 </since_tizen>
712 /// Please do not use! This will be deprecated!
713 /// Dispose() method in Singletone classes (ex: FocusManager, StyleManager, VisualFactory, ImfManager, TtsPlayer, Window) is not required.
714 [EditorBrowsable(EditorBrowsableState.Never)]
715 protected override void Dispose(DisposeTypes type)
722 if (type == DisposeTypes.Explicit)
725 //Release your own managed resources here.
726 //You should release all of your own disposable objects here.
730 //Release your own unmanaged resources here.
731 //You should not access any managed member here except static instance
732 //because the execution order of Finalizes is non-deterministic.
734 if (_keyboardTypeChangedEventCallback != null)
736 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
739 if (swigCPtr.Handle != global::System.IntPtr.Zero)
744 Interop.InputMethodContext.delete_InputMethodContext(swigCPtr);
746 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
752 private void OnActivated(IntPtr data)
754 ActivatedEventArgs e = new ActivatedEventArgs();
758 e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(data) as ImfManager;
761 if (_activatedEventHandler != null)
763 _activatedEventHandler(this, e);
767 private IntPtr OnEventReceived(IntPtr imfManager, IntPtr imfEventData)
769 ImfCallbackData imfCallbackData = null;
771 EventReceivedEventArgs e = new EventReceivedEventArgs();
773 if (imfManager != null)
775 e.ImfManager = Registry.GetManagedBaseHandleFromNativePtr(imfManager) as ImfManager;
777 if (imfEventData != null)
779 e.ImfEventData = ImfEventData.GetImfEventDataFromPtr(imfEventData);
782 if (_eventReceivedEventHandler != null)
784 imfCallbackData = _eventReceivedEventHandler(this, e);
786 if (imfCallbackData != null)
788 return imfCallbackData.GetImfCallbackDataPtr();
792 return new ImfCallbackData().GetImfCallbackDataPtr();
796 private void OnStatusChanged(bool statusChanged)
798 StatusChangedEventArgs e = new StatusChangedEventArgs();
800 e.StatusChanged = statusChanged;
802 if (_statusChangedEventHandler != null)
804 _statusChangedEventHandler(this, e);
808 private void OnResized(int resized)
810 ResizedEventArgs e = new ResizedEventArgs();
813 if (_resizedEventHandler != null)
815 _resizedEventHandler(this, e);
819 private void OnLanguageChanged(int languageChanged)
821 LanguageChangedEventArgs e = new LanguageChangedEventArgs();
822 e.LanguageChanged = languageChanged;
824 if (_languageChangedEventHandler != null)
826 _languageChangedEventHandler(this, e);
830 private void OnKeyboardTypeChanged(KeyboardType type)
832 KeyboardTypeChangedEventArgs e = new KeyboardTypeChangedEventArgs();
834 e.KeyboardType = type;
836 if (_keyboardTypeChangedEventHandler != null)
838 _keyboardTypeChangedEventHandler(this, e);
843 /// This structure is used to pass on data from the IMF regarding predictive text.
845 /// <since_tizen> 3 </since_tizen>
846 public class ImfEventData : global::System.IDisposable
849 /// The state if it owns memory
851 /// <since_tizen> 3 </since_tizen>
852 protected bool swigCMemOwn;
855 /// A flag to check if it is already disposed.
857 /// <since_tizen> 3 </since_tizen>
858 protected bool disposed = false;
860 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
862 //A flag to check who called Dispose(). (By User or DisposeQueue)
863 private bool isDisposeQueued = false;
866 /// The default constructor.
868 /// <since_tizen> 3 </since_tizen>
869 public ImfEventData() : this(Interop.InputMethodContext.new_InputMethodContext_EventData__SWIG_0(), true)
871 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
877 /// <param name="aEventName">The name of the event from the IMF.</param>
878 /// <param name="aPredictiveString">The pre-edit or the commit string.</param>
879 /// <param name="aCursorOffset">Start the position from the current cursor position to start deleting characters.</param>
880 /// <param name="aNumberOfChars">The number of characters to delete from the cursorOffset.</param>
881 /// <since_tizen> 3 </since_tizen>
882 public ImfEventData(ImfManager.ImfEvent aEventName, string aPredictiveString, int aCursorOffset, int aNumberOfChars) : this(Interop.InputMethodContext.new_InputMethodContext_EventData__SWIG_1((int)aEventName, aPredictiveString, aCursorOffset, aNumberOfChars), true)
884 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
887 internal ImfEventData(IntPtr cPtr, bool cMemoryOwn)
889 swigCMemOwn = cMemoryOwn;
890 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
894 /// Releases the resource.
896 /// <since_tizen> 3 </since_tizen>
899 if (!isDisposeQueued)
901 isDisposeQueued = true;
902 DisposeQueue.Instance.Add(this);
907 /// The pre-edit or the commit string.
909 /// <since_tizen> 4 </since_tizen>
910 public string PredictiveString
914 Interop.InputMethodContext.InputMethodContext_EventData_predictiveString_set(swigCPtr, value);
915 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
919 string ret = Interop.InputMethodContext.InputMethodContext_EventData_predictiveString_get(swigCPtr);
920 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
926 /// The name of the event from the IMF.
928 /// <since_tizen> 4 </since_tizen>
929 public ImfManager.ImfEvent EventName
933 Interop.InputMethodContext.InputMethodContext_EventData_eventName_set(swigCPtr, (int)value);
934 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
938 ImfManager.ImfEvent ret = (ImfManager.ImfEvent)Interop.InputMethodContext.InputMethodContext_EventData_eventName_get(swigCPtr);
939 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
945 /// The start position from the current cursor position to start deleting characters.
947 /// <since_tizen> 4 </since_tizen>
948 public int CursorOffset
952 Interop.InputMethodContext.InputMethodContext_EventData_cursorOffset_set(swigCPtr, value);
953 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
957 int ret = Interop.InputMethodContext.InputMethodContext_EventData_cursorOffset_get(swigCPtr);
958 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
964 /// The number of characters to delete from the cursorOffset.
966 /// <since_tizen> 4 </since_tizen>
967 public int NumberOfChars
971 Interop.InputMethodContext.InputMethodContext_EventData_numberOfChars_set(swigCPtr, value);
972 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
976 int ret = Interop.InputMethodContext.InputMethodContext_EventData_numberOfChars_get(swigCPtr);
977 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
983 /// The dispose pattern.
985 /// <since_tizen> 3 </since_tizen>
986 public void Dispose()
988 //Throw excpetion if Dispose() is called in separate thread.
989 if (!Window.IsInstalled())
991 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
996 Dispose(DisposeTypes.Implicit);
1000 Dispose(DisposeTypes.Explicit);
1001 System.GC.SuppressFinalize(this);
1005 internal static ImfEventData GetImfEventDataFromPtr(IntPtr cPtr)
1007 ImfEventData ret = new ImfEventData(cPtr, false);
1008 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1012 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImfEventData obj)
1014 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1018 /// You can override it to clean-up your own resources.
1020 /// <since_tizen> 3 </since_tizen>
1021 protected virtual void Dispose(DisposeTypes type)
1028 if (type == DisposeTypes.Explicit)
1031 //Release your own managed resources here.
1032 //You should release all of your own disposable objects here.
1036 //Release your own unmanaged resources here.
1037 //You should not access any managed member here except static instance.
1038 //because the execution order of Finalizes is non-deterministic.
1040 if (swigCPtr.Handle != IntPtr.Zero)
1044 swigCMemOwn = false;
1045 Interop.InputMethodContext.delete_InputMethodContext_EventData(swigCPtr);
1047 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1055 /// Data required by the IMF from the callback.
1057 /// <since_tizen> 3 </since_tizen>
1058 public class ImfCallbackData : global::System.IDisposable
1061 /// The state if it owns memory
1063 /// <since_tizen> 3 </since_tizen>
1064 protected bool swigCMemOwn;
1067 /// A flag to check if it is already disposed.
1069 /// <since_tizen> 3 </since_tizen>
1070 protected bool disposed = false;
1072 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
1074 //A flag to check who called Dispose(). (By User or DisposeQueue)
1075 private bool isDisposeQueued = false;
1078 /// The default constructor.
1080 /// <since_tizen> 3 </since_tizen>
1081 public ImfCallbackData() : this(Interop.InputMethodContext.new_InputMethodContext_CallbackData__SWIG_0(), true)
1083 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1087 /// The constructor.
1089 /// <param name="aUpdate">True if the cursor position needs to be updated.</param>
1090 /// <param name="aCursorPosition">The new position of the cursor.</param>
1091 /// <param name="aCurrentText">The current text string.</param>
1092 /// <param name="aPreeditResetRequired">Flag if preedit reset is required.</param>
1093 /// <since_tizen> 3 </since_tizen>
1094 public ImfCallbackData(bool aUpdate, int aCursorPosition, string aCurrentText, bool aPreeditResetRequired) : this(Interop.InputMethodContext.new_InputMethodContext_CallbackData__SWIG_1(aUpdate, aCursorPosition, aCurrentText, aPreeditResetRequired), true)
1096 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1099 internal ImfCallbackData(IntPtr cPtr, bool cMemoryOwn)
1101 swigCMemOwn = cMemoryOwn;
1102 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
1106 /// Releases the resource.
1108 /// <since_tizen> 3 </since_tizen>
1111 if (!isDisposeQueued)
1113 isDisposeQueued = true;
1114 DisposeQueue.Instance.Add(this);
1119 /// The current text string.
1121 /// <since_tizen> 4 </since_tizen>
1122 public string CurrentText
1126 Interop.InputMethodContext.InputMethodContext_CallbackData_currentText_set(swigCPtr, value);
1127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1131 string ret = Interop.InputMethodContext.InputMethodContext_CallbackData_currentText_get(swigCPtr);
1132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1138 /// The current text string.
1140 /// <since_tizen> 4 </since_tizen>
1141 public int CursorPosition
1145 Interop.InputMethodContext.InputMethodContext_CallbackData_cursorPosition_set(swigCPtr, value);
1146 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1150 int ret = Interop.InputMethodContext.InputMethodContext_CallbackData_cursorPosition_get(swigCPtr);
1151 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1157 /// If the cursor position needs to be updated.
1159 /// <since_tizen> 4 </since_tizen>
1164 Interop.InputMethodContext.InputMethodContext_CallbackData_update_set(swigCPtr, value);
1165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1169 bool ret = Interop.InputMethodContext.InputMethodContext_CallbackData_update_get(swigCPtr);
1170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1176 /// Flags if preedit reset is required.
1178 /// <since_tizen> 4 </since_tizen>
1179 public bool PreeditResetRequired
1183 Interop.InputMethodContext.InputMethodContext_CallbackData_preeditResetRequired_set(swigCPtr, value);
1184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1188 bool ret = Interop.InputMethodContext.InputMethodContext_CallbackData_preeditResetRequired_get(swigCPtr);
1189 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1195 /// The dispose pattern.
1197 /// <since_tizen> 3 </since_tizen>
1198 public void Dispose()
1200 //Throw excpetion if Dispose() is called in separate thread.
1201 if (!Window.IsInstalled())
1203 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
1206 if (isDisposeQueued)
1208 Dispose(DisposeTypes.Implicit);
1212 Dispose(DisposeTypes.Explicit);
1213 System.GC.SuppressFinalize(this);
1217 internal IntPtr GetImfCallbackDataPtr()
1219 return (IntPtr)swigCPtr;
1222 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImfCallbackData obj)
1224 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1227 internal static ImfCallbackData GetImfCallbackDataFromPtr(IntPtr cPtr)
1229 ImfCallbackData ret = new ImfCallbackData(cPtr, false);
1230 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1235 /// You can override it to clean-up your own resources.
1237 /// <since_tizen> 3 </since_tizen>
1238 protected virtual void Dispose(DisposeTypes type)
1245 if (type == DisposeTypes.Explicit)
1248 //Release your own managed resources here.
1249 //You should release all of your own disposable objects here.
1253 //Release your own unmanaged resources here.
1254 //You should not access any managed member here except static instance.
1255 //because the execution order of Finalizes is non-deterministic.
1257 if (swigCPtr.Handle != IntPtr.Zero)
1261 swigCMemOwn = false;
1262 Interop.InputMethodContext.delete_InputMethodContext_CallbackData(swigCPtr);
1264 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1272 /// ImfManager activated event arguments.
1274 /// <since_tizen> 4 </since_tizen>
1275 public class ActivatedEventArgs : EventArgs
1278 /// The instance of ImfManager
1280 /// <since_tizen> 4 </since_tizen>
1281 public ImfManager ImfManager
1289 /// ImfManager event received event arguments.
1291 /// <since_tizen> 4 </since_tizen>
1292 public class EventReceivedEventArgs : EventArgs
1295 /// The instance of ImfManager
1297 /// <since_tizen> 4 </since_tizen>
1298 public ImfManager ImfManager
1305 /// The event data of IMF
1307 /// <since_tizen> 4 </since_tizen>
1308 public ImfEventData ImfEventData
1316 /// ImfManager status changed event arguments.
1318 /// <since_tizen> 4 </since_tizen>
1319 public class StatusChangedEventArgs : EventArgs
1322 /// ImfManager status
1324 /// <since_tizen> 4 </since_tizen>
1325 public bool StatusChanged
1333 /// ImfManager resized event.
1335 /// <since_tizen> 4 </since_tizen>
1336 public class ResizedEventArgs : EventArgs
1339 /// The state if the IMF resized.
1341 /// <since_tizen> 4 </since_tizen>
1350 /// ImfManager language changed event args.
1352 /// <since_tizen> 4 </since_tizen>
1353 public class LanguageChangedEventArgs : EventArgs
1356 /// language changed.
1358 /// <since_tizen> 4 </since_tizen>
1359 public int LanguageChanged
1367 /// ImfManager keyboard type changed event arguments.
1369 /// <since_tizen> 4 </since_tizen>
1370 public class KeyboardTypeChangedEventArgs : EventArgs
1373 /// ImfManager keyboard type
1375 /// <since_tizen> 4 </since_tizen>
1376 public KeyboardType KeyboardType