gui_virtual_keyboard.c
来自「The font library converting tool MCT mai」· C语言 代码 · 共 1,129 行 · 第 1/3 页
C
1,129 行
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* gui_virtual_keyboard.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* Virtual keyboard - UI component
*
* Author:
* -------
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#include "MMI_features.h"
#include "gui_virtual_keyboard.h"
#include "wgui_virtual_keyboard.h"
#include "gui_themes.h"
#include "wgui.h"
#include "wgui_categories_defs.h"
#include "wgui_categories_util.h" /* get_image() */
#include "DebugInitDef.h"
#ifdef __MMI_GB__
#include "gb_wrapper.h"
#endif //__MMI_GB__
/*
* FIXME.
*
* 1. Currently we only support one matrix layout per keyboard.
* 2. Use static memory to avoid out-of-memory in control buffer
*
*/
extern BOOL r2lMMIFlag;
/*****************************************************************************
* Define
*****************************************************************************/
#define VKBD_DIFF_HALF(a, b) ((a) >= (b) ? (((a)-(b))>>1) : 0)
/*****************************************************************************
* Typedef
*****************************************************************************/
/*****************************************************************************
* Local Variable
*****************************************************************************/
/*****************************************************************************
* Local Function
*****************************************************************************/
static void pixtel_UI_virtual_keyboard_clear_selected_key(virtual_keyboard_selection_struct *s)
{
s->matrix_index = -1;
s->matrix_column = -1;
s->matrix_row = -1;
s->custom_key_index = -1;
s->key_width = 0;
s->key_height = 0;
s->key_x = 0;
s->key_y = 0;
}
static BOOL pixtel_UI_virtual_keyboard_check_dead_key(UI_character_type ch)
{
switch (ch)
{
case 0x60: /* ` */
case 0xB4:
case 0x5E: /* ^ */
case 0xA8:
case 0x7E: /* ~ */
return MMI_TRUE;
default:
return MMI_FALSE;
}
}
static void pixtel_UI_virtual_keyboard_show_char_center_align(UI_character_type ch, S32 key_x, S32 key_y, S32 key_width, S32 key_height, S32 *glyph_width, S32 *glyph_height)
{
S32 bbox_x, bbox_y, bbox_width, bbox_height;
S32 char_x, char_y;
if (ch == (UI_character_type)'_') /* '_' is special because it will get confused with '-' */
{
pixtel_UI_measure_character(ch, glyph_width, glyph_height);
char_x = key_x + VKBD_DIFF_HALF(key_width, *glyph_width);
char_y = key_y + VKBD_DIFF_HALF(key_width, *glyph_height);
}
else
{
Get_CharBoundingBox(ch, glyph_width, glyph_height, &bbox_x, &bbox_y, &bbox_width, &bbox_height);
char_x = key_x + VKBD_DIFF_HALF(key_width, bbox_width) - bbox_x;
char_y = key_y + VKBD_DIFF_HALF(key_height, bbox_height) - bbox_y;
/* HACK. the number of remaing pixels is odd. */
/* It is not always correct depending on the baseline of the font database */
/* The magic number bbox_y + "1" can be modified */
if (((key_height - bbox_height) & 1) && (bbox_y + 1 > *glyph_height - bbox_height - bbox_y))
char_y++;
if (r2lMMIFlag)
{
char_x += *glyph_width;
}
}
pixtel_UI_move_text_cursor(char_x, char_y);
pixtel_UI_print_character(ch);
}
static MMI_BOOL pixtel_UI_virtual_keyboard_is_key_disabled(virtual_keyboard *v, mmi_gui_virtual_keyboard_pen_enum event, UI_character_type ch)
{
if (v->allowed_characters)
{
MMI_BOOL disabled = MMI_TRUE;
/* pixtel_UI_set_virtual_keyboard_allowed_characters() and
pixtel_UI_set_virtual_board_disable_list() are mutually-exclusive */
MMI_DBG_ASSERT(v->disabled_chars[0] == 0 && v->disabled_symbols[0] == GUI_VKBD_PEN_NONE);
switch (event)
{
// TODO: GUI_VKBD_PEN_EUROSYMB is not supported
case GUI_VKBD_PEN_HIDE:
case GUI_VKBD_PEN_SHOW:
case GUI_VKBD_PEN_CAPSLOCK:
case GUI_VKBD_PEN_BAKSPACE:
case GUI_VKBD_PEN_DISPLAY_AREA:
/* GUI_VKBD_PEN_DISPLAY_AREA is always enabled because it's display only */
disabled = MMI_FALSE;
break;
case GUI_VKBD_PEN_NEWLINE:
ch = (UI_character_type)'\n';
event = GUI_VKBD_PEN_CHAR_I;
break;
case GUI_VKBD_PEN_SPACE:
ch = (UI_character_type)' ';
event = GUI_VKBD_PEN_CHAR_I;
break;
case GUI_VKBD_PEN_SYMBPICKER:
{
/* Check existence of non-alphanumeric character */
const UI_character_type *pch = v->allowed_characters;
UI_character_type tmp;
while ((tmp = *pch++) != 0)
{
if (tmp == (UI_character_type)'\\' || /* Assume the next character to be punctuation */
!(tmp == (UI_character_type)'-' ||
(tmp >= (UI_character_type)'a' && tmp <= (UI_character_type)'z') ||
(tmp >= (UI_character_type)'A' && tmp <= (UI_character_type)'Z') ||
(tmp >= (UI_character_type)'0' && tmp <= (UI_character_type)'9')))
{
disabled = MMI_FALSE;
break;
}
}
break;
}
}
if (event == GUI_VKBD_PEN_CHAR_I)
{
const UI_character_type *pch = v->allowed_characters;
S32 idx;
for (idx = 0; pch[idx]; idx++)
{
UI_character_type tmp = pch[idx];
if (tmp == (UI_character_type)'-' && idx > 0 && pch[idx + 1])
{
if (ch >= pch[idx - 1] && ch <= pch[idx + 1])
{
disabled = MMI_FALSE;
break;
}
idx++;
}
else
{
if (tmp == (UI_character_type)'\\' && pch[idx + 1])
{
tmp = pch[++idx];
}
if (tmp == ch)
{
disabled = MMI_FALSE;
break;
}
}
}
}
return disabled;
}
else
{
if (event == GUI_VKBD_PEN_CHAR_I)
{
UI_character_type *ptr = v->disabled_chars, tmp;
if (ch == 0)
{
return MMI_TRUE;
}
while ((tmp = *ptr++) != 0)
{
if (tmp == ch)
{
return MMI_TRUE;
}
}
return MMI_FALSE;
}
else if (event == GUI_VKBD_PEN_NONE)
{
return MMI_TRUE;
}
else
{
mmi_gui_virtual_keyboard_pen_enum *ptr = v->disabled_symbols, tmp;
while ((tmp = *ptr++) != GUI_VKBD_PEN_NONE)
{
if (tmp == event)
{
return MMI_TRUE;
}
}
return MMI_FALSE;
}
}
}
#ifdef __MMI_TOUCH_SCREEN__
/* Return > 0 if dead key sequence is completed */
UI_character_type pixtel_UI_get_dead_key_symbol(mmi_gui_virtual_keyboard_language_enum lang_type, U16 *input_string, S32 input_len)
{
S32 i;
S32 n_entry;
const gui_keyboard_language_struct *lang;
const mmi_gui_dead_key_map_struct *t;
const mmi_gui_dead_key_symbol_struct *d;
lang = MMI_virtual_keyboard_language_map[lang_type].virtual_keyboard_language;
if (!lang->enable_dead_key)
{
return 0;
}
t = &gui_dead_key_symbol_table[lang_type];
n_entry = t->nentry;
d = &t->dead_key_symbol[0];
for(i=0; i < n_entry; i++)
{
if (input_len != d->nInputLen)
continue;
if (memcmp(d->input_char, input_string, d->nInputLen * 2) == 0)
{
return d->output_char;
}
d++;
}
return 0;
}
static BOOL pixtel_UI_virtual_keyboard_get_selected_key(virtual_keyboard *v, UI_character_type *ch, mmi_gui_virtual_keyboard_pen_enum *evt)
{
const gui_keyboard_language_struct *lang;
virtual_keyboard_selection_struct *s = &v->selected_key;
*ch = 0;
*evt = GUI_VKBD_PEN_NONE;
lang = MMI_virtual_keyboard_language_map[v->lang_type].virtual_keyboard_language;
if (s->matrix_index < 0 && s->custom_key_index < 0)
{
return MMI_FALSE;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?