@@ -2,40 +2,64 @@ package com.equationl.calculator_compose.dataModel
2
2
3
3
import androidx.compose.ui.graphics.Color
4
4
5
- const val KeyIndex_Percentage = 19
6
- const val KeyIndex_CE = 1001
7
- const val KeyIndex_C = 1002
8
- const val KeyIndex_Back = 1003
9
- const val KeyIndex_Reciprocal = 16
10
- const val KeyIndex_Pow2 = 17
11
- const val KeyIndex_Sqrt = 18
12
- const val KeyIndex_Divide = 13
13
- const val KeyIndex_7 = 7
14
- const val KeyIndex_8 = 8
15
- const val KeyIndex_9 = 9
16
- const val KeyIndex_Multiply = 12
17
- const val KeyIndex_4 = 4
18
- const val KeyIndex_5 = 5
19
- const val KeyIndex_6 = 6
20
- const val KeyIndex_Minus = 11
5
+ // 数字按键
6
+ const val KeyIndex_0 = 0
21
7
const val KeyIndex_1 = 1
22
8
const val KeyIndex_2 = 2
23
9
const val KeyIndex_3 = 3
24
- const val KeyIndex_Add = 10
25
- const val KeyIndex_NegativeNumber = 14
26
- const val KeyIndex_0 = 0
27
- const val KeyIndex_Point = 15
28
- const val KeyIndex_Equal = 200
10
+ const val KeyIndex_4 = 4
11
+ const val KeyIndex_5 = 5
12
+ const val KeyIndex_6 = 6
13
+ const val KeyIndex_7 = 7
14
+ const val KeyIndex_8 = 8
15
+ const val KeyIndex_9 = 9
16
+ const val KeyIndex_A = 17 // 不按照顺序往下编号是因为在程序员键盘中使用的是 ascii 索引, 而数字 9 和 A 间隔了 7 位
17
+ const val KeyIndex_B = 18
18
+ const val KeyIndex_C = 19
19
+ const val KeyIndex_D = 20
20
+ const val KeyIndex_E = 21
21
+ const val KeyIndex_F = 22
22
+
23
+ // 运算按键
24
+ const val KeyIndex_Add = 100
25
+ const val KeyIndex_Minus = 101
26
+ const val KeyIndex_Multiply = 102
27
+ const val KeyIndex_Divide = 103
28
+ const val KeyIndex_NegativeNumber = 104
29
+ const val KeyIndex_Point = 105
30
+ const val KeyIndex_Reciprocal = 106
31
+ const val KeyIndex_Pow2 = 107
32
+ const val KeyIndex_Sqrt = 108
33
+ const val KeyIndex_Percentage = 109
34
+ const val KeyIndex_Lsh = 110
35
+ const val KeyIndex_Rsh = 111
36
+ const val KeyIndex_And = 112
37
+ const val KeyIndex_Or = 113
38
+ const val KeyIndex_Not = 114
39
+ const val KeyIndex_NAnd = 115
40
+ const val KeyIndex_NOr = 116
41
+ const val KeyIndex_XOr = 117
42
+
43
+ // 功能按键
44
+ const val KeyIndex_Equal = 1000
45
+ const val KeyIndex_CE = 1001
46
+ const val KeyIndex_Clear = 1002
47
+ const val KeyIndex_Back = 1003
48
+
49
+ // 预留按键
50
+ const val KeyIndex_Null = - 1
51
+
29
52
30
53
val NumberColor = Color .White
31
54
val FunctionColor = Color .LightGray
32
55
val EqualColor = Color .Cyan
56
+ val UnavailableColor = Color .Transparent
33
57
34
58
val StandardKeyBoardBtn = listOf (
35
59
listOf (
36
60
KeyBoardData (" %" , FunctionColor , KeyIndex_Percentage ),
37
61
KeyBoardData (" CE" , FunctionColor , KeyIndex_CE ),
38
- KeyBoardData (" C" , FunctionColor , KeyIndex_C ),
62
+ KeyBoardData (" C" , FunctionColor , KeyIndex_Clear ),
39
63
KeyBoardData (" ←" , FunctionColor , KeyIndex_Back ),
40
64
),
41
65
listOf (
@@ -70,10 +94,65 @@ val StandardKeyBoardBtn = listOf(
70
94
)
71
95
)
72
96
97
+ val ProgrammerKeyBoardBtn = listOf (
98
+ listOf (
99
+ KeyBoardData (" A" , NumberColor , KeyIndex_A ),
100
+ KeyBoardData (" XOR" , FunctionColor , KeyIndex_XOr ),
101
+ KeyBoardData (" CE" , FunctionColor , KeyIndex_CE ),
102
+ KeyBoardData (" C" , FunctionColor , KeyIndex_Clear ),
103
+ KeyBoardData (" ←" , FunctionColor , KeyIndex_Back ),
104
+ ),
105
+ listOf (
106
+ KeyBoardData (" B" , NumberColor , KeyIndex_B ),
107
+ KeyBoardData (" AND" , FunctionColor , KeyIndex_And ),
108
+ KeyBoardData (" OR" , FunctionColor , KeyIndex_Or ),
109
+ KeyBoardData (" NOT" , FunctionColor , KeyIndex_Not ),
110
+ KeyBoardData (Operator .Divide .showText, FunctionColor , KeyIndex_Divide ),
111
+ ),
112
+ listOf (
113
+ KeyBoardData (" C" , NumberColor , KeyIndex_C ),
114
+ KeyBoardData (" 7" , NumberColor , KeyIndex_7 ),
115
+ KeyBoardData (" 8" , NumberColor , KeyIndex_8 ),
116
+ KeyBoardData (" 9" , NumberColor , KeyIndex_9 ),
117
+ KeyBoardData (Operator .MULTIPLY .showText, FunctionColor , KeyIndex_Multiply ),
118
+ ),
119
+ listOf (
120
+ KeyBoardData (" D" , NumberColor , KeyIndex_D ),
121
+ KeyBoardData (" 4" , NumberColor , KeyIndex_4 ),
122
+ KeyBoardData (" 5" , NumberColor , KeyIndex_5 ),
123
+ KeyBoardData (" 6" , NumberColor , KeyIndex_6 ),
124
+ KeyBoardData (Operator .MINUS .showText, FunctionColor , KeyIndex_Minus ),
125
+ ),
126
+ listOf (
127
+ KeyBoardData (" E" , NumberColor , KeyIndex_E ),
128
+ KeyBoardData (" 1" , NumberColor , KeyIndex_1 ),
129
+ KeyBoardData (" 2" , NumberColor , KeyIndex_2 ),
130
+ KeyBoardData (" 3" , NumberColor , KeyIndex_3 ),
131
+ KeyBoardData (Operator .ADD .showText, FunctionColor , KeyIndex_Add ),
132
+ ),
133
+ listOf (
134
+ KeyBoardData (" F" , NumberColor , KeyIndex_F ),
135
+ KeyBoardData (" <<" , FunctionColor , KeyIndex_Lsh ),
136
+ KeyBoardData (" 0" , NumberColor , KeyIndex_0 ),
137
+ KeyBoardData (" >>" , FunctionColor , KeyIndex_Rsh ),
138
+ KeyBoardData (" =" , FunctionColor , KeyIndex_Equal ),
139
+ )
140
+ )
141
+
142
+ val BitOperationList = listOf (
143
+ Operator .NOT ,
144
+ Operator .AND ,
145
+ Operator .OR ,
146
+ Operator .XOR ,
147
+ Operator .LSH ,
148
+ Operator .RSH
149
+ )
150
+
73
151
data class KeyBoardData (
74
152
val text : String ,
75
153
val background : Color ,
76
- val clickInfo : Int
154
+ val index : Int ,
155
+ val isAvailable : Boolean = true
77
156
)
78
157
79
158
enum class Operator (val showText : String ) {
@@ -83,5 +162,49 @@ enum class Operator(val showText: String) {
83
162
Divide (" ÷" ),
84
163
SQRT (" √" ),
85
164
POW2 (" ²" ),
165
+ NOT (" NOT" ),
166
+ AND (" AND " ),
167
+ OR (" OR " ),
168
+ XOR (" XOR " ),
169
+ LSH (" Lsh " ),
170
+ RSH (" Rsh " ),
86
171
NUll (" " )
172
+ }
173
+
174
+ enum class InputBase (val number : Int , val forbidBtn : List <Int >) {
175
+ HEX (16 , listOf ()),
176
+ DEC (10 , listOf (
177
+ KeyIndex_A ,
178
+ KeyIndex_B ,
179
+ KeyIndex_C ,
180
+ KeyIndex_D ,
181
+ KeyIndex_E ,
182
+ KeyIndex_F
183
+ )),
184
+ OCT (8 , listOf (
185
+ KeyIndex_A ,
186
+ KeyIndex_B ,
187
+ KeyIndex_C ,
188
+ KeyIndex_D ,
189
+ KeyIndex_E ,
190
+ KeyIndex_F ,
191
+ KeyIndex_8 ,
192
+ KeyIndex_9 ,
193
+ )),
194
+ BIN (2 , listOf (
195
+ KeyIndex_A ,
196
+ KeyIndex_B ,
197
+ KeyIndex_C ,
198
+ KeyIndex_D ,
199
+ KeyIndex_E ,
200
+ KeyIndex_F ,
201
+ KeyIndex_9 ,
202
+ KeyIndex_8 ,
203
+ KeyIndex_7 ,
204
+ KeyIndex_6 ,
205
+ KeyIndex_5 ,
206
+ KeyIndex_4 ,
207
+ KeyIndex_3 ,
208
+ KeyIndex_2
209
+ ))
87
210
}
0 commit comments