www.pudn.com > T9forC.rar > put.c, change:2001-08-28,size:21833b


/*-------------------------------------------------------------------------------*/ 
/*-------------------------------------------------------------------------------*/ 
/*程序设计:张进*/ 
/*最后改动:2001.06.20*/ 
/*-------------------------------------------------------------------------------*/ 
/*-------------------------------------------------------------------------------*/ 
#include<graphics.h> 
#include<io.h> 
#include<stdio.h> 
#include<stdlib.h> 
#include<conio.h> 
#include<index.c> 
 
headdisp(){ 
unsigned int  gst[25][14]= 
{ 
/*GstBitMap:             db 25,14*/ 
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 
0x0,0x0,0x0,0x0,0x0,0x0,0x1a,0xaa,0xa8,0x0,0x0,0x8,0x0,0x0, 
0x1,0xaa,0xaa,0x2,0xaa,0xac,0x15,0x55,0x5c,0x0,0x3,0x0,0x0,0x0, 
0x5,0x55,0x55,0x5,0x55,0x56,0x2a,0xaa,0xac,0x0,0x20,0x0,0x0,0x0, 
0xa,0xaa,0xab,0xa,0xaa,0xab,0x15,0x55,0x5e,0x0,0x50,0x0,0x0,0x0, 
0x5,0x5d,0xd5,0x95,0x7f,0xd5,0x3f,0xaf,0xfc,0x4,0x0,0x4,0x0,0x0, 
0xa,0xff,0xeb,0x8a,0xff,0xeb,0x3f,0xdf,0xfc,0xb,0x0,0xc8,0x0,0x0, 
0x15,0xff,0xf5,0xd5,0xff,0xdf,0xf,0xaf,0xfc,0x25,0x8,0x80,0x0,0x0, 
0xa,0xaa,0xbf,0x8a,0xe0,0x1f,0x0,0xae,0x0,0xd4,0x14,0x0,0x0,0x0, 
0x15,0xc0,0x1f,0x15,0x55,0x5f,0x0,0x5c,0x0,0xa9,0x48,0x0,0x0,0x0, 
0x2b,0xcb,0x6b,0x8a,0xaa,0xa4,0x0,0xbc,0x1,0x50,0x80,0x44,0x0,0x0, 
0x15,0xd5,0x97,0x95,0x55,0x54,0x1,0x5c,0x0,0xad,0x42,0x20,0x0,0x0, 
0x2b,0x8a,0x6b,0xf,0xff,0xae,0x0,0xbc,0x0,0x52,0x35,0x0,0x0,0x0, 
0x17,0x97,0x97,0x7,0xff,0xd6,0x1,0x58,0x0,0xc,0x4a,0x0,0x0,0x0, 
0x2b,0x8f,0xef,0x2f,0xff,0xae,0x0,0xbc,0x0,0x16,0xb0,0x0,0x0,0x0, 
0x57,0x8f,0x16,0x50,0x0,0x56,0x3,0x78,0x0,0xb,0x48,0x14,0x0,0x0, 
0x2a,0xaa,0xdf,0x55,0x55,0x5e,0x2,0xb8,0x0,0xa,0x81,0x40,0x0,0x0, 
0x55,0x55,0x6e,0x2a,0xaa,0xae,0x1,0x70,0x0,0x1,0x4c,0x80,0x0,0x0, 
0x2a,0xaa,0x9e,0x55,0x55,0x5e,0x2,0xb8,0x0,0x2,0xab,0x0,0x0,0x0, 
0x15,0x55,0x7e,0x2a,0xaa,0xbe,0x5,0x70,0x0,0x1,0x54,0x20,0x0,0x0, 
0x1f,0xff,0xfc,0x1f,0xff,0xfc,0x3,0xf0,0x0,0x0,0x28,0x0,0x0,0x0, 
0xf,0xff,0xf8,0x1f,0xff,0xf8,0x1,0xf0,0x0,0x0,0x50,0x0,0x0,0x0, 
0x7,0xff,0xe0,0xf,0xff,0xf0,0x1,0xf0,0x0,0x0,0x0,0x0,0x0,0x0, 
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 
}; 
 
int x=0; 
int y=0; 
register m,n,i,ii,j,k=0; 
     for(i=0;i<25;i++) 
     { 
        for(j=0;j<14;j++) 
        { 
            for(k=0;k<8;k++) 
            { 
                  if(((gst[i][j]>>(7-k))&0x1)!=NULL) 
                  { 
                   putpixel(x+8*j+k,y+i,GREEN); 
                  } 
            } 
        } 
     } 
} 
 
 
 
pydisp()             /*拼音状态显示*/ 
{ 
unsigned int py[5][2]= {38,20,         /*'拼'*/ 
		       50,84,         /*'音'*/ 
		       42,68,         /*'输'*/ 
		       40,75,         /*'入'*/ 
		       03,26,};       /*':'*/ 
int s1; 
    for(s1=0;s1<5;s1++) 
    { 
     puthz(s1*16,50,py[s1][0],py[s1][1],4); 
    } 
} 
 
sengdisp()           /*英文输入状态显示(小写)*/ 
{ 
unsigned int syw[7][2]={51,02,         /*'英'*/ 
			46,36,         /*'文'*/ 
			42,68,         /*'输'*/ 
			40,75,         /*'入'*/ 
			48,01,         /*'小'*/ 
			48,20,         /*'写'*/ 
			03,26,};       /*':'*/ 
int s1; 
    for(s1=0;s1<7;s1++) 
    { 
    puthz(s1*16,50,syw[s1][0],syw[s1][1],4); 
    } 
} 
bengdisp()            /*英文输入状态显示(大写)*/ 
{ 
unsigned int byw[7][2]={51,02,         /*'英'*/ 
			46,36,         /*'文'*/ 
			42,68,         /*'输'*/ 
			40,75,         /*'入'*/ 
			20,83,         /*'大'*/ 
			48,20,         /*'写'*/ 
			03,26,};       /*':'*/ 
 
 
int s1; 
   for(s1=0;s1<7;s1++) 
   { 
   puthz(s1*16,50,byw[s1][0],byw[s1][1],4); 
   } 
} 
 
numdisp() 
{ 
 
unsigned int snum[5][2]={42,93,       /*'数'*/ 
			 55,54,       /*'字'*/ 
			 42,68,         /*'输'*/ 
			 40,75,         /*'入'*/ 
			 03,26,};       /*':'*/ 
 
int s1; 
   for(s1=0;s1<5;s1++) 
   { 
   puthz(s1*16,50,snum[s1][0],snum[s1][1],4); 
   } 
} 
 
 
zifudisp() 
{ 
unsigned int zifu[5][2]={ 
                       55,54,       /*'字'*/ 
		       23,91,       /*'符'*/ 
                       42,68,       /*'输'*/ 
                       40,75,       /*'入'*/ 
                       03,26,};     /*':'*/ 
 
int s1; 
    for(s1=0;s1<5;s1++) 
    { 
    puthz(s1*16,50,zifu[s1][0],zifu[s1][1],4); 
    } 
} 
 
headdisp2() 
{ 
unsigned int head[4][2]={26,03, 
                        45,69, 
                        25,11, 
                        43,30, 
                            }; 
int s1; 
   for(s1=0;s1<4;s1++) 
   { 
   puthz((s1+10)*16,0,head[s1][0],head[s1][1],4); 
   } 
} 
 
puthz(int x,int y,int h,int l,int color) 
{ 
FILE *fp; 
int kk; 
char buffer[32]; 
register m,n,i,ii,j,k=0; 
unsigned char qh,wh; 
unsigned long int offset; 
   if((fp=fopen("hzk16","rb"))==NULL) 
   { 
   printf("can't open hzk16,please addit!"); 
   getch(); 
   closegraph(); 
   exit(0); 
   } 
offset=(94*(h-1)+(l-1))*32L; 
fseek(fp,offset,SEEK_SET); 
fread(buffer,32,1,fp); 
    for(i=0;i<16;i++) 
    { 
      for(j=0;j<2;j++) 
      { 
         for(k=0;k<8;k++) 
         { 
             if(((buffer[i*2+j]>>(7-k))&0x1)!=NULL) 
             { 
             putpixel(x+8*j+k,y+i,color); 
             } 
         } 
      } 
    } 
    if(x>512) 
    { 
    x=0;y=y+16; 
    } 
fclose(fp); 
} 
 
 
putnum(int x,int y,int dem,int color) 
{ 
register m,n,i,ii,j,k=0; 
   for(i=0;i<16;i++) 
   { 
       for(j=0;j<1;j++) 
       { 
           for(k=0;k<8;k++) 
           { 
                if(((num[dem][i+j]>>(7-k))&0x1)!=NULL) 
                { 
                putpixel(x+8*j+k,y+i,color); 
                } 
           } 
       } 
   } 
} 
 
putzimub(int x2,int y2,int dem2,int color2) 
{ 
register m2,n2,i2,ii2,j2,k2=0; 
     for(i2=0;i2<16;i2++) 
     { 
          for(j2=0;j2<1;j2++) 
          { 
               for(k2=0;k2<8;k2++) 
               { 
                    if(((beng[dem2][i2+j2]>>(7-k2))&0x1)!=NULL) 
                    { 
                     putpixel(x2+8*j2+k2,y2+i2,color2); 
                    } 
               } 
          } 
     } 
} 
 
putzimus(int x3,int y3,int dem3,int color3) 
{ 
register m3,n3,i3,ii3,j3,k3=0; 
    for(i3=0;i3<16;i3++) 
    { 
        for(j3=0;j3<1;j3++) 
        { 
             for(k3=0;k3<8;k3++) 
             { 
                if(((seng[dem3][i3+j3]>>(7-k3))&0x1)!=NULL) 
                { 
                putpixel(x3+8*j3+k3,y3+i3,color3); 
                } 
             } 
        } 
    } 
} 
 
 
putzifu(int x,int y,int dem,int color) 
{ 
register m,n,i,ii,j,k=0; 
     for(i=0;i<16;i++) 
     { 
         for(j=0;j<1;j++) 
         { 
             for(k=0;k<8;k++) 
             { 
                 if(((sig[dem][i+j]>>(7-k))&0x1)!=NULL) 
                 { 
                 putpixel(x+8*j+k,y+i,color); 
                 } 
             } 
         } 
     } 
} 
 
 
 
 
 
check_key( unsigned char k)  /*查看并确认键值*/ 
{ 
int c; 
   switch(k) 
           { 
           case '1':c=1; 
           break; 
           case '2':c=2; 
           break; 
           case '3':c=3; 
           break; 
           case '4':c=4; 
           break; 
           case '5':c=5; 
           break; 
           case '6':c=6; 
           break; 
           case '7':c=7; 
           break; 
           case '8':c=8; 
           break; 
           case '9':c=9; 
           break; 
           case '0':c=0; 
           break; 
           case 'q':c=10;                       /*define F1*/ 
           break; 
           case 'w':c=11;                       /*define F2*/ 
           break; 
           case 'e':c=12;                       /*define F3*/ 
           break; 
           case 'r':c=13;                       /*define F4*/ 
           break; 
           case 'c': 
           closegraph(); 
           exit(0); 
           default: 
           c=20; 
           break; 
           } 
return(c); 
} 
 
main() 
{ 
int firqmh,firqml; 
int a[6][16]; 
int key[6],i,j,s,ii,k,m,kkk,kk=0,jj=120,n,nn=0; 
int ks,mm,d=0,key1,key2,qmh,qml,ss,kp,kd=0,page=0,page1=0; 
int driver=DETECT,mode; 
int end; 
int endd; 
int mu; 
int end1; 
int sm[6]; 
int ok; 
char kc; 
initgraph(&driver,&mode,""); 
setcolor(5); 
headdisp(); 
headdisp2(); 
bar(0,50,500,100); 
bar(0,100,500,220); 
     for(i=0;i<5;i++) 
     { 
     line(0,100+i,500,100+i);  
     } 
     for(i=0;i<5;i++) 
     { 
     line(0,220+i,500,220+i); 
     } 
     for(i=0;i<5;i++) 
     { 
     line(0,45+i,500,45+i); 
     } 
     for(i=0;i<2;i++) 
     { 
     line(i,45,i,220); 
     } 
     for(i=0;i<2;i++) 
     { 
     line(i+500,45,i+500,220); 
     } 
top: 
     if(kd==4) 
     { 
     kd=0; 
     }        /*键盘状态循环*/ 
     while(kd==0)         /*汉字输入状态*/ 
     { 
     bar(0,50,500,100); 
     pydisp(); 
     h1: 
        for(;;) 
        { 
        page=0; 
            for(i=0;i<7;i++) 
            { 
            again: 
            key[i]=check_key(getch());    /*取键值*/ 
                 if(key[0]==0) 
                 { 
                  goto again; 
                 } 
                 switch(key[i]) 
                 {               /*判断键状态*/ 
                 case 9:kk=kk+8;goto h1; 
                 case 13:kd++;goto  top;       /*是否是状态切换键*/ 
                 case 12: 
                 kk=kk-8; 
                 bar(kk,jj,kk+8,jj+16); 
                      if(kk<0) 
                      { 
                      kk=304; 
                      jj=jj-16; 
                      } 
                      if(jj<=120) 
                      { 
                      jj=120; 
                      } 
                 goto h1; 
                 case 0 : 
                 s=check_key(getch()); 
                 goto outhz;    /*汉字输入确认*/ 
                 case 10:i=i-2;if(i<0){i=0;goto top;} 
                 break; 
                 case 11: 
                 case 20: 
                 goto again; 
                 } 
                 if(i==0) 
                 {              /*若为第一次读键*/ 
                    for(k=0;k<402;k++) 
                    { 
                          if(hzk_index[k][0]==key[0])    /*搜索索引表*/ 
                          { 
                          ok=k; 
                          goto here; 
                          } 
                    } 
                 } 
                 if(i==1) 
                 {               /*若为第二次读键*/ 
                 mu=0; 
                     for(k=0;k<402;k++) 
                     { 
                         if(hzk_index[k][0]==key[0]&&hzk_index[k][1]==key[1])   /*搜索索引表*/ 
                         {         
                         mu=1; 
                         ok=k; 
                         goto here; 
                         } 
                     } 
                     if(mu==0){sm[i]=ok;goto again;} 
                } 
 
                if(i==2) 
                {              /*若为第三次读键*/ 
                mu=0; 
                     for(k=0;k<402;k++) 
                     { 
                          if(hzk_index[k][0]==key[0]&&hzk_index[k][1]==key[1]&&hzk_index[k][2]==key[2])/*搜索索引表*/ 
                          {    
                          ok=k; 
                          mu=1; 
                          goto here; 
                          } 
                     } 
                     if(mu==0){sm[i]=ok;goto again;} 
                } 
 
                if(i==3) 
                {            /*若为第四次读键*/ 
                mu=0; 
                      for(k=0;k<402;k++) 
                      { 
                            if(hzk_index[k][0]==key[0]&&hzk_index[k][1]==key[1]&&hzk_index[k][2]==key[2]&&hzk_index[k][3]==key[3]) 
                            { 
                            ok=k; 
                            mu=1; 
                            goto here; 
                            } 
                      } 
                      if(mu==0){sm[i]=ok;goto again;} 
                } 
 
                if(i==4) 
                {            /*若为第五次读键*/ 
                mu=0; 
                      for(k=0;k<402;k++) 
                      { 
                            if(hzk_index[k][0]==key[0]&&hzk_index[k][1]==key[1]&&hzk_index[k][2]==key[2]&&hzk_index[k][3]==key[3]&&hzk_index[k][4]==key[4]) 
                            { 
                            mu=1; 
                            ok=k; 
                            goto here; 
                            } 
                      } 
                      if(mu==0){sm[i]=ok;goto again;} 
                } 
                 
                if(i==5) 
                {           /*若为第六次读键*/ 
                mu=0; 
                      for(k=0;k<402;k++) 
                      { 
                            if(hzk_index[k][0]==key[0]&&hzk_index[k][1]==key[1]&&hzk_index[k][2]==key[2]&&hzk_index[k][3]==key[3]&&hzk_index[k][4]==key[4]&&hzk_index[k][5]==key[5]) 
                            { 
                            mu=1; 
                            ok=k; 
                            goto here; 
                            } 
                      } 
                      if(mu==0){sm[i]=ok;goto again;} 
                } 
 
                here:                /*显示对应键盘字母所有的可能组合*/ 
                m=hzk_index[k][6];     /*m为所有可能数,它位于索引表每行第7列*/ 
                firqmh=hzk_index[k][7]; 
                firqml=hzk_index[k][8]; 
                bar(0,50,300,100); 
                pydisp(); 
                bar(100,50,200,100); 
                       for(ks=0;ks<9;ks++) 
                       { 
                       putnum(ks*32,70,ks+1,2); 
                       puthz((ks*2+1)*16,70,firqmh,firqml+ks,2); 
                       } 
                       for(n=0;n<m;n++) 
                       { 
                       putnum(10*8+n*64,50,n+1,2); 
                            for(kkk=1;kkk<=i+1;kkk++) 
                            { 
                             a[n][kkk]=hzk_index[k][18+(n*(i+1)+kkk)]; 
                             putzimus(11*8+n*64+kkk*8,50,a[n][kkk]-1,2); 
                            } 
                       } 
 
          }  
 
 
 
          outhz:               /*用户选择组合中所有可能中的一种*/ 
          nn=++nn ; 
               if(mu==1) 
               { 
               qmh=hzk_index[k][7+(s-1)*2]; 
               qml=hzk_index[k][7+(s-1)*2+1]; 
               } 
               if(mu==0) 
               { 
               qmh=hzk_index[sm[i]][7+(s-1)*2]; 
               qml=hzk_index[sm[i]][7+(s-1)*2+1]; 
               } 
          fydisp: 
          bar(0,50,500,100); 
          pydisp(); 
               for(i=0;i<9;i++) 
               { 
               putnum(i*32,70,i+1,2); 
               puthz((i*2+1)*16,70,qmh,qml+i+(9*page),2);  
               } 
          endtop: 
          end=check_key(getch()); 
          switch(end) 
               { 
                case 11:page=page+1;goto fydisp; 
                case 10:page=page-1;goto fydisp; 
                case 20:goto endtop; 
                case 12:goto endtop; 
                case 13:kd++;goto top; 
                default: 
                break; 
               } 
          puthz(kk,jj,qmh,qml+end+page*9-1,2); 
          kk=kk+16; 
               if(kk>300) 
               { 
               kk=0; 
               jj=jj+16; 
               } 
         } 
    } 
 
 
 
    while(kd==1)       /*字母输入状态*/ 
    { 
     top1: 
     bar(0,50,500,100); 
     bengdisp(); 
         for(;;) 
         { 
              while(d) 
              {                   /*大写字母输入*/ 
              top2: 
              key1=check_key(getch());     /*判断键值*/ 
                     switch(key1) 
                     {               /*判断键状态*/ 
                      case 9:kk=kk+8;goto top2; 
                      case 13:kd++;goto  top; 
                      case 0: d=!d;goto top1;     /*大小写切换*/ 
                      case 20: 
                      case 11: 
                      case 10: goto top2; 
                      case 12: 
                      kk=kk-8; 
                      bar(kk,jj,kk+8,jj+16); 
                             if(kk<0) 
                             { 
                             kk=304; 
                             jj=jj-16; 
                             } 
                             if(jj<=120) 
                             { 
                             jj=120; 
                             } 
                             goto  top2; 
                             } 
                      qmh=key1*3-3; 
                      kp=key1; 
                      bar(0,50,500,100); 
                      bengdisp(); 
                             for(mm=0;mm<3;mm++) 
                             { 
                             putzimub((mm+15)*8,50,qmh+mm,3); 
                             } 
                      key2=check_key(getch()); 
                      switch(key2) 
                             { 
                              case 13:kd++;goto top; 
                              case 0:d=!d;goto top1; 
                             } 
                      goto outen; 
                      } 
 
             while(!d) 
             {           /*小写字母输入*/ 
             top3: 
             bar(0,50,500,100); 
             sengdisp(); 
             key1=check_key(getch());     /*判断键值*/ 
             switch(key1) 
                    {               /*判断键状态*/ 
                    case 9:kk=kk+8;goto top3; 
                    case 13:kd++;goto  top; 
                    case 0: d=!d;goto top1;     /*大小写切换*/ 
                    case 10: 
                    case 11: 
                    case 20:goto top3; 
                    case 12: 
                    kk=kk-8; 
                    bar(kk,jj,kk+8,jj+16); 
                          if(kk<0) 
                          { 
                          kk=304; 
                          jj=jj-16; 
                          } 
                          if(jj<=120) 
                          { 
                          jj=120; 
                          } 
                    goto top3; 
                    } 
              qmh=key1*3-3; 
              kp=key1; 
              bar(0,50,500,100); 
              sengdisp(); 
                    for(mm=0;mm<3;mm++) 
                    { 
                    putzimus((mm+15)*8,50,qmh+mm,3); 
                    } 
              key2=check_key(getch()); 
              switch(key2) 
                    { 
                    case 13:kd++;goto  top; 
                    case 0: d=!d;goto top1; 
                    case 9:kk=kk+8;goto top; 
                    case 12: 
                    kk=kk-8; 
                    bar(kk,jj,kk+8,jj+16); 
                          if(kk<0) 
                          { 
                          kk=304; 
                          jj=jj-16; 
                          } 
                          if(jj<=120) 
                          { 
                          jj=120; 
                          } 
                          goto top3; 
                    } 
             goto outen; 
             } 
        } 
        outen:               /*从显示的三个字母中选出所需的字母*/ 
             if(d) 
             { 
             ii=kp*3-4+key2; 
             putzimub(kk,jj,ii,3); 
             kk=kk+8; 
                     if(kk>288) 
                     { 
                     kk=0; 
                     jj=jj+16; 
                     } 
             } 
             if(!d) 
             { 
             ii=kp*3-4+key2; 
             putzimus(kk,jj,ii,3); 
             kk=kk+8; 
                     if(kk>288) 
                     { 
                     kk=0; 
                     jj=jj+16; 
                     } 
            } 
      } 
 
      while(kd==2)           /*数字输入状态*/ 
      { 
      bar(0,50,500,100); 
      numdisp(); 
      top4: 
            for(;;) 
            { 
            key1=check_key(getch());           /*判断键值*/ 
            switch(key1) 
                   { 
                   case 13:kd++;goto  top; 
                   case 11: 
                   case 10: 
                   case 20:goto top4; 
                   case 12:kk=kk-8; 
                   bar(kk,jj,kk+8,jj+16); 
                        if(kk<0) 
                        { 
                        kk=304; 
                        jj=jj-16; 
                        } 
                        if(jj<=120) 
                        {  
                        jj=120; 
                        } 
                  goto top4; 
                  } 
            putnum(kk,jj,key1,3); 
            kk=kk+8; 
                  if(kk>288) 
                  { 
                  kk=0; 
                  jj=jj+16; 
                  } 
           } 
     } 
 
     while(kd==3)         /*字符输入状态*/ 
     { 
     zifudisp: 
     bar(0,50,500,100); 
     zifudisp(); 
     bar(100,50,200,100); 
           for(ks=0;ks<9;ks++) 
           { 
           putnum(ks*32,70,ks+1,2); 
           putzifu((ks*2+1)*16,70,ks+9*page1,2); 
           } 
     endtop1: 
     end1=check_key(getch()); 
     switch(end1) 
           { 
           case 11:page1=page1+1;if(page1>=2){page1=2;}goto zifudisp; 
           case 10:page1=page1-1;if(page1<=0){page1=0;}goto zifudisp; 
           case 20:goto endtop1; 
           case 13:kd++;goto top; 
           case 12: 
           kk=kk-8; 
           bar(kk,jj,kk+8,jj+16); 
                  if(kk<0) 
                  { 
                  kk=304; 
                  jj=jj-16; 
                  } 
                  if(jj<=120) 
                  { 
                  jj=120; 
                  } 
           goto endtop1; 
           } 
      putzifu(kk,jj,end1+page1*9-1,2); 
      kk=kk+8; 
           if(kk>300) 
           { 
           kk=0; 
           jj=jj+16; 
           } 
      } 
}