/*
* Copyright(c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
namespace Tizen.NUI
{
///
/// Specifically manages the input method framework (IMF) that enables the virtual or hardware keyboards.
///
/// 5
public class InputMethodContext : BaseHandle
{
private ActivatedEventCallbackType _activatedEventCallback;
private EventReceivedEventCallbackType _eventReceivedEventCallback;
private StatusChangedEventCallbackType _statusChangedEventCallback;
private ResizedEventCallbackType _resizedEventCallback;
private LanguageChangedEventCallbackType _languageChangedEventCallback;
private KeyboardTypeChangedEventCallbackType _keyboardTypeChangedEventCallback;
private ContentReceivedCallbackType _contentReceivedEventCallback;
///
/// Constructor.
///
/// 5
/// This will be deprecated
[Obsolete("Deprecated in API8; Will be removed in API10")]
public InputMethodContext() : this(Interop.InputMethodContext.New(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal InputMethodContext(IntPtr cPtr, bool cMemoryOwn) : base(Interop.InputMethodContext.Upcast(cPtr), cMemoryOwn)
{
}
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void ActivatedEventCallbackType(IntPtr data);
private delegate IntPtr EventReceivedEventCallbackType(IntPtr inputMethodContext, IntPtr eventData);
private delegate void StatusChangedEventCallbackType(bool statusChanged);
private delegate void ResizedEventCallbackType(int resized);
private delegate void LanguageChangedEventCallbackType(int languageChanged);
private delegate void KeyboardTypeChangedEventCallbackType(KeyboardType type);
private delegate void ContentReceivedCallbackType(string content, string description, string mimeType);
private event EventHandler _activatedEventHandler;
private event EventHandlerWithReturnType _eventReceivedEventHandler;
private event EventHandler _statusChangedEventHandler;
private event EventHandler _resizedEventHandler;
private event EventHandler _languageChangedEventHandler;
private event EventHandler _keyboardTypeChangedEventHandler;
private event EventHandler _contentReceivedEventHandler;
///
/// InputMethodContext activated.
///
/// 5
public event EventHandler Activated
{
add
{
if (_activatedEventHandler == null)
{
_activatedEventCallback = OnActivated;
ActivatedSignal().Connect(_activatedEventCallback);
}
_activatedEventHandler += value;
}
remove
{
_activatedEventHandler -= value;
if (_activatedEventHandler == null && _activatedEventCallback != null)
{
ActivatedSignal().Disconnect(_activatedEventCallback);
}
}
}
///
/// InputMethodContext event received.
///
/// 5
public event EventHandlerWithReturnType EventReceived
{
add
{
if (_eventReceivedEventHandler == null)
{
_eventReceivedEventCallback = OnEventReceived;
EventReceivedSignal().Connect(_eventReceivedEventCallback);
}
_eventReceivedEventHandler += value;
}
remove
{
_eventReceivedEventHandler -= value;
if (_eventReceivedEventHandler == null && _eventReceivedEventCallback != null)
{
EventReceivedSignal().Disconnect(_eventReceivedEventCallback);
}
}
}
///
/// InputMethodContext status changed.
///
/// 5
public event EventHandler StatusChanged
{
add
{
if (_statusChangedEventHandler == null)
{
_statusChangedEventCallback = OnStatusChanged;
StatusChangedSignal().Connect(_statusChangedEventCallback);
}
_statusChangedEventHandler += value;
}
remove
{
_statusChangedEventHandler -= value;
if (_statusChangedEventHandler == null && _statusChangedEventCallback != null)
{
StatusChangedSignal().Disconnect(_statusChangedEventCallback);
}
}
}
///
/// InputMethodContext resized.
///
/// 5
public event EventHandler Resized
{
add
{
if (_resizedEventHandler == null)
{
_resizedEventCallback = OnResized;
ResizedSignal().Connect(_resizedEventCallback);
}
_resizedEventHandler += value;
}
remove
{
_resizedEventHandler -= value;
if (_resizedEventHandler == null && _resizedEventCallback != null)
{
ResizedSignal().Disconnect(_resizedEventCallback);
}
}
}
///
/// InputMethodContext language changed.
///
/// 5
public event EventHandler LanguageChanged
{
add
{
if (_languageChangedEventHandler == null)
{
_languageChangedEventCallback = OnLanguageChanged;
LanguageChangedSignal().Connect(_languageChangedEventCallback);
}
_languageChangedEventHandler += value;
}
remove
{
_languageChangedEventHandler -= value;
if (_languageChangedEventHandler == null && _languageChangedEventCallback != null)
{
LanguageChangedSignal().Disconnect(_languageChangedEventCallback);
}
}
}
///
/// InputMethodContext keyboard type changed.
///
/// 5
public event EventHandler KeyboardTypeChanged
{
add
{
if (_keyboardTypeChangedEventHandler == null)
{
_keyboardTypeChangedEventCallback = OnKeyboardTypeChanged;
KeyboardTypeChangedSignal().Connect(_keyboardTypeChangedEventCallback);
}
_keyboardTypeChangedEventHandler += value;
}
remove
{
_keyboardTypeChangedEventHandler -= value;
if (_keyboardTypeChangedEventHandler == null && _keyboardTypeChangedEventCallback != null)
{
KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
}
}
}
///
/// InputMethodContext content received.
///
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public event EventHandler ContentReceived
{
add
{
if (_contentReceivedEventHandler == null)
{
_contentReceivedEventCallback = OnContentReceived;
ContentReceivedSignal().Connect(_contentReceivedEventCallback);
}
_contentReceivedEventHandler += value;
}
remove
{
_contentReceivedEventHandler -= value;
if (_contentReceivedEventHandler == null && _contentReceivedEventCallback != null)
{
ContentReceivedSignal().Disconnect(_contentReceivedEventCallback);
}
}
}
///
/// The direction of the text.
///
/// 5
public enum TextDirection
{
///
/// Left to right.
///
LeftToRight,
///
/// Right to left.
///
RightToLeft
}
///
/// Events that are generated by the IMF.
///
/// 5
public enum EventType
{
///
/// No event.
///
/// 5
Void,
///
/// Pre-edit changed.
///
/// 5
Preedit,
///
/// Commit received.
///
/// 5
Commit,
///
/// An event to delete a range of characters from the string.
///
/// 5
DeleteSurrounding,
///
/// An event to query string and the cursor position.
///
/// 5
GetSurrounding,
///
/// Private command sent from the input panel.
///
/// 5
PrivateCommand
}
///
/// Enumeration for the state of the input panel.
///
/// 5
public enum State
{
///
/// Unknown state.
///
/// 5
Default = 0,
///
/// Input panel is shown.
///
/// 5
Show,
///
/// Input panel is hidden.
///
/// 5
Hide,
///
/// Input panel in process of being shown.
///
/// 5
WillShow
}
///
/// Enumeration for the types of keyboard.
///
/// 5
public enum KeyboardType
{
///
/// Software keyboard (virtual keyboard) is default.
///
/// 5
SoftwareKeyboard,
///
/// Hardware keyboard.
///
/// 5
HardwareKeyboard
}
///
/// Enumeration for the language mode of the input panel.
///
/// 8
public enum InputPanelLanguage
{
///
/// IME Language is automatically set depending on the system display.
///
/// 8
Automatic,
///
/// Latin alphabet at all times.
///
/// 8
Alphabet
}
///
/// Gets or sets whether the IM context allows to use the text prediction.
///
/// 8
public bool TextPrediction
{
get
{
return IsTextPredictionAllowed();
}
set
{
AllowTextPrediction(value);
}
}
///
/// Destroys the context of the IMF.
///
/// 5
public void DestroyContext()
{
Interop.InputMethodContext.Finalize(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Activates the IMF.
/// It means that the text editing has started.
/// If the hardware keyboard is not connected, then it shows the virtual keyboard.
///
/// 5
public void Activate()
{
Interop.InputMethodContext.Activate(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Deactivates the IMF.
/// It means that the text editing is complete.
///
/// 5
public void Deactivate()
{
Interop.InputMethodContext.Deactivate(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Gets the restoration status, which controls if the keyboard is restored after the focus is lost and then regained.
/// If true, then the keyboard will be restored (activated) after the focus is regained.
///
/// The restoration status.
/// 5
public bool RestoreAfterFocusLost()
{
bool ret = Interop.InputMethodContext.RestoreAfterFocusLost(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets the status whether the IMF has to restore the keyboard after losing focus.
///
/// True means that keyboard must be restored after the focus is lost and regained.
/// 5
public void SetRestoreAfterFocusLost(bool toggle)
{
Interop.InputMethodContext.SetRestoreAfterFocusLost(SwigCPtr, toggle);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sends a message reset to the pre-edit state or the IMF module.
///
/// 5
public new void Reset()
{
Interop.InputMethodContext.Reset(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Notifies the IMF context that the cursor position has changed, required for features such as auto-capitalization.
///
/// 5
public void NotifyCursorPosition()
{
Interop.InputMethodContext.NotifyCursorPosition(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
///
/// The position of the cursor.
/// 5
public void SetCursorPosition(uint cursorPosition)
{
Interop.InputMethodContext.SetCursorPosition(SwigCPtr, cursorPosition);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Gets the cursor position stored in VirtualKeyboard, this is required by the IMF context.
///
/// The current position of the cursor.
/// 5
public uint GetCursorPosition()
{
uint ret = Interop.InputMethodContext.GetCursorPosition(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// A method to store the string required by the IMF, this is used to provide predictive word suggestions.
///
/// The text string surrounding the current cursor point.
/// 5
public void SetSurroundingText(string text)
{
Interop.InputMethodContext.SetSurroundingText(SwigCPtr, text);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Gets the current text string set within the IMF manager, this is used to offer predictive suggestions.
///
/// The surrounding text.
/// 5
public string GetSurroundingText()
{
string ret = Interop.InputMethodContext.GetSurroundingText(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Notifies the IMF context that text input is set to multiline or not.
///
/// True if multiline text input is used.
/// 5
public void NotifyTextInputMultiLine(bool multiLine)
{
Interop.InputMethodContext.NotifyTextInputMultiLine(SwigCPtr, multiLine);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Returns the text direction of the current input language of the keyboard.
///
/// The direction of the text.
/// 5
public InputMethodContext.TextDirection GetTextDirection()
{
InputMethodContext.TextDirection ret = (InputMethodContext.TextDirection)Interop.InputMethodContext.GetTextDirection(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Provides the size and the position of the keyboard.
/// The position is relative to whether the keyboard is visible or not.
/// If the keyboard is not visible, then the position will be off the screen.
/// If the keyboard is not being shown when this method is called, the keyboard is partially setup (IMFContext) to get/>
/// the values then taken down. So ideally, GetInputMethodArea() must be called after Show().
///
/// Rectangle which is keyboard panel x, y, width, and height.
/// 5
public Rectangle GetInputMethodArea()
{
Rectangle ret = new Rectangle(Interop.InputMethodContext.GetInputMethodArea(SwigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets up the input panel specific data.
///
/// The specific data to be set to the input panel.
/// 5
public void SetInputPanelUserData(string text)
{
Interop.InputMethodContext.SetInputPanelUserData(SwigCPtr, text);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Gets the specific data of the current active input panel.
///
/// The specific data to be received from the input panel.
/// 5
public void GetInputPanelUserData(out string text)
{
Interop.InputMethodContext.GetInputPanelUserData(SwigCPtr, out text);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Gets the state of the current active input panel.
///
/// The state of the input panel.
/// 5
public InputMethodContext.State GetInputPanelState()
{
InputMethodContext.State ret = (InputMethodContext.State)Interop.InputMethodContext.GetInputPanelState(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets the return key on the input panel to be visible or invisible.
/// The default value is true.
///
/// True if the return key is visible (enabled), false otherwise.
/// 5
public void SetReturnKeyState(bool visible)
{
Interop.InputMethodContext.SetReturnKeyState(SwigCPtr, visible);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Enables to show the input panel automatically when focused.
///
/// If true, the input panel will be shown when focused.
/// 5
public void AutoEnableInputPanel(bool enabled)
{
Interop.InputMethodContext.AutoEnableInputPanel(SwigCPtr, enabled);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Shows the input panel.
///
/// 5
public void ShowInputPanel()
{
Interop.InputMethodContext.ShowInputPanel(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Hides the input panel.
///
/// 5
public void HideInputPanel()
{
Interop.InputMethodContext.HideInputPanel(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Gets the keyboard type.
/// The default keyboard type is SoftwareKeyboard.
///
/// The keyboard type.
/// 5
public InputMethodContext.KeyboardType GetKeyboardType()
{
InputMethodContext.KeyboardType ret = (InputMethodContext.KeyboardType)Interop.InputMethodContext.GetKeyboardType(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Gets the current language locale of the input panel.
/// For example, en_US, en_GB, en_PH, fr_FR, and so on.
///
/// The current language locale of the input panel.
/// 5
public string GetInputPanelLocale()
{
string ret = Interop.InputMethodContext.GetInputPanelLocale(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets the allowed MIME Type to deliver to the input panel.
/// For example, string mimeType = "text/plain,image/png,image/gif,application/pdf";
///
/// The allowed MIME type.
/// 8
public void SetMIMEType(string mimeType)
{
Interop.InputMethodContext.SetMIMEType(SwigCPtr, mimeType);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sets the x,y coordinates of the input panel.
///
/// The top-left x coordinate of the input panel.
/// The top-left y coordinate of the input panel.
/// 8
public void SetInputPanelPosition(uint x, uint y)
{
Interop.InputMethodContext.SetInputPanelPosition(SwigCPtr, x, y);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Sets the language of the input panel.
///
/// The language to be set to the input panel
/// 8
public void SetInputPanelLanguage(InputMethodContext.InputPanelLanguage language)
{
Interop.InputMethodContext.SetInputPanelLanguage(SwigCPtr, (int)language);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Gets the language of the input panel.
///
/// The language of the input panel
/// 8
public InputMethodContext.InputPanelLanguage GetInputPanelLanguage()
{
InputMethodContext.InputPanelLanguage ret = (InputMethodContext.InputPanelLanguage)Interop.InputMethodContext.GetInputPanelLanguage(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(InputMethodContext obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.SwigCPtr;
}
internal InputMethodContext(InputMethodContext inputMethodContext) : this(Interop.InputMethodContext.NewInputMethodContext(InputMethodContext.getCPtr(inputMethodContext)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal InputMethodContext Assign(InputMethodContext inputMethodContext)
{
InputMethodContext ret = new InputMethodContext(Interop.InputMethodContext.Assign(SwigCPtr, InputMethodContext.getCPtr(inputMethodContext)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal static InputMethodContext DownCast(BaseHandle handle)
{
InputMethodContext ret = new InputMethodContext(Interop.InputMethodContext.DownCast(BaseHandle.getCPtr(handle)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void ApplyOptions(InputMethodOptions options)
{
Interop.InputMethodContext.ApplyOptions(SwigCPtr, InputMethodOptions.getCPtr(options));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal void AllowTextPrediction(bool prediction)
{
Interop.InputMethodContext.AllowTextPrediction(SwigCPtr, prediction);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal bool IsTextPredictionAllowed()
{
bool ret = Interop.InputMethodContext.IsTextPredictionAllowed(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal ActivatedSignalType ActivatedSignal()
{
ActivatedSignalType ret = new ActivatedSignalType(Interop.InputMethodContext.ActivatedSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal KeyboardEventSignalType EventReceivedSignal()
{
KeyboardEventSignalType ret = new KeyboardEventSignalType(Interop.InputMethodContext.EventReceivedSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal StatusSignalType StatusChangedSignal()
{
StatusSignalType ret = new StatusSignalType(Interop.InputMethodContext.StatusChangedSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal KeyboardResizedSignalType ResizedSignal()
{
KeyboardResizedSignalType ret = new KeyboardResizedSignalType(Interop.InputMethodContext.ResizedSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal LanguageChangedSignalType LanguageChangedSignal()
{
LanguageChangedSignalType ret = new LanguageChangedSignalType(Interop.InputMethodContext.LanguageChangedSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal KeyboardTypeSignalType KeyboardTypeChangedSignal()
{
KeyboardTypeSignalType ret = new KeyboardTypeSignalType(Interop.InputMethodContext.KeyboardTypeChangedSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal ContentReceivedSignalType ContentReceivedSignal()
{
ContentReceivedSignalType ret = new ContentReceivedSignalType(Interop.InputMethodContext.ContentReceivedSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// You can override it to clean-up your own resources.
///
/// Dispose Type
/// 5
/// Please do not use! This will be deprecated!
/// Dispose() method in Singletone classes (ex: FocusManager, StyleManager, VisualFactory, InputMethodContext, TtsPlayer, Window) is not required.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance
//because the execution order of Finalizes is non-deterministic.
if (_keyboardTypeChangedEventCallback != null)
{
KeyboardTypeChangedSignal().Disconnect(_keyboardTypeChangedEventCallback);
}
base.Dispose(type);
}
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
Interop.InputMethodContext.DeleteInputMethodContext(swigCPtr);
}
private void OnActivated(IntPtr data)
{
ActivatedEventArgs e = new ActivatedEventArgs();
if (data != null)
{
e.InputMethodContext = Registry.GetManagedBaseHandleFromNativePtr(data) as InputMethodContext;
}
if (_activatedEventHandler != null)
{
_activatedEventHandler(this, e);
}
}
private IntPtr OnEventReceived(IntPtr inputMethodContext, IntPtr eventData)
{
CallbackData callbackData = null;
EventReceivedEventArgs e = new EventReceivedEventArgs();
if (inputMethodContext != null)
{
e.InputMethodContext = Registry.GetManagedBaseHandleFromNativePtr(inputMethodContext) as InputMethodContext;
}
if (eventData != null)
{
e.EventData = EventData.GetEventDataFromPtr(eventData);
}
if (_eventReceivedEventHandler != null)
{
callbackData = _eventReceivedEventHandler(this, e);
}
if (callbackData != null)
{
return callbackData.GetCallbackDataPtr();
}
else
{
return new CallbackData().GetCallbackDataPtr();
}
}
private void OnStatusChanged(bool statusChanged)
{
StatusChangedEventArgs e = new StatusChangedEventArgs();
e.StatusChanged = statusChanged;
if (_statusChangedEventHandler != null)
{
_statusChangedEventHandler(this, e);
}
}
private void OnResized(int resized)
{
ResizedEventArgs e = new ResizedEventArgs();
e.Resized = resized;
if (_resizedEventHandler != null)
{
_resizedEventHandler(this, e);
}
}
private void OnLanguageChanged(int languageChanged)
{
LanguageChangedEventArgs e = new LanguageChangedEventArgs();
e.LanguageChanged = languageChanged;
if (_languageChangedEventHandler != null)
{
_languageChangedEventHandler(this, e);
}
}
private void OnKeyboardTypeChanged(KeyboardType type)
{
KeyboardTypeChangedEventArgs e = new KeyboardTypeChangedEventArgs();
e.KeyboardType = type;
if (_keyboardTypeChangedEventHandler != null)
{
_keyboardTypeChangedEventHandler(this, e);
}
}
private void OnContentReceived(string content, string description, string mimeType)
{
ContentReceivedEventArgs e = new ContentReceivedEventArgs();
e.Content = content;
e.Description = description;
e.MimeType = mimeType;
if (_contentReceivedEventHandler != null)
{
_contentReceivedEventHandler(this, e);
}
}
///
/// This structure is used to pass on data from the IMF regarding predictive text.
///
/// 5
public class EventData : Disposable
{
///
/// The state if it owns memory
///
/// 5
//ToDo : raise ACR as [Obsolete("This has been deprecated in API9 and will be removed in API11. Please use swigCMemOwn which is declared in parent class")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "")]
protected bool swigCMemOwn;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
///
/// The default constructor.
///
/// 5
public EventData() : this(Interop.InputMethodContext.NewInputMethodContextEventData(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The constructor.
///
/// The name of the event from the IMF.
/// The pre-edit or the commit string.
/// Start the position from the current cursor position to start deleting characters.
/// The number of characters to delete from the cursorOffset.
/// 5
public EventData(InputMethodContext.EventType aEventName, string aPredictiveString, int aCursorOffset, int aNumberOfChars) : this(Interop.InputMethodContext.NewInputMethodContextEventData((int)aEventName, aPredictiveString, aCursorOffset, aNumberOfChars), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal EventData(IntPtr cPtr, bool cMemoryOwn)
{
swigCMemOwn = cMemoryOwn;
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
///
/// The pre-edit or the commit string.
///
/// 5
public string PredictiveString
{
set
{
Interop.InputMethodContext.EventDataPredictiveStringSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
string ret = Interop.InputMethodContext.EventDataPredictiveStringGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// The name of the event from the IMF.
///
/// 5
public InputMethodContext.EventType EventName
{
set
{
Interop.InputMethodContext.EventDataEventNameSet(swigCPtr, (int)value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
InputMethodContext.EventType ret = (InputMethodContext.EventType)Interop.InputMethodContext.EventDataEventNameGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// The start position from the current cursor position to start deleting characters.
///
/// 5
public int CursorOffset
{
set
{
Interop.InputMethodContext.EventDataCursorOffsetSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
int ret = Interop.InputMethodContext.EventDataCursorOffsetGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// The number of characters to delete from the cursorOffset.
///
/// 5
public int NumberOfChars
{
set
{
Interop.InputMethodContext.EventDataNumberOfCharsSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
int ret = Interop.InputMethodContext.EventDataNumberOfCharsGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(EventData obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
}
internal static EventData GetEventDataFromPtr(IntPtr cPtr)
{
EventData ret = new EventData(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// You can override it to clean-up your own resources.
///
/// 5
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//because the execution order of Finalizes is non-deterministic.
if (swigCPtr.Handle != IntPtr.Zero)
{
if (swigCMemOwn)
{
swigCMemOwn = false;
Interop.InputMethodContext.DeleteInputMethodContextEventData(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
}
base.Dispose(type);
}
}
///
/// Data required by the IMF from the callback.
///
/// 5
public class CallbackData : Disposable
{
///
/// The state if it owns memory
///
/// 5
//ToDo : raise ACR as [Obsolete("This has been deprecated in API9 and will be removed in API11. Please use SwigCMemOwn which is declared in parent class")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "")]
protected bool swigCMemOwn;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
///
/// The default constructor.
///
/// 5
public CallbackData() : this(Interop.InputMethodContext.NewInputMethodContextCallbackData(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The constructor.
///
/// True if the cursor position needs to be updated.
/// The new position of the cursor.
/// The current text string.
/// Flag if preedit reset is required.
/// 5
public CallbackData(bool aUpdate, int aCursorPosition, string aCurrentText, bool aPreeditResetRequired) : this(Interop.InputMethodContext.NewInputMethodContextCallbackData(aUpdate, aCursorPosition, aCurrentText, aPreeditResetRequired), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The current text string.
///
/// 5
public string CurrentText
{
set
{
Interop.InputMethodContext.CallbackDataCurrentTextSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
string ret = Interop.InputMethodContext.CallbackDataCurrentTextGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// The current cursor position.
///
/// 5
public int CursorPosition
{
set
{
Interop.InputMethodContext.CallbackDataCursorPositionSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
int ret = Interop.InputMethodContext.CallbackDataCursorPositionGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// The state if the cursor position needs to be updated.
///
/// 5
public bool Update
{
set
{
Interop.InputMethodContext.CallbackDataUpdateSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
bool ret = Interop.InputMethodContext.CallbackDataUpdateGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
///
/// Flags if the pre-edit reset is required.
///
/// 5
public bool PreeditResetRequired
{
set
{
Interop.InputMethodContext.CallbackDataPreeditResetRequiredSet(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
bool ret = Interop.InputMethodContext.CallbackDataPreeditResetRequiredGet(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return ret;
}
}
internal IntPtr GetCallbackDataPtr()
{
return (IntPtr)swigCPtr;
}
internal CallbackData(IntPtr cPtr, bool cMemoryOwn)
{
swigCMemOwn = cMemoryOwn;
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
internal static CallbackData GetCallbackDataFromPtr(IntPtr cPtr)
{
CallbackData ret = new CallbackData(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// You can override it to clean-up your own resources.
///
/// 5
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//Because the execution order of Finalizes is non-deterministic.
if (swigCPtr.Handle != IntPtr.Zero)
{
if (swigCMemOwn)
{
swigCMemOwn = false;
Interop.InputMethodContext.DeleteInputMethodContextCallbackData(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero);
}
base.Dispose(type);
}
}
///
/// InputMethodContext activated event arguments.
///
/// 5
public class ActivatedEventArgs : EventArgs
{
///
/// The instance of InputMethodContext
///
/// 5
public InputMethodContext InputMethodContext
{
get;
set;
}
}
///
/// InputMethodContext event receives event arguments.
///
/// 5
public class EventReceivedEventArgs : EventArgs
{
///
/// The instance of InputMethodContext
///
/// 5
public InputMethodContext InputMethodContext
{
get;
set;
}
///
/// The event data of IMF
///
/// 5
public EventData EventData
{
get;
set;
}
}
///
/// InputMethodContext status changed event arguments.
///
/// 5
public class StatusChangedEventArgs : EventArgs
{
///
/// InputMethodContext status.
///
/// 5
public bool StatusChanged
{
get;
set;
}
}
///
/// InputMethodContext resized event arguments.
///
/// 5
public class ResizedEventArgs : EventArgs
{
///
/// The state if the IMF resized.
///
/// 5
public int Resized
{
get;
set;
}
}
///
/// InputMethodContext language changed event arguments.
///
/// 5
public class LanguageChangedEventArgs : EventArgs
{
///
/// Language changed.
///
/// 5
public int LanguageChanged
{
get;
set;
}
}
///
/// InputMethodContext keyboard type changed event arguments.
///
/// 5
public class KeyboardTypeChangedEventArgs : EventArgs
{
///
/// InputMethodContext keyboard type.
///
/// 5
public KeyboardType KeyboardType
{
get;
set;
}
}
///
/// InputMethodContext content received event arguments.
///
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public class ContentReceivedEventArgs : EventArgs
{
///
/// The content, such as images, of input method
///
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public string Content
{
get;
set;
}
///
/// The description of content
///
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public string Description
{
get;
set;
}
///
/// The mime type of content, such as jpg, png, and so on
///
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public string MimeType
{
get;
set;
}
}
}
}