📄 gb_wrapper.c
字号:
}
void GBKey8PressHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_8, GBKT_Down);
}
void GBKey9PressHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_9, GBKT_Down);
}
void GBKey0PressHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_0, GBKT_Down);
}
void GBKeyArrowUpHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_Up, GBKT_Down);
}
void GBKeyArrowRightHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_Right, GBKT_Down);
}
void GBKeyArrowDownHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_Down, GBKT_Down);
}
void GBKeyArrowLeftHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_Left, GBKT_Down);
}
void GBKeyStarPressHandlerForInputBox(void)
{
if(GB_IS_ACTIVE())
{
//为了解决大写英文模式下面*切换
//只好禁止在大写英文模式下面的大小写切换功能
if(INPUT_MODE_SMART_UPPERCASE_ABC != MMI_current_input_mode)
{
GBEventHandler(GBET_In_Key, GBKEY_Star, GBKT_Down);
}
if(INPUT_MODE_SMART_UPPERCASE_GERMAN != MMI_current_input_mode)
{
GBEventHandler(GBET_In_Key, GBKEY_Star, GBKT_Down);
}
}
}
void GBKeyPoundPressHandlerForInputBox(void)
{
if(GB_IS_ACTIVE())
{
GBEventHandler(GBET_In_Key, GBKEY_Sharp, GBKT_Down);
}
}
void GBKeyOKHandlerForInputBox(void)
{
if(GB_IS_ACTIVE())
{
GBEventHandler(GBET_In_Key, GBKEY_OK, GBKT_Down);
}
}
void GBKeyBackHandlerForInputBox(void)
{
if(GB_IS_ACTIVE())
{
GBEventHandler(GBET_In_Key, GBKEY_Back, GBKT_Down);
}
}
/**
* \brief 这个函数主要是为了解决长按clear清除内容时,
* 按键EVENT_UP的时候会导致界面返回上一页。
*/
static void GBRskTempHandler(void)
{
if(g_rsk_handler != NULL)
{
set_right_softkey_function(g_rsk_handler, KEY_EVENT_UP);
}
}
void GBKeyClearAllHandlerForInputBox(void)
{
if(GbIsInputEmpty() && gbCurInputBox.pfDeleteAll)
{
(*gbCurInputBox.pfDeleteAll)();
g_rsk_handler = GetKeyHandler(MMI_RIGHT_SOFTKEY, KEY_EVENT_UP);
if(!g_rsk_handler)
{
set_right_softkey_function(GBRskTempHandler, KEY_EVENT_UP);
}
}
GBInputMethodReset();
GBDrawCandWnd();
}
typedef void (* FuncPtr)(void);
void GBSetInputboxLSKFunction(FuncPtr f)
{
gb_inputbox_LSK_function = f;
}
void GBChangeInputModeForInputBox(int inputMethod)
{
g_lastInputMode = inputMethod;
switch(inputMethod)
{
/* case INPUT_MODE_SM_PINYIN:
GBEventHandler(GBET_In_ChgInputMode, GBIM_Chn_Pinyin, GBL_Chinese);
//BUG 中英文切换中解决词头小写状态的BUG.
GBEventHandler(GBET_In_SetLatinEngineOption, EN_OPTION_OUTPUT_NORMAL, 0);
break;
case INPUT_MODE_SM_STROKE:
GBEventHandler(GBET_In_ChgInputMode, GBIM_Chn_Stroke, GBL_Chinese);
//BUG 中英文切换中解决词头小写状态的BUG.
GBEventHandler(GBET_In_SetLatinEngineOption, EN_OPTION_OUTPUT_NORMAL, 0);
break;
case INPUT_MODE_TR_STROKE://Sam,add pyStroke
GBEventHandler(GBET_In_ChgInputMode, GBIM_Chn_YinStroke, GBL_Chinese);
//BUG 中英文切换中解决词头小写状态的BUG.
GBEventHandler(GBET_In_SetLatinEngineOption, EN_OPTION_OUTPUT_NORMAL, 0);
break;*/
case INPUT_MODE_SMART_UPPERCASE_ABC:
GBEventHandler(GBET_In_ChgInputMode, GBIM_SmartLatin, GBL_English);
GBEventHandler(GBET_In_SetLatinEngineOption, EN_OPTION_OUTPUT_CAPITAL, 0);
break;
case INPUT_MODE_SMART_LOWERCASE_ABC:
GBEventHandler(GBET_In_ChgInputMode, GBIM_SmartLatin, GBL_English);
GBEventHandler(GBET_In_SetLatinEngineOption, EN_OPTION_OUTPUT_NORMAL, 0);
break;
case INPUT_MODE_SMART_UPPERCASE_GERMAN:
GBEventHandler(GBET_In_ChgInputMode, GBIM_SmartLatin, GBL_German);
GBEventHandler(GBET_In_SetLatinEngineOption, EN_OPTION_OUTPUT_CAPITAL, 0);
break;
case INPUT_MODE_SMART_LOWERCASE_GERMAN:
GBEventHandler(GBET_In_ChgInputMode, GBIM_SmartLatin, GBL_German);
GBEventHandler(GBET_In_SetLatinEngineOption, EN_OPTION_OUTPUT_NORMAL, 0);
break;
}
GBDrawCandWnd();
}
void GBClearKeyHandler(U16 type)
{
static const struct {
U16 key;
U16 type;
} validKeys[] =
{
{KEY_0, gbKeyNum},
{KEY_1, gbKeyNum},
{KEY_2, gbKeyNum},
{KEY_3, gbKeyNum},
{KEY_4, gbKeyNum},
{KEY_5, gbKeyNum},
{KEY_6, gbKeyNum},
{KEY_7, gbKeyNum},
{KEY_8, gbKeyNum},
{KEY_9, gbKeyNum},
{KEY_STAR, gbKeyStar},
{KEY_POUND, gbKeyPound},
{KEY_UP_ARROW, gbKeyArrow},
{KEY_DOWN_ARROW,gbKeyArrow},
{KEY_RIGHT_ARROW,gbKeyArrow},
{KEY_LEFT_ARROW,gbKeyArrow},
{KEY_ENTER, gbKeyOK},
};
int i;
U16 keyType;
for(i = 0; i < sizeof(validKeys) / sizeof(validKeys[0]); i++)
{
if(validKeys[i].type & type)
{
for(keyType = 0; keyType < MAX_KEY_TYPE; keyType++)
{
ClearKeyHandler(validKeys[i].key, keyType);
}
}
}
}
void GBInputMethodReset(void)
{
GBEventHandler(GBET_In_ReSet, 0, 0);
}
/**
* \brief 方向键的处理函数, 各个input box有自己的方向键处理函数,
* 候选框关闭的时候我们要
*/
static void GBSetAllArrowHandler(void)
{
SetKeyHandler(GBKeyArrowRightHandlerForInputBox,KEY_RIGHT_ARROW,KEY_EVENT_DOWN);
SetKeyHandler(GBKeyArrowDownHandlerForInputBox, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
SetKeyHandler(GBKeyArrowLeftHandlerForInputBox, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
SetKeyHandler(GBKeyArrowUpHandlerForInputBox, KEY_UP_ARROW, KEY_EVENT_DOWN);
}
void GBSetAllKeyHandler(void)
{
//先清除所有其他的处理函数,如果长按#号可能被其他的地方改成别的处理函数,
//在我们输入法里面不应该处理
GBClearAllKeyHandler();
//清除右软键的所有处理函数
clear_right_softkey();
//将方向键设置为我们处理
GBSetAllArrowHandler();
//#键
SetKeyHandler(GBKeyPoundPressHandlerForInputBox, KEY_POUND, KEY_EVENT_DOWN);
//OK键
SetKeyHandler(GBKeyOKHandlerForInputBox, KEY_ENTER, KEY_EVENT_DOWN);
//数字键
SetKeyHandler(GBKey0PressHandlerForInputBox,KEY_0,KEY_EVENT_DOWN);
SetKeyHandler(GBKey1PressHandlerForInputBox,KEY_1,KEY_EVENT_DOWN);
SetKeyHandler(GBKey2PressHandlerForInputBox,KEY_2,KEY_EVENT_DOWN);
SetKeyHandler(GBKey3PressHandlerForInputBox,KEY_3,KEY_EVENT_DOWN);
SetKeyHandler(GBKey4PressHandlerForInputBox,KEY_4,KEY_EVENT_DOWN);
SetKeyHandler(GBKey5PressHandlerForInputBox,KEY_5,KEY_EVENT_DOWN);
SetKeyHandler(GBKey6PressHandlerForInputBox,KEY_6,KEY_EVENT_DOWN);
SetKeyHandler(GBKey7PressHandlerForInputBox,KEY_7,KEY_EVENT_DOWN);
SetKeyHandler(GBKey8PressHandlerForInputBox,KEY_8,KEY_EVENT_DOWN);
SetKeyHandler(GBKey9PressHandlerForInputBox,KEY_9,KEY_EVENT_DOWN);
//刚开始的时候,右软键由系统处理,
//有按键之后,RSK将由GBEventHandler函数设置为我们自己处理
if(gbCurInputBox.pfSetRSK)
{
(*gbCurInputBox.pfSetRSK)();
}
//把我们的候选窗口显示出来
// GBCheckCandWnd();
/*
#ifdef __MMI_TOUCH_SCREEN__
mmi_pen_editor_vk_show();
#else
#endif
*/
//右键长按设置为清除输入框里面的所有内容
set_right_softkey_function(GBKeyClearAllHandlerForInputBox, KEY_EVENT_LONG_PRESS);
//这时候输入串肯定是空的。
if(gbCurInputBox.pfSetArrowKey)
{
(*gbCurInputBox.pfSetArrowKey)();
}
}
void GBShowCand(void)
{
#ifdef __MMI_TOUCH_SCREEN__
if(GUI_VIRTUAL_KEYBOARD_GUOBI_CAND != MMI_virtual_keyboard.lang_type)
{
mmi_pen_editor_vk_show();
}
#else
if(!s_bShowingCand)
{
s_bShowingCand = 1; //防止循环
GBResizeContentArea(-CAND_HEIGHT);
GBDrawCandWnd();
}
#endif
}
/**
* \brief 暂时没有用到
*/
void GBCloseCand(void)
{
#ifdef __MMI_TOUCH_SCREEN__
if(GUI_VIRTUAL_KEYBOARD_GUOBI_CAND == MMI_virtual_keyboard.lang_type)
{
mmi_pen_editor_vk_hide();
}
#else
if(s_bShowingCand)
{
s_bShowingCand = 0;
GBResizeContentArea(CAND_HEIGHT);
}
#endif
}
/**
* \brief 用于切换输入法之后检查我们的Virtual Keyboard有没有显示出来
*/
void GBCheckCandWnd(void)
{
#ifdef __MMI_TOUCH_SCREEN__
if((INPUT_MODE_SMART_UPPERCASE_ABC == MMI_current_input_mode
|| INPUT_MODE_SMART_LOWERCASE_ABC == MMI_current_input_mode
|| INPUT_MODE_SM_PINYIN == MMI_current_input_mode
|| INPUT_MODE_SM_STROKE == MMI_current_input_mode
|| INPUT_MODE_TR_STROKE == MMI_current_input_mode
||INPUT_MODE_SMART_UPPERCASE_GERMAN == MMI_current_input_mode
|| INPUT_MODE_SMART_LOWERCASE_GERMAN == MMI_current_input_mode))
{
//打开候选框窗口
mmi_pen_editor_vk_show();
}
else if(GUI_VIRTUAL_KEYBOARD_GUOBI_CAND == MMI_virtual_keyboard.lang_type)
{
//关闭候选窗口
mmi_pen_editor_vk_hide();
}
#else
if(INPUT_MODE_SMART_UPPERCASE_ABC == MMI_current_input_mode
|| INPUT_MODE_SMART_LOWERCASE_ABC == MMI_current_input_mode
|| INPUT_MODE_SM_PINYIN == MMI_current_input_mode
|| INPUT_MODE_SM_STROKE == MMI_current_input_mode
|| INPUT_MODE_TR_STROKE == MMI_current_input_mode
|| INPUT_MODE_SMART_UPPERCASE_GERMAN == MMI_current_input_mode
|| INPUT_MODE_SMART_LOWERCASE_GERMAN == MMI_current_input_mode)
{
GBShowCand();
}
else
{
GBCloseCand();
}
#endif
}
void GBSaveSMData(void)
{
/* U32 write_len;
#ifdef __MMI_GB_CN_SM__
if(s_bChnSMDataChanged)
{
FILE_HANDLE fhSM;
fhSM = pfopen(GB_SC_SM_FILE, PFS_WRITE);
if(fhSM >= 0)
{
pfwrite(s_gbCnSMData, 1, sizeof(s_gbCnSMData), fhSM, &write_len);
pfclose(fhSM);
}
s_bChnSMDataChanged = 0;
}
#endif*/
#ifdef __MMI_GB_LATIN_SM__
if(s_bLatinSMDataChanged)
{
FILE_HANDLE fhSM;
fhSM = pfopen(GB_EN_SM_FILE, PFS_WRITE);
if(fhSM >= 0)
{
pfwrite(s_gbLatinSMData, 1, sizeof(s_gbLatinSMData), fhSM, &write_len);
pfclose(fhSM);
}
s_bLatinSMDataChanged = 0;
}
#endif
}
void GBInputMethodEnterCategory5(void)
{
GBInputMethodReset();
GBSaveSMData();
}
void GBInputMethodExitCategory5(void)
{
GBInputMethodReset();
GBSaveSMData();
}
void GBInputMethodEnterCategory28(void)
{
GBInputMethodReset();
GBSaveSMData();
}
void GBInputMethodExitCategory28(void)
{
GBInputMethodReset();
GBSaveSMData();
}
void GBInputMethodExit(void)
{
GBInputMethodReset();
//关闭候选框
GBSaveSMData();
}
static const U16 comp_unicodes[] =
{
0x6728,
0x624C,
0x8279,
0x8F66,
0x96E8,
0x76EE,
0x5C71,
0xE822,
0x53E3,
0x65E5,
0x6708,
0xE836,
0x9485,
0x72AD,
0x4EBB,
0x8FB6,
0x5FC4,
0x6C35,
0x5B80,
0x706B,
0x5F13,
0x5973,
0x961D,
0x7E9F,
0x9A6C,
0x8ECA,
0x91D2,
0x7CF9,
0x99AC,
/*
0x4E00,
0x4E28,
0x4E3F,
0x4E36,
0x4E5B,*/
0
};
static U16 FindCompIndex(U16 comp)
{
const U16 * pComp = comp_unicodes;
while(*pComp && *pComp != comp)
{
++pComp;
}
return pComp - comp_unicodes;
}
/**
* \brief
* \param [out] drawStrLen 输出画了汉字的长度, 可以为空
* \return 实际使用的长度
*/
static U16 RightAlignDrawText(U32 x, U32 y, U16 width, UI_string_type text, U16 * drawStrLen)
{
int len;
int widthLeft = width;
S32 w,h;
UI_string_type pTextStart;
if(text == NULL
|| *text == 0)
{
if(drawStrLen)
{
*drawStrLen = 0;
}
return 0;
}
len = pixtel_UI_strlen(text);
pTextStart = text + len - 1;
while(widthLeft > 0 && pTextStart >= text)
{
pixtel_UI_measure_character(*pTextStart, &w, &h);
if(widthLeft < w)
{
if(drawStrLen)
{
*drawStrLen = len - (pTextStart - text);
}
pixtel_UI_move_text_cursor(x, y);
pixtel_UI_print_text(pTextStart);
return widthLeft - width;
}
widthLeft -= w;
--pTextStart;
}
if(drawStrLen)
{
*drawStrLen = len;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -