⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dict_start.c

📁 在MTK下开发的一个词典项目
💻 C
📖 第 1 页 / 共 4 页
字号:
void dict_pen_up_fun(mmi_pen_point_struct pos)
{

	unsigned short move_line_num;
	int i;
/*	int k;*/
	dict_down_place_fun();

	if (pos.y>199&&pos.y<220)
	{
		if (pos.x>4&&pos.x<35)
		{
//			dict_show_bottom_text(0,!DICT_IS_INPUT_NULL,0);
			dict_main_left_key_fun();
			return;
		}
		if (pos.x>142&&pos.x<173)
		{
//			dict_show_bottom_text(0,!DICT_IS_INPUT_NULL,0);
			dict_main_right_key_fun();
			return;
		}
		return;
	}
	if (pos.y>45&&pos.y<69)//窗口选择按钮
	{
		if (pos.x>0&&pos.x<29)
		{
			if (dict_sc_cur_menu==0)
			{
				return;
			}
			dict_sc_cur_menu = 0;
			dict_init_data();
			dict_draw_win();
			return;
		}
		if (pos.x>29&&pos.x<58)
		{
			if (dict_sc_cur_menu==1)
			{
				return;
			}
			dict_sc_cur_menu = 1;
			dict_init_data();
			dict_draw_win();
			return;
		}
		if (pos.x>58&&pos.x<88)
		{
			if (dict_sc_cur_menu==2)
			{
				return;
			}
			dict_sc_cur_menu = 2;
			dict_init_data();
			dict_draw_win();
			return;
		}
		if (pos.x>88&&pos.x<116)
		{
			if (dict_sc_cur_menu==3)
			{
				return;
			}            
			dict_sc_cur_menu = 3;
//			MY_write_error_info((char*)"begin init data\r\n");
			dict_init_data();
//			MY_write_error_info((char*)"end of init data \r\n");
//				MY_write_error_info((char*)"begin draw win\r\n");
			dict_draw_win();
//			MY_write_error_info((char*)"end of draw win\r\n");
			return;
		}
		if (pos.x>116&&pos.x<146)
		{
			if (dict_sc_cur_menu==4)
			{
				return;
			}
			dict_sc_cur_menu = 4;
			dict_init_data();
			dict_draw_win();
			return;
		}
		if (pos.x>146&&pos.x<176)
		{
			if (dict_sc_cur_menu==5)
			{
				return;
			}
			dict_sc_cur_menu = 5;
			dict_init_data();
			dict_draw_win();
			return;
		}
		return;
	}
	if (DICT_IS_SHOW_CUR_ITEM==0&&dict_sc_cur_menu!=3&&pos.x>0&&pos.x<176&&pos.y>70&&pos.x<199)
	{
		DICT_IS_SHOW_CUR_ITEM = 1;
		dict_output_word_list(1);
//		dict_show_bottom_text(0,!DICT_IS_INPUT_NULL,0);
		dict_show_lsk_fun(0);
		dict_show_rsk_fun(0);	
		return;
	}
	if (pos.x>120&&pos.x<146&&pos.y>22&&pos.y<44)//输入法框
	{
//		if (dict_sc_cur_menu==0||dict_sc_cur_menu==4||dict_sc_cur_menu==5)
//		{
//			return;
//		}
//		else 
		{
			memset(gnoteString1,0,64);
			memcpy(gnoteString1,MMI_singleline_inputbox.text,2*UCS2_Text_len((unsigned short *)MMI_singleline_inputbox.text));
			Draw_Picture_by_name(DISK_TYPE,"dict\\input_chn_normal.gif",122,23,0);
//			StopTimer(LEARN_MACHINE_KEYS_TIMER_ID);
//			StopTimer(LEARN_MACHINE_GET_WORDLIST);
			LM_pinyin_shurufa();
			return;
		}
	}
	if (pos.x>120&&pos.x<176&&pos.y>20&&pos.y<44)//删除框
	{
		Draw_Picture_by_name(DISK_TYPE,"dict\\delete_button_normal.gif",150,23,0);
		if (DICT_IS_INPUT_NULL==0)
		{
			singleline_inputbox_delete_character();
		}
		return;
	}
	if(pos.y>70&&pos.y<199)
	{
		if (dict_sc_cur_menu==3)
		{
			ZXWX_Vscroll_bar_pen_event((unsigned char *)(&zt_dict_exp_vertical_scroll_bar),pos,EVENT_PEN_UP);				
			return;
		}
		else
		{
			if (pos.x>74&&pos.x<88)//need modify
			{
				if (dict_cur_focus)
				{
					dict_cur_focus = 0;
					dict_output_word_list(0);
					dict_output_word_explain();
				}
				ZXWX_Vscroll_bar_pen_event((unsigned char *)(&zt_dict_list_vertical_scroll_bar),pos,EVENT_PEN_UP);
				return;
			}	
			if (pos.x>88&&pos.x<176)//解释的多块区域
			{
				if (dict_cur_focus == 0)
				{
					dict_cur_focus = 1;
					dict_output_word_list(0);
					dict_output_word_explain();
				}
				ZXWX_Vscroll_bar_pen_event((unsigned char *)(&zt_dict_exp_vertical_scroll_bar),pos,EVENT_PEN_UP);
				return;
			}
			if (pos.x>0&&pos.x<71)
			{
				i = (pos.y-70)/20;
				if (i<WORD_NUM_PER_PAGE && i<word_list_num)
				{
					dict_cur_focus = 0;
					if ((i-dict_list_cur_line)>0)
					{
						move_line_num = (unsigned short)(i - dict_list_cur_line);
						if (move_line_num==1)
						{
							ZXWX_Vscroll_bar_KeyDown((unsigned char *)&zt_dict_list_vertical_scroll_bar,1);
							ZXWX_Vscroll_bar_KeyUp((unsigned char*)&zt_dict_list_vertical_scroll_bar);
						}
						else
						{
							zt_dict_list_vertical_scroll_bar.scroll_cur_line = (unsigned short)(zt_dict_list_vertical_scroll_bar.scroll_cur_line + move_line_num - 1);
							ZXWX_Vscroll_bar_KeyDown((unsigned char *)&zt_dict_list_vertical_scroll_bar,1);
							ZXWX_Vscroll_bar_KeyUp((unsigned char*)&zt_dict_list_vertical_scroll_bar);
						}

						return;
					}
					else if ((i - dict_list_cur_line)<0)
					{
						dict_cur_focus = 0;
						move_line_num =(unsigned short)(dict_list_cur_line - i);
						if (move_line_num == 1)
						{
							ZXWX_Vscroll_bar_KeyDown((unsigned char *)&zt_dict_list_vertical_scroll_bar,0);
							ZXWX_Vscroll_bar_KeyUp((unsigned char*)&zt_dict_list_vertical_scroll_bar);
						}
						else
						{
							zt_dict_list_vertical_scroll_bar.scroll_cur_line = (unsigned short)(zt_dict_list_vertical_scroll_bar.scroll_cur_line - move_line_num +1);
							ZXWX_Vscroll_bar_KeyDown((unsigned char *)&zt_dict_list_vertical_scroll_bar,0);
							ZXWX_Vscroll_bar_KeyUp((unsigned char*)&zt_dict_list_vertical_scroll_bar);
						}
						
						return;
					}
					else 
					{
							dict_output_word_list(0);
							dict_output_word_explain();
							return;
					}
				}
				else
				{
					if (dict_cur_focus==0)
					{
						return;
					}
					dict_cur_focus = 0;
					dict_output_word_list(0);
					dict_output_word_explain();
					return;
				}
			}
		}
		return;
	}

}
void dict_down_place_fun(void)
{
	int i;
	for(i=0;i<10;i++)
	{
		if(dict_down_place[i] == 1)
			break;
	}
	Text_Clip_Begin();
	switch(i)
	{
		case 0:
			dict_draw_picture_by_name("dict\\input_chn_normal.gif",122,23);
			break;
		case 1:
			dict_draw_picture_by_name("dict\\delete_button_normal.gif",150,23);
			break;
		case 2:
			dict_draw_picture_by_name((char*)"dict\\en_ch_button_normal.gif",1,46);
			break;
		case 3:
			dict_draw_picture_by_name((char*)"dict\\ch_en_button_normal.gif",30,46);
			break;
		case 4:
			dict_draw_picture_by_name((char*)"dict\\idiom_button_normal.gif",59,46);
			break;
		case 5:
			dict_draw_picture_by_name((char*)"dict\\ch_word_button_normal.gif",88,46);
			break;
		case 6:
			dict_draw_picture_by_name((char*)"dict\\man_name_button_normal.gif",117,46);
			break;
		case 7:
			dict_draw_picture_by_name((char*)"dict\\place_button_normal.gif",146,46);
			break;
		case 8:
			dict_show_lsk_fun(0);
			break;
		case 9:
			dict_show_rsk_fun(0);
			break;
	}
	Text_Clip_End();
}
void dict_pen_move_fun(mmi_pen_point_struct pos)
{
	if (DICT_IS_SHOW_CUR_ITEM&&dict_sc_cur_menu!=3)
	{
		return;
	}
// 	if (DICT_IS_INPUT_NULL&&pos.x>110&&pos.x<240&&pos.y>63&&pos.y<288&&dict_sc_cur_menu!=3)
// 	{
// 		return;
// 	}
	if (dict_sc_cur_menu != 3)
	{
		ZXWX_Vscroll_bar_pen_event((unsigned char *)(&zt_dict_exp_vertical_scroll_bar),pos,EVENT_PEN_MOVE);		
	}
	ZXWX_Vscroll_bar_pen_event((unsigned char *)&zt_dict_list_vertical_scroll_bar,pos,EVENT_PEN_MOVE);
}
#endif
void dict_switch_menu(int flag)
{
	dict_sc_cur_menu+=flag;
	if (dict_sc_cur_menu<0)
	{
		dict_sc_cur_menu = 5;
	}
	dict_sc_cur_menu = dict_sc_cur_menu%6;
	dict_init_data();
	dict_draw_win();
}
int dict_divide_text_to_arraylist(unsigned short pix_num,//每行能放下英文字符的个数
								 char *str_ptr,//输入字符串指针
								 char *p_dust,
								 unsigned short length)
{
	int t_lines =0;
	/*	unsigned char *p_word=str_ptr;*/
	int cur_position = 0;
	int prev_position = 0;
	int cur_length = 0;
	int txt_len=strlen((char*)str_ptr);
	int width=0,next_add=0;
	char char_buf;
	unsigned short wchar_buf;
	char  exp[80];
	
	while(cur_position < txt_len-1)
	{
		memset(exp,0,80);
		if(str_ptr[cur_position]==10||str_ptr[cur_position]==13)
		{
			memcpy(exp,str_ptr+prev_position,cur_position-prev_position);
			strcpy(p_dust+t_lines*length,exp);
			t_lines++;
			if(str_ptr[cur_position+1]==10||str_ptr[cur_position+1]==13)
			{
				cur_position+=2;
				prev_position=cur_position;
				cur_length = 0;
				continue;
			}
			else
			{
				cur_position+=1;
				prev_position = cur_position;
				cur_length = 0;
				continue;
			}
		}
		else if ((unsigned char)str_ptr[cur_position]<=0x7f)
		{
			char_buf = str_ptr[cur_position];
			width = UI_get_character_width(char_buf);
			//			width = GUI_GetFontWidth(font,(uint16)char_buf);
			next_add = 1;
		}
		else
		{
			memcpy(&wchar_buf,str_ptr+cur_position,2);
			width = UI_get_character_width(wchar_buf);
			//			width = GUI_GetFontWidth(font,(uint16)wchar_buf);
			next_add = 2;
		}
		if((cur_length+width)<=pix_num)
		{
			cur_length += width;
			cur_position += next_add;
		}
		else
		{
			memcpy(exp,str_ptr+prev_position,cur_position-prev_position);
			strcpy(p_dust+t_lines*length,exp);
			prev_position =cur_position;
			t_lines++;
			cur_length = 0;
		}
	}
	memcpy(exp,str_ptr+prev_position,cur_position+1-prev_position);
	strcpy(p_dust+t_lines*length,exp);
	t_lines++;
	return t_lines;	
}
void dict_init_data(void)
{
	zt_dict_list_roll_content_current_line = 1;
	zt_dict_exp_roll_content_current_line = 1;
	zt_dict_list_flag = 0;
	word_list_num = 0;
	if (dict_sc_cur_menu != 3)
	{	dict_cur_focus = 0;}
	else dict_cur_focus = 1;
	dict_key_down_line = 0;
	dict_list_begin = 0;
	DICT_IS_INPUT_NULL = 1;
	dict_list_cur_line = 0;
	if (dict_sc_cur_menu==3)
	{
		DICT_IS_SHOW_CUR_ITEM = 1;
	}
	else
		DICT_IS_SHOW_CUR_ITEM = 0;
	if(word_list)
		memset(word_list,0,1024);
	if(dict_explain_array)
		memset(dict_explain_array,0,1024);
	gui_single_line_input_box_clear(&MMI_singleline_inputbox);
	dict_is_show_charge_win = 1;
//	reset_singleline_inputbox();
//	memset(dicts_single_inputbox_buf,0,128);
}
void LM_Dicts_chinese_input_refresh(void)
{
	int text_len=0;
	///////////////////
	
	text_len = (int)UCS2_Text_len((unsigned short *)tempsave);
	if(text_len>30){ text_len=30; }
	else if(text_len<0){ text_len = 0; }
	
	memset(MMI_singleline_inputbox.text, 0, 64);
	memcpy(MMI_singleline_inputbox.text, tempsave, text_len*2);
	MMI_singleline_inputbox.text_length=text_len*2;
	MMI_singleline_inputbox.current_text_p = MMI_singleline_inputbox.text+text_len*2;
}


void dict_draw_picture_by_name(char* gb_name,int off_x,int off_y)
{
	unsigned short un_buf[128];
	char			text_buf[128];
	int LM_drive;
	LM_drive = FS_GetDrive(FS_DRIVE_V_REMOVABLE, 1, FS_NO_ALT_DRIVE);

	memset(un_buf, 0, 256);
	sprintf(text_buf, "%c:\\%s", (char)LM_drive, gb_name);
	AnsiiToUnicodeString((char *)un_buf, (char *)text_buf);

	gdi_image_draw_file(off_x, off_y, (char *)un_buf);
}
void Change_Sound_Text(unsigned char *sound_input,unsigned char* sound_output)
{
	unsigned short ii=0,kk=0;
	const unsigned char yinjie_font14_asc[38][2]=
	{
		{0x65, 0x01},//e 1
		{0x69, 0x02},//i 2
		{0x45, 0x03},//E 3
		{0x62, 0x04},//b 4
		{0x41, 0x05},//A 5
		{0x6B, 0x06},//k 6
		{0x35, 0x07},//5 7
		{0x73, 0x08},//s 8
		{0x6E, 0x09},//n 9
		{0x64, 0x0A},//d 10
		{0x46, 0x0B},//F 11
		{0x74, 0x0C},//t 12
		{0x77, 0x0D},//w 13
		{0x42, 0x0E},//B 14
		{0x6D, 0x0F},//m 15
		{0x71, 0x10},//q 16
		{0x63, 0x11},//c 17
		{0x6C, 0x12},//l 18
		{0x3A, 0x13},//: 19
		{0x37, 0x14},//7 20
		{0x75, 0x15},//u 21
		{0x56, 0x16},//V 22
		{0x72, 0x17},//r 23
		{0x70, 0x18},//p 24
		{0x4E, 0x19},//N 25
		{0x6A, 0x1A},//j 26
		{0x5C, 0x1B},//\/ 27
		{0x57, 0x1C},//W 28
		{0x54, 0x1D},//T 29
		{0x61, 0x1E},//a 30
		{0x66, 0x1F},//f 31
		{0x67, 0x20},//g 32
		{0x76, 0x21},//v 33
		{0x7A, 0x22},//z 34
		{0x68, 0x23},//h 35
		{0x5A, 0x24},//Z 36
		{0x5B, 0x25},//[ 37
		{0x5D, 0x26},//] 38
	};
	for(ii=0; sound_input[ii]!=0; ii++)
	{
		for(kk=0; kk<38; kk++)
		{
			if(sound_input[ii] == yinjie_font14_asc[kk][0])
			{ 	
				sound_output[ii*2] = yinjie_font14_asc[kk][1]; 
				sound_output[ii*2+1] = 0x00;
				break; 
			}				
		}////for(kk)
	}////for(ii)
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -