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 (IMF) that enables the virtual or hardware keyboards.
27 /// <since_tizen> 5 </since_tizen>
28 public class InputMethodContext : BaseHandle
30 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
32 private ActivatedEventCallbackType _activatedEventCallback;
33 private EventReceivedEventCallbackType _eventReceivedEventCallback;
34 private StatusChangedEventCallbackType _statusChangedEventCallback;
35 private ResizedEventCallbackType _resizedEventCallback;
36 private LanguageChangedEventCallbackType _languageChangedEventCallback;
37 private KeyboardTypeChangedEventCallbackType _keyboardTypeChangedEventCallback;
38 private ContentReceivedCallbackType _contentReceivedEventCallback;
43 /// <since_tizen> 5 </since_tizen>
44 public InputMethodContext() : this(Interop.InputMethodContext.InputMethodContext_New(), true)
46 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50 internal InputMethodContext(IntPtr cPtr, bool cMemoryOwn) : base(Interop.InputMethodContext.InputMethodContext_SWIGUpcast(cPtr), cMemoryOwn)
52 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
55 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
56 private delegate void ActivatedEventCallbackType(IntPtr data);
57 private delegate IntPtr EventReceivedEventCallbackType(IntPtr inputMethodContext, IntPtr eventData);
58 private delegate void StatusChangedEventCallbackType(bool statusChanged);
59 private delegate void ResizedEventCallbackType(int resized);
60 private delegate void LanguageChangedEventCallbackType(int languageChanged);
61 private delegate void KeyboardTypeChangedEventCallbackType(KeyboardType type);
62 private delegate void ContentReceivedCallbackType(string content, string description, string mimeType);
64 private event EventHandler<ActivatedEventArgs> _activatedEventHandler;
65 private event EventHandlerWithReturnType<object, EventReceivedEventArgs, CallbackData> _eventReceivedEventHandler;
66 private event EventHandler<StatusChangedEventArgs> _statusChangedEventHandler;
67 private event EventHandler<ResizedEventArgs> _resizedEventHandler;
68 private event EventHandler<LanguageChangedEventArgs> _languageChangedEventHandler;
69 private event EventHandler<KeyboardTypeChangedEventArgs> _keyboardTypeChangedEventHandler;
70 private event EventHandler<ContentReceivedEventArgs> _contentReceivedEventHandler;
73 /// InputMethodContext activated.
75 /// <since_tizen> 5 </since_tizen>
76 public event EventHandler<ActivatedEventArgs> Activated
80 if (_activatedEventHandler == null)
82 _activatedEventCallback = OnActivated;
83 ActivatedSignal().Connect(_activatedEventCallback);
86 _activatedEventHandler += value;
90 _activatedEventHandler -= value;
92 if (_activatedEventHandler == null && _activatedEventCallback != null)
94 ActivatedSignal().Disconnect(_activatedEventCallback);
100 /// InputMethodContext event received.
102 /// <since_tizen> 5 </since_tizen>
103 public event EventHandlerWithReturnType<object, EventReceivedEventArgs, CallbackData> EventReceived
107 if (_eventReceivedEventHandler == null)
109 _eventReceivedEventCallback = OnEventReceived;
110 EventReceivedSignal().Connect(_eventReceivedEventCallback);
113 _eventReceivedEventHandler += value;
117 _eventReceivedEventHandler -= value;
119 if (_eventReceivedEventHandler == null && _eventReceivedEventCallback != null)
121 EventReceivedSignal().Disconnect(_eventReceivedEventCallback);
127 /// InputMethodContext status changed.
129 /// <since_tizen> 5 </since_tizen>
130 public event EventHandler<StatusChangedEventArgs> StatusChanged
134 if (_statusChangedEventHandler == null)
136 _statusChangedEventCallback = OnStatusChanged;
137 StatusChangedSignal().Connect(_statusChangedEventCallback);
140 _statusChangedEventHandler += value;
144 _statusChangedEventHandler -= value;
146 if (_statusChangedEventHandler == null && _statusChangedEventCallback != null)
148 StatusChangedSignal().Disconnect(_statusChangedEventCallback);
154 /// InputMethodContext resized.
156 /// <since_tizen> 5 </since_tizen>
157 public event EventHandler<ResizedEventArgs> Resized
161 if (_resizedEventHandler == null)
163 _resizedEventCallback = OnResized;
164 ResizedSignal().Connect(_resizedEventCallback);
167 _resizedEventHandler += value;
171 _resizedEventHandler -= value;
173 if (_resizedEventHandler == null && _resizedEventCallback != null)
175 ResizedSignal().Disconnect(_resizedEventCallback);
181 /// InputMethodContext language changed.
183 /// <since_tizen> 5 </since_tizen>
184 public event EventHandler<LanguageChangedEventArgs> LanguageChanged
188 if (_languageChangedEventHandler == null)
190 _languageChangedEventCallback = OnLanguageChanged;
191 LanguageChangedSignal().Connect(_languageChangedEventCallback);
194 _languageChangedEventHandler += value;
198 _languageChangedEventHandler -= value;
200 if (_languageChangedEventHandler == null && _languageChangedEventCallback != null)
202 LanguageChangedSignal().Disconnect(_languageChangedEventCallback);
208 /// InputMethodContext keyboard type changed.
210 /// <since_tizen> 5 </since_tizen>
211 public event EventHandler<KeyboardTypeChangedEventArgs> KeyboardTypeChanged
215 if (_keyboardTypeChangedEventHandler == null)
217 _keyboardTypeChangedEventCallback = OnKeyboardTypeChanged;
218 KeyboardTypeChangedSignal().Connect(_keyboardTypeChangedEventCallback);
221 _keyboardTypeChangedEventHandler += value;
225 _keyboardTypeChangedEventHandler -= value;
227 if (_keyboardTypeChangedEventHandler == null && _keyboardTypeChangedEventCallback != null)
229 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
235 /// InputMethodContext content received.
237 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
238 [EditorBrowsable(EditorBrowsableState.Never)]
239 public event EventHandler<ContentReceivedEventArgs> ContentReceived
243 if (_contentReceivedEventHandler == null)
245 _contentReceivedEventCallback = OnContentReceived;
246 ContentReceivedSignal().Connect(_contentReceivedEventCallback);
249 _contentReceivedEventHandler += value;
253 _contentReceivedEventHandler -= value;
255 if (_contentReceivedEventHandler == null && _contentReceivedEventCallback != null)
257 ContentReceivedSignal().Disconnect(_contentReceivedEventCallback);
263 /// The direction of the text.
265 /// <since_tizen> 5 </since_tizen>
266 public enum TextDirection
279 /// Events that are generated by the IMF.
281 /// <since_tizen> 5 </since_tizen>
282 public enum EventType
287 /// <since_tizen> 5 </since_tizen>
290 /// Pre-edit changed.
292 /// <since_tizen> 5 </since_tizen>
297 /// <since_tizen> 5 </since_tizen>
300 /// An event to delete a range of characters from the string.
302 /// <since_tizen> 5 </since_tizen>
305 /// An event to query string and the cursor position.
307 /// <since_tizen> 5 </since_tizen>
310 /// Private command sent from the input panel.
312 /// <since_tizen> 5 </since_tizen>
317 /// Enumeration for the state of the input panel.
319 /// <since_tizen> 5 </since_tizen>
325 /// <since_tizen> 5 </since_tizen>
328 /// Input panel is shown.
330 /// <since_tizen> 5 </since_tizen>
333 /// Input panel is hidden.
335 /// <since_tizen> 5 </since_tizen>
338 /// Input panel in process of being shown.
340 /// <since_tizen> 5 </since_tizen>
345 /// Enumeration for the types of keyboard.
347 /// <since_tizen> 5 </since_tizen>
348 public enum KeyboardType
351 /// Software keyboard (virtual keyboard) is default.
353 /// <since_tizen> 5 </since_tizen>
356 /// Hardware keyboard.
358 /// <since_tizen> 5 </since_tizen>
363 /// Gets or sets whether the IM context allows to use the text prediction.
365 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
366 [EditorBrowsable(EditorBrowsableState.Never)]
367 public bool TextPrediction
371 return IsTextPredictionAllowed();
375 AllowTextPrediction(value);
380 /// Destroys the context of the IMF.<br/>
382 /// <since_tizen> 5 </since_tizen>
383 public void DestroyContext()
385 Interop.InputMethodContext.InputMethodContext_Finalize(swigCPtr);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
390 /// Activates the IMF.<br/>
391 /// It means that the text editing has started.<br/>
392 /// If the hardware keyboard is not connected, then it shows the virtual keyboard.
394 /// <since_tizen> 5 </since_tizen>
395 public void Activate()
397 Interop.InputMethodContext.InputMethodContext_Activate(swigCPtr);
398 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
402 /// Deactivates the IMF.<br/>
403 /// It means that the text editing is complete.
405 /// <since_tizen> 5 </since_tizen>
406 public void Deactivate()
408 Interop.InputMethodContext.InputMethodContext_Deactivate(swigCPtr);
409 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
413 /// Gets the restoration status, which controls if the keyboard is restored after the focus is lost and then regained.<br/>
414 /// If true, then the keyboard will be restored (activated) after the focus is regained.
416 /// <returns>The restoration status.</returns>
417 /// <since_tizen> 5 </since_tizen>
418 public bool RestoreAfterFocusLost()
420 bool ret = Interop.InputMethodContext.InputMethodContext_RestoreAfterFocusLost(swigCPtr);
421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
426 /// Sets the status whether the IMF has to restore the keyboard after losing focus.
428 /// <param name="toggle">True means that keyboard must be restored after the focus is lost and regained.</param>
429 /// <since_tizen> 5 </since_tizen>
430 public void SetRestoreAfterFocusLost(bool toggle)
432 Interop.InputMethodContext.InputMethodContext_SetRestoreAfterFocusLost(swigCPtr, toggle);
433 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437 /// Sends a message reset to the pre-edit state or the IMF module.
439 /// <since_tizen> 5 </since_tizen>
440 public new void Reset()
442 Interop.InputMethodContext.InputMethodContext_Reset(swigCPtr);
443 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
447 /// Notifies the IMF context that the cursor position has changed, required for features such as auto-capitalization.
449 /// <since_tizen> 5 </since_tizen>
450 public void NotifyCursorPosition()
452 Interop.InputMethodContext.InputMethodContext_NotifyCursorPosition(swigCPtr);
453 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
457 /// Sets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
459 /// <param name="cursorPosition">The position of the cursor.</param>
460 /// <since_tizen> 5 </since_tizen>
461 public void SetCursorPosition(uint cursorPosition)
463 Interop.InputMethodContext.InputMethodContext_SetCursorPosition(swigCPtr, cursorPosition);
464 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
468 /// Gets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
470 /// <returns>The current position of the cursor.</returns>
471 /// <since_tizen> 5 </since_tizen>
472 public uint GetCursorPosition()
474 uint ret = Interop.InputMethodContext.InputMethodContext_GetCursorPosition(swigCPtr);
475 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480 /// A method to store the string required by the IMF, this is used to provide predictive word suggestions.
482 /// <param name="text">The text string surrounding the current cursor point.</param>
483 /// <since_tizen> 5 </since_tizen>
484 public void SetSurroundingText(string text)
486 Interop.InputMethodContext.InputMethodContext_SetSurroundingText(swigCPtr, text);
487 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
491 /// Gets the current text string set within the IMF manager, this is used to offer predictive suggestions.
493 /// <returns>The surrounding text.</returns>
494 /// <since_tizen> 5 </since_tizen>
495 public string GetSurroundingText()
497 string ret = Interop.InputMethodContext.InputMethodContext_GetSurroundingText(swigCPtr);
498 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
503 /// Notifies the IMF context that text input is set to multiline or not.
505 /// <param name="multiLine">True if multiline text input is used.</param>
506 /// <since_tizen> 5 </since_tizen>
507 public void NotifyTextInputMultiLine(bool multiLine)
509 Interop.InputMethodContext.InputMethodContext_NotifyTextInputMultiLine(swigCPtr, multiLine);
510 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
514 /// Returns the text direction of the current input language of the keyboard.
516 /// <returns>The direction of the text.</returns>
517 /// <since_tizen> 5 </since_tizen>
518 public InputMethodContext.TextDirection GetTextDirection()
520 InputMethodContext.TextDirection ret = (InputMethodContext.TextDirection)Interop.InputMethodContext.InputMethodContext_GetTextDirection(swigCPtr);
521 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
526 /// Provides the size and the position of the keyboard.<br/>
527 /// The position is relative to whether the keyboard is visible or not.<br/>
528 /// If the keyboard is not visible, then the position will be off the screen.<br/>
529 /// If the keyboard is not being shown when this method is called, the keyboard is partially setup (IMFContext) to get/>
530 /// the values then taken down. So ideally, GetInputMethodArea() must be called after Show().
532 /// <returns>Rectangle which is keyboard panel x, y, width, and height.</returns>
533 /// <since_tizen> 5 </since_tizen>
534 public Rectangle GetInputMethodArea()
536 Rectangle ret = new Rectangle(Interop.InputMethodContext.InputMethodContext_GetInputMethodArea(swigCPtr), true);
537 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
542 /// Sets up the input panel specific data.
544 /// <param name="text">The specific data to be set to the input panel.</param>
545 /// <since_tizen> 5 </since_tizen>
546 public void SetInputPanelUserData(string text)
548 Interop.InputMethodContext.InputMethodContext_SetInputPanelUserData(swigCPtr, text);
549 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
553 /// Gets the specific data of the current active input panel.
555 /// <param name="text">The specific data to be received from the input panel.</param>
556 /// <since_tizen> 5 </since_tizen>
557 public void GetInputPanelUserData(out string text)
559 Interop.InputMethodContext.InputMethodContext_GetInputPanelUserData(swigCPtr, out text);
560 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
564 /// Gets the state of the current active input panel.
566 /// <returns>The state of the input panel.</returns>
567 /// <since_tizen> 5 </since_tizen>
568 public InputMethodContext.State GetInputPanelState()
570 InputMethodContext.State ret = (InputMethodContext.State)Interop.InputMethodContext.InputMethodContext_GetInputPanelState(swigCPtr);
571 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
576 /// Sets the return key on the input panel to be visible or invisible.<br/>
577 /// The default value is true.
579 /// <param name="visible">True if the return key is visible (enabled), false otherwise.</param>
580 /// <since_tizen> 5 </since_tizen>
581 public void SetReturnKeyState(bool visible)
583 Interop.InputMethodContext.InputMethodContext_SetReturnKeyState(swigCPtr, visible);
584 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
588 /// Enables to show the input panel automatically when focused.
590 /// <param name="enabled">If true, the input panel will be shown when focused.</param>
591 /// <since_tizen> 5 </since_tizen>
592 public void AutoEnableInputPanel(bool enabled)
594 Interop.InputMethodContext.InputMethodContext_AutoEnableInputPanel(swigCPtr, enabled);
595 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
599 /// Shows the input panel.
601 /// <since_tizen> 5 </since_tizen>
602 public void ShowInputPanel()
604 Interop.InputMethodContext.InputMethodContext_ShowInputPanel(swigCPtr);
605 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
609 /// Hides the input panel.
611 /// <since_tizen> 5 </since_tizen>
612 public void HideInputPanel()
614 Interop.InputMethodContext.InputMethodContext_HideInputPanel(swigCPtr);
615 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
619 /// Gets the keyboard type.<br/>
620 /// The default keyboard type is SoftwareKeyboard.
622 /// <returns>The keyboard type.</returns>
623 /// <since_tizen> 5 </since_tizen>
624 public InputMethodContext.KeyboardType GetKeyboardType()
626 InputMethodContext.KeyboardType ret = (InputMethodContext.KeyboardType)Interop.InputMethodContext.InputMethodContext_GetKeyboardType(swigCPtr);
627 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
632 /// Gets the current language locale of the input panel.<br/>
633 /// For example, en_US, en_GB, en_PH, fr_FR, and so on.
635 /// <returns>The current language locale of the input panel.</returns>
636 /// <since_tizen> 5 </since_tizen>
637 public string GetInputPanelLocale()
639 string ret = Interop.InputMethodContext.InputMethodContext_GetInputPanelLocale(swigCPtr);
640 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645 /// Sets the allowed MIME Type to deliver to the input panel. <br/>
646 /// For example, string mimeType = "text/plain,image/png,image/gif,application/pdf";
648 /// <param name="mimeType">The allowed MIME type.</param>
649 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
650 [EditorBrowsable(EditorBrowsableState.Never)]
651 public void SetMIMEType(string mimeType)
653 Interop.InputMethodContext.InputMethodContext_SetMIMEType(swigCPtr, mimeType);
654 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
658 /// Sets the x,y coordinates of the input panel.
660 /// <param name="x">The top-left x coordinate of the input panel.</param>
661 /// <param name="y">The top-left y coordinate of the input panel.</param>
662 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
663 [EditorBrowsable(EditorBrowsableState.Never)]
664 public void SetInputPanelPosition(uint x, uint y)
666 Interop.InputMethodContext.InputMethodContext_SetInputPanelPosition(swigCPtr, x, y);
667 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
670 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(InputMethodContext obj)
672 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
675 internal InputMethodContext(InputMethodContext inputMethodContext) : this(Interop.InputMethodContext.new_InputMethodContext__SWIG_1(InputMethodContext.getCPtr(inputMethodContext)), true)
677 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
680 internal InputMethodContext Assign(InputMethodContext inputMethodContext)
682 InputMethodContext ret = new InputMethodContext(Interop.InputMethodContext.InputMethodContext_Assign(swigCPtr, InputMethodContext.getCPtr(inputMethodContext)), false);
683 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687 internal static InputMethodContext DownCast(BaseHandle handle)
689 InputMethodContext ret = new InputMethodContext(Interop.InputMethodContext.InputMethodContext_DownCast(BaseHandle.getCPtr(handle)), true);
690 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
694 internal void ApplyOptions(InputMethodOptions options)
696 Interop.InputMethodContext.InputMethodContext_ApplyOptions(swigCPtr, InputMethodOptions.getCPtr(options));
697 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
700 internal void AllowTextPrediction(bool prediction)
702 Interop.InputMethodContext.InputMethodContext_AllowTextPrediction(swigCPtr, prediction);
703 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
706 internal bool IsTextPredictionAllowed()
708 bool ret = Interop.InputMethodContext.InputMethodContext_IsTextPredictionAllowed(swigCPtr);
709 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
713 internal ActivatedSignalType ActivatedSignal()
715 ActivatedSignalType ret = new ActivatedSignalType(Interop.InputMethodContext.InputMethodContext_ActivatedSignal(swigCPtr), false);
716 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
720 internal KeyboardEventSignalType EventReceivedSignal()
722 KeyboardEventSignalType ret = new KeyboardEventSignalType(Interop.InputMethodContext.InputMethodContext_EventReceivedSignal(swigCPtr), false);
723 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
727 internal StatusSignalType StatusChangedSignal()
729 StatusSignalType ret = new StatusSignalType(Interop.InputMethodContext.InputMethodContext_StatusChangedSignal(swigCPtr), false);
730 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
734 internal KeyboardResizedSignalType ResizedSignal()
736 KeyboardResizedSignalType ret = new KeyboardResizedSignalType(Interop.InputMethodContext.InputMethodContext_ResizedSignal(swigCPtr), false);
737 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
741 internal LanguageChangedSignalType LanguageChangedSignal()
743 LanguageChangedSignalType ret = new LanguageChangedSignalType(Interop.InputMethodContext.InputMethodContext_LanguageChangedSignal(swigCPtr), false);
744 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
748 internal KeyboardTypeSignalType KeyboardTypeChangedSignal()
750 KeyboardTypeSignalType ret = new KeyboardTypeSignalType(Interop.InputMethodContext.InputMethodContext_KeyboardTypeChangedSignal(swigCPtr), false);
751 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
755 internal ContentReceivedSignalType ContentReceivedSignal()
757 ContentReceivedSignalType ret = new ContentReceivedSignalType(Interop.InputMethodContext.InputMethodContext_ContentReceivedSignal(swigCPtr), false);
758 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
763 /// You can override it to clean-up your own resources.
765 /// <param name="type">Dispose Type</param>
766 /// <since_tizen> 5 </since_tizen>
767 /// Please do not use! This will be deprecated!
768 /// Dispose() method in Singletone classes (ex: FocusManager, StyleManager, VisualFactory, InputMethodContext, TtsPlayer, Window) is not required.
769 [EditorBrowsable(EditorBrowsableState.Never)]
770 protected override void Dispose(DisposeTypes type)
777 //Release your own unmanaged resources here.
778 //You should not access any managed member here except static instance
779 //because the execution order of Finalizes is non-deterministic.
781 if (_keyboardTypeChangedEventCallback != null)
783 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
786 if (swigCPtr.Handle != global::System.IntPtr.Zero)
791 Interop.InputMethodContext.delete_InputMethodContext(swigCPtr);
793 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
799 private void OnActivated(IntPtr data)
801 ActivatedEventArgs e = new ActivatedEventArgs();
805 e.InputMethodContext = Registry.GetManagedBaseHandleFromNativePtr(data) as InputMethodContext;
808 if (_activatedEventHandler != null)
810 _activatedEventHandler(this, e);
814 private IntPtr OnEventReceived(IntPtr inputMethodContext, IntPtr eventData)
816 CallbackData callbackData = null;
818 EventReceivedEventArgs e = new EventReceivedEventArgs();
820 if (inputMethodContext != null)
822 e.InputMethodContext = Registry.GetManagedBaseHandleFromNativePtr(inputMethodContext) as InputMethodContext;
824 if (eventData != null)
826 e.EventData = EventData.GetEventDataFromPtr(eventData);
829 if (_eventReceivedEventHandler != null)
831 callbackData = _eventReceivedEventHandler(this, e);
833 if (callbackData != null)
835 return callbackData.GetCallbackDataPtr();
839 return new CallbackData().GetCallbackDataPtr();
843 private void OnStatusChanged(bool statusChanged)
845 StatusChangedEventArgs e = new StatusChangedEventArgs();
847 e.StatusChanged = statusChanged;
849 if (_statusChangedEventHandler != null)
851 _statusChangedEventHandler(this, e);
855 private void OnResized(int resized)
857 ResizedEventArgs e = new ResizedEventArgs();
860 if (_resizedEventHandler != null)
862 _resizedEventHandler(this, e);
866 private void OnLanguageChanged(int languageChanged)
868 LanguageChangedEventArgs e = new LanguageChangedEventArgs();
869 e.LanguageChanged = languageChanged;
871 if (_languageChangedEventHandler != null)
873 _languageChangedEventHandler(this, e);
877 private void OnKeyboardTypeChanged(KeyboardType type)
879 KeyboardTypeChangedEventArgs e = new KeyboardTypeChangedEventArgs();
881 e.KeyboardType = type;
883 if (_keyboardTypeChangedEventHandler != null)
885 _keyboardTypeChangedEventHandler(this, e);
889 private void OnContentReceived(string content, string description, string mimeType)
891 ContentReceivedEventArgs e = new ContentReceivedEventArgs();
893 e.Description = description;
894 e.MimeType = mimeType;
896 if (_contentReceivedEventHandler != null)
898 _contentReceivedEventHandler(this, e);
903 /// This structure is used to pass on data from the IMF regarding predictive text.
905 /// <since_tizen> 5 </since_tizen>
906 public class EventData : global::System.IDisposable
909 /// The state if it owns memory
911 /// <since_tizen> 5 </since_tizen>
912 protected bool swigCMemOwn;
915 /// A flag to check if it is already disposed.
917 /// <since_tizen> 5 </since_tizen>
918 protected bool disposed = false;
920 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
922 //A flag to check who called Dispose(). (By User or DisposeQueue)
923 private bool isDisposeQueued = false;
926 /// The default constructor.
928 /// <since_tizen> 5 </since_tizen>
929 public EventData() : this(Interop.InputMethodContext.new_InputMethodContext_EventData__SWIG_0(), true)
931 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
937 /// <param name="aEventName">The name of the event from the IMF.</param>
938 /// <param name="aPredictiveString">The pre-edit or the commit string.</param>
939 /// <param name="aCursorOffset">Start the position from the current cursor position to start deleting characters.</param>
940 /// <param name="aNumberOfChars">The number of characters to delete from the cursorOffset.</param>
941 /// <since_tizen> 5 </since_tizen>
942 public EventData(InputMethodContext.EventType aEventName, string aPredictiveString, int aCursorOffset, int aNumberOfChars) : this(Interop.InputMethodContext.new_InputMethodContext_EventData__SWIG_1((int)aEventName, aPredictiveString, aCursorOffset, aNumberOfChars), true)
944 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
947 internal EventData(IntPtr cPtr, bool cMemoryOwn)
949 swigCMemOwn = cMemoryOwn;
950 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
954 /// Releases the resource.
956 /// <since_tizen> 5 </since_tizen>
959 if (!isDisposeQueued)
961 isDisposeQueued = true;
962 DisposeQueue.Instance.Add(this);
967 /// The pre-edit or the commit string.
969 /// <since_tizen> 5 </since_tizen>
970 public string PredictiveString
974 Interop.InputMethodContext.InputMethodContext_EventData_predictiveString_set(swigCPtr, value);
975 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
979 string ret = Interop.InputMethodContext.InputMethodContext_EventData_predictiveString_get(swigCPtr);
980 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
986 /// The name of the event from the IMF.
988 /// <since_tizen> 5 </since_tizen>
989 public InputMethodContext.EventType EventName
993 Interop.InputMethodContext.InputMethodContext_EventData_eventName_set(swigCPtr, (int)value);
994 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
998 InputMethodContext.EventType ret = (InputMethodContext.EventType)Interop.InputMethodContext.InputMethodContext_EventData_eventName_get(swigCPtr);
999 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1005 /// The start position from the current cursor position to start deleting characters.
1007 /// <since_tizen> 5 </since_tizen>
1008 public int CursorOffset
1012 Interop.InputMethodContext.InputMethodContext_EventData_cursorOffset_set(swigCPtr, value);
1013 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1017 int ret = Interop.InputMethodContext.InputMethodContext_EventData_cursorOffset_get(swigCPtr);
1018 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1024 /// The number of characters to delete from the cursorOffset.
1026 /// <since_tizen> 5 </since_tizen>
1027 public int NumberOfChars
1031 Interop.InputMethodContext.InputMethodContext_EventData_numberOfChars_set(swigCPtr, value);
1032 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1036 int ret = Interop.InputMethodContext.InputMethodContext_EventData_numberOfChars_get(swigCPtr);
1037 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1043 /// The dispose pattern.
1045 /// <since_tizen> 5 </since_tizen>
1046 public void Dispose()
1048 //Throw excpetion if Dispose() is called in separate thread.
1049 if (!Window.IsInstalled())
1051 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
1054 if (isDisposeQueued)
1056 Dispose(DisposeTypes.Implicit);
1060 Dispose(DisposeTypes.Explicit);
1061 System.GC.SuppressFinalize(this);
1065 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(EventData obj)
1067 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1070 internal static EventData GetEventDataFromPtr(IntPtr cPtr)
1072 EventData ret = new EventData(cPtr, false);
1073 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1078 /// You can override it to clean-up your own resources.
1080 /// <since_tizen> 5 </since_tizen>
1081 protected virtual void Dispose(DisposeTypes type)
1088 if (type == DisposeTypes.Explicit)
1091 //Release your own managed resources here.
1092 //You should release all of your own disposable objects here.
1096 //Release your own unmanaged resources here.
1097 //You should not access any managed member here except static instance.
1098 //because the execution order of Finalizes is non-deterministic.
1100 if (swigCPtr.Handle != IntPtr.Zero)
1104 swigCMemOwn = false;
1105 Interop.InputMethodContext.delete_InputMethodContext_EventData(swigCPtr);
1107 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1115 /// Data required by the IMF from the callback.
1117 /// <since_tizen> 5 </since_tizen>
1118 public class CallbackData : global::System.IDisposable
1121 /// The state if it owns memory
1123 /// <since_tizen> 5 </since_tizen>
1124 protected bool swigCMemOwn;
1127 /// A Flag to check if it is already disposed.
1129 /// <since_tizen> 5 </since_tizen>
1130 protected bool disposed = false;
1132 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
1134 //A flag to check who called Dispose(). (By User or DisposeQueue)
1135 private bool isDisposeQueued = false;
1138 /// The default constructor.
1140 /// <since_tizen> 5 </since_tizen>
1141 public CallbackData() : this(Interop.InputMethodContext.new_InputMethodContext_CallbackData__SWIG_0(), true)
1143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1147 /// The constructor.
1149 /// <param name="aUpdate">True if the cursor position needs to be updated.</param>
1150 /// <param name="aCursorPosition">The new position of the cursor.</param>
1151 /// <param name="aCurrentText">The current text string.</param>
1152 /// <param name="aPreeditResetRequired">Flag if preedit reset is required.</param>
1153 /// <since_tizen> 5 </since_tizen>
1154 public CallbackData(bool aUpdate, int aCursorPosition, string aCurrentText, bool aPreeditResetRequired) : this(Interop.InputMethodContext.new_InputMethodContext_CallbackData__SWIG_1(aUpdate, aCursorPosition, aCurrentText, aPreeditResetRequired), true)
1156 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1160 /// Releases the resource.
1162 /// <since_tizen> 5 </since_tizen>
1165 if (!isDisposeQueued)
1167 isDisposeQueued = true;
1168 DisposeQueue.Instance.Add(this);
1173 /// The current text string.
1175 /// <since_tizen> 5 </since_tizen>
1176 public string CurrentText
1180 Interop.InputMethodContext.InputMethodContext_CallbackData_currentText_set(swigCPtr, value);
1181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1185 string ret = Interop.InputMethodContext.InputMethodContext_CallbackData_currentText_get(swigCPtr);
1186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1192 /// The current cursor position.
1194 /// <since_tizen> 5 </since_tizen>
1195 public int CursorPosition
1199 Interop.InputMethodContext.InputMethodContext_CallbackData_cursorPosition_set(swigCPtr, value);
1200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1204 int ret = Interop.InputMethodContext.InputMethodContext_CallbackData_cursorPosition_get(swigCPtr);
1205 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1211 /// The state if the cursor position needs to be updated.
1213 /// <since_tizen> 5 </since_tizen>
1218 Interop.InputMethodContext.InputMethodContext_CallbackData_update_set(swigCPtr, value);
1219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1223 bool ret = Interop.InputMethodContext.InputMethodContext_CallbackData_update_get(swigCPtr);
1224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1230 /// Flags if the pre-edit reset is required.
1232 /// <since_tizen> 5 </since_tizen>
1233 public bool PreeditResetRequired
1237 Interop.InputMethodContext.InputMethodContext_CallbackData_preeditResetRequired_set(swigCPtr, value);
1238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1242 bool ret = Interop.InputMethodContext.InputMethodContext_CallbackData_preeditResetRequired_get(swigCPtr);
1243 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1249 /// The dispose pattern.
1251 /// <since_tizen> 5 </since_tizen>
1252 public void Dispose()
1254 //Throw excpetion if Dispose() is called in separate thread.
1255 if (!Window.IsInstalled())
1257 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
1260 if (isDisposeQueued)
1262 Dispose(DisposeTypes.Implicit);
1266 Dispose(DisposeTypes.Explicit);
1267 System.GC.SuppressFinalize(this);
1271 internal IntPtr GetCallbackDataPtr()
1273 return (IntPtr)swigCPtr;
1276 internal CallbackData(IntPtr cPtr, bool cMemoryOwn)
1278 swigCMemOwn = cMemoryOwn;
1279 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
1282 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CallbackData obj)
1284 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1287 internal static CallbackData GetCallbackDataFromPtr(IntPtr cPtr)
1289 CallbackData ret = new CallbackData(cPtr, false);
1290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1295 /// You can override it to clean-up your own resources.
1297 /// <since_tizen> 5 </since_tizen>
1298 protected virtual void Dispose(DisposeTypes type)
1305 if (type == DisposeTypes.Explicit)
1308 //Release your own managed resources here.
1309 //You should release all of your own disposable objects here.
1313 //Release your own unmanaged resources here.
1314 //You should not access any managed member here except static instance.
1315 //Because the execution order of Finalizes is non-deterministic.
1317 if (swigCPtr.Handle != IntPtr.Zero)
1321 swigCMemOwn = false;
1322 Interop.InputMethodContext.delete_InputMethodContext_CallbackData(swigCPtr);
1324 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1332 /// InputMethodContext activated event arguments.
1334 /// <since_tizen> 5 </since_tizen>
1335 public class ActivatedEventArgs : EventArgs
1338 /// The instance of InputMethodContext
1340 /// <since_tizen> 5 </since_tizen>
1341 public InputMethodContext InputMethodContext
1349 /// InputMethodContext event receives event arguments.
1351 /// <since_tizen> 5 </since_tizen>
1352 public class EventReceivedEventArgs : EventArgs
1355 /// The instance of InputMethodContext
1357 /// <since_tizen> 5 </since_tizen>
1358 public InputMethodContext InputMethodContext
1365 /// The event data of IMF
1367 /// <since_tizen> 5 </since_tizen>
1368 public EventData EventData
1376 /// InputMethodContext status changed event arguments.
1378 /// <since_tizen> 5 </since_tizen>
1379 public class StatusChangedEventArgs : EventArgs
1382 /// InputMethodContext status.
1384 /// <since_tizen> 5 </since_tizen>
1385 public bool StatusChanged
1393 /// InputMethodContext resized event arguments.
1395 /// <since_tizen> 5 </since_tizen>
1396 public class ResizedEventArgs : EventArgs
1399 /// The state if the IMF resized.
1401 /// <since_tizen> 5 </since_tizen>
1410 /// InputMethodContext language changed event arguments.
1412 /// <since_tizen> 5 </since_tizen>
1413 public class LanguageChangedEventArgs : EventArgs
1416 /// Language changed.
1418 /// <since_tizen> 5 </since_tizen>
1419 public int LanguageChanged
1427 /// InputMethodContext keyboard type changed event arguments.
1429 /// <since_tizen> 5 </since_tizen>
1430 public class KeyboardTypeChangedEventArgs : EventArgs
1433 /// InputMethodContext keyboard type.
1435 /// <since_tizen> 5 </since_tizen>
1436 public KeyboardType KeyboardType
1444 /// InputMethodContext content received event arguments.
1446 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1447 [EditorBrowsable(EditorBrowsableState.Never)]
1448 public class ContentReceivedEventArgs : EventArgs
1451 /// The content, such as images, of input method
1453 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1454 [EditorBrowsable(EditorBrowsableState.Never)]
1455 public string Content
1461 /// The description of content
1463 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1464 [EditorBrowsable(EditorBrowsableState.Never)]
1465 public string Description
1471 /// The mime type of content, such as jpg, png, and so on
1473 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1474 [EditorBrowsable(EditorBrowsableState.Never)]
1475 public string MimeType