1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FM_IMC_PROJECT_INPUT_METHOD_UTILS_H 17 #define FM_IMC_PROJECT_INPUT_METHOD_UTILS_H 18 19 #include <stdint.h> 20 21 namespace OHOS { 22 namespace MiscServices { 23 enum class EnterKeyType { 24 UNSPECIFIED = 0, 25 NONE, 26 GO, 27 SEARCH, 28 SEND, 29 NEXT, 30 DONE, 31 PREVIOUS 32 }; 33 34 enum class TextInputType { 35 NONE = -1, 36 TEXT = 0, 37 MULTILINE, 38 NUMBER, 39 PHONE, 40 DATETIME, 41 EMAIL_ADDRESS, 42 URL, 43 VISIBLE_PASSWORD, 44 }; 45 46 enum class Direction { 47 NONE = 0, 48 UP = 1, 49 DOWN, 50 LEFT, 51 RIGHT, 52 }; 53 54 class Configuration { 55 public: GetEnterKeyType()56 EnterKeyType GetEnterKeyType() const 57 { 58 return enterKeyType; 59 } 60 SetEnterKeyType(EnterKeyType keyType)61 void SetEnterKeyType(EnterKeyType keyType) 62 { 63 enterKeyType = keyType; 64 } 65 GetTextInputType()66 TextInputType GetTextInputType() const 67 { 68 return textInputType; 69 } 70 SetTextInputType(TextInputType textType)71 void SetTextInputType(TextInputType textType) 72 { 73 textInputType = textType; 74 } 75 76 private: 77 EnterKeyType enterKeyType = EnterKeyType::UNSPECIFIED; 78 TextInputType textInputType = TextInputType::TEXT; 79 }; 80 81 struct CursorInfo { 82 double left = 0.0; 83 double top = 0.0; 84 double width = 0.0; 85 double height = 0.0; 86 }; 87 88 class KeyEvent { 89 }; 90 91 enum class KeyboardStatus { 92 NONE = 0, 93 HIDE, 94 SHOW 95 }; 96 enum class FunctionKey { 97 NONE = 0, 98 CONFIRM 99 }; 100 class KeyboardInfo { 101 public: GetKeyboardStatus()102 KeyboardStatus GetKeyboardStatus() const 103 { 104 return keyboardStatus; 105 } 106 SetKeyboardStatus(int32_t status)107 void SetKeyboardStatus(int32_t status) 108 { 109 keyboardStatus = static_cast<KeyboardStatus>(status); 110 } 111 GetFunctionKey()112 FunctionKey GetFunctionKey() const 113 { 114 return functionKey; 115 } 116 SetFunctionKey(int32_t key)117 void SetFunctionKey(int32_t key) 118 { 119 functionKey = static_cast<FunctionKey>(key); 120 } 121 private: 122 KeyboardStatus keyboardStatus = KeyboardStatus::NONE; 123 FunctionKey functionKey = FunctionKey::NONE; 124 }; 125 } 126 } 127 #endif // FM_IMC_PROJECT_INPUT_METHOD_UTILS_H 128