📄 dictionary_touch_5_touch.c
字号:
#include "MMI_features.h"
#define __NEWSIMULATOR
#include "stdC.h"
#include "L4Dr1.h"
#include "PixtelDataTypes.h"
#include "GlobalDefs.h"
#include "GlobalConstants.h" /* KEY ID define */
#include "Fat_fs.h" /* File System, must after "GlobalConstants.h" */
//#include "FileSystemDef.h" /* file function */
#include "GlobalDefs.h" /* Golbal Image and String ID. */
#include "gui.h" /* Gui functions */
#include "wgui_categories.h" /* Categories */
#include "HistoryGprot.h" /* Screen history */
#include "Unicodexdcl.h" /* Unicode transform functions */
#include "EventsGprot.h" /* Event handling */
#include "SettingDefs.h" /* popup sound */
#include "DebugInitDef.h" /* MMI_ASSERT */
#include "CommonScreens.h" /* Popup */
#include "SubLCDHistoryGprot.h" /* SubLCD */
#include "lcd_sw_rnd.h" /* lcd */
#include "lcd_if.h" /* lcd */
#include "gdi_include.h" /* graphic library */
#include "mdi_datatype.h" /* mdi datatype */
#include "mdi_audio.h" /* audio lib */
#include "kal_release.h" /* kal */
#include "Unicodexdcl.h" /* string manipulation */
#define __NEWSIMULATOR
//the head of functions of NetWork and File
#include "FileManagerGProt.h"
#include "PersonalizationDef.h"
#include "gdi_datatype.h"
#include "StdC.h"
#include "L4Dr1.h"
#include "L4Dr.h"
#include "DebugInitDef.h"
#include "FrameworkStruct.h"
#include "globalconstants.h"
#include "CommonScreens.h" //redifined gIndexIconsImageList
#include "wgui_categories.h"
#include "GlobalDefs.h"
#include "historyGprot.h"
#include "ProtocolEvents.h"
#include "PixtelDataTypes.h"
#include "MMI_trc.h"
#include "app_mine.h"
#include "Conversions.h"
#include "FileMgr.h"
#include "MainMenuDef.h"
#include "soc_api.h"
#include "app2soc_struct.h"
#include "custom_em.h"
#undef __NEWSIMULATOR
#include "wgui_categories_inputsenum.h"
#include "TouchScreenGprot.h"
S8 str[1024]={0};
S8 str2[2048]={0};
S8 input_word[20];
S8 input_word2[20];
S8 input_words[20];
S8 head_chan[2];
S8 head_chan2[2];
S8 head[4];
S8 input_words_chan[40];
S8 tmp_word[10][20];
S8 tmp_word_chan[10][40];
S8 tmp_word_clean[20];
S8 tmp_word_chan_clean[40];
S8* token_pt;
void Chinene_to_English(void);
void My_Translation(void);
void My_Main22(void);
void Dic_Input_Show(void);
void Convert_GBK_to_Unicode4(const char *pGBK, U16 *pUnicode, U16 len)
{
#ifndef MMI_ON_WIN32
mmi_chset_text_to_ucs2_str((kal_uint8*)pUnicode, len, (kal_uint8*)pGBK, GB2312_ENCODING_TYPE);
#else
MultiByteToWideChar(CP_ACP, 0, pGBK, len, (U16 *)pUnicode, len);
#endif
}
void Convert_Unicode_to_GBK(const char *pUnicode , U16 *pGBK, U16 len)
{
#ifndef MMI_ON_WIN32
mmi_chset_ucs2_to_text_str((kal_uint8 *)pGBK, len, (kal_uint8 *)pUnicode,GB2312_ENCODING_TYPE);
#else
WideCharToMultiByte(CP_ACP,0,(U16 *)pUnicode,len,pGBK,len,NULL,NULL);
#endif
}
void Open_File(void)
{
U16 file_len = 0;
kal_int16 a;
U16 actread;
FS_HANDLE hFile = -1;
S8 file_str[12] = ":\\dic.txt";
S8 disk_tk = 'c';
//S8 disk_tk = MMI_CARD_DRV;
S8 file_add[20] ={0};
S8 file_add_chan[30];
//file_add[0] = disk_tk;
//strcat(file_add,file_str);
sprintf(file_add,"%c%s",disk_tk,file_str);
Convert_GBK_to_Unicode4(file_add,(U16 *)file_add_chan,30); //use GBK or unicode ?
hFile = FS_Open((PU16)file_add_chan, FS_READ_ONLY);
if(hFile<0)
{
gui_move_text_cursor(20,20);
gui_set_text_color(UI_COLOR_RED);
gui_print_text(L"file open failed!");
gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
return;
}
if(FS_GetFileSize(hFile, (UINT*)&file_len) != FS_NO_ERROR)
{
gui_move_text_cursor(20,80);
gui_set_text_color(UI_COLOR_RED);
gui_print_text(L"file GET failed!");
gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
return;
}
a=FS_Read(hFile,str,file_len,(UINT*)&actread); //把str写成了str2,应该写转换前的,却写成转换后的!
if(a < 0)
{
gui_move_text_cursor(40,40);
gui_set_text_color(UI_COLOR_BLACK);
gui_print_text(L"file READ failed!");
gui_BLT_double_buffer(0,0,UI_device_height-1,UI_device_width-1);
return;
}
FS_Close(hFile);
}
void English_to_Chinese(void)
{
S8 ch_word[20]={0};
//the varitys of function File
S8* str_en;
S8* str_ch;
U16 count_i=0;
U16 count_j=0;
U16 count_k=0;
S8 str_en_chan[30];
S8 str_ch_chan[30];
Open_File();
if((str_en= strstr(str, input_word))!= NULL)
{
while( *(--str_en) != '\n') //the second time mismatch such as "en",however, as the words growing, it will disapear.
{
while(*str_en != '\n')
{
str_en++;
}
str_en = strstr(str_en, input_word); //match in the less wide area
}
while(*str_en != '\t')
{
str_en++;
count_i++;
}
str_ch = str_en;
str_en = str_en - count_i + 1; //str_en point to the En word
count_i=0; //to find the EN word
while(*str_en != '\t')
{
count_i++;
str_en++;
}
str_en -= count_i;
/*
for(count_j=0; count_j<20; count_j++) //if add this , that will print the same as 1
{
tmp_word[0][count_j]=' ';
}
for(count_k=0; count_k<40; count_k++)
{
tmp_word_chan[0][count_k]=' ';
}*/
memcpy(tmp_word[0],tmp_word_clean,20);
memcpy(tmp_word_chan[0],tmp_word_chan_clean,40);
memcpy(tmp_word[0],str_en,count_i);
Convert_GBK_to_Unicode4(tmp_word[0],(U16 *)tmp_word_chan[0], 40); //占用太大内存,把str_ch清空了
str_ch += 1; //to find the CH word
count_i=0;
while(*str_ch != '\n')
{
count_i++;
str_ch++;
}
token_pt = str_ch;
str_ch -= count_i;
/*for(count_j=0; count_j<20; count_j++) //useful
{
tmp_word[1][count_j]=' ';
}
for(count_k=0; count_k<40; count_k++)
{
tmp_word_chan[1][count_k]=' ';
}*/
memcpy(tmp_word[1],tmp_word_clean,20);
memcpy(tmp_word_chan[1],tmp_word_chan_clean,40);
memcpy(tmp_word[1],str_ch,count_i);
Convert_GBK_to_Unicode4(tmp_word[1],(U16 *)tmp_word_chan[1],40); //占用太大内存,把str_ch清空了
}
else //the first time mismatch
{
gui_move_text_cursor(10,150);
gui_set_text_color(UI_COLOR_RED);
gui_print_text(L"have no this word!");
gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
return;
}
//print the words followed
count_i = 0;
str_en = token_pt;
str_en++;
while(*str_en != '\t')
{
str_en++;
count_i++;
}
token_pt = str_en;
str_en -= count_i;
/*for(count_j=0; count_j<20; count_j++)
{
tmp_word[2][count_j]=' ';
}
for(count_k=0; count_k<40; count_k++)
{
tmp_word_chan[2][count_k]=' ';
}*/
memcpy(tmp_word[2],tmp_word_clean,20);
memcpy(tmp_word_chan[2],tmp_word_chan_clean,40);
memcpy(tmp_word[2],str_en,count_i);
Convert_GBK_to_Unicode4(tmp_word[2],(U16 *)tmp_word_chan[2],40); //占用太大内存,把str_ch清空了
count_i = 0;
str_ch = token_pt;
str_ch++;
while(*str_ch != '\n')
{
str_ch++;
count_i++;
}
token_pt = str_ch;
str_ch -= count_i;
/*for(count_j=0; count_j<20; count_j++)
{
tmp_word[3][count_j]=' ';
}
for(count_k=0; count_k<40; count_k++)
{
tmp_word_chan[3][count_k]=' ';
}*/
memcpy(tmp_word[3],tmp_word_clean,20);
memcpy(tmp_word_chan[3],tmp_word_chan_clean,40);
memcpy(tmp_word[3],str_ch,count_i);
Convert_GBK_to_Unicode4(tmp_word[3],(U16 *)tmp_word_chan[3],40); //take up too much
count_i = 0;
str_en = token_pt;
str_en++;
while(*str_en != '\t')
{
str_en++;
count_i++;
}
token_pt = str_en;
str_en -= count_i;
/*for(count_j=0; count_j<20; count_j++)
{
tmp_word[4][count_j]=' ';
}
for(count_k=0; count_k<40; count_k++)
{
tmp_word_chan[4][count_k]=' ';
}*/
memcpy(tmp_word[4],tmp_word_clean,20);
memcpy(tmp_word_chan[4],tmp_word_chan_clean,40);
memcpy(tmp_word[4],str_en,count_i);
Convert_GBK_to_Unicode4(tmp_word[4],(U16 *)tmp_word_chan[4],40); //占用太大内存,把str_ch清空了
count_i = 0;
str_ch = token_pt;
str_ch++;
while(*str_ch != '\n')
{
str_ch++;
count_i++;
}
token_pt = str_ch;
str_ch -= count_i;
/*for(count_j=0; count_j<20; count_j++)
{
tmp_word[5][count_j]=' ';
}
for(count_k=0; count_k<40; count_k++)
{
tmp_word_chan[5][count_k]=' ';
}*/
memcpy(tmp_word[5],tmp_word_clean,20);
memcpy(tmp_word_chan[5],tmp_word_chan_clean,40);
memcpy(tmp_word[5],str_ch,count_i);
Convert_GBK_to_Unicode4(tmp_word[5],(U16 *)tmp_word_chan[5],40); //take up too much
count_i = 0;
str_en = token_pt;
str_en++;
while(*str_en != '\t')
{
str_en++;
count_i++;
}
token_pt = str_en;
str_en -= count_i;
/*for(count_j=0; count_j<20; count_j++)
{
tmp_word[6][count_j]=' ';
}
for(count_k=0; count_k<40; count_k++)
{
tmp_word_chan[6][count_k]=' ';
}*/
memcpy(tmp_word[6],tmp_word_clean,20);
memcpy(tmp_word_chan[6],tmp_word_chan_clean,40);
memcpy(tmp_word[6],str_en,count_i);
Convert_GBK_to_Unicode4(tmp_word[6],(U16 *)tmp_word_chan[6],40); //占用太大内存,把str_ch清空了
count_i = 0;
str_ch = token_pt;
str_ch++;
while(*str_ch != '\n')
{
str_ch++;
count_i++;
}
token_pt = str_ch;
str_ch -= count_i;
/*for(count_j=0; count_j<20; count_j++)
{
tmp_word[7][count_j]=' ';
}
for(count_k=0; count_k<40; count_k++)
{
tmp_word_chan[7][count_k]=' ';
}*/
memcpy(tmp_word[7],tmp_word_clean,20);
memcpy(tmp_word_chan[7],tmp_word_chan_clean,40);
memcpy(tmp_word[7],str_ch,count_i);
Convert_GBK_to_Unicode4(tmp_word[7],(U16 *)tmp_word_chan[7],40); //take up too much
//GoBackHistory();
My_Main22();
//Dic_Input_Show();
}
void Chinese_to_English(void)
{
S8 en_word[20]={0};
S8* str_ch;
S8* str_en;
S8 str_ch_chan[30];
U16 count_j=0;
U16 count_k=0;
Open_File();
if((str_ch= strstr(str, input_word2))!= NULL)
{
while( *(--str_ch) != '\t')
{
while(*str_ch != '\t')
{
str_ch++;
}
str_ch = strstr(str_ch, input_word2); //match in the less wide area
}
str_en = str_ch;
token_pt = str_ch;
while(*token_pt != '\n') //store the token_pt;
{
token_pt++;
}
count_j=0;
while(*str_ch != '\n')
{
str_ch++;
count_j++;
}
str_ch -= count_j;
memcpy(tmp_word[0],tmp_word_clean,20);
memcpy(tmp_word_chan[0],tmp_word_chan_clean,40);
memcpy(tmp_word[0],str_ch,count_j);
Convert_GBK_to_Unicode4(tmp_word[0],(U16 *)tmp_word_chan[0],40);
count_j=0;
while(*str_en != '\n')
{
str_en--;
count_j++;
}
str_en++;
count_j--;
memcpy(tmp_word[1],tmp_word_clean,20);
memcpy(tmp_word_chan[1],tmp_word_chan_clean,40);
memcpy(tmp_word[1],str_en,count_j);
Convert_GBK_to_Unicode4(tmp_word[1],(U16 *)tmp_word_chan[1],40); //占用太大内存,把str_ch清空了
}
else
{
gui_move_text_cursor(10,150);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -