gui_virtual_keyboard.c
来自「The font library converting tool MCT mai」· C语言 代码 · 共 1,129 行 · 第 1/3 页
C
1,129 行
for (i=0;i<n_matrix_row;i++)
{
matrix_string = lang->matrix_string[i];
for(j=0;j<n_matrix_column;j++)
{
BOOL restore_text_color = MMI_FALSE;
key_char = matrix_string[j];
if (enable_dead_key && pixtel_UI_virtual_keyboard_check_dead_key(key_char))
{
pixtel_UI_set_text_color(v->keyboard_theme->dead_key_up_text_color);
restore_text_color = MMI_TRUE;
}
pixtel_UI_virtual_keyboard_show_char_center_align(key_char, key_x, key_y, key_width, key_height, &glyph_width, &glyph_height);
if (restore_text_color)
{
pixtel_UI_set_text_color(v->keyboard_theme->key_up_text_color);
}
if (pixtel_UI_virtual_keyboard_is_key_disabled(v, GUI_VKBD_PEN_CHAR_I, key_char))
{
pixtel_UI_greyscale_rectangle(key_x,
key_y,
key_x + key_width - 1,
key_y + key_height - 1,
MMI_VKBD_GRAYSCALE_VALUE,
MMI_BG_GREYSCALE_BLACK_VALUE);
}
key_x += horizontal_text_gap + key_width;
}
key_x = v->x + matrix->x;
key_y += vertical_text_gap + key_height;
}
}
for (i=0; i<layout->n_custom_keys; i++)
{
UI_image_type custom_image;
key_x = v->x + layout->custom_keys[i].x;
key_y = v->y + layout->custom_keys[i].y;
key_width = layout->custom_keys[i].key_width;
key_height = layout->custom_keys[i].key_height;
key_char = lang->custom_string[i];
if (lang->custom_key_type[i] == GUI_VKBD_PEN_DISPLAY_AREA)
{
pixtel_UI_set_text_color(v->keyboard_theme->disp_area_text_color);
pixtel_UI_measure_string((UI_string_type) v->disp_area_text, &glyph_width, &glyph_height);
pixtel_UI_move_text_cursor(key_x + VKBD_DIFF_HALF(key_width, glyph_width), key_y+VKBD_DIFF_HALF(key_height, glyph_height));
pixtel_UI_print_text((UI_string_type) v->disp_area_text);
/* Restore text color */
pixtel_UI_set_text_color(v->keyboard_theme->key_up_text_color);
}
else if(!key_char)
{
custom_image = get_image(lang->custom_key_image[i]);
pixtel_UI_measure_image(custom_image, &glyph_width, &glyph_height);
pixtel_UI_show_image(key_x+VKBD_DIFF_HALF(key_width, glyph_width), key_y+VKBD_DIFF_HALF(key_height, glyph_height), custom_image);
}
else
{
BOOL restore_text_color = MMI_FALSE;
if (enable_dead_key && pixtel_UI_virtual_keyboard_check_dead_key(key_char))
{
pixtel_UI_set_text_color(v->keyboard_theme->dead_key_up_text_color);
restore_text_color = MMI_TRUE;
}
pixtel_UI_virtual_keyboard_show_char_center_align(key_char, key_x, key_y, key_width, key_height, &glyph_width, &glyph_height);
if (restore_text_color)
{
pixtel_UI_set_text_color(v->keyboard_theme->key_up_text_color);
}
}
if (pixtel_UI_virtual_keyboard_is_key_disabled(v, lang->custom_key_type[i], key_char))
{
pixtel_UI_greyscale_rectangle(key_x,
key_y,
key_x + key_width - 1,
key_y + key_height - 1,
MMI_VKBD_GRAYSCALE_VALUE,
MMI_BG_GREYSCALE_BLACK_VALUE);
}
}
pixtel_UI_pop_clip();
pixtel_UI_pop_text_clip();
}
/*****************************************************************************
* FUNCTION
* pixtel_UI_set_virtual_keyboard_display_area
* DESCRIPTION
* Update text displayed on display area
*
* PARAMETERS
* v IN
* string IN string to be displayed in display area
* redraw IN whether to redraw the keyboard
* RETURNS
* void
* GLOBALS AFFECTED
* void
* REMARKS
*
*****************************************************************************/
void pixtel_UI_set_virtual_keyboard_display_area(virtual_keyboard *v, const U8 *string, BOOL redraw)
{
const gui_keyboard_layout_struct *layout;
const gui_keyboard_language_struct *lang;
S32 x1, y1, x2, y2, glyph_width, glyph_height;
S32 i;
UCS2Strncpy((S8*) v->disp_area_text, (const S8*) string, MMI_VKBD_MAX_DISPLAY_AREA_TEXT_LEN);
/* redraw the area only */
if (redraw)
{
layout = MMI_virtual_keyboard_language_map[v->lang_type].virtual_keyboard_layout;
lang = MMI_virtual_keyboard_language_map[v->lang_type].virtual_keyboard_language;
pixtel_UI_set_font( v->keyboard_theme->text_font);
for (i = 0; i < layout->n_custom_keys; i++)
{
if (lang->custom_key_type[i] == GUI_VKBD_PEN_DISPLAY_AREA)
{
const gui_custom_key_layout_struct *custom_key = &layout->custom_keys[i];
x1 = v->x + custom_key->x;
y1 = v->y + custom_key->y;
x2 = x1 + custom_key->key_width - 1;
y2 = y1 + custom_key->key_height - 1;
pixtel_UI_lock_double_buffer();
pixtel_UI_push_clip();
pixtel_UI_push_text_clip();
pixtel_UI_set_clip(x1, y1, x2, y2);
pixtel_UI_set_text_clip(x1, y1, x2, y2);
pixtel_UI_show_image(x1, y1, get_image(lang->custom_key_image[i]));
pixtel_UI_set_text_color(v->keyboard_theme->disp_area_text_color);
pixtel_UI_measure_string((UI_string_type) v->disp_area_text, &glyph_width, &glyph_height);
pixtel_UI_move_text_cursor(x1 + VKBD_DIFF_HALF(custom_key->key_width, glyph_width), y1+VKBD_DIFF_HALF(custom_key->key_height, glyph_height));
pixtel_UI_print_text((UI_string_type) v->disp_area_text);
pixtel_UI_pop_clip();
pixtel_UI_pop_text_clip();
pixtel_UI_unlock_double_buffer();
pixtel_UI_BLT_double_buffer(x1, y1, x2, y2);
break;
}
}
}
}
/*****************************************************************************
* FUNCTION
* pixtel_UI_set_virtual_keyboard_allowed_characters
* DESCRIPTION
* Only the allowd characters can be input on keyboard.
* This function and pixtel_UI_set_virtual_board_disable_list() are mutually-exclusive.
*
* Control keys such as GUI_VKBD_PEN_HIDE, GUI_VKBD_PEN_SHOW... are enabled because
* they are not related to character insertion.
*
* `allowed_characters' may contain '-' for consecutive characters
* (Ex. 'a-z' for characters from a to z.)
* If we want to accept "-", please write it as '\-'.
* For example, '\-0-9.' represents "-0123456789."
*
* Example of valid characters in email addresss:
* wgui_set_virtual_keyboard_allowed_characters((const UI_character_type *) L"+_\\-.@A-Za-z0-9");
* (it is not a complete list of all characters allowed in RFC, but it satisfies almost all cases)
*
* PARAMETERS
* v IN virtual keyboard
* allowed_chars IN allowed characters
* RETURNS
* void
*****************************************************************************/
void pixtel_UI_set_virtual_keyboard_allowed_characters(virtual_keyboard *v, const UI_character_type *allowed_chars)
{
v->allowed_characters = allowed_chars;
}
/*****************************************************************************
* FUNCTION
* pixtel_UI_set_virtual_board_disable_list
* DESCRIPTION
* Disable some keys on keyboard.
* This function and pixtel_UI_set_virtual_keyboard_allowed_characters() are mutually-exclusive.
* PARAMETERS
* v IN virtual keyboard
* disabled_chars IN Null-terminated array of disabled unicode characters
* disabled_symbols IN ended by GUI_VKBD_PEN_NONE
* RETURNS
* void
* GLOBALS AFFECTED
* void
* REMARKS
*
*****************************************************************************/
void pixtel_UI_set_virtual_board_disable_list(virtual_keyboard *v, const UI_character_type *disabled_chars, const mmi_gui_virtual_keyboard_pen_enum *disabled_symbols)
{
S32 i;
/* Setup v->disabled_chars[] */
for (i = 0; i < MMI_VKBD_MAX_DISABLED_KEYS; i++)
{
if (!disabled_chars[i])
{
break;
}
v->disabled_chars[i] = disabled_chars[i];
}
MMI_DBG_ASSERT(i < MMI_VKBD_MAX_DISABLED_KEYS || !disabled_chars[i]);
v->disabled_chars[i] = 0;
/* Setup v->disabled_symbols[] */
for (i = 0; i < MMI_VKBD_MAX_DISABLED_KEYS; i++)
{
if (disabled_symbols[i] == GUI_VKBD_PEN_NONE)
{
break;
}
v->disabled_symbols[i] = disabled_symbols[i];
}
MMI_DBG_ASSERT(i < MMI_VKBD_MAX_DISABLED_KEYS || (disabled_symbols[i] == GUI_VKBD_PEN_NONE));
v->disabled_symbols[i] = GUI_VKBD_PEN_NONE;
}
#ifdef __MMI_TOUCH_SCREEN__
BOOL pixtel_UI_virtual_keyboard_translate_pen_event(virtual_keyboard *v, S16 x, S16 y, mmi_pen_event_type_enum pen_event,mmi_gui_virtual_keyboard_pen_enum *vkbd_event,mmi_gui_pen_event_param_struct *vkbd_param)
{
BOOL ret = MMI_TRUE;
const gui_keyboard_language_struct *lang;
UI_character_type ch;
mmi_gui_virtual_keyboard_pen_enum evt;
*vkbd_event = GUI_VKBD_PEN_NONE;
GUI_PEN_EVENT_PARAM_SET_VOID(vkbd_param);
lang = MMI_virtual_keyboard_language_map[v->lang_type].virtual_keyboard_language;
switch (pen_event)
{
case MMI_PEN_EVENT_DOWN:
v->key_down_accepted = MMI_FALSE;
if (PEN_CHECK_BOUND(x, y, v->x, v->y, v->width, v->height))
{
if (pixtel_UI_virtual_keyboard_translate_pen_position(v, x, y, &v->selected_key))
{
pixtel_UI_virtual_keyboard_get_selected_key(v, &ch, &evt);
if ((evt == GUI_VKBD_PEN_NONE) ||
pixtel_UI_virtual_keyboard_is_key_disabled(v, evt, ch))
{
/* Do nothing */
}
else
{
v->key_down_accepted = MMI_TRUE;
pixtel_UI_virtual_keyboard_cache_and_show_selected_key(v);
/*
* If Pen Down and Pen Up comes together, we should temporarily suspend MMI task.
* Otherwise, user can not see pen down due to delayed LCM update.
*/
#ifdef MMI_ON_HARDWARE_P
kal_sleep_task(kal_milli_secs_to_ticks(30));
#endif /* MMI_ON_HARDWARE_P */
}
}
}
else
{
return MMI_FALSE;
}
break;
case MMI_PEN_EVENT_MOVE:
if (v->key_down_accepted)
{
virtual_keyboard_selection_struct s;
if (PEN_CHECK_BOUND(x, y, v->x, v->y, v->width, v->height) &&
pixtel_UI_virtual_keyboard_translate_pen_position(v, x, y, &s))
{
if (memcmp(&v->selected_key, &s, sizeof(s)))
{
pixtel_UI_virtual_keyboard_show_unselect_key_from_cache(v);
memcpy(&v->selected_key, &s, sizeof(s));
pixtel_UI_virtual_keyboard_get_selected_key(v, &ch, &evt);
if (!((evt == GUI_VKBD_PEN_NONE) ||
pixtel_UI_virtual_keyboard_is_key_disabled(v, evt, ch)))
{
pixtel_UI_virtual_keyboard_cache_and_show_selected_key(v);
}
}
}
else
{
pixtel_UI_virtual_keyboard_show_unselect_key_from_cache(v);
pixtel_UI_virtual_keyboard_clear_selected_key(&v->selected_key);
}
}
break;
case MMI_PEN_EVENT_UP:
if (v->key_down_accepted)
{
pixtel_UI_virtual_keyboard_show_unselect_key_from_cache(v);
if (pixtel_UI_virtual_keyboard_get_selected_key(v, &ch, &evt))
{
pixtel_UI_virtual_keyboard_translate_dead_key(v, &ch, &evt);
if (evt == GUI_VKBD_PEN_SPACE)
{
evt = GUI_VKBD_PEN_CHAR_I;
ch = (UI_character_type) ' ';
}
else if (evt == GUI_VKBD_PEN_DEAD_KEY)
{
evt = GUI_VKBD_PEN_NONE;
}
*vkbd_event = evt;
if (evt == GUI_VKBD_PEN_CHAR_I)
{
GUI_PEN_EVENT_PARAM_SET_INTEGER(vkbd_param, (int)ch);
}
}
}
break;
case MMI_PEN_EVENT_ABORT:
pixtel_UI_virtual_keyboard_show_unselect_key_from_cache(v);
pixtel_UI_virtual_keyboard_clear_dead_key(v);
break;
case MMI_PEN_EVENT_LONG_TAP:
/* FALLTHROUGH no break */
case MMI_PEN_EVENT_REPEAT:
/* Do nothing */
break;
}
#if defined(__MMI_GB__)
if(pen_event == MMI_PEN_EVENT_DOWN && GUI_VIRTUAL_KEYBOARD_GUOBI_CAND == MMI_virtual_keyboard.lang_type)
{
GBHandleTouchEvent(x, y);
}
#endif
return ret;
}
#endif /* __MMI_TOUCH_SCREEN__ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?