/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * 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 static Interop.InputMethod; namespace Tizen.Uix.InputMethod { /// /// Enumeration for Input Panel Layout /// public enum InputPanelLayout { /// /// Normal /// LayoutNormal, /// /// Number /// LayoutNumber, /// /// Email /// LayoutEMail, /// /// URL /// LayoutURL, /// /// Phone Number /// LayoutPhoneNumber, /// /// IP /// LayoutIP, /// /// Month /// LayoutMonth, /// /// Number Only /// LayoutNumberOnly, /// /// Invalid /// LayoutInvalid, /// /// HEX /// LayoutHEX, /// /// Terminal /// LayoutTerminal, /// /// Password /// LayoutPassword, /// /// Date Time /// LayoutDateTime, /// /// Emoticon /// LayoutEmoticon, /// /// Voice /// LayoutVoice, /// /// Undefined /// Undefined }; /// /// Enumeration for Layout Variation /// public enum LayoutVariation { /// /// The plain normal layout /// NormalNormal = 0, /// /// Filename layout; symbols such as '/', '\*', '\', '|', '<', '>', '?', '"' and ':' should be disabled /// NormalFileName, /// /// The name of a person /// NormalPersonName, /// /// The plain normal number layout /// NumberOnlyNormal = 0, /// /// The number layout to allow a negative sign /// NumberOnlySigned, /// /// The number layout to allow decimal point to provide fractional value /// NumberOnlyDecimal, /// /// The number layout to allow decimal point and negative sign /// NumberOnlySignedAndDecimal, /// /// The normal password layout /// PasswordNormal = 0, /// /// The password layout to allow only number /// PasswordNumberOnly, /// /// Undefined /// Undefined }; /// /// Enumeration for AutoCapital Type /// public enum AutoCapitalization { /// /// None /// None, /// /// Word /// Word, /// /// Sentence /// Sentence, /// /// All Character /// AllCharacter, /// /// Undefined /// Undefined }; /// /// Enumeration for InputPanel ReturnKey Type /// public enum InputPanelReturnKey { /// /// Default /// Default, /// /// Done /// Done, /// /// Go /// Go, /// /// Join /// Join, /// /// Login /// Login, /// /// Next /// Next, /// /// Search /// Search, /// /// Send /// Send, /// /// SignIn /// SignIn, /// /// Undefined /// Undefined }; /// /// Enumeration for InputHints /// public enum InputHints { /// /// None /// None, /// /// AutoComplete /// AutoComplete, /// /// SensitiveData /// SensitiveData, /// /// Multiline /// Multiline, /// /// Undefined /// Undefined }; /// /// Enumeration for BiDi Direction /// public enum BiDirection { /// /// Neutral /// Neutral, /// /// LTR /// LTR, /// /// RTL /// RTL, /// /// Undefined /// Undefined }; /// /// Enumeration for InputPanel Language /// public enum InputPanelLanguage { /// /// Automatic /// Automatic, /// /// Alphabet /// Alphabet, /// /// Undefined /// Undefined }; /// /// This class represents the context of InputMethodEditor /// public class InputMethodContext { private IntPtr _handle; internal InputMethodContext(IntPtr handle) { _handle = handle; } /// /// Gets the layout information. /// public InputPanelLayout Layout { get { InputPanelLayout layout; ErrorCode error = ImeContextGetLayout(_handle, out layout); if (error != ErrorCode.None) { Log.Error(LogTag, "GetLayout Failed with error " + error); return InputPanelLayout.Undefined; } return layout; } } /// /// Gets the layout variation information. /// public LayoutVariation LayoutVariation { get { LayoutVariation layoutVariation; ErrorCode error = ImeContextGetLayoutVariation(_handle, out layoutVariation); if (error != ErrorCode.None) { Log.Error(LogTag, "GetLayoutVariation Failed with error " + error); return LayoutVariation.Undefined; } return layoutVariation; } } /// /// Gets the cursor position information. /// public int CursorPosition { get { int cursorPosition; ErrorCode error = ImeContextGetCursorPosition(_handle, out cursorPosition); if (error != ErrorCode.None) { Log.Error(LogTag, "GetCursorPosition Failed with error " + error); return -1; } return cursorPosition; } } /// /// Gets the autocapital type information. /// public AutoCapitalization AutoCapitalization { get { AutoCapitalization autoCapitalType; ErrorCode error = ImeContextGetAutocapitalType(_handle, out autoCapitalType); if (error != ErrorCode.None) { Log.Error(LogTag, "GetAutoCapitalization Failed with error " + error); return AutoCapitalization.Undefined; } return autoCapitalType; } } /// /// Gets the Return key label type information. /// public InputPanelReturnKey ReturnKey { get { InputPanelReturnKey returnKeyType; ErrorCode error = ImeContextGetReturnKey(_handle, out returnKeyType); if (error != ErrorCode.None) { Log.Error(LogTag, "GetReturnKey Failed with error " + error); return InputPanelReturnKey.Undefined; } return returnKeyType; } } /// /// Gets the Return key state information. /// public bool ReturnKeyState { get { bool returnKeyState; ErrorCode error = ImeContextGetReturnKeyState(_handle, out returnKeyState); if (error != ErrorCode.None) { Log.Error(LogTag, "GetReturnKeyState Failed with error " + error); return false; } return returnKeyState; } } /// /// Gets the prediction mode information. /// public bool PredictionMode { get { bool predictionMode; ErrorCode error = ImeContextGetPredictionMode(_handle, out predictionMode); if (error != ErrorCode.None) { Log.Error(LogTag, "GetPredictionMode Failed with error " + error); return false; } return predictionMode; } } /// /// Gets the password mode information. /// public bool PasswordMode { get { bool passwordMode; ErrorCode error = ImeContextGetPasswordMode(_handle, out passwordMode); if (error != ErrorCode.None) { Log.Error(LogTag, "GetPasswordMode Failed with error " + error); return false; } return passwordMode; } } /// /// Gets the input hint information. /// public InputHints InputHint { get { InputHints inputHint; ErrorCode error = ImeContextGetInputHint(_handle, out inputHint); if (error != ErrorCode.None) { Log.Error(LogTag, "GetInputHint Failed with error " + error); return InputHints.Undefined; } return inputHint; } } /// /// Gets the text bidirectional information. /// public BiDirection BiDirection { get { BiDirection biDiDirection; ErrorCode error = ImeContextGetBidiDirection(_handle, out biDiDirection); if (error != ErrorCode.None) { Log.Error(LogTag, "GetBiDirection Failed with error " + error); return BiDirection.Undefined; } return biDiDirection; } } /// /// Gets the preferred language information. /// public InputPanelLanguage Language { get { InputPanelLanguage langauge; ErrorCode error = ImeContextGetLanguage(_handle, out langauge); if (error != ErrorCode.None) { Log.Error(LogTag, "GetLanguage Failed with error " + error); return InputPanelLanguage.Undefined; } return langauge; } } } }