Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

561 lines
15 KiB

  1. /*************************************************
  2. * abcsda.c *
  3. * *
  4. * Copyright (C) 1995-1999 Microsoft Inc. *
  5. * *
  6. *************************************************/
  7. #include <windows.h>
  8. #include <winerror.h>
  9. #include <winuser.h>
  10. #include <windowsx.h>
  11. #include <immdev.h>
  12. #include <stdio.h>
  13. #include "abc95def.h"
  14. #include "resource.h"
  15. #include "resrc1.h"
  16. //#include "data.H"
  17. #include "abcsda.h"
  18. /*****************************************************
  19. FUCTION: find if the input char is yuanyin or fuyin
  20. ENTRY: input char
  21. RESULT: STC----fuyin
  22. CLC----yuanyin
  23. ******************************************************/
  24. BOOL WINAPI yuan_or_fu(input_char)
  25. WORD input_char;
  26. {
  27. switch (input_char&0xdf){ //change the xiaoxie to Cap, cock
  28. case 'A':
  29. case 'E':
  30. case 'I':
  31. case 'O':
  32. case 'U':
  33. return(CLC);
  34. default:
  35. return(STC);
  36. }
  37. }
  38. /**********************************************************
  39. FUCTION: match the fuyin or fuher fuyin
  40. ENTRY: input char
  41. RESULT: fill the correct spelling in the communicated buffer
  42. currect_number
  43. STC----not match
  44. CLC----match
  45. ************************************************************/
  46. BOOL WINAPI match_and_find_0(input_char)
  47. WORD input_char;
  48. {
  49. WORD tmp_chr;
  50. int i,cnt,begin_pos;
  51. //if (input_char == 'u')
  52. // DebugShow ("match and find 0",0);
  53. tmp_chr=input_char&0xdf; //change it to CAP
  54. for (i=0; i<sizeof sound_cvt_table_index; i++){
  55. if (tmp_chr==sound_cvt_table_index[i]){
  56. tmp_chr=0xff;
  57. break;}//if
  58. }//for
  59. if (tmp_chr!=0xff){ //not fuher shengmu
  60. // if (tmp_chr == 'U' )
  61. /* Because 'I' also dont stand for any ShengMu, so when you type in a ShengMu,
  62. 'I' should also be ignored. , Fix Bug 27914
  63. Weibing Zhan, 3-15-1996
  64. */
  65. if (tmp_chr == 'U' || tmp_chr == 'I')
  66. {current_number=0;
  67. MessageBeep(0);
  68. return(STC);}
  69. current_number=1;
  70. sda_out[0]=input_char;
  71. return(CLC);
  72. }
  73. tmp_chr=sound_cvt_table_value[i];
  74. if (tmp_chr==DK_RP){
  75. current_number=1;
  76. sda_out[0]=DK_RP;
  77. return(CLC);
  78. }
  79. begin_pos=(tmp_chr-1)*5;
  80. cnt=0;
  81. while (slbl_tab[begin_pos]!=0x30){
  82. sda_out[cnt++]=(WORD)(slbl_tab[begin_pos++]|0x20); //change to small letter
  83. } //get the fuher shengmu
  84. current_number=(BYTE)cnt;
  85. return(CLC);
  86. }
  87. /**********************************************************
  88. FUCTION: match the fuyin or fuher fuyin
  89. ENTRY: input char
  90. RESULT: fill the correct spelling in the communicated buffer
  91. currect_number
  92. STC----not match
  93. CLC----match
  94. ************************************************************/
  95. BOOL WINAPI match_and_find_1(input_char)
  96. WORD input_char;
  97. {
  98. WORD tmp_chr,sy_pos;
  99. tmp_chr=input_char;
  100. tmp_chr=(tmp_chr&0xdf)-0x41; //sub "a"
  101. tmp_chr&=0xff;
  102. sy_pos=rule_buf[rule_pointer-1].chr;
  103. sy_pos-=0x61; //sub "a"
  104. sy_pos=sy_tab_base[sy_pos*26+tmp_chr];
  105. if (!sy_pos){
  106. MessageBeep(0);
  107. sda_out[0]=0xff;
  108. return(STC);
  109. }
  110. tmp_chr=input_char&0xdf;
  111. tmp_chr-=0x41; //sub "A"
  112. tmp_chr=sy_tab1[tmp_chr*2+sy_pos-1];
  113. got_py(tmp_chr);
  114. return(CLC);
  115. }
  116. BOOL WINAPI got_py(tmp_chr)
  117. WORD tmp_chr;
  118. {
  119. int begin_pos,i;
  120. if (tmp_chr>=0x41){
  121. sda_out[0]=tmp_chr|0x20;
  122. current_number=1;
  123. }
  124. else{
  125. begin_pos=(tmp_chr-1)*5;
  126. i=0;
  127. while (slbl_tab[begin_pos]>0x30)
  128. sda_out[i++]=(WORD)(slbl_tab[begin_pos++]|0x20); //change to small letter
  129. current_number=(BYTE)i;
  130. }
  131. return 0;
  132. }
  133. /****************************************************
  134. FUCTION: change the input char to correct spelling.
  135. ENTRY: STC-----not match
  136. CLC-----match
  137. *****************************************************/
  138. BOOL WINAPI match_and_find(input_char)
  139. WORD input_char;
  140. {
  141. if (current_flag&0x10)
  142. {
  143. if (match_and_find_1(input_char))
  144. return(1); //display shengmu tishi
  145. else
  146. return(-1);
  147. }//if
  148. else
  149. {
  150. if (!(match_and_find_0(input_char))) //find yumu
  151. return(-1);
  152. else {
  153. find_tishi_pp(input_char);
  154. return(0);
  155. }
  156. }//else
  157. }
  158. /*******************************************************
  159. find_tish_pp(): find the yumu which can match with the
  160. shengmu.
  161. ENTRY: input char
  162. RESULT: yumu in the yu_tishi[] buffer.
  163. *********************************************************/
  164. BOOL WINAPI find_tishi_pp(input_char)
  165. WORD input_char;
  166. {
  167. int n,i,cnt,tmp_num;
  168. int begin_pos,match_flag;
  169. BYTE key_match;
  170. for (i=0; i<34*4; i++){
  171. Key_Exc_Value[i]=0x20;
  172. }
  173. key_match='a';
  174. begin_pos=(input_char-0x61)*26;
  175. for (i=begin_pos; i<begin_pos+26; i++){
  176. match_flag=sy_tab_base[i];
  177. if (match_flag){
  178. tmp_num=sy_tab1[(key_match-0x61)*2+match_flag-1];
  179. cnt=Key_Pos_Array[key_match-'a']*4; //one key has 4 units
  180. if (tmp_num>=0x30){
  181. Key_Exc_Value[cnt]=(BYTE)tmp_num;
  182. }//if(tmp_num)
  183. else{
  184. n=(tmp_num-1)*5;
  185. while (slbl_tab[n]>0x30)
  186. Key_Exc_Value[cnt++]=slbl_tab[n++];
  187. }//else
  188. }//if(match_flag)
  189. key_match++;
  190. }//for
  191. return 0; //##!!
  192. }
  193. /*******************************************************
  194. FUCTION: fill the ruler buffer.
  195. ********************************************************/
  196. BOOL WINAPI fill_rule(input_char)
  197. WORD input_char;
  198. {
  199. input_sum+=current_number;
  200. if (input_sum>40){ //94/4/21 >=40
  201. sda_out[0]=0xff; //if input are more than 40 chars,
  202. input_sum -= current_number;
  203. MessageBeep(0);
  204. return(STC);} //don't input anymore
  205. else{
  206. rule_buf[rule_pointer].length=current_number;
  207. rule_buf[rule_pointer].type=current_flag;
  208. rule_buf[rule_pointer].chr=input_char;
  209. rule_pointer++;
  210. return(CLC);
  211. }
  212. }
  213. /********************************************************
  214. FUNCTION: find out the input char's character
  215. ENTRY: input_char
  216. RESULT: current_flag & char identification
  217. current_flag definication:
  218. 7 6 5 4 3 2 1 0
  219. | | | | | | | |________1=fuyin
  220. | | | | | | |______________0
  221. | | | | | |____________________0
  222. | | | | |__________________________0
  223. | | | |___________________0=this key is fuyin
  224. | | | 1=this key is yunmu
  225. | | |_________________________1=number
  226. | |_______________________________0
  227. |_____________________________________1=zimu
  228. ********************************************************/
  229. int WINAPI chr_type(input_char)
  230. WORD input_char;
  231. {
  232. if (!rule_pointer)
  233. current_flag=0;
  234. else
  235. current_flag=rule_buf[rule_pointer-1].type&0x10;
  236. if (input_char==VK_BACK)
  237. return(SDA_DELETE);
  238. switch (input_char) { //1993.4.20 omit the arrow key
  239. case VK_SPACE: //can't edit in SDA method
  240. return(SPACE);
  241. case VK_LEFT+0x100: //in C_input, VK_LEFT etc plus 0x100
  242. case VK_UP+0x100:
  243. case VK_RIGHT+0x100:
  244. case VK_DOWN+0x100:
  245. return(CURSOR);
  246. }
  247. if (input_char==VK_ESCAPE)
  248. return(ESCAPE);
  249. if (input_char<0x20)
  250. return(FUC_CHR); //function key, just return key value
  251. if ((input_char>=0x30) && (input_char<0x3a)){
  252. current_flag|=0x30; //00110000b mark number and set this key
  253. //94 4,8 current_flag = 0x20;
  254. return(SDA_NUMBER);} //is yumu
  255. if ((input_char>=0x61) && (input_char<=0x7a)){
  256. if (rule_pointer){
  257. if (current_flag) //if last current_flag need fuyn
  258. current_flag=0; //current_flag need yuanyin.
  259. else //vice versa
  260. current_flag=0x10;
  261. }
  262. if (yuan_or_fu(input_char)) //yuan=CLC
  263. current_flag|=0x88; //10001000b yuan
  264. else
  265. current_flag|=0x81; //10000001b fu
  266. return(CHR);}
  267. if ((input_char>=0x41) && (input_char<=0x5a)){
  268. current_flag=0x90; //10010000b; CAP=yunmu
  269. return(CAP_CHR);}
  270. if ((input_char==DK_SUB)||(input_char==DK_ZHENGX)||(input_char==DK_FANX))
  271. {
  272. current_flag=0x30; //produce like number
  273. //94 4,8 current_flag = 0x20;
  274. return(SDA_NUMBER);
  275. }
  276. if ((input_char==DK_LP)||(input_char==DK_RP)){
  277. current_flag=0x88; //input is yuanyin 'o',
  278. return(CHR); //and we need yumu at this time
  279. }
  280. return(FUC_CHR); //rest key return
  281. }
  282. /******************************************************
  283. disp_tishi(): send WM_PAINT message to the dialog
  284. in order to display the help
  285. *******************************************************/
  286. void WINAPI disp_tishi(hIMC, mark)
  287. HIMC hIMC;
  288. int mark;
  289. {
  290. int i, j /*cnt*/,k;
  291. //DebugShow("mark",mark);
  292. if (mark == 9) {mark = disp_mark;}
  293. disp_mark = mark;
  294. j=0;
  295. if (mark){ //Shengmu tishi
  296. for (i=0; i<34; i++)
  297. for (k=0; k<4; k++)
  298. Key_Exc_Value[j++]=Sheng_Tishi[i][k];
  299. /*for (i=0; i<4; i++){
  300. cnt=Key_Pos_Array[Sheng_Mu[i]-'A']*4;
  301. Key_Exc_Value[cnt++]=Sheng_Tishi[j++]; //get fuhe shengmu
  302. Key_Exc_Value[cnt++]=Sheng_Tishi[j++];
  303. cnt+=2; //4 units for one sheng mu
  304. }//for*/
  305. }//if
  306. //SendMessage(hSdaKeyBWnd,MD_PAINT, 0x80, 0l);
  307. return ;
  308. }
  309. FAR PASCAL tran_data(hdSdaFlag, hIMC, Sd_Open_flag)
  310. int hdSdaFlag; //HWND Return;
  311. HIMC hIMC;
  312. BYTE Sd_Open_flag;
  313. {
  314. Sd_Open=Sd_Open_flag;
  315. if (hdSdaFlag==0)
  316. {
  317. // ShowWindow(hSdaKeyBWnd, SW_SHOWNOACTIVATE);
  318. // UpdateWindow(hSdaKeyBWnd);
  319. return TRUE;
  320. }
  321. if (hdSdaFlag==1)
  322. {
  323. // DestroyWindow(hSdaKeyBWnd);
  324. return TRUE;
  325. }
  326. if (hdSdaFlag==2)
  327. {
  328. // ShowWindow(hSdaKeyBWnd, SW_HIDE);
  329. // UpdateWindow(hSdaKeyBWnd);
  330. return TRUE;
  331. }
  332. disp_tishi(hIMC,9);
  333. // sda_ts(hIMC,WM_PAINT, 0, 0l);
  334. return TRUE; //InitKeyWindow(hdSdaProc, hIMC, hCursor);
  335. }
  336. int FAR PASCAL sda_proc(input_char,sda_trans,step_mode,hIMC)
  337. WORD input_char;
  338. LPWORD sda_trans; //sda_out is WORD
  339. BYTE step_mode;
  340. HIMC hIMC;
  341. {
  342. int i;
  343. int disp_flag;
  344. sda_out=sda_trans;
  345. if (step_mode==SELECT){
  346. if ((input_char>=0x61) && (input_char<=0x7a)){
  347. input_sum=0;
  348. rule_pointer=0; //if on SELECT step, and input ascii
  349. current_number=0;} //reset the pointer
  350. }
  351. if ((step_mode==START)||(step_mode==RESELECT)){
  352. input_sum=0;
  353. rule_pointer=0;
  354. current_number=0;
  355. }
  356. switch(chr_type(input_char)){
  357. case FUC_CHR:
  358. sda_out[0]=input_char;
  359. if (step_mode==ONINPUT){
  360. if (!Sd_Open){ //for display keyboard
  361. sda_out[0]=0xf0; //sign for main progress destroy the dialog
  362. sda_out[1]=input_char;
  363. // DestroyWindow(hSdaKeyBWnd);
  364. }//if (Sd_Open)
  365. }
  366. return(CLC);
  367. case SDA_NUMBER:
  368. case CAP_CHR:
  369. if ( input_sum >= 40 )
  370. {
  371. sda_out[0] = input_char;
  372. return(STC);
  373. }
  374. current_number=1;
  375. if (fill_rule(input_char)){
  376. sda_out[0]=input_char;
  377. disp_tishi(hIMC, 1);
  378. return(CLC);}
  379. else
  380. return(STC);
  381. case SDA_DELETE:
  382. if ((!rule_pointer) || (step_mode!=ONINPUT)){
  383. sda_out[0]=VK_BACK;
  384. return(CLC);
  385. }
  386. rule_pointer--; //rule_pointer go back one key
  387. for (i=0; i<rule_buf[rule_pointer].length; i++)
  388. sda_out[i]=VK_BACK;
  389. input_sum -= (BYTE)i; /* 94/4/21 input sum should sub when del */
  390. if(!rule_pointer)
  391. {
  392. if (!Sd_Open)
  393. {
  394. sda_out[0]=0xf0;
  395. sda_out[1]=VK_ESCAPE;
  396. // DestroyWindow(hSdaKeyBWnd);
  397. return (CLC);
  398. }
  399. else
  400. {
  401. sda_out[0] = VK_BACK;
  402. disp_tishi(hIMC, 1);
  403. return (CLC);
  404. }
  405. }
  406. if ( rule_buf[rule_pointer-1].type&0x30 )
  407. disp_tishi(hIMC, 1);
  408. else
  409. {
  410. find_tishi_pp(rule_buf[rule_pointer-1].chr);
  411. disp_tishi(hIMC, 0);
  412. }
  413. return(CLC);
  414. case ESCAPE:
  415. sda_out[0]=VK_ESCAPE;
  416. if (!Sd_Open){
  417. sda_out[0]=0xf0;
  418. sda_out[1]=VK_ESCAPE;
  419. // DestroyWindow(hSdaKeyBWnd);
  420. }
  421. else
  422. disp_tishi(hIMC, 1); //1993.4
  423. return(CLC);
  424. case SPACE:
  425. sda_out[0]=VK_SPACE;
  426. if (step_mode==ONINPUT){
  427. if (!Sd_Open){
  428. sda_out[0]=0xf0; //sign for main progress destroy the dialog
  429. sda_out[1]=VK_SPACE;
  430. // DestroyWindow(hSdaKeyBWnd);
  431. }
  432. else
  433. disp_tishi(hIMC, 1); //1993,4
  434. }
  435. return(CLC);
  436. case CURSOR:
  437. sda_out[0]=0;
  438. MessageBeep((UINT)-1);
  439. return(STC);
  440. case CHR:
  441. if ( input_sum >= 40 )
  442. {
  443. sda_out[0] = input_char;
  444. return(STC);
  445. }
  446. if ((input_char==DK_LP)||(input_char==DK_RP)){
  447. if(rule_buf[rule_pointer-1].chr!='o')
  448. input_char='o'; //1993.2 if left and right pie
  449. else {
  450. MessageBeep(0);
  451. return(STC);
  452. }
  453. }
  454. //produce like shengmu "o"
  455. disp_flag = match_and_find(input_char);
  456. if (disp_flag == -1 )
  457. return(STC);
  458. else
  459. {
  460. if (fill_rule(input_char))
  461. {
  462. disp_tishi(hIMC, disp_flag);
  463. return(CLC);
  464. }
  465. else
  466. return(STC);
  467. }
  468. }
  469. return STC;
  470. }