@@ -164,7 +164,7 @@ KeypadDrawContext::KeypadDrawContext(int charWidth, int charHeight) :
164
164
165
165
const KeypadImage *KeypadDrawContext::getImage (const RawKey &key) const {
166
166
const KeypadImage *result;
167
- switch (key. _lower ) {
167
+ switch (getKey ( key) ) {
168
168
case K_CUT: result = &_cutImage; break ;
169
169
case K_COPY: result = &_copyImage; break ;
170
170
case K_PASTE: result = &_pasteImage; break ;
@@ -188,6 +188,18 @@ void KeypadDrawContext::toggle() {
188
188
_keySet = static_cast <Keyset>((_keySet + 1 ) % kSize );
189
189
}
190
190
191
+ KeyCode KeypadDrawContext::getKey (RawKey key) const {
192
+ KeyCode keyCode;
193
+ switch (_keySet) {
194
+ case kLower : keyCode = key._lower ; break ;
195
+ case kUpper : keyCode = key._upper ; break ;
196
+ case kNumber : keyCode = key._number ; break ;
197
+ case kSymbol : keyCode = key._symbol ; break ;
198
+ case kSize : keyCode = K_NULL; break ;
199
+ }
200
+ return keyCode;
201
+ }
202
+
191
203
//
192
204
// Key
193
205
//
@@ -210,14 +222,7 @@ int Key::color(const KeypadTheme *theme) const {
210
222
211
223
char Key::getKey (const KeypadDrawContext *context) const {
212
224
char result;
213
- KeyCode keyCode;
214
-
215
- switch (context->_keySet ) {
216
- case kLower : keyCode = _key._lower ; break ;
217
- case kUpper : keyCode = _key._upper ; break ;
218
- case kNumber : keyCode = _key._number ; break ;
219
- case kSymbol : keyCode = _key._symbol ; break ;
220
- }
225
+ KeyCode keyCode = context->getKey (_key);
221
226
switch (keyCode) {
222
227
case K_EXT1: result = (char )164 ; break ;
223
228
case K_EXT2: result = (char )172 ; break ;
@@ -305,7 +310,7 @@ void Key::onClick(const KeypadDrawContext *context) const {
305
310
auto *event = new MAEvent ();
306
311
event->type = EVENT_TYPE_KEY_PRESSED;
307
312
event->nativeKey = 0 ;
308
- switch (_key. _lower ) {
313
+ switch (context-> getKey ( _key) ) {
309
314
case K_BACKSPACE:
310
315
event->key = SB_KEY_BACKSPACE;
311
316
break ;
@@ -415,7 +420,7 @@ void Keypad::layout(int x, int y, int w, int h) {
415
420
}
416
421
Key *key = _keys[index++];
417
422
int keyWidth = keyW;
418
- if (key->_key ._lower == K_ENTER || key-> _key . _lower == K_HELP || key-> _key . _lower == K_BACKSPACE ) {
423
+ if (isRightMargin ( key->_key ._lower ) ) {
419
424
keyWidth = _width - xPos;
420
425
} else if (row == 0 ) {
421
426
keyWidth = _width / cols;
0 commit comments