• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2023 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 FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_UTILS_H
17 #define FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_UTILS_H
18 
19 #include <stdint.h>
20 
21 #include "input_attribute.h"
22 #include "panel_info.h"
23 
24 namespace OHOS {
25 namespace MiscServices {
26 constexpr uint32_t INIT_WINDOW_ID = 0;
27 constexpr uint32_t INVALID_WINDOW_ID = INIT_WINDOW_ID - 1;
28 constexpr int32_t INVALID_VALUE = -1;
29 enum class EnterKeyType {
30     UNSPECIFIED = 0,
31     NONE,
32     GO,
33     SEARCH,
34     SEND,
35     NEXT,
36     DONE,
37     PREVIOUS,
38     NEW_LINE,
39 };
40 
41 enum class TextInputType {
42     NONE = -1,
43     TEXT = 0,
44     MULTILINE,
45     NUMBER,
46     PHONE,
47     DATETIME,
48     EMAIL_ADDRESS,
49     URL,
50     VISIBLE_PASSWORD,
51     NUMBER_PASSWORD,
52     SCREEN_LOCK_PASSWORD,
53     USER_NAME,
54     NEW_PASSWORD,
55     NUMBER_DECIMAL,
56 };
57 
58 enum class Direction {
59     NONE = 0,
60     UP = 1,
61     DOWN,
62     LEFT,
63     RIGHT,
64 };
65 
66 enum class SecurityMode {
67     BASIC = 0,
68     FULL = 1,
69 };
70 
71 enum class ExtendAction {
72     SELECT_ALL = 0,
73     CUT = 3,
74     COPY,
75     PASTE,
76 };
77 
78 class Configuration {
79 public:
GetEnterKeyType()80     EnterKeyType GetEnterKeyType() const
81     {
82         return enterKeyType;
83     }
84 
SetEnterKeyType(EnterKeyType keyType)85     void SetEnterKeyType(EnterKeyType keyType)
86     {
87         enterKeyType = keyType;
88     }
89 
GetTextInputType()90     TextInputType GetTextInputType() const
91     {
92         return textInputType;
93     }
94 
SetTextInputType(TextInputType textType)95     void SetTextInputType(TextInputType textType)
96     {
97         textInputType = textType;
98     }
99 
100 private:
101     EnterKeyType enterKeyType = EnterKeyType::UNSPECIFIED;
102     TextInputType textInputType = TextInputType::TEXT;
103 };
104 
105 struct CursorInfo {
106     double left = -1.0;
107     double top = -1.0;
108     double width = -1.0;
109     double height = -1.0;
110     bool operator==(const CursorInfo &info) const
111     {
112         return (left == info.left && top == info.top && width == info.width && height == info.height);
113     }
114 };
115 
116 class KeyEvent {};
117 
118 enum class KeyboardStatus : int32_t { NONE = 0, HIDE, SHOW }; // soft keyboard
119 
120 enum Trigger : int32_t { IME_APP, IMF, END };
121 struct PanelStatusInfo {
122     PanelInfo panelInfo;
123     bool visible{ false };
124     Trigger trigger{ END };
125     bool operator==(const PanelStatusInfo &info) const
126     {
127         return info.panelInfo.panelFlag == panelInfo.panelFlag && info.panelInfo.panelType == panelInfo.panelType
128                && info.visible == visible && info.trigger == trigger;
129     }
130 };
131 
132 class FunctionKey {
133 public:
GetEnterKeyType()134     EnterKeyType GetEnterKeyType() const
135     {
136         return enterKeyType;
137     }
138 
SetEnterKeyType(EnterKeyType keyType)139     void SetEnterKeyType(EnterKeyType keyType)
140     {
141         enterKeyType = keyType;
142     }
143 
144 private:
145     EnterKeyType enterKeyType = EnterKeyType::UNSPECIFIED;
146 };
147 
148 struct SelectionRange {
149     int32_t start = INVALID_VALUE;
150     int32_t end = INVALID_VALUE;
151 };
152 
153 struct TextSelection {
154     int32_t oldBegin = INVALID_VALUE;
155     int32_t oldEnd = INVALID_VALUE;
156     int32_t newBegin = INVALID_VALUE;
157     int32_t newEnd = INVALID_VALUE;
158 };
159 
160 class TextTotalConfig {
161 public:
162     InputAttribute inputAttribute = {};
163     CursorInfo cursorInfo = {};
164     TextSelection textSelection = {};
165     uint32_t windowId = INVALID_WINDOW_ID;
166     double positionY = 0;
167     double height = 0;
168 };
169 
170 struct TextConfig {
171     InputAttribute inputAttribute = {};
172     CursorInfo cursorInfo = {};
173     SelectionRange range = {};
174     uint32_t windowId = INVALID_WINDOW_ID;
175     double positionY = 0;
176     double height = 0;
177 };
178 
179 enum class InputType {
180     NONE = -1,
181     CAMERA_INPUT = 0,
182     SECURITY_INPUT,
183 };
184 
185 enum class SwitchTrigger : uint32_t { CURRENT_IME = 0, SYSTEM_APP, IMSA };
186 } // namespace MiscServices
187 } // namespace OHOS
188 #endif // FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_UTILS_H
189