📄 gb_wrapper.c
字号:
//#ifdef __MMI_GB__
#include "PixtelDataTypes.h"
#include "MMI_features.h"
#include "oslmemory.h"
#include "GlobalConstants.h"
#include "Eventsdef.h"
#include "Frameworkstruct.h"
#include "EventsDef.h"
#include "Wgui.h"
#include "Timerevents.h"
#include "DebugInitDef.h"
#include "CustDataRes.h"
#include "MessagesResourceData.h"
#include "GlobalDefs.h"
#include "Gui_config.h"
#include "stddef.h"
//#include "GBAr_tran.h"
/*MTK Terry for Selection Size for different LCM size and Font size*/
#include "gdi_lcd_config.h"
/*MTK end*/
//to restruct the header files for new simulator
#include "gui_ems.h"
//#include "Ems.h"
#include "wgui_categories_inputs.h"
#include "gui.h"
#include "gui_themes.h"
#include "Wgui_softkeys.h"
#include "gb_wrapper.h"
#include "wgui_categories_defs.h"
#include "wgui_categories_util.h"
#include "GBMMI.h"
#include "GBGlobal.h"
#include "gui_virtual_keyboard.h"
#include "wgui_virtual_keyboard.h"
#include "EditorPen.h"
#include "FileSystemDef.h"
/**
* \brief macros....
*/
#ifdef __MMI_MAINLCD_240X320__
#define GB_CN_CANDIDATE_LEN 7
#define GB_SYMBOL_CANDIDATE_LEN 7
#define GB_LATIN_CANDIDATE_COUNT 9
#define GB_LATIN_CANDIDATE_LEN 18
#else
#define GB_CN_CANDIDATE_LEN 5 //中文输入法侯选个数
#define GB_SYMBOL_CANDIDATE_LEN 5 //符号侯选个数
#define GB_LATIN_CANDIDATE_COUNT 6 //非中文的侯选个数
#define GB_LATIN_CANDIDATE_LEN 12 //非中文的侯选总字符数
#endif
#define GB_CN_SM_DATA_SIZE (5 * 1024)
#define GB_LATIN_SM_DATA_SIZE 2048
#define GB_SC_SM_FILE "gb_sc.smd"
#define GB_EN_SM_FILE "gb_en.smd"
#ifdef __MMI_MAINLCD_240X320__
#define CAND_TOP 252//254
#define CAND_BOTTOM 294//296
#define CAND_LEFT 1
#define CAND_RIGHT 239
#define CAND_HEIGHT 43
#define CAND_WIDTH 240
#else
#define CAND_TOP (154+3+2)
#define CAND_BOTTOM (196+3)
#define CAND_LEFT 1
#define CAND_RIGHT 175
#define CAND_HEIGHT (43-2)
#define CAND_WIDTH 176
#endif
//#define CAND_LINE_HEIGHT 2//((CAND_HEIGHT - 3) / 2)
#define SELECTOR_WIDTH 8
#define SELECTOR_HEIGHT 12
#define COMP_WIDTH 8//16
#define COMP_HEIGHT 12//16
#define CAND_VCENTER ((CAND_TOP + CAND_BOTTOM) / 2)
#define CAND_LINE_TOP (CAND_VCENTER + 1)
#ifdef __MMI_MAINLCD_240X320__
#define CAND_LINE_WIDTH 210
#else
#define CAND_LINE_WIDTH 150
#endif
#define CAND_LINE_HEIGHT ((CAND_HEIGHT - 5) / 2)
#define CAND_LINE_LEFT (CAND_LEFT + 1)
#define CAND_LINE_BOTTOM (CAND_BOTTOM - 1)
#define CAND_LINE_RIGHT (CAND_LINE_LEFT + CAND_LINE_WIDTH - 1)
#define UP_LINE_TOP (CAND_TOP + 1)
#define UP_LINE_LEFT (CAND_LEFT + 1)
#define UP_LINE_HEIGHT CAND_LINE_HEIGHT
#define UP_LINE_BOTTOM (CAND_VCENTER - 1)
#ifdef __MMI_MAINLCD_240X320__
#define UP_LINE_WIDTH 210
#else
#define UP_LINE_WIDTH 150
#endif
#define UP_LINE_RIGHT (UP_LINE_LEFT + UP_LINE_WIDTH - 1)
#define INDEX_TO_CHAR(i) ('0' + ((i) + 1) % 10)
#define FONT_CLR_HOT UI_COLOR_BLACK
#define BG_CLR_HOT pixtel_UI_color(200, 200, 255)
#define FONT_CLR_SELECTED UI_COLOR_WHITE
#define BG_CLR_SELECTED pixtel_UI_color(55, 55, 0)
#define FONT_CLR_NORMAL UI_COLOR_BLACK
#define BG_CLR_NORMAL UI_COLOR_WHITE
#define BG_CLR_ACTIVE_LINE pixtel_UI_color(200, 200, 200)
#define BG_CLR_DEACTIVE_LINE UI_COLOR_WHITE
#define ALL_COMP_COUNT 29
#define min(X,Y) (((X) < (Y)) ? (X) : (Y))
/***************************************************************************************/
/***********************************Structure ************************************/
/***************************************************************************************/
#ifdef __MMI_TOUCH_SCREEN__
typedef struct __GB_Touch_Region {
U16 top, bottom, left, right;
U32 gbEvent;
U32 param;
} GBTouchRegion;
#define GB_MAX_REGION_COUNT 20
#endif //__MMI_TOUCH_SCREEN__
/***************************************************************************************/
/***********************************Static Variable ************************************/
/***************************************************************************************/
#ifdef __MMI_GB_CN_SM__
static unsigned long s_gbCnSMData[GB_CN_SM_DATA_SIZE / sizeof(long)];
static U8 s_bChnSMDataChanged;
#endif
#ifdef __MMI_GB_LATIN_SM__
static unsigned long s_gbLatinSMData[GB_LATIN_SM_DATA_SIZE / sizeof(long)];
static U8 s_bLatinSMDataChanged;
#endif
#ifdef __MMI_TOUCH_SCREEN__
//有触摸屏的情况下面, 申请触摸区域
static GBTouchRegion s_gbTouchRegions[GB_MAX_REGION_COUNT];
static int s_gbTouchRegionsCount = 0;
#else
//候选区完全是自己画的, 所以根本不需要任何窗口,
//需要的只是适当的时候把EMS和multiline Inputbox 缩小
//static U16 s_CandInputBoxBuffer[2];
//static single_line_input_box s_CandWnd;
static U8 s_bShowingCand = 0;
#endif //__MMI_TOUCH_SCREEN__
int g_lastInputMode = INPUT_MODE_SMART_UPPERCASE_GERMAN;
static FuncPtr g_rsk_handler;
static const unsigned short okToBeginMakeWordStr[] = {'O', 'K', ' ', 'T', 'o', ' ', 'm', 'a', 'k', 'e', ' ', 'w', 'o', 'r', 'd', '\0'};
static const unsigned short okToAddMakeWordStr[] = {'O', 'K', ' ', 'T', 'o', ' ', 'a', 'd', 'd', ' ', 'w', 'o', 'r', 'd', '\0'};
void (* gb_inputbox_LSK_function)(void);
static GBIInputBox gbCurInputBox;
extern void wgui_set_EMS_inputbox_RSK(void);
extern void register_EMS_inputbox_keys(void);
extern UI_EMS_input_box MMI_EMS_inputbox;
static void GBUpScreen(void);
void GBKeyBackHandlerForInputBox(void);
void GBKeyClearAllHandlerForInputBox(void);
void GBKeyStarPressHandlerForInputBox(void);
void handle_category28_input(void);
#define GBClearAllKeyHandler() GBClearKeyHandler(gbKeyAll)
static void GBSetAllArrowHandler(void);
void GBKeyPoundPressHandlerForInputBox(void);
void GBResizeContentArea(int changed_height);
#ifdef __MMI_TOUCH_SCREEN__
#define INSERT_REGION(l, t, r, b, e, p) \
if(s_gbTouchRegionsCount < GB_MAX_REGION_COUNT) { \
GBTouchRegion * pRegion = &s_gbTouchRegions[s_gbTouchRegionsCount];\
pRegion->top = (t);\
pRegion->left = (l);\
pRegion->bottom = (b);\
pRegion->right = (r);\
pRegion->gbEvent = (e);\
pRegion->param = (p);\
++s_gbTouchRegionsCount;\
}
#else
#define INSERT_REGION(l, t, r, b, e, p) ((void)0)
#endif
#define PT_IN_REGION(x, y, pRegion) \
((x) >= (pRegion)->left && (x) <= (pRegion)->right \
&& (y) >= (pRegion)->top && (y) <= (pRegion)->bottom)
/*
#ifdef __MMI_GB_CN_SM__
static void GBOnChnSMDataChanged(const void * p1, unsigned long len)
{
s_bChnSMDataChanged = 1;
}
#endif
*/
#ifdef __MMI_GB_LATIN_SM__
static void GBOnLatinSMDataChanged(const void * pData, void * param)
{
s_bLatinSMDataChanged = 1;
}
#endif
static long GBGetAsciiStringWidth(const char * str)
{
S32 h, w;
GBUINT16 ret = 0;
while(*str)
{
pixtel_UI_measure_character(*str, &w, &h);
ret += w;
++str;
}
return ret;
}
static long GBGetWStringWidth(const GBUINT16 * str)
{
return pixtel_UI_get_string_width((UI_string_type)str);
}
#define SYLLABLE_SEPERATE 10
void GBInputMethodInit(void)
{
GBEvent evt;
int ret;
extern const unsigned long prv_dataArray[];
extern const unsigned long prv_enDataArray[];
extern const unsigned long prv_deDataArray[];
/* //中文数据初始化
g_gbMMIGlobals.initData.chnInitData.nCandDesireLenInWord = GB_CN_CANDIDATE_LEN;
g_gbMMIGlobals.initData.chnInitData.nInterpunctionDesireLen = GB_SYMBOL_CANDIDATE_LEN;
g_gbMMIGlobals.initData.chnInitData.pLDBData = prv_dataArray;
#ifdef __MMI_GB_CN_SM__
{
FILE_HANDLE fhSM;
size_t read;
fhSM = pfopen(GB_SC_SM_FILE, PFS_READ);
if(fhSM >= 0)
{
read = 0;
pfread(s_gbCnSMData, 1, sizeof(s_gbCnSMData), fhSM, &read);
if(read != sizeof(s_gbCnSMData))
{
memset(s_gbCnSMData, 0, sizeof(s_gbCnSMData));
}
pfclose(fhSM);
}
}
g_gbMMIGlobals.initData.chnInitData.pUDBData = s_gbCnSMData;
g_gbMMIGlobals.initData.chnInitData.nUDBDataLen = sizeof(s_gbCnSMData);
g_gbMMIGlobals.initData.chnInitData.fpOnChnSelfMakeDataChanged = GBOnChnSMDataChanged;
#else
g_gbMMIGlobals.initData.chnInitData.pUDBData = NULL;
g_gbMMIGlobals.initData.chnInitData.nUDBDataLen = 0;
g_gbMMIGlobals.initData.chnInitData.fpOnChnSelfMakeDataChanged = NULL;
#endif*/
//英文数据初始化
g_gbMMIGlobals.initData.latinInitData[0].nLanguageType = GBL_English;
g_gbMMIGlobals.initData.latinInitData[0].nCandDesireLenInWord = GB_LATIN_CANDIDATE_LEN;
g_gbMMIGlobals.initData.latinInitData[0].nCandDesireCountInWord = GB_LATIN_CANDIDATE_COUNT;
g_gbMMIGlobals.initData.latinInitData[0].pLDBData = prv_enDataArray;
#ifdef __MMI_GB_LATIN_SM__
{
FILE_HANDLE fhSM;
size_t read;
fhSM = pfopen(GB_EN_SM_FILE, PFS_READ);
if(fhSM >= 0)
{
read = 0;
pfread(s_gbLatinSMData, 1, sizeof(s_gbLatinSMData), fhSM, &read);
if(read != sizeof(s_gbLatinSMData))
{
memset(s_gbLatinSMData, 0, sizeof(s_gbLatinSMData));
}
pfclose(fhSM);
}
}
g_gbMMIGlobals.initData.latinInitData[0].pUDBData = s_gbLatinSMData;
g_gbMMIGlobals.initData.latinInitData[0].nUDBDataLen = sizeof(s_gbLatinSMData);
g_gbMMIGlobals.initData.latinInitData[0].fpOnLtSelfMakeDataChanged = GBOnLatinSMDataChanged;
memcpy(g_gbMMIGlobals.initData.latinInitData[0].okToBeginMakeWordStr,
okToBeginMakeWordStr,
sizeof(okToBeginMakeWordStr));
memcpy(g_gbMMIGlobals.initData.latinInitData[0].okToAddMakeWordStr,
okToAddMakeWordStr,
sizeof(okToAddMakeWordStr));
#else
g_gbMMIGlobals.initData.latinInitData[0].pUDBData = NULL;
g_gbMMIGlobals.initData.latinInitData[0].nUDBDataLen = 0;
g_gbMMIGlobals.initData.latinInitData[0].fpOnLtSelfMakeDataChanged = 0;
#endif
//德文数据初始化
g_gbMMIGlobals.initData.latinInitData[1].nLanguageType = GBL_German;
g_gbMMIGlobals.initData.latinInitData[1].nCandDesireLenInWord = GB_LATIN_CANDIDATE_LEN;
g_gbMMIGlobals.initData.latinInitData[1].nCandDesireCountInWord = GB_LATIN_CANDIDATE_COUNT;
g_gbMMIGlobals.initData.latinInitData[1].pLDBData = prv_deDataArray;
#ifdef __MMI_GB_LATIN_SM__
{
FILE_HANDLE fhSM;
size_t read;
fhSM = pfopen(GB_EN_SM_FILE, PFS_READ);
if(fhSM >= 0)
{
read = 0;
pfread(s_gbLatinSMData, 1, sizeof(s_gbLatinSMData), fhSM, &read);
if(read != sizeof(s_gbLatinSMData))
{
memset(s_gbLatinSMData, 0, sizeof(s_gbLatinSMData));
}
pfclose(fhSM);
}
}
g_gbMMIGlobals.initData.latinInitData[1].pUDBData = s_gbLatinSMData;
g_gbMMIGlobals.initData.latinInitData[1].nUDBDataLen = sizeof(s_gbLatinSMData);
g_gbMMIGlobals.initData.latinInitData[1].fpOnLtSelfMakeDataChanged = GBOnLatinSMDataChanged;
memcpy(g_gbMMIGlobals.initData.latinInitData[1].okToBeginMakeWordStr,
okToBeginMakeWordStr,
sizeof(okToBeginMakeWordStr));
memcpy(g_gbMMIGlobals.initData.latinInitData[1].okToAddMakeWordStr,
okToAddMakeWordStr,
sizeof(okToAddMakeWordStr));
#else
g_gbMMIGlobals.initData.latinInitData[1].pUDBData = NULL;
g_gbMMIGlobals.initData.latinInitData[1].nUDBDataLen = 0;
g_gbMMIGlobals.initData.latinInitData[1].fpOnLtSelfMakeDataChanged = 0;
#endif
//g_gbMMIGlobals.initData.bChnEnConvert = 1;
g_gbMMIGlobals.initData.bUpNumber = 1;
g_gbMMIGlobals.initData.bUseLongPhress = 0;
//g_gbMMIGlobals.uiInfo.npreEditWidth = 240;
//g_gbMMIGlobals.uiInfo.nsyllableSplit = 10;
//g_gbMMIGlobals.uiInfo.fpGetStrWidth = GBGetAsciiStringWidth;
//g_gbMMIGlobals.uiInfo.fpGetWCharWidth = GBGetWStringWidth;
evt.nType = GBET_In_Init;
evt.param1 = GBIM_SmartLatin;
evt.param2 = GBL_German;
ret = GBHandleInputEvent(&evt);
memset(&gbCurInputBox, 0, sizeof(gbCurInputBox));
#ifndef __MMI_TOUCH_SCREEN__
//create
#endif
}
static int GBEventHandler(UINT evtType, GBINT32 param1, GBINT32 param2)
{
GBEvent evt;
int ret;
int oldShowCand;
evt.nType = evtType;
evt.param1 = param1;
evt.param2 = param2;
oldShowCand = g_gbMMIGlobals.outputInfo.isShowIMWin;
//pre event handle
ret = GBHandleInputEvent(&evt);
//post event handle
if(GBET_In_Key == evtType
|| GBET_In_SetPinYinIndex == evtType
|| GBET_In_SelCandidate == evtType)
{
GBUpScreen();
GBDrawCandWnd();
}
/*
else if(evtType == GBET_In_ChgInputMode)
{
GBDrawCandWnd();//这里面会到gui_show_virtual_keyboard里面进行重画
}*/
//
if(oldShowCand && !g_gbMMIGlobals.outputInfo.isShowIMWin)
{
GBClearKeyHandler(gbKeyArrow);
//右键也要EMS处理,这里面可能以后要改为singline 和multiline input box都适用的版本
if(gbCurInputBox.pfSetRSK)
{
(*gbCurInputBox.pfSetRSK)();
}
//wgui_set_EMS_inputbox_RSK();
//把方向键交给EMS处理
if(gbCurInputBox.pfSetArrowKey)
{
(*gbCurInputBox.pfSetArrowKey)();
}
//register_EMS_inputbox_keys();
if(gbCurInputBox.pfInputBoxIsEmtpy
&& (*gbCurInputBox.pfInputBoxIsEmtpy)())
{
set_right_softkey_label((UI_string_type) get_string(STR_GLOBAL_BACK));
}
else
{
set_right_softkey_label((UI_string_type) get_string(STR_GLOBAL_CLEAR));
}
set_right_softkey_icon(NULL);
show_softkey_background();//Sam ,refresh
redraw_right_softkey();
}
if(g_gbMMIGlobals.outputInfo.isShowIMWin)
{
//这个时候方向键需要我们自己处理
GBSetAllArrowHandler();
//如果输入框为空的时候,而输入法里面有内容的时候
//我们需要把右软件设置为删除
if(gbCurInputBox.pfInputBoxIsEmtpy
&& (*gbCurInputBox.pfInputBoxIsEmtpy)()
&& !GbIsInputEmpty())
{
set_right_softkey_label((UI_string_type) get_string(STR_GLOBAL_CLEAR));
set_right_softkey_icon(NULL);
show_softkey_background();//Sam ,refresh
redraw_right_softkey();
}
//将右软件设置为我们自己的删除函数
set_right_softkey_function(GBKeyBackHandlerForInputBox, KEY_EVENT_UP);
set_right_softkey_function(UI_dummy_function, KEY_EVENT_DOWN);
set_right_softkey_function(GBKeyClearAllHandlerForInputBox, KEY_EVENT_LONG_PRESS);
}
if(g_gbMMIGlobals.outputInfo.fullOutput &&
g_gbMMIGlobals.outputInfo.fullOutput[0]
&& g_gbMMIGlobals.outputInfo.isShowIMWin)
{
//*输入*
SetKeyHandler(GBKeyStarPressHandlerForInputBox, KEY_STAR, KEY_EVENT_DOWN);
}
else
{
//*作为输入法切换键
SetKeyHandler(gbCurInputBox.pfChangeInputMode, KEY_STAR, KEY_EVENT_DOWN);
}
return ret;
}
void GBKey1PressHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_1, GBKT_Down);
}
void GBKey2PressHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_2, GBKT_Down);
}
void GBKey3PressHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_3, GBKT_Down);
}
void GBKey4PressHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_4, GBKT_Down);
}
void GBKey5PressHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_5, GBKT_Down);
}
void GBKey6PressHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_6, GBKT_Down);
}
void GBKey7PressHandlerForInputBox(void)
{
GBEventHandler(GBET_In_Key, GBKEY_7, GBKT_Down);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -