?? ws_text_op.h~
字號:
/*************************************************** Copyright(C), 2008 , JUST File name: ws_text_op.h Author: StevenZ Version: 0.9 Date: 080906 Description: 點劃式網頁瀏覽器層次結構的顯示與 正文(三種正文類型)操作 History: 08/07/25 完成單擊,雙擊,上下劃動判斷 08/08/06 完成按鍵位置設置 08/08/15 完成頁面層次結構的顯示 08/08/16 添加語音合成函數 ***************************************************/#ifndef _WS_TEXT_OP_H#define _WS_TEXT_OP_H#include "ws_share_func.h"//公用的相關函數int WebShow_InWhichArea(TS_RET *p);void get_L_ip_port(char ip_port[],char *Ltext);void get_L_text(char text[],char *Ltext);int can_forward(struct websitedata *wsd);void do_forward(struct websitedata *wsd);int can_backward(struct websitedata *wsd);void do_backward(struct websitedata *wsd);int can_link_or_enter(struct websitedata *wsd);void do_web_link(struct websitedata *wsd);void do_text_enter(struct Web_Data *wd);void do_blank_fill(struct websitedata *wsd);void do_web_show_double_click(struct websitedata *wsd);void do_text_up(struct websitedata *wsd);void do_text_down(struct websitedata *wsd);void do_text_stay(struct websitedata *wsd);void * web_show_click(void *data);void web_show(struct websitedata *wsd);void show_wsd(struct websitedata *wsd);void play_mp3();/*判斷點了觸摸屏具體位置*/int WebShow_InWhichArea(TS_RET *p){ if(p->x<LFA) { if(p->y>MYA) return FAVOR; return BACKWARD; } if(p->x>RFA) { if(p->y>MYA) return WEB_SAVE; return FLUSH; } if(p->y>TYA) return WEB_ADDR; if(p->y<BYA) return EXIT_BACK; return 0;}/*得到tflag=IP_PORT_D時text的網頁地址*/void get_L_ip_port(char ip_port[],char *Ltext){ int i,j; for(i=0;;i++) { if(Ltext[i]=='\"') break; } i++; for(j=0;;i++,j++) { if(Ltext[i]=='\"') break; ip_port[j]=Ltext[i]; } ip_port[j]='\0';}/*得到tflag=TEXT_D時text的正文內容*/void get_L_text(char text[],char *Ltext){ int i; for(i=0;;i++) { if(Ltext[i]=='\"') break; text[i]=Ltext[i]; } text[i]='\0';}/*判斷是否可以前進,未在程序中使用*/int can_forward(struct websitedata *wsd){ if(wsd->web_data[wsd->website_head].can_text_forward>0) return 1; if(wsd->website_head>=wsd->website_tail) { if(wsd->website_head-wsd->website_tail<wsd->website_total) return 2; } else { if(wsd->website_head+WEBDATASIZE-wsd->website_tail<wsd->website_total) return 2; } return 0;}/*前進處理函數*/void do_forward(struct websitedata *wsd){ int cf; struct Web_Data* wd=&wsd->web_data[wsd->website_head]; cf=can_forward(wsd); switch(cf) { case 1: wd->current=wd->current->child; wd->can_text_backward++; wd->can_text_forward--; break; case 2: NEED_DOWNLOAD_WEB=1; break; default: //語音提示不可前進#ifdef TTS T2S_t2s("不可前進");#endif }}/*判斷是否可以后退,及正文級后退還是網頁級后退*/int can_backward(struct websitedata *wsd){ DPRINTF("wsd->website_total=%d\n",wsd->website_total); DPRINTF("wsd->website_head=%d\n",wsd->website_head); DPRINTF("wsd->website_tail=%d\n",wsd->website_tail); if(wsd->web_data[wsd->website_head].can_text_backward>0) return 1;//正文級后退 if(wsd->website_head!=wsd->website_tail) { return 2;//網頁級后退 } return 0;//不可后退}/*執行后退*/void do_backward(struct websitedata *wsd){ int bf; char temp[1024]; struct Web_Data* wd=&wsd->web_data[wsd->website_head]; bf=can_backward(wsd); switch(bf) { case 1:/*返回至上一級正文*/ DPRINTF("text backward!\n"); for(;;) { if(wd->current->prev==NULL) break; wd->current=wd->current->prev; } wd->current=wd->current->parent; wd->can_text_backward--; wd->can_text_forward++; //語音讀出當前text#ifdef TTS switch(wd->current->tflag) { case TEXT_D: strcpy(temp,wd->current->text); if(wd->current->child!=NULL) { strcat(temp,".可進入"); } T2S_t2s(temp); break; case IP_PORT_D: get_L_text(temp,wd->current->text); strcat(temp,".可鏈接"); T2S_t2s(temp); break; case BLANK_D: T2S_t2s("表單,請雙擊填寫"); break; }#endif DPRINTF("%s\n",wd->current->text); break; case 2: DPRINTF("link backward!\n"); /*網頁指針指向上一次打開的網頁,返回至上一個網頁的進入處*/ if(wsd->website_head-1<0) wsd->website_head=WEBDATASIZE-1; else wsd->website_head--; wsd->website_total--; break; default: //語音提示不可后退#ifdef TTS T2S_t2s("不可后退");#endif DPRINTF("can't backward!!\n"); }}/*判斷雙擊進入的類型,正文級還是網頁級*/int can_link_or_enter(struct websitedata *wsd){ if(wsd->web_data[wsd->website_head].current->tflag==IP_PORT_D) { return 1; } if(wsd->web_data[wsd->website_head].current->tflag==BLANK_D) { return 3; } if(wsd->web_data[wsd->website_head].current->child!=NULL) { return 2; } return 0;}static void get_ip(char *s){ int i=0; if(strncmp(s,"http://",7)==0) { i=7; } for(;;i++) { if(s[i]=='/'||s[i]=='\0') break; } if(s[i]=='\0') s[i]='/'; s[i+1]='\0';}static void add_ip_port(char *des,char *ip_port){ char t_des[255]; char t_ip_port[100]; int i,n=strlen(des),count=0; printf("des=%s\nip_port=%s\n",des,ip_port); //sleep(1); if(strncmp(des,"http",4)==0) return; strcpy(t_ip_port,ip_port); get_ip(t_ip_port); printf("get_ip=%s\n",t_ip_port); //sleep(1); strcpy(t_des,des); sprintf(des,"%s%s",t_ip_port,t_des); printf("end des=%s\n",des); //sleep(1); }/*網頁進入新的鏈接網頁*/void do_web_link(struct websitedata *wsd) { char temp[255]; /*得到要進入的網頁地址*/ get_L_ip_port(temp,wsd->web_data[wsd->website_head].current->text); /*如果沒有ip頭加ip頭*/ add_ip_port(temp,wsd->web_data[wsd->website_head].ip_port); /*使網頁指針指向下一個空網頁,以便給空網頁輸入網址*/ if(wsd->website_total!=0) { if((wsd->website_head+1)%WEBDATASIZE==wsd->website_tail) { wsd->website_tail=(wsd->website_tail+1)%WEBDATASIZE; wsd->website_head=(wsd->website_head+1)%WEBDATASIZE; wsd->website_total=10; } else { wsd->website_head=(wsd->website_head+1)%WEBDATASIZE; wsd->website_total++; } } else { wsd->website_total++; } /*將所選的網址信息拷給wsd*/ if(wsd->web_data[wsd->website_head].ip_port) {//清空ip_port free(wsd->web_data[wsd->website_head].ip_port); } wsd->web_data[wsd->website_head].ip_port=(char *)malloc(strlen(temp)+1); strcpy(wsd->web_data[wsd->website_head].ip_port,temp); /*重新下載*/ NEED_DOWNLOAD_WEB=1;}/*進入正文下一級*/void do_text_enter(struct Web_Data *wd){ char temp[1024]; DPRINTF("text entered!\n"); wd->current=wd->current->child; wd->can_text_backward++; wd->can_text_forward--; //語音輸出第一個正文或無內容 DPRINTF("wd->current->tflag=%d\n",wd->current->tflag);#ifdef TTS switch(wd->current->tflag) { case TEXT_D: strcpy(temp,wd->current->text); if(wd->current->child!=NULL) { strcat(temp,".可進入"); } T2S_t2s(temp); break; case IP_PORT_D: get_L_text(temp,wd->current->text); strcat(temp,".可鏈接"); T2S_t2s(temp); break; case BLANK_D: T2S_t2s("表單,請雙擊填寫"); break; }#endif DPRINTF("%s\n",wd->current->text); }/*進行表單操作*/void do_blank_fill(struct websitedata *wsd){ int i,submit_i=0,flg=0; struct Web_Data *wd=&wsd->web_data[wsd->website_head]; BLANK *pblk=wd->current->text; char temp[1000]; DPRINTF("wsd->web_data[wsd->website_head].current->tflag=%d\n", wsd->web_data[wsd->website_head].current->text); DPRINTF("pblk->input_num=%d\n",pblk->input_num); /*依次填寫表單*/ for(i=0;i<pblk->input_num;i++) { DPRINTF("(pblk->type_h)[%d]=%s\n",i,(pblk->type_h)[i]); switch((pblk->type_h)[i][0]) { case 't'://text#ifdef TTS strcpy(temp,"請輸入"); strcat(temp,(pblk->note_h)[i]); DPRINTF("blank_fill-%s\n",temp); T2S_t2s(temp); stop_t2s(temp);#endif ts_close(); DPRINTF("********use blind ime**********\n"); ShowBitmap(160,120,BGBMPIME); get_blind_words(temp);//調用盲文輸入法 ts_open(); if((pblk->value_h)[i]) free((pblk->value_h)[i]); (pblk->value_h)[i]=(char *)malloc(strlen(temp)+1); if((pblk->value_h)[i]==NULL) printf("(pblk->value_h)[%d] mem error!\n",i); strcpy((pblk->value_h)[i],temp); break; case 'h'://hidden break; case 'r'://radio break; case 'c'://checkbox break; case 's'://submit#ifdef TTS strcpy(temp,"是否"); strcat(temp,(pblk->value_h)[i]); T2S_t2s(temp);#endif //提交圖片 ShowBitmap(160,120,BGBMPSB); if(select_favor())//左半屏是,右半屏否 { submit_i=1; } ClearBitmap(160,120,BGBMPSB,BGBMPGIRL); break; default: printf("no match input type!!\n"); } } /*根據method選擇不同方式發送表單數據*/ DPRINTF("submit_i=%d\n",submit_i); if(submit_i) { switch(pblk->method[0]) { case 'G'://GET /*將各個value值拼接至action之后*/ DPRINTF("wd->ip_port=%s\n",wd->ip_port); //flg=0; for(i=0;;i++) {//得到網址 if(wd->ip_port[i]==TEXT_SEP_CHAR ||wd->ip_port[i]=='\0' ||(wd->ip_port[i]=='/'&&i>6)) break; temp[i]=wd->ip_port[i]; } if(wd->ip_port[i]=='/') temp[i++]='/'; temp[i]='\0'; strcat(temp,pblk->action);//拼接action for(i=0;i<pblk->input_num;i++) {//拼接value if((pblk->name_h)[i][0]=='\0')//name項為空沒表單參數 continue; if(i==0) { strcat(temp,"?"); } else { strcat(temp,"&"); } strcat(temp,(pblk->name_h)[i]); strcat(temp,"="); //strcat(temp,"%CC%E1%BD%BB"); strcat(temp,(pblk->value_h)[i]); } DPRINTF("SUBMIT=%s\n",temp); sleep(2); add_ip_port(temp,wsd->web_data[wsd->website_head].ip_port); DPRINTF("SUBMIT=%s\n",temp); sleep(2); /*使網頁指針指向下一個空網頁,以便給空網頁輸入網址*/ if(wsd->website_total!=0) { if((wsd->website_head+1)%WEBDATASIZE==wsd->website_tail) { wsd->website_tail=(wsd->website_tail+1)%WEBDATASIZE; wsd->website_head=(wsd->website_head+1)%WEBDATASIZE; wsd->website_total=10; } else { wsd->website_head=(wsd->website_head+1)%WEBDATASIZE; wsd->website_total++; } } else { wsd->website_total++; } /*將所選的網址信息拷給wsd*/ if(wsd->web_data[wsd->website_head].ip_port) {//清空ip_port free(wsd->web_data[wsd->website_head].ip_port); } wsd->web_data[wsd->website_head].ip_port=(char *)malloc(strlen(temp)+1); strcpy(wsd->web_data[wsd->website_head].ip_port,temp); DPRINTF("submit GET ip_port=%s\n",temp); /*重新下載*/ NEED_DOWNLOAD_WEB=1; break; case 'P'://POST //func break; default: printf("no match method type!!\n"); } } else {#ifdef TTS strcpy(temp,"您已放棄表單操作"); T2S_t2s(temp);#endif }}/*根據雙擊區域執行函數*/void do_web_show_double_click(struct websitedata *wsd)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -