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();
657 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(InputMethodContext obj)
659 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
662 internal InputMethodContext(InputMethodContext inputMethodContext) : this(Interop.InputMethodContext.new_InputMethodContext__SWIG_1(InputMethodContext.getCPtr(inputMethodContext)), true)
664 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
667 internal InputMethodContext Assign(InputMethodContext inputMethodContext)
669 InputMethodContext ret = new InputMethodContext(Interop.InputMethodContext.InputMethodContext_Assign(swigCPtr, InputMethodContext.getCPtr(inputMethodContext)), false);
670 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674 internal static InputMethodContext DownCast(BaseHandle handle)
676 InputMethodContext ret = new InputMethodContext(Interop.InputMethodContext.InputMethodContext_DownCast(BaseHandle.getCPtr(handle)), true);
677 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
681 internal void ApplyOptions(InputMethodOptions options)
683 Interop.InputMethodContext.InputMethodContext_ApplyOptions(swigCPtr, InputMethodOptions.getCPtr(options));
684 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687 internal void AllowTextPrediction(bool prediction)
689 Interop.InputMethodContext.InputMethodContext_AllowTextPrediction(swigCPtr, prediction);
690 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
693 internal bool IsTextPredictionAllowed()
695 bool ret = Interop.InputMethodContext.InputMethodContext_IsTextPredictionAllowed(swigCPtr);
696 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
700 internal ActivatedSignalType ActivatedSignal()
702 ActivatedSignalType ret = new ActivatedSignalType(Interop.InputMethodContext.InputMethodContext_ActivatedSignal(swigCPtr), false);
703 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707 internal KeyboardEventSignalType EventReceivedSignal()
709 KeyboardEventSignalType ret = new KeyboardEventSignalType(Interop.InputMethodContext.InputMethodContext_EventReceivedSignal(swigCPtr), false);
710 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
714 internal StatusSignalType StatusChangedSignal()
716 StatusSignalType ret = new StatusSignalType(Interop.InputMethodContext.InputMethodContext_StatusChangedSignal(swigCPtr), false);
717 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
721 internal KeyboardResizedSignalType ResizedSignal()
723 KeyboardResizedSignalType ret = new KeyboardResizedSignalType(Interop.InputMethodContext.InputMethodContext_ResizedSignal(swigCPtr), false);
724 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
728 internal LanguageChangedSignalType LanguageChangedSignal()
730 LanguageChangedSignalType ret = new LanguageChangedSignalType(Interop.InputMethodContext.InputMethodContext_LanguageChangedSignal(swigCPtr), false);
731 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
735 internal KeyboardTypeSignalType KeyboardTypeChangedSignal()
737 KeyboardTypeSignalType ret = new KeyboardTypeSignalType(Interop.InputMethodContext.InputMethodContext_KeyboardTypeChangedSignal(swigCPtr), false);
738 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
742 internal ContentReceivedSignalType ContentReceivedSignal()
744 ContentReceivedSignalType ret = new ContentReceivedSignalType(Interop.InputMethodContext.InputMethodContext_ContentReceivedSignal(swigCPtr), false);
745 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
750 /// You can override it to clean-up your own resources.
752 /// <param name="type">Dispose Type</param>
753 /// <since_tizen> 5 </since_tizen>
754 /// Please do not use! This will be deprecated!
755 /// Dispose() method in Singletone classes (ex: FocusManager, StyleManager, VisualFactory, InputMethodContext, TtsPlayer, Window) is not required.
756 [EditorBrowsable(EditorBrowsableState.Never)]
757 protected override void Dispose(DisposeTypes type)
764 //Release your own unmanaged resources here.
765 //You should not access any managed member here except static instance
766 //because the execution order of Finalizes is non-deterministic.
768 if (_keyboardTypeChangedEventCallback != null)
770 KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
773 if (swigCPtr.Handle != global::System.IntPtr.Zero)
778 Interop.InputMethodContext.delete_InputMethodContext(swigCPtr);
780 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
786 private void OnActivated(IntPtr data)
788 ActivatedEventArgs e = new ActivatedEventArgs();
792 e.InputMethodContext = Registry.GetManagedBaseHandleFromNativePtr(data) as InputMethodContext;
795 if (_activatedEventHandler != null)
797 _activatedEventHandler(this, e);
801 private IntPtr OnEventReceived(IntPtr inputMethodContext, IntPtr eventData)
803 CallbackData callbackData = null;
805 EventReceivedEventArgs e = new EventReceivedEventArgs();
807 if (inputMethodContext != null)
809 e.InputMethodContext = Registry.GetManagedBaseHandleFromNativePtr(inputMethodContext) as InputMethodContext;
811 if (eventData != null)
813 e.EventData = EventData.GetEventDataFromPtr(eventData);
816 if (_eventReceivedEventHandler != null)
818 callbackData = _eventReceivedEventHandler(this, e);
820 if (callbackData != null)
822 return callbackData.GetCallbackDataPtr();
826 return new CallbackData().GetCallbackDataPtr();
830 private void OnStatusChanged(bool statusChanged)
832 StatusChangedEventArgs e = new StatusChangedEventArgs();
834 e.StatusChanged = statusChanged;
836 if (_statusChangedEventHandler != null)
838 _statusChangedEventHandler(this, e);
842 private void OnResized(int resized)
844 ResizedEventArgs e = new ResizedEventArgs();
847 if (_resizedEventHandler != null)
849 _resizedEventHandler(this, e);
853 private void OnLanguageChanged(int languageChanged)
855 LanguageChangedEventArgs e = new LanguageChangedEventArgs();
856 e.LanguageChanged = languageChanged;
858 if (_languageChangedEventHandler != null)
860 _languageChangedEventHandler(this, e);
864 private void OnKeyboardTypeChanged(KeyboardType type)
866 KeyboardTypeChangedEventArgs e = new KeyboardTypeChangedEventArgs();
868 e.KeyboardType = type;
870 if (_keyboardTypeChangedEventHandler != null)
872 _keyboardTypeChangedEventHandler(this, e);
876 private void OnContentReceived(string content, string description, string mimeType)
878 ContentReceivedEventArgs e = new ContentReceivedEventArgs();
880 e.Description = description;
881 e.MimeType = mimeType;
883 if (_contentReceivedEventHandler != null)
885 _contentReceivedEventHandler(this, e);
890 /// This structure is used to pass on data from the IMF regarding predictive text.
892 /// <since_tizen> 5 </since_tizen>
893 public class EventData : global::System.IDisposable
896 /// The state if it owns memory
898 /// <since_tizen> 5 </since_tizen>
899 protected bool swigCMemOwn;
902 /// A flag to check if it is already disposed.
904 /// <since_tizen> 5 </since_tizen>
905 protected bool disposed = false;
907 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
909 //A flag to check who called Dispose(). (By User or DisposeQueue)
910 private bool isDisposeQueued = false;
913 /// The default constructor.
915 /// <since_tizen> 5 </since_tizen>
916 public EventData() : this(Interop.InputMethodContext.new_InputMethodContext_EventData__SWIG_0(), true)
918 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
924 /// <param name="aEventName">The name of the event from the IMF.</param>
925 /// <param name="aPredictiveString">The pre-edit or the commit string.</param>
926 /// <param name="aCursorOffset">Start the position from the current cursor position to start deleting characters.</param>
927 /// <param name="aNumberOfChars">The number of characters to delete from the cursorOffset.</param>
928 /// <since_tizen> 5 </since_tizen>
929 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)
931 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
934 internal EventData(IntPtr cPtr, bool cMemoryOwn)
936 swigCMemOwn = cMemoryOwn;
937 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
941 /// Releases the resource.
943 /// <since_tizen> 5 </since_tizen>
946 if (!isDisposeQueued)
948 isDisposeQueued = true;
949 DisposeQueue.Instance.Add(this);
954 /// The pre-edit or the commit string.
956 /// <since_tizen> 5 </since_tizen>
957 public string PredictiveString
961 Interop.InputMethodContext.InputMethodContext_EventData_predictiveString_set(swigCPtr, value);
962 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
966 string ret = Interop.InputMethodContext.InputMethodContext_EventData_predictiveString_get(swigCPtr);
967 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
973 /// The name of the event from the IMF.
975 /// <since_tizen> 5 </since_tizen>
976 public InputMethodContext.EventType EventName
980 Interop.InputMethodContext.InputMethodContext_EventData_eventName_set(swigCPtr, (int)value);
981 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
985 InputMethodContext.EventType ret = (InputMethodContext.EventType)Interop.InputMethodContext.InputMethodContext_EventData_eventName_get(swigCPtr);
986 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
992 /// The start position from the current cursor position to start deleting characters.
994 /// <since_tizen> 5 </since_tizen>
995 public int CursorOffset
999 Interop.InputMethodContext.InputMethodContext_EventData_cursorOffset_set(swigCPtr, value);
1000 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1004 int ret = Interop.InputMethodContext.InputMethodContext_EventData_cursorOffset_get(swigCPtr);
1005 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1011 /// The number of characters to delete from the cursorOffset.
1013 /// <since_tizen> 5 </since_tizen>
1014 public int NumberOfChars
1018 Interop.InputMethodContext.InputMethodContext_EventData_numberOfChars_set(swigCPtr, value);
1019 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1023 int ret = Interop.InputMethodContext.InputMethodContext_EventData_numberOfChars_get(swigCPtr);
1024 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1030 /// The dispose pattern.
1032 /// <since_tizen> 5 </since_tizen>
1033 public void Dispose()
1035 //Throw excpetion if Dispose() is called in separate thread.
1036 if (!Window.IsInstalled())
1038 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
1041 if (isDisposeQueued)
1043 Dispose(DisposeTypes.Implicit);
1047 Dispose(DisposeTypes.Explicit);
1048 System.GC.SuppressFinalize(this);
1052 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(EventData obj)
1054 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1057 internal static EventData GetEventDataFromPtr(IntPtr cPtr)
1059 EventData ret = new EventData(cPtr, false);
1060 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1065 /// You can override it to clean-up your own resources.
1067 /// <since_tizen> 5 </since_tizen>
1068 protected virtual void Dispose(DisposeTypes type)
1075 if (type == DisposeTypes.Explicit)
1078 //Release your own managed resources here.
1079 //You should release all of your own disposable objects here.
1083 //Release your own unmanaged resources here.
1084 //You should not access any managed member here except static instance.
1085 //because the execution order of Finalizes is non-deterministic.
1087 if (swigCPtr.Handle != IntPtr.Zero)
1091 swigCMemOwn = false;
1092 Interop.InputMethodContext.delete_InputMethodContext_EventData(swigCPtr);
1094 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1102 /// Data required by the IMF from the callback.
1104 /// <since_tizen> 5 </since_tizen>
1105 public class CallbackData : global::System.IDisposable
1108 /// The state if it owns memory
1110 /// <since_tizen> 5 </since_tizen>
1111 protected bool swigCMemOwn;
1114 /// A Flag to check if it is already disposed.
1116 /// <since_tizen> 5 </since_tizen>
1117 protected bool disposed = false;
1119 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
1121 //A flag to check who called Dispose(). (By User or DisposeQueue)
1122 private bool isDisposeQueued = false;
1125 /// The default constructor.
1127 /// <since_tizen> 5 </since_tizen>
1128 public CallbackData() : this(Interop.InputMethodContext.new_InputMethodContext_CallbackData__SWIG_0(), true)
1130 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1134 /// The constructor.
1136 /// <param name="aUpdate">True if the cursor position needs to be updated.</param>
1137 /// <param name="aCursorPosition">The new position of the cursor.</param>
1138 /// <param name="aCurrentText">The current text string.</param>
1139 /// <param name="aPreeditResetRequired">Flag if preedit reset is required.</param>
1140 /// <since_tizen> 5 </since_tizen>
1141 public CallbackData(bool aUpdate, int aCursorPosition, string aCurrentText, bool aPreeditResetRequired) : this(Interop.InputMethodContext.new_InputMethodContext_CallbackData__SWIG_1(aUpdate, aCursorPosition, aCurrentText, aPreeditResetRequired), true)
1143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1147 /// Releases the resource.
1149 /// <since_tizen> 5 </since_tizen>
1152 if (!isDisposeQueued)
1154 isDisposeQueued = true;
1155 DisposeQueue.Instance.Add(this);
1160 /// The current text string.
1162 /// <since_tizen> 5 </since_tizen>
1163 public string CurrentText
1167 Interop.InputMethodContext.InputMethodContext_CallbackData_currentText_set(swigCPtr, value);
1168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1172 string ret = Interop.InputMethodContext.InputMethodContext_CallbackData_currentText_get(swigCPtr);
1173 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1179 /// The current cursor position.
1181 /// <since_tizen> 5 </since_tizen>
1182 public int CursorPosition
1186 Interop.InputMethodContext.InputMethodContext_CallbackData_cursorPosition_set(swigCPtr, value);
1187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1191 int ret = Interop.InputMethodContext.InputMethodContext_CallbackData_cursorPosition_get(swigCPtr);
1192 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1198 /// The state if the cursor position needs to be updated.
1200 /// <since_tizen> 5 </since_tizen>
1205 Interop.InputMethodContext.InputMethodContext_CallbackData_update_set(swigCPtr, value);
1206 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1210 bool ret = Interop.InputMethodContext.InputMethodContext_CallbackData_update_get(swigCPtr);
1211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1217 /// Flags if the pre-edit reset is required.
1219 /// <since_tizen> 5 </since_tizen>
1220 public bool PreeditResetRequired
1224 Interop.InputMethodContext.InputMethodContext_CallbackData_preeditResetRequired_set(swigCPtr, value);
1225 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1229 bool ret = Interop.InputMethodContext.InputMethodContext_CallbackData_preeditResetRequired_get(swigCPtr);
1230 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1236 /// The dispose pattern.
1238 /// <since_tizen> 5 </since_tizen>
1239 public void Dispose()
1241 //Throw excpetion if Dispose() is called in separate thread.
1242 if (!Window.IsInstalled())
1244 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
1247 if (isDisposeQueued)
1249 Dispose(DisposeTypes.Implicit);
1253 Dispose(DisposeTypes.Explicit);
1254 System.GC.SuppressFinalize(this);
1258 internal IntPtr GetCallbackDataPtr()
1260 return (IntPtr)swigCPtr;
1263 internal CallbackData(IntPtr cPtr, bool cMemoryOwn)
1265 swigCMemOwn = cMemoryOwn;
1266 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
1269 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CallbackData obj)
1271 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
1274 internal static CallbackData GetCallbackDataFromPtr(IntPtr cPtr)
1276 CallbackData ret = new CallbackData(cPtr, false);
1277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1282 /// You can override it to clean-up your own resources.
1284 /// <since_tizen> 5 </since_tizen>
1285 protected virtual void Dispose(DisposeTypes type)
1292 if (type == DisposeTypes.Explicit)
1295 //Release your own managed resources here.
1296 //You should release all of your own disposable objects here.
1300 //Release your own unmanaged resources here.
1301 //You should not access any managed member here except static instance.
1302 //Because the execution order of Finalizes is non-deterministic.
1304 if (swigCPtr.Handle != IntPtr.Zero)
1308 swigCMemOwn = false;
1309 Interop.InputMethodContext.delete_InputMethodContext_CallbackData(swigCPtr);
1311 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
1319 /// InputMethodContext activated event arguments.
1321 /// <since_tizen> 5 </since_tizen>
1322 public class ActivatedEventArgs : EventArgs
1325 /// The instance of InputMethodContext
1327 /// <since_tizen> 5 </since_tizen>
1328 public InputMethodContext InputMethodContext
1336 /// InputMethodContext event receives event arguments.
1338 /// <since_tizen> 5 </since_tizen>
1339 public class EventReceivedEventArgs : EventArgs
1342 /// The instance of InputMethodContext
1344 /// <since_tizen> 5 </since_tizen>
1345 public InputMethodContext InputMethodContext
1352 /// The event data of IMF
1354 /// <since_tizen> 5 </since_tizen>
1355 public EventData EventData
1363 /// InputMethodContext status changed event arguments.
1365 /// <since_tizen> 5 </since_tizen>
1366 public class StatusChangedEventArgs : EventArgs
1369 /// InputMethodContext status.
1371 /// <since_tizen> 5 </since_tizen>
1372 public bool StatusChanged
1380 /// InputMethodContext resized event arguments.
1382 /// <since_tizen> 5 </since_tizen>
1383 public class ResizedEventArgs : EventArgs
1386 /// The state if the IMF resized.
1388 /// <since_tizen> 5 </since_tizen>
1397 /// InputMethodContext language changed event arguments.
1399 /// <since_tizen> 5 </since_tizen>
1400 public class LanguageChangedEventArgs : EventArgs
1403 /// Language changed.
1405 /// <since_tizen> 5 </since_tizen>
1406 public int LanguageChanged
1414 /// InputMethodContext keyboard type changed event arguments.
1416 /// <since_tizen> 5 </since_tizen>
1417 public class KeyboardTypeChangedEventArgs : EventArgs
1420 /// InputMethodContext keyboard type.
1422 /// <since_tizen> 5 </since_tizen>
1423 public KeyboardType KeyboardType
1431 /// InputMethodContext content received event arguments.
1433 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1434 [EditorBrowsable(EditorBrowsableState.Never)]
1435 public class ContentReceivedEventArgs : EventArgs
1438 /// The content, such as images, of input method
1440 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1441 [EditorBrowsable(EditorBrowsableState.Never)]
1442 public string Content
1448 /// The description of content
1450 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1451 [EditorBrowsable(EditorBrowsableState.Never)]
1452 public string Description
1458 /// The mime type of content, such as jpg, png, and so on
1460 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1461 [EditorBrowsable(EditorBrowsableState.Never)]
1462 public string MimeType