diff options
Diffstat (limited to 'navit/gui/internal/gui_internal_keyboard.c')
-rw-r--r-- | navit/gui/internal/gui_internal_keyboard.c | 156 |
1 files changed, 74 insertions, 82 deletions
diff --git a/navit/gui/internal/gui_internal_keyboard.c b/navit/gui/internal/gui_internal_keyboard.c index 509cc5ed4..3e0d1aa33 100644 --- a/navit/gui/internal/gui_internal_keyboard.c +++ b/navit/gui/internal/gui_internal_keyboard.c @@ -16,8 +16,8 @@ /** * @brief Processes a key press on the internal GUI keyboard * - * If the keyboard is currently in uppercase mode, it is then switched to the corresponding lowercase - * mode. + * If the keyboard is currently in uppercase mode and {@code VKBD_MODE_2} is set, it is then switched to + * the corresponding lowercase mode. * * @param this The internal GUI instance * @param wm @@ -30,12 +30,12 @@ gui_internal_cmd_keypress(struct gui_priv *this, struct widget *wm, void *data) gui_internal_keypress_do(this, (char *) wm->data); md=gui_internal_menu_data(this); // Switch to lowercase after the first key is pressed - if (md->keyboard_mode == 2) // Latin - gui_internal_keyboard_do(this, md->keyboard, 10); - if (md->keyboard_mode == 26) // Umlaut - gui_internal_keyboard_do(this, md->keyboard, 34); - if (md->keyboard_mode == 42) // Russian/Ukrainian/Belorussian - gui_internal_keyboard_do(this, md->keyboard, 50); + if (md->keyboard_mode == (VKBD_LATIN_UPPER | VKBD_FLAG_2)) // Latin + gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_LOWER | VKBD_FLAG_2); + if (md->keyboard_mode == (VKBD_UMLAUT_UPPER | VKBD_FLAG_2)) // Umlaut + gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_LOWER | VKBD_FLAG_2); + if (md->keyboard_mode == (VKBD_CYRILLIC_UPPER | VKBD_FLAG_2)) // Russian/Ukrainian/Belorussian + gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_LOWER | VKBD_FLAG_2); } static struct widget * @@ -78,14 +78,14 @@ struct gui_internal_keyb_mode { int case_mode; /**< Mode to switch to when case CHANGE() key is pressed. */ int umlaut_mode; /**< Mode to switch to when UMLAUT() key is pressed. */ } gui_internal_keyb_modes[]= { - /* 0*/ {"ABC", 2, 8, 24}, - /* 8*/ {"abc", 2, 0, 32}, - /*16*/ {"123", 2, 0, 24}, - /*24*/ {"ÄÖÜ", 2, 40, 0}, - /*32*/ {"äöü", 2, 32, 8}, - /*40*/ {"АБВ", 2, 48, 0}, - /*48*/ {"абв", 2, 40, 8}, - /*56*/ {"DEG", 2, 2, 2} + /* 0: VKBD_LATIN_UPPER */ {"ABC", 2, VKBD_LATIN_LOWER, VKBD_UMLAUT_UPPER}, + /* 8: VKBD_LATIN_LOWER */ {"abc", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_LOWER}, + /*16: VKBD_NUMERIC */ {"123", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_UPPER}, + /*24: VKBD_UMLAUT_UPPER */ {"ÄÖÜ", 2, VKBD_UMLAUT_LOWER, VKBD_LATIN_UPPER}, + /*32: VKBD_UMLAUT_LOWER */ {"äöü", 2, VKBD_UMLAUT_UPPER, VKBD_LATIN_LOWER}, + /*40: VKBD_CYRILLIC_UPPER*/ {"АБВ", 2, VKBD_CYRILLIC_UPPER, VKBD_LATIN_UPPER}, + /*48: VKBD_CYRILLIC_LOWER*/ {"абв", 2, VKBD_CYRILLIC_UPPER, VKBD_LATIN_LOWER}, + /*56: VKBD_DEGREE */ {"DEG", 2, VKBD_FLAG_2, VKBD_FLAG_2} }; @@ -97,7 +97,7 @@ struct gui_internal_keyb_mode { gui_internal_keyb_modes[(x)/8].title, \ gui_internal_keyb_modes[(x)/8].font, \ gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h) \ - -> datai=(mode&7)+((x)&~7) + -> datai = (mode & VKBD_MASK_7) | ((x) & VKBD_LAYOUT_MASK) #define SWCASE() MODE(gui_internal_keyb_modes[mode/8].case_mode) #define UMLAUT() MODE(gui_internal_keyb_modes[mode/8].umlaut_mode) /** @@ -130,7 +130,7 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) this->current.x=-1; this->current.y=-1; gui_internal_highlight(this); - if (md->keyboard_mode >= 1024) + if (md->keyboard_mode & VKBD_FLAG_1024) render=2; else render=1; @@ -147,55 +147,55 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) max_w=max_w/8; max_h=max_h/8; // Allows 3 results in the list when searching for Towns wkbd->p.y=max_h*2; - if(mode>=40&&mode<56) { // Russian/Ukrainian/Belarussian layout needs more space... + if (((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER) || ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER)) { // Russian/Ukrainian/Belarussian layout needs more space... max_h=max_h*4/5; max_w=max_w*8/9; wkbd->cols=9; } - if (mode >= 0 && mode < 8) { + if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_UPPER) { for (i = 0 ; i < 26 ; i++) { char text[]={'A'+i,'\0'}; KEY(text); } gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h); - if (mode == 0) { + if (!(mode & VKBD_MASK_7)) { KEY("-"); KEY("'"); wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h); - wk->datai=mode+1024; + wk->datai = mode | VKBD_FLAG_1024; } else { wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h); - wk->datai=mode+1024; + wk->datai = mode | VKBD_FLAG_1024; SWCASE(); - MODE(16); + MODE(VKBD_NUMERIC); } UMLAUT(); gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h); } - if (mode >= 8 && mode < 16) { + if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_LOWER) { for (i = 0 ; i < 26 ; i++) { char text[]={'a'+i,'\0'}; KEY(text); } gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h); - if (mode == 8) { + if (!(mode & VKBD_MASK_7)) { KEY("-"); KEY("'"); wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h); - wk->datai=mode+1024; + wk->datai = mode | VKBD_FLAG_1024; } else { wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h); - wk->datai=mode+1024; + wk->datai = mode | VKBD_FLAG_1024; SWCASE(); - MODE(16); + MODE(VKBD_NUMERIC); } UMLAUT(); gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h); } - if (mode >= 16 && mode < 24) { + if ((mode & VKBD_LAYOUT_MASK) == VKBD_NUMERIC) { for (i = 0 ; i < 10 ; i++) { char text[]={'0'+i,'\0'}; KEY(text); @@ -205,27 +205,27 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) - if (mode == 16) { + if (!(mode & VKBD_MASK_7)) { SPACER(); KEY("-"); KEY("'"); wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h); - wk->datai=mode+1024; + wk->datai = mode | VKBD_FLAG_1024; SPACER(); SPACER(); } else { SPACER(); - MODE(40); - MODE(48); + MODE(VKBD_CYRILLIC_UPPER); + MODE(VKBD_CYRILLIC_LOWER); wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h); - wk->datai=mode+1024; - MODE(0); - MODE(8); + wk->datai = mode | VKBD_FLAG_1024; + MODE(VKBD_LATIN_UPPER); + MODE(VKBD_LATIN_LOWER); } UMLAUT(); gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h); } - if (mode >= 24 && mode < 32) { + if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_UPPER) { KEY("Ä"); KEY("Ë"); KEY("Ï"); KEY("Ö"); KEY("Ü"); KEY("Æ"); KEY("Ø"); KEY("Å"); KEY("Á"); KEY("É"); KEY("Í"); KEY("Ó"); KEY("Ú"); KEY("Š"); KEY("Č"); KEY("Ž"); KEY("À"); KEY("È"); KEY("Ì"); KEY("Ò"); KEY("Ù"); KEY("Ś"); KEY("Ć"); KEY("Ź"); @@ -235,7 +235,7 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h); } - if (mode >= 32 && mode < 40) { + if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_LOWER) { KEY("ä"); KEY("ë"); KEY("ï"); KEY("ö"); KEY("ü"); KEY("æ"); KEY("ø"); KEY("å"); KEY("á"); KEY("é"); KEY("í"); KEY("ó"); KEY("ú"); KEY("š"); KEY("č"); KEY("ž"); KEY("à"); KEY("è"); KEY("ì"); KEY("ò"); KEY("ù"); KEY("ś"); KEY("ć"); KEY("ź"); @@ -245,7 +245,7 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h); } - if (mode >= 40 && mode < 48) { + if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER) { KEY("А"); KEY("Б"); KEY("В"); KEY("Г"); KEY("Д"); KEY("Е"); KEY("Ж"); KEY("З"); KEY("И"); KEY("Й"); KEY("К"); KEY("Л"); KEY("М"); KEY("Н"); KEY("О"); KEY("П"); KEY("Р"); KEY("С"); KEY("Т"); KEY("У"); KEY("Ф"); KEY("Х"); KEY("Ц"); KEY("Ч"); KEY("Ш"); KEY("Щ"); KEY("Ъ"); @@ -254,17 +254,17 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h); wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h); - wk->datai=mode+1024; + wk->datai = mode | VKBD_FLAG_1024; SWCASE(); - MODE(16); + MODE(VKBD_NUMERIC); SPACER(); gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h); } - if (mode >= 48 && mode < 56) { + if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER) { KEY("а"); KEY("б"); KEY("в"); KEY("г"); KEY("д"); KEY("е"); KEY("ж"); KEY("з"); KEY("и"); KEY("й"); KEY("к"); KEY("л"); KEY("м"); KEY("н"); KEY("о"); KEY("п"); KEY("р"); KEY("с"); KEY("т"); KEY("у"); KEY("ф"); KEY("х"); KEY("ц"); KEY("ч"); KEY("ш"); KEY("щ"); KEY("ъ"); @@ -273,11 +273,11 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h); wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h); - wk->datai=mode+1024; + wk->datai = mode | VKBD_FLAG_1024; SWCASE(); - MODE(16); + MODE(VKBD_NUMERIC); SPACER(); @@ -287,10 +287,10 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) if(md->search_list && md->search_list->type==widget_table) { struct table_data *td=(struct table_data*)(md->search_list->data); - td->scroll_buttons.button_box_hide=mode<1024; + td->scroll_buttons.button_box_hide = !(mode & VKBD_FLAG_1024); } - if (mode >= 56 && mode < 64) { /* special case for coordinates input screen (enter_coord) */ + if ((mode & VKBD_LAYOUT_MASK) == VKBD_DEGREE) { /* special case for coordinates input screen (enter_coord) */ KEY("0"); KEY("1"); KEY("2"); KEY("3"); KEY("4"); SPACER(); KEY("N"); KEY("S"); KEY("5"); KEY("6"); KEY("7"); KEY("8"); KEY("9"); SPACER(); KEY("E"); KEY("W"); KEY("°"); KEY("."); KEY("'"); @@ -298,17 +298,17 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) SPACER(); wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h); - wk->datai=mode+1024; + wk->datai = mode | VKBD_FLAG_1024; SPACER(); gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h); } - if (mode >= 1024) { + if (mode & VKBD_FLAG_1024) { char *text=NULL; int font=0; struct widget *wkl; - mode -= 1024; + mode &= ~VKBD_FLAG_1024; text=gui_internal_keyb_modes[mode/8].title; font=gui_internal_keyb_modes[mode/8].font; wk=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_fill); @@ -352,20 +352,11 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) * * This function creates a widget to display the internal GUI keyboard. * - * The {@code mode} argument specifies the type of keyboard which should initially be displayed: - * <ul> - * <li>0: ABC (Latin uppercase)</li> - * <li>8: abc (Latin lowercase)</li> - * <li>16: 123 (Numeric)</li> - * <li>24: ÄÖÜ (Umlaut uppercase)</li> - * <li>32: äöü (Umlaut lowercase)</li> - * <li>40: АБВ (Cyrillic uppercase)</li> - * <li>48: абв (Cyrillic lowercase)</li> - * <li>56: DEG (Coordinate input: 0–9, decimal dot, NESW, degree/minute signs)</li> - * </ul> + * The {@code mode} argument specifies the type of keyboard which should initially be displayed. Refer + * to {@link enum vkbd_mode} for a list of possible modes and their meaning. * * @param this The internal GUI instance - * @param mode The mode for the keyboard, see description + * @param mode The mode for the keyboard * * @return A new keyboard widget */ @@ -391,7 +382,8 @@ gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *da * * @param lang The two-letter country code * - * @return 40 (АБВ) for countries using the Cyrillic alphabet, 0 (ABC) otherwise + * @return {@code VKBD_CYRILLIC_UPPER} for countries using the Cyrillic alphabet, + * {@code VKBD_LATIN_UPPER} otherwise */ int gui_internal_keyboard_init_mode(char *lang) @@ -403,25 +395,25 @@ gui_internal_keyboard_init_mode(char *lang) * Set cyrillic keyboard for countries using Cyrillic alphabet */ if (strstr(lang,"RU")) - ret = 40; - if (strstr(lang,"UA")) - ret = 40; - if (strstr(lang,"BY")) - ret = 40; - if (strstr(lang,"RS")) - ret = 40; - if (strstr(lang,"BG")) - ret = 40; - if (strstr(lang,"MK")) - ret = 40; - if (strstr(lang,"KZ")) - ret = 40; - if (strstr(lang,"KG")) - ret = 40; - if (strstr(lang,"TJ")) - ret = 40; - if (strstr(lang,"MN")) - ret = 40; + ret = VKBD_CYRILLIC_UPPER; + else if (strstr(lang,"UA")) + ret = VKBD_CYRILLIC_UPPER; + else if (strstr(lang,"BY")) + ret = VKBD_CYRILLIC_UPPER; + else if (strstr(lang,"RS")) + ret = VKBD_CYRILLIC_UPPER; + else if (strstr(lang,"BG")) + ret = VKBD_CYRILLIC_UPPER; + else if (strstr(lang,"MK")) + ret = VKBD_CYRILLIC_UPPER; + else if (strstr(lang,"KZ")) + ret = VKBD_CYRILLIC_UPPER; + else if (strstr(lang,"KG")) + ret = VKBD_CYRILLIC_UPPER; + else if (strstr(lang,"TJ")) + ret = VKBD_CYRILLIC_UPPER; + else if (strstr(lang,"MN")) + ret = VKBD_CYRILLIC_UPPER; g_free(lang); return ret; } |