Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

country2.c

Go to the documentation of this file.
00001 // Copyright (c) 1985 - 1999, Microsoft Corporation 00002 // 00003 // MODULE: country2.c 00004 // 00005 // PURPOSE: Console IME control. 00006 // FarEast country specific module 2 for conime. 00007 // 00008 // PLATFORMS: Windows NT-FE 3.51 00009 // 00010 // FUNCTIONS: 00011 // ImeUIOpenCandidate() - routine for make system line string 00012 // 00013 // History: 00014 // 00015 // 15.Jul.1996 v-HirShi (Hirotoshi Shimizu) Created for TAIWAN & KOREA & PRC 00016 // 00017 // COMMENTS: 00018 // 00019 #include "precomp.h" 00020 #pragma hdrstop 00021 00022 00023 BOOL 00024 ImeUIOpenCandidate( 00025 HWND hwnd, 00026 DWORD CandList, 00027 BOOL OpenFlag 00028 ) 00029 { 00030 PCONSOLE_TABLE ConTbl; 00031 HIMC hIMC; 00032 00033 DBGPRINT(("CONIME: Get IMN_OPENCANDIDATE Message\n")); 00034 00035 00036 ConTbl = SearchConsole(LastConsole); 00037 00038 if (ConTbl->fNestCandidate) 00039 return TRUE; 00040 00041 if (ConTbl == NULL) { 00042 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 00043 return FALSE; 00044 } 00045 00046 hIMC = ImmGetContext( hwnd ); 00047 if ( hIMC == 0 ) 00048 return FALSE; 00049 00050 // 00051 // Set fInCandidate variables. 00052 // 00053 ConTbl->fInCandidate = TRUE; 00054 00055 switch ( HKL_TO_LANGID(ConTbl->hklActive)) 00056 { 00057 case LANG_ID_JAPAN: 00058 OpenCandidateJapan(hwnd, hIMC, ConTbl, CandList, OpenFlag ); 00059 break; 00060 case LANG_ID_TAIWAN: 00061 OpenCandidateTaiwan(hwnd, hIMC, ConTbl, CandList, OpenFlag ); 00062 break; 00063 case LANG_ID_PRC: 00064 OpenCandidatePRC(hwnd, hIMC, ConTbl, CandList, OpenFlag ); 00065 break; 00066 case LANG_ID_KOREA: 00067 OpenCandidateKorea(hwnd, hIMC, ConTbl, CandList, OpenFlag ); 00068 break; 00069 default: 00070 return FALSE; 00071 } 00072 00073 ImmReleaseContext( hwnd, hIMC ); 00074 00075 return TRUE; 00076 } 00077 00078 00079 BOOL 00080 OpenCandidateJapan( 00081 HWND hwnd, 00082 HIMC hIMC , 00083 PCONSOLE_TABLE ConTbl, 00084 DWORD CandList, 00085 BOOL OpenFlag 00086 ) 00087 { 00088 DWORD dwLength; 00089 DWORD dwIndex; 00090 DWORD i; 00091 DWORD j; 00092 LPWSTR lpStr; 00093 DWORD dwDspLen; 00094 DWORD width; 00095 DWORD StartIndex; 00096 DWORD CountDispWidth; 00097 DWORD AllocLength; 00098 LPCANDIDATELIST lpCandList; 00099 LPCONIME_CANDMESSAGE SystemLine; 00100 DWORD SystemLineSize; 00101 COPYDATASTRUCT CopyData; 00102 BOOL EnableCodePoint; 00103 00104 for (dwIndex = 0; dwIndex < MAX_LISTCAND ; dwIndex ++ ) { 00105 if ( CandList & ( 1 << dwIndex ) ) { 00106 dwLength = ImmGetCandidateList(hIMC, dwIndex, NULL, 0); 00107 if (dwLength == 0) 00108 return FALSE; 00109 if ( (ConTbl->CandListMemAllocSize[dwIndex] != dwLength ) && 00110 (ConTbl->lpCandListMem[dwIndex] != NULL)) { 00111 LocalFree(ConTbl->lpCandListMem[dwIndex]); 00112 ConTbl->CandListMemAllocSize[dwIndex] = 0; 00113 ConTbl->lpCandListMem[dwIndex] = NULL; 00114 } 00115 if (ConTbl->lpCandListMem[dwIndex] == NULL) { 00116 ConTbl->lpCandListMem[dwIndex] = LocalAlloc(LPTR, dwLength); 00117 if (ConTbl->lpCandListMem[dwIndex] == NULL) 00118 return FALSE; 00119 ConTbl->CandListMemAllocSize[dwIndex] = dwLength; 00120 } 00121 lpCandList = ConTbl->lpCandListMem[dwIndex]; 00122 ImmGetCandidateList(hIMC, dwIndex, lpCandList, dwLength); 00123 00124 // 00125 // check each offset value is not over than buffer size. 00126 // 00127 if ((lpCandList->dwCount > 1) && 00128 (lpCandList->dwSelection >= dwLength || 00129 lpCandList->dwPageStart >= dwLength || 00130 lpCandList->dwOffset[lpCandList->dwSelection] >= dwLength || 00131 lpCandList->dwOffset[lpCandList->dwPageStart] >= dwLength ) 00132 ) 00133 break; 00134 00135 dwLength = ConTbl->ScreenBufferSize.X; 00136 dwLength = (dwLength > 128) ? 128 : dwLength ; 00137 dwLength = ((dwLength < 12) ? 12 : dwLength ); 00138 00139 j = (dwLength-7)/(DELIMITERWIDTH+sizeof(WCHAR)); 00140 j = ((j > 9)?9:j); 00141 j = lpCandList->dwCount / j + 10; 00142 AllocLength = (j > DEFAULTCANDTABLE) ? j : DEFAULTCANDTABLE; 00143 00144 if (lpCandList->dwStyle == IME_CAND_CODE){ 00145 EnableCodePoint = TRUE; 00146 } 00147 else{ 00148 EnableCodePoint = FALSE; 00149 } 00150 00151 if (EnableCodePoint){ 00152 CountDispWidth = CODEDISPLEN; 00153 } 00154 else { 00155 for (CountDispWidth = 0 ,j = 1; j <= lpCandList->dwCount; CountDispWidth++) 00156 j *= 10; 00157 CountDispWidth *= 2; 00158 CountDispWidth++; 00159 } 00160 00161 if ((ConTbl->CandSepAllocSize != sizeof(DWORD)*AllocLength) && 00162 (ConTbl->CandSep != NULL)) { 00163 LocalFree(ConTbl->CandSep); 00164 ConTbl->CandSep = NULL; 00165 ConTbl->CandSepAllocSize = 0; 00166 } 00167 if (ConTbl->CandSep == NULL) { 00168 ConTbl->CandSep= LocalAlloc(LPTR, sizeof(DWORD)*AllocLength); 00169 if (ConTbl->CandSep == NULL) 00170 return FALSE; 00171 ConTbl->CandSepAllocSize = sizeof(DWORD)*AllocLength; 00172 } 00173 00174 if ( EnableCodePoint ){ 00175 j = 0; 00176 ConTbl->CandSep[j++] = 0; 00177 if (OpenFlag) { 00178 ConTbl->CandOff = lpCandList->dwSelection % 9; 00179 } 00180 i = ConTbl->CandOff; 00181 for (; i < lpCandList->dwCount; i+= 9 ) { 00182 ConTbl->CandSep[j++] = i; 00183 } 00184 if (i > lpCandList->dwCount) { 00185 i = lpCandList->dwCount; 00186 } 00187 } 00188 else{ 00189 j = 0; 00190 if (OpenFlag) { 00191 ConTbl->CandOff = 0; 00192 } 00193 ConTbl->CandSep[j++] = ConTbl->CandOff; 00194 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ 0 ]); 00195 dwDspLen = DispLenUnicode( lpStr ); 00196 width = dwDspLen + DELIMITERWIDTH; // '1:xxxx 2:xxxx ' 00197 for( i = 1; i < lpCandList->dwCount; i++ ) { 00198 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ i ]); 00199 dwDspLen = DispLenUnicode( lpStr ); 00200 width += dwDspLen + DELIMITERWIDTH; 00201 if ((width > dwLength-CountDispWidth) || 00202 ( i - ConTbl->CandSep[j-1] >= 9)){ 00203 ConTbl->CandSep[j++] = i; 00204 width = dwDspLen + DELIMITERWIDTH; 00205 } 00206 } 00207 } 00208 ConTbl->CandSep[j] = i; 00209 ConTbl->CandMax = j; 00210 00211 SystemLineSize = (sizeof(WCHAR)+sizeof(UCHAR))*dwLength + sizeof(DWORD); 00212 if (ConTbl->SystemLineSize < SystemLineSize ){ 00213 if (ConTbl->SystemLine != NULL){ 00214 LocalFree( ConTbl->SystemLine ); 00215 ConTbl->SystemLine = NULL; 00216 ConTbl->SystemLineSize = 0; 00217 } 00218 ConTbl->SystemLine = (LPCONIME_CANDMESSAGE)LocalAlloc(LPTR, SystemLineSize ); 00219 if (ConTbl->SystemLine == NULL) { 00220 return FALSE; 00221 } 00222 ConTbl->SystemLineSize = SystemLineSize; 00223 } 00224 SystemLine = ConTbl->SystemLine; 00225 00226 SystemLine->AttrOff = sizeof(WCHAR) * dwLength + sizeof(DWORD); 00227 00228 CopyData.dwData = CI_CONIMECANDINFO; 00229 CopyData.cbData = (sizeof(WCHAR)+sizeof(UCHAR))*dwLength + sizeof(DWORD); 00230 CopyData.lpData = SystemLine; 00231 StartIndex = GetSystemLineJ( lpCandList, 00232 SystemLine->String, 00233 (LPSTR)SystemLine + SystemLine->AttrOff, 00234 dwLength, 00235 CountDispWidth, 00236 ConTbl, 00237 EnableCodePoint); 00238 00239 ConTbl->fNestCandidate = TRUE; // ImmNotyfyIME call back OpenCandidate Message 00240 // by same data. 00241 // so We ignore this mesage. 00242 ImmNotifyIME(hIMC, 00243 NI_SETCANDIDATE_PAGESTART, 00244 dwIndex, 00245 ConTbl->CandSep[StartIndex]); 00246 00247 ImmNotifyIME(hIMC, 00248 NI_SETCANDIDATE_PAGESIZE, 00249 dwIndex, 00250 ConTbl->CandSep[StartIndex+1] - 00251 ConTbl->CandSep[StartIndex]); 00252 ConTbl->fNestCandidate = FALSE; 00253 00254 ConsoleImeSendMessage( ConTbl->hWndCon, 00255 (WPARAM)hwnd, 00256 (LPARAM)&CopyData 00257 ); 00258 } 00259 } 00260 return TRUE; 00261 } 00262 00263 BOOL 00264 OpenCandidateTaiwan( 00265 HWND hwnd, 00266 HIMC hIMC , 00267 PCONSOLE_TABLE ConTbl, 00268 DWORD CandList, 00269 BOOL OpenFlag 00270 ) 00271 { 00272 DWORD dwLength; 00273 DWORD dwIndex; 00274 DWORD i; 00275 DWORD j; 00276 LPWSTR lpStr; 00277 DWORD dwDspLen; 00278 DWORD width; 00279 DWORD StartIndex; 00280 DWORD CountDispWidth; 00281 DWORD AllocLength; 00282 LPCANDIDATELIST lpCandList; 00283 LPCONIME_CANDMESSAGE SystemLine; 00284 DWORD SystemLineSize; 00285 COPYDATASTRUCT CopyData; 00286 LPCONIME_UIMODEINFO lpModeInfo; 00287 00288 lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc( LPTR, sizeof(CONIME_UIMODEINFO) ); 00289 if ( lpModeInfo == NULL) { 00290 return FALSE; 00291 } 00292 00293 for (dwIndex = 0; dwIndex < MAX_LISTCAND ; dwIndex ++ ) { 00294 if ( CandList & ( 1 << dwIndex ) ) { 00295 dwLength = ImmGetCandidateList(hIMC, dwIndex, NULL, 0); 00296 if (dwLength == 0) 00297 return FALSE; 00298 if ( (ConTbl->CandListMemAllocSize[dwIndex] != dwLength ) && 00299 (ConTbl->lpCandListMem[dwIndex] != NULL)) { 00300 LocalFree(ConTbl->lpCandListMem[dwIndex]); 00301 ConTbl->CandListMemAllocSize[dwIndex] = 0; 00302 ConTbl->lpCandListMem[dwIndex] = NULL; 00303 } 00304 if (ConTbl->lpCandListMem[dwIndex] == NULL) { 00305 ConTbl->lpCandListMem[dwIndex] = LocalAlloc(LPTR, dwLength); 00306 if (ConTbl->lpCandListMem[dwIndex] == NULL) 00307 return FALSE; 00308 ConTbl->CandListMemAllocSize[dwIndex] = dwLength; 00309 } 00310 lpCandList = ConTbl->lpCandListMem[dwIndex]; 00311 ImmGetCandidateList(hIMC, dwIndex, lpCandList, dwLength); 00312 00313 // 00314 // check each offset value is not over than buffer size. 00315 // 00316 if ((lpCandList->dwCount > 1) && 00317 (lpCandList->dwSelection >= dwLength || 00318 lpCandList->dwPageStart >= dwLength || 00319 lpCandList->dwOffset[lpCandList->dwSelection] >= dwLength || 00320 lpCandList->dwOffset[lpCandList->dwPageStart] >= dwLength ) 00321 ) 00322 break; 00323 00324 dwLength = ConTbl->ScreenBufferSize.X; 00325 dwLength = (dwLength > 128) ? 128 : dwLength ; 00326 dwLength = ((dwLength < 12) ? 12 : dwLength ); 00327 #if defined (CANDCOUNTCHT) //for wider candidate list space v-hirshi Oct.16.1996 00328 dwLength -= 28; // 6+1+4+1+10+1+....+4+1 00329 #else 00330 dwLength -= IMECNameLength+1+IMECModeFullShapeLen*2+1; // 4+1+2+1+.... 00331 #endif 00332 00333 j = (dwLength-7)/(DELIMITERWIDTH+sizeof(WCHAR)); 00334 j = ((j > 9)?9:j); 00335 j = lpCandList->dwCount / j + 10; 00336 AllocLength = (j > DEFAULTCANDTABLE) ? j : DEFAULTCANDTABLE; 00337 00338 for (CountDispWidth = 0 ,j = 1; j <= lpCandList->dwCount; CountDispWidth++) 00339 j *= 10; 00340 CountDispWidth *= 2; 00341 CountDispWidth++; 00342 00343 if ((ConTbl->CandSepAllocSize != sizeof(DWORD)*AllocLength) && 00344 (ConTbl->CandSep != NULL)) { 00345 LocalFree(ConTbl->CandSep); 00346 ConTbl->CandSep = NULL; 00347 ConTbl->CandSepAllocSize = 0; 00348 } 00349 if (ConTbl->CandSep == NULL) { 00350 ConTbl->CandSep= LocalAlloc(LPTR, sizeof(DWORD)*AllocLength); 00351 if (ConTbl->CandSep == NULL) 00352 return FALSE; 00353 ConTbl->CandSepAllocSize = sizeof(DWORD)*AllocLength; 00354 } 00355 00356 j = 0; 00357 if (OpenFlag) { 00358 ConTbl->CandOff = 0; 00359 } 00360 ConTbl->CandSep[j++] = ConTbl->CandOff; 00361 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ 0 ]); 00362 dwDspLen = DispLenUnicode( lpStr ); 00363 width = dwDspLen + DELIMITERWIDTH; // '1:xxxx 2:xxxx ' 00364 for( i = 1; i < lpCandList->dwCount; i++ ) { 00365 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ i ]); 00366 dwDspLen = DispLenUnicode( lpStr ); 00367 width += dwDspLen + DELIMITERWIDTH; 00368 if ((width > dwLength-CountDispWidth) || 00369 ( i - ConTbl->CandSep[j-1] >= 9)){ 00370 ConTbl->CandSep[j++] = i; 00371 width = dwDspLen + DELIMITERWIDTH; 00372 } 00373 } 00374 ConTbl->CandSep[j] = i; 00375 ConTbl->CandMax = j; 00376 00377 SystemLineSize = (sizeof(WCHAR)+sizeof(UCHAR))*dwLength + sizeof(DWORD); 00378 if (ConTbl->SystemLineSize < SystemLineSize ){ 00379 if (ConTbl->SystemLine != NULL){ 00380 LocalFree( ConTbl->SystemLine ); 00381 ConTbl->SystemLine = NULL; 00382 ConTbl->SystemLineSize = 0; 00383 } 00384 ConTbl->SystemLine = (LPCONIME_CANDMESSAGE)LocalAlloc(LPTR, SystemLineSize ); 00385 if (ConTbl->SystemLine == NULL) { 00386 return FALSE; 00387 } 00388 ConTbl->SystemLineSize = SystemLineSize; 00389 } 00390 SystemLine = ConTbl->SystemLine; 00391 00392 SystemLine->AttrOff = sizeof(WCHAR) * dwLength + sizeof(DWORD); 00393 00394 StartIndex = GetSystemLineT( lpCandList, 00395 SystemLine->String, 00396 (LPSTR)SystemLine + SystemLine->AttrOff, 00397 dwLength, 00398 CountDispWidth, 00399 ConTbl 00400 ); 00401 00402 ConTbl->fNestCandidate = TRUE; // ImmNotyfyIME call back OpenCandidate Message 00403 // by same data. 00404 // so We ignore this mesage. 00405 ImmNotifyIME(hIMC, 00406 NI_SETCANDIDATE_PAGESTART, 00407 dwIndex, 00408 ConTbl->CandSep[StartIndex]); 00409 00410 ImmNotifyIME(hIMC, 00411 NI_SETCANDIDATE_PAGESIZE, 00412 dwIndex, 00413 ConTbl->CandSep[StartIndex+1] - 00414 ConTbl->CandSep[StartIndex]); 00415 ConTbl->fNestCandidate = FALSE; 00416 00417 CopyData.dwData = CI_CONIMEMODEINFO; 00418 CopyData.cbData = sizeof(CONIME_UIMODEINFO); 00419 CopyData.lpData = lpModeInfo; 00420 if (MakeInfoStringTaiwan(ConTbl, lpModeInfo) ) { 00421 ConsoleImeSendMessage( ConTbl->hWndCon, 00422 (WPARAM)hwnd, 00423 (LPARAM)&CopyData 00424 ); 00425 } 00426 } 00427 } 00428 LocalFree( lpModeInfo ); 00429 return TRUE; 00430 } 00431 00432 BOOL 00433 OpenCandidatePRC( 00434 HWND hwnd, 00435 HIMC hIMC , 00436 PCONSOLE_TABLE ConTbl, 00437 DWORD CandList, 00438 BOOL OpenFlag 00439 ) 00440 { 00441 DWORD dwLength; 00442 DWORD dwIndex; 00443 DWORD i; 00444 DWORD j; 00445 LPWSTR lpStr; 00446 DWORD dwDspLen; 00447 DWORD width; 00448 DWORD StartIndex; 00449 DWORD CountDispWidth; 00450 DWORD AllocLength; 00451 LPCANDIDATELIST lpCandList; 00452 LPCONIME_CANDMESSAGE SystemLine; 00453 DWORD SystemLineSize; 00454 COPYDATASTRUCT CopyData; 00455 LPCONIME_UIMODEINFO lpModeInfo; 00456 00457 lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc( LPTR, sizeof(CONIME_UIMODEINFO) ); 00458 if ( lpModeInfo == NULL) { 00459 return FALSE; 00460 } 00461 00462 for (dwIndex = 0; dwIndex < MAX_LISTCAND ; dwIndex ++ ) { 00463 if ( CandList & ( 1 << dwIndex ) ) { 00464 dwLength = ImmGetCandidateList(hIMC, dwIndex, NULL, 0); 00465 if (dwLength == 0) 00466 return FALSE; 00467 if ( (ConTbl->CandListMemAllocSize[dwIndex] != dwLength ) && 00468 (ConTbl->lpCandListMem[dwIndex] != NULL)) { 00469 LocalFree(ConTbl->lpCandListMem[dwIndex]); 00470 ConTbl->CandListMemAllocSize[dwIndex] = 0; 00471 ConTbl->lpCandListMem[dwIndex] = NULL; 00472 } 00473 if (ConTbl->lpCandListMem[dwIndex] == NULL) { 00474 ConTbl->lpCandListMem[dwIndex] = LocalAlloc(LPTR, dwLength); 00475 if (ConTbl->lpCandListMem[dwIndex] == NULL) 00476 return FALSE; 00477 ConTbl->CandListMemAllocSize[dwIndex] = dwLength; 00478 } 00479 lpCandList = ConTbl->lpCandListMem[dwIndex]; 00480 ImmGetCandidateList(hIMC, dwIndex, lpCandList, dwLength); 00481 00482 // 00483 // check each offset value is not over than buffer size. 00484 // 00485 if ((lpCandList->dwCount > 1) && 00486 (lpCandList->dwSelection >= dwLength || 00487 lpCandList->dwPageStart >= dwLength || 00488 lpCandList->dwOffset[lpCandList->dwSelection] >= dwLength || 00489 lpCandList->dwOffset[lpCandList->dwPageStart] >= dwLength ) 00490 ) 00491 break; 00492 00493 dwLength = ConTbl->ScreenBufferSize.X; 00494 dwLength = (dwLength > 128) ? 128 : dwLength ; 00495 dwLength = ((dwLength < 12) ? 12 : dwLength ); 00496 #if defined (CANDCOUNTPRC) //for wider candidate list space v-hirshi Oct.16.1996 00497 dwLength -= (20 + PRCCOMPWIDTH); //(8+1+4+1+PRCCOMPWIDTH+1+...+5) 00498 #else 00499 dwLength -= (15 + PRCCOMPWIDTH); //(8+1+4+1+PRCCOMPWIDTH+1+...) 00500 #endif 00501 00502 j = (dwLength-7)/(DELIMITERWIDTH+sizeof(WCHAR)); 00503 j = ((j > 9)?9:j); 00504 j = lpCandList->dwCount / j + 10; 00505 AllocLength = (j > DEFAULTCANDTABLE) ? j : DEFAULTCANDTABLE; 00506 00507 #if defined (CANDCOUNTPRC) //for wider candidate list space v-hirshi Oct.16.1996 00508 for (CountDispWidth = 0 ,j = 1; j <= lpCandList->dwCount; CountDispWidth++) 00509 j *= 10; 00510 CountDispWidth *= 2; 00511 CountDispWidth++; 00512 #else 00513 CountDispWidth = 0; 00514 #endif 00515 00516 if ((ConTbl->CandSepAllocSize != sizeof(DWORD)*AllocLength) && 00517 (ConTbl->CandSep != NULL)) { 00518 LocalFree(ConTbl->CandSep); 00519 ConTbl->CandSep = NULL; 00520 ConTbl->CandSepAllocSize = 0; 00521 } 00522 if (ConTbl->CandSep == NULL) { 00523 ConTbl->CandSep= LocalAlloc(LPTR, sizeof(DWORD)*AllocLength); 00524 if (ConTbl->CandSep == NULL) 00525 return FALSE; 00526 ConTbl->CandSepAllocSize = sizeof(DWORD)*AllocLength; 00527 } 00528 00529 j = 0; 00530 if (OpenFlag) { 00531 ConTbl->CandOff = 0; 00532 } 00533 ConTbl->CandSep[j++] = ConTbl->CandOff; 00534 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ 0 ]); 00535 dwDspLen = DispLenUnicode( lpStr ); 00536 width = dwDspLen + DELIMITERWIDTH; // '1:xxxx 2:xxxx ' 00537 for( i = 1; i < lpCandList->dwCount; i++ ) { 00538 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ i ]); 00539 dwDspLen = DispLenUnicode( lpStr ); 00540 width += dwDspLen + DELIMITERWIDTH; 00541 if ((width > dwLength-CountDispWidth) || 00542 ( i - ConTbl->CandSep[j-1] >= 9)){ 00543 ConTbl->CandSep[j++] = i; 00544 width = dwDspLen + DELIMITERWIDTH; 00545 } 00546 } 00547 ConTbl->CandSep[j] = i; 00548 ConTbl->CandMax = j; 00549 00550 SystemLineSize = (sizeof(WCHAR)+sizeof(UCHAR))*dwLength + sizeof(DWORD); 00551 if (ConTbl->SystemLineSize < SystemLineSize ){ 00552 if (ConTbl->SystemLine != NULL){ 00553 LocalFree( ConTbl->SystemLine ); 00554 ConTbl->SystemLine = NULL; 00555 ConTbl->SystemLineSize = 0; 00556 } 00557 ConTbl->SystemLine = (LPCONIME_CANDMESSAGE)LocalAlloc(LPTR, SystemLineSize ); 00558 if (ConTbl->SystemLine == NULL) { 00559 return FALSE; 00560 } 00561 ConTbl->SystemLineSize = SystemLineSize; 00562 } 00563 SystemLine = ConTbl->SystemLine; 00564 00565 SystemLine->AttrOff = sizeof(WCHAR) * dwLength + sizeof(DWORD); 00566 00567 StartIndex = GetSystemLineP( lpCandList, 00568 SystemLine->String, 00569 (LPSTR)SystemLine + SystemLine->AttrOff, 00570 dwLength, 00571 CountDispWidth, 00572 ConTbl 00573 ); 00574 00575 ConTbl->fNestCandidate = TRUE; // ImmNotyfyIME call back OpenCandidate Message 00576 // by same data. 00577 // so We ignore this mesage. 00578 ImmNotifyIME(hIMC, 00579 NI_SETCANDIDATE_PAGESTART, 00580 dwIndex, 00581 ConTbl->CandSep[StartIndex]); 00582 00583 ImmNotifyIME(hIMC, 00584 NI_SETCANDIDATE_PAGESIZE, 00585 dwIndex, 00586 ConTbl->CandSep[StartIndex+1] - 00587 ConTbl->CandSep[StartIndex]); 00588 ConTbl->fNestCandidate = FALSE; 00589 00590 CopyData.dwData = CI_CONIMEMODEINFO; 00591 CopyData.cbData = sizeof(CONIME_UIMODEINFO); 00592 CopyData.lpData = lpModeInfo; 00593 if (MakeInfoStringPRC(ConTbl, lpModeInfo) ) { 00594 ConsoleImeSendMessage( ConTbl->hWndCon, 00595 (WPARAM)hwnd, 00596 (LPARAM)&CopyData 00597 ); 00598 } 00599 } 00600 } 00601 LocalFree( lpModeInfo ); 00602 return TRUE; 00603 } 00604 00605 BOOL 00606 OpenCandidateKorea( 00607 HWND hwnd, 00608 HIMC hIMC , 00609 PCONSOLE_TABLE ConTbl, 00610 DWORD CandList, 00611 BOOL OpenFlag 00612 ) 00613 { 00614 DWORD dwLength; 00615 DWORD dwIndex; 00616 DWORD i; 00617 DWORD j; 00618 LPWSTR lpStr; 00619 DWORD dwDspLen; 00620 DWORD width; 00621 DWORD StartIndex; 00622 DWORD CountDispWidth; 00623 DWORD AllocLength; 00624 LPCANDIDATELIST lpCandList; 00625 LPCONIME_CANDMESSAGE SystemLine; 00626 DWORD SystemLineSize; 00627 COPYDATASTRUCT CopyData; 00628 BOOL EnableCodePoint; 00629 00630 for (dwIndex = 0; dwIndex < MAX_LISTCAND ; dwIndex ++ ) { 00631 if ( CandList & ( 1 << dwIndex ) ) { 00632 dwLength = ImmGetCandidateList(hIMC, dwIndex, NULL, 0); 00633 if (dwLength == 0) 00634 return FALSE; 00635 if ( (ConTbl->CandListMemAllocSize[dwIndex] != dwLength ) && 00636 (ConTbl->lpCandListMem[dwIndex] != NULL)) { 00637 LocalFree(ConTbl->lpCandListMem[dwIndex]); 00638 ConTbl->CandListMemAllocSize[dwIndex] = 0; 00639 ConTbl->lpCandListMem[dwIndex] = NULL; 00640 } 00641 if (ConTbl->lpCandListMem[dwIndex] == NULL) { 00642 ConTbl->lpCandListMem[dwIndex] = LocalAlloc(LPTR, dwLength); 00643 if (ConTbl->lpCandListMem[dwIndex] == NULL) 00644 return FALSE; 00645 ConTbl->CandListMemAllocSize[dwIndex] = dwLength; 00646 } 00647 lpCandList = ConTbl->lpCandListMem[dwIndex]; 00648 ImmGetCandidateList(hIMC, dwIndex, lpCandList, dwLength); 00649 00650 // 00651 // check each offset value is not over than buffer size. 00652 // 00653 if ((lpCandList->dwCount > 1) && 00654 (lpCandList->dwSelection >= dwLength || 00655 lpCandList->dwPageStart >= dwLength || 00656 lpCandList->dwOffset[lpCandList->dwSelection] >= dwLength || 00657 lpCandList->dwOffset[lpCandList->dwPageStart] >= dwLength ) 00658 ) 00659 break; 00660 00661 dwLength = ConTbl->ScreenBufferSize.X; 00662 dwLength = (dwLength > 128) ? 128 : dwLength ; 00663 dwLength = ((dwLength < 12) ? 12 : dwLength ); 00664 00665 j = (dwLength-7)/(DELIMITERWIDTH+sizeof(WCHAR)); 00666 j = ((j > 9)?9:j); 00667 j = lpCandList->dwCount / j + 10; 00668 AllocLength = (j > DEFAULTCANDTABLE) ? j : DEFAULTCANDTABLE; 00669 00670 if (lpCandList->dwStyle == IME_CAND_CODE){ 00671 EnableCodePoint = TRUE; 00672 } 00673 else{ 00674 EnableCodePoint = FALSE; 00675 } 00676 00677 if (EnableCodePoint){ 00678 CountDispWidth = CODEDISPLEN; 00679 } 00680 else { 00681 for (CountDispWidth = 0 ,j = 1; j <= lpCandList->dwCount; CountDispWidth++) 00682 j *= 10; 00683 CountDispWidth *= 2; 00684 CountDispWidth++; 00685 } 00686 00687 if ((ConTbl->CandSepAllocSize != sizeof(DWORD)*AllocLength) && 00688 (ConTbl->CandSep != NULL)) { 00689 LocalFree(ConTbl->CandSep); 00690 ConTbl->CandSep = NULL; 00691 ConTbl->CandSepAllocSize = 0; 00692 } 00693 if (ConTbl->CandSep == NULL) { 00694 ConTbl->CandSep= LocalAlloc(LPTR, sizeof(DWORD)*AllocLength); 00695 if (ConTbl->CandSep == NULL) 00696 return FALSE; 00697 ConTbl->CandSepAllocSize = sizeof(DWORD)*AllocLength; 00698 } 00699 00700 if ( EnableCodePoint ){ 00701 j = 0; 00702 ConTbl->CandSep[j++] = 0; 00703 if (OpenFlag) { 00704 ConTbl->CandOff = lpCandList->dwSelection % 9; 00705 } 00706 i = ConTbl->CandOff; 00707 for (; i < lpCandList->dwCount; i+= 9 ) { 00708 ConTbl->CandSep[j++] = i; 00709 } 00710 if (i > lpCandList->dwCount) { 00711 i = lpCandList->dwCount; 00712 } 00713 } 00714 else{ 00715 j = 0; 00716 if (OpenFlag) { 00717 ConTbl->CandOff = 0; 00718 } 00719 ConTbl->CandSep[j++] = ConTbl->CandOff; 00720 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ 0 ]); 00721 dwDspLen = DispLenUnicode( lpStr ); 00722 width = dwDspLen + DELIMITERWIDTH; // '1:xxxx 2:xxxx ' 00723 for( i = 1; i < lpCandList->dwCount; i++ ) { 00724 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ i ]); 00725 dwDspLen = DispLenUnicode( lpStr ); 00726 width += dwDspLen + DELIMITERWIDTH; 00727 if ((width > dwLength-CountDispWidth) || 00728 ( i - ConTbl->CandSep[j-1] >= 9)){ 00729 ConTbl->CandSep[j++] = i; 00730 width = dwDspLen + DELIMITERWIDTH; 00731 } 00732 } 00733 } 00734 ConTbl->CandSep[j] = i; 00735 ConTbl->CandMax = j; 00736 00737 SystemLineSize = (sizeof(WCHAR)+sizeof(UCHAR))*dwLength + sizeof(DWORD); 00738 if (ConTbl->SystemLineSize < SystemLineSize ){ 00739 if (ConTbl->SystemLine != NULL){ 00740 LocalFree( ConTbl->SystemLine ); 00741 ConTbl->SystemLine = NULL; 00742 ConTbl->SystemLineSize = 0; 00743 } 00744 ConTbl->SystemLine = (LPCONIME_CANDMESSAGE)LocalAlloc(LPTR, SystemLineSize ); 00745 if (ConTbl->SystemLine == NULL) { 00746 return FALSE; 00747 } 00748 ConTbl->SystemLineSize = SystemLineSize; 00749 } 00750 SystemLine = ConTbl->SystemLine; 00751 00752 SystemLine->AttrOff = sizeof(WCHAR) * dwLength + sizeof(DWORD); 00753 00754 CopyData.dwData = CI_CONIMECANDINFO; 00755 CopyData.cbData = (sizeof(WCHAR)+sizeof(UCHAR))*dwLength + sizeof(DWORD); 00756 CopyData.lpData = SystemLine; 00757 StartIndex = GetSystemLineJ( lpCandList, 00758 SystemLine->String, 00759 (LPSTR)SystemLine + SystemLine->AttrOff, 00760 dwLength, 00761 CountDispWidth, 00762 ConTbl, 00763 EnableCodePoint); 00764 00765 ConTbl->fNestCandidate = TRUE; // ImmNotyfyIME call back OpenCandidate Message 00766 // by same data. 00767 // so We ignore this mesage. 00768 ImmNotifyIME(hIMC, 00769 NI_SETCANDIDATE_PAGESTART, 00770 dwIndex, 00771 ConTbl->CandSep[StartIndex]); 00772 00773 ImmNotifyIME(hIMC, 00774 NI_SETCANDIDATE_PAGESIZE, 00775 dwIndex, 00776 ConTbl->CandSep[StartIndex+1] - 00777 ConTbl->CandSep[StartIndex]); 00778 ConTbl->fNestCandidate = FALSE; 00779 00780 ConsoleImeSendMessage( ConTbl->hWndCon, 00781 (WPARAM)hwnd, 00782 (LPARAM)&CopyData 00783 ); 00784 } 00785 } 00786 return TRUE; 00787 } 00788 00789 DWORD 00790 DispLenUnicode( 00791 LPWSTR lpString ) 00792 { 00793 DWORD i; 00794 DWORD Length; 00795 00796 Length = 0; 00797 00798 for ( i = 0; lpString[i] != 0; i++) { 00799 Length += IsUnicodeFullWidth(lpString[i]) ? 2 : 1; 00800 } 00801 return Length; 00802 } 00803 00804 DWORD 00805 GetSystemLineJ( 00806 LPCANDIDATELIST lpCandList , 00807 LPWSTR String, 00808 LPSTR Attr, 00809 DWORD dwLength, 00810 DWORD CountDispWidth, 00811 PCONSOLE_TABLE FocusedConsole, 00812 BOOL EnableCodePoint) 00813 { 00814 DWORD dwStrLen; 00815 DWORD dwDspLen; 00816 DWORD i; 00817 DWORD j; 00818 DWORD SepIndex; 00819 DWORD SelCount; 00820 DWORD Length; 00821 DWORD dwWholeLen; 00822 BOOL lfBreak = FALSE; 00823 LPWSTR StrToWrite; 00824 LPSTR AttrToSel; 00825 LPWSTR lpStr; 00826 USHORT MultiChar; 00827 USHORT TempMulti; 00828 00829 if ((lpCandList->dwSelection > lpCandList->dwCount)|| 00830 (lpCandList->dwSelection < 0)) { 00831 lpCandList->dwSelection = 0; 00832 } 00833 00834 for ( SepIndex = FocusedConsole->CandMax; SepIndex > 0; SepIndex--) { 00835 if (lpCandList->dwSelection >= FocusedConsole->CandSep[SepIndex]) 00836 break; 00837 } 00838 if (SepIndex == FocusedConsole->CandMax) 00839 SepIndex = 0; 00840 00841 for ( i = 0; i < dwLength; i++) { 00842 Attr[i] = 0x0000; 00843 } 00844 StrToWrite = String; 00845 AttrToSel = Attr; 00846 dwWholeLen = 0; 00847 #if 1 00848 // HACK HACK ntbug #69699 00849 // MS-IME97 & MS-IME97A does not return correct value for IME_PROP_CANDLIST_START_FROM_1. 00850 // These always return its starting from 0. 00851 // Currently there is not IME starting from 0. So we hack. 00852 // Actually IME should be fixed. 00853 SelCount = 1; 00854 #else 00855 if (FocusedConsole->ImmGetProperty & IME_PROP_CANDLIST_START_FROM_1) 00856 SelCount = 1; 00857 else 00858 SelCount = 0; 00859 #endif 00860 00861 if (EnableCodePoint){ 00862 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[lpCandList->dwSelection]); 00863 WideCharToMultiByte(CP_OEMCP, 0, lpStr, 1, (PBYTE)&TempMulti, 2, NULL, NULL); 00864 *StrToWrite = UNICODE_LEFT; 00865 StrToWrite++; 00866 MultiChar = (USHORT)(HIBYTE(TempMulti)| LOBYTE(TempMulti)<<8); 00867 for (i = 0; i < 4; i++) { 00868 j = (MultiChar & 0xf000 ) >> 12; 00869 if ( j <= 9) 00870 *StrToWrite = (USHORT)(j + UNICODE_ZERO); 00871 else 00872 *StrToWrite = (USHORT)(j + UNICODE_HEXBASE); 00873 StrToWrite++; 00874 MultiChar = (USHORT)(MultiChar << 4); 00875 } 00876 *StrToWrite = UNICODE_RIGHT; 00877 StrToWrite++; 00878 *StrToWrite = UNICODE_SPACE; 00879 StrToWrite++; 00880 AttrToSel += CountDispWidth; 00881 dwWholeLen += CountDispWidth; 00882 CountDispWidth = 0; 00883 } 00884 00885 for (i = FocusedConsole->CandSep[SepIndex]; i < FocusedConsole->CandSep[SepIndex+1]; i++) { 00886 // 00887 // check each offset value is not over than buffer size. 00888 // 00889 if (lpCandList->dwOffset[i] >= lpCandList->dwSize) 00890 break; 00891 00892 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ i ]); 00893 dwStrLen = lstrlenW( lpStr ); 00894 dwDspLen = DispLenUnicode( lpStr ); 00895 00896 if ( dwWholeLen + dwDspLen + DELIMITERWIDTH > dwLength - CountDispWidth ){ 00897 Length = 0; 00898 lfBreak = TRUE; 00899 for (j = 0; j < dwStrLen; j++ ){ 00900 Length += IsUnicodeFullWidth(lpStr[j]) ? 2 : 1; 00901 if (dwWholeLen + Length > dwLength - (CountDispWidth + DELIMITERWIDTH)){ 00902 dwStrLen = j-1; 00903 dwDspLen = Length - IsUnicodeFullWidth(lpStr[j]) ? 2 : 1; 00904 break; 00905 } 00906 } 00907 } 00908 if ((dwWholeLen + dwDspLen + DELIMITERWIDTH + CountDispWidth ) <= dwLength ) // if minus value 00909 dwWholeLen += (dwDspLen + DELIMITERWIDTH); 00910 else { 00911 break; 00912 } 00913 00914 if (i == lpCandList->dwSelection) { 00915 for (j = 0; j < dwStrLen+2; j++) 00916 *(AttrToSel+j) = 1; 00917 } 00918 *StrToWrite = (USHORT)(SelCount + UNICODE_ZERO); 00919 StrToWrite++; 00920 *StrToWrite = UNICODE_COLON; 00921 StrToWrite++; 00922 CopyMemory(StrToWrite, lpStr, dwStrLen * sizeof(WCHAR)); 00923 StrToWrite += dwStrLen; 00924 *StrToWrite = UNICODE_SPACE; 00925 StrToWrite++; 00926 AttrToSel += dwStrLen+DELIMITERWIDTH; 00927 SelCount++; 00928 if (lfBreak) 00929 break; 00930 } 00931 *StrToWrite = 0; 00932 dwDspLen = DispLenUnicode( String ); 00933 if (dwDspLen > (dwLength - CountDispWidth)) 00934 return SepIndex; 00935 00936 if (EnableCodePoint){ 00937 for (i = dwDspLen; i < dwLength; i++) { 00938 *StrToWrite = UNICODE_SPACE; 00939 StrToWrite++; 00940 } 00941 } 00942 else { 00943 for (i = dwDspLen; i < (dwLength - CountDispWidth); i++) { 00944 *StrToWrite = UNICODE_SPACE; 00945 StrToWrite++; 00946 } 00947 00948 i = (CountDispWidth-1) / 2; 00949 NumString(StrToWrite,lpCandList->dwSelection+1,i); 00950 StrToWrite+=i; 00951 *StrToWrite = UNICODE_SLASH; 00952 StrToWrite++; 00953 NumString(StrToWrite,lpCandList->dwCount, i); 00954 StrToWrite+=i; 00955 } 00956 *StrToWrite = 0; 00957 00958 return SepIndex; 00959 } 00960 00961 DWORD 00962 GetSystemLineT( 00963 LPCANDIDATELIST lpCandList , 00964 LPWSTR String, 00965 LPSTR Attr, 00966 DWORD dwLength, 00967 DWORD CountDispWidth, 00968 PCONSOLE_TABLE FocusedConsole 00969 ) 00970 { 00971 DWORD dwStrLen; 00972 DWORD dwDspLen; 00973 DWORD i; 00974 DWORD j; 00975 DWORD SepIndex; 00976 DWORD SelCount; 00977 DWORD Length; 00978 DWORD dwWholeLen; 00979 BOOL lfBreak = FALSE; 00980 LPWSTR StrToWrite; 00981 LPSTR AttrToSel; 00982 LPWSTR lpStr; 00983 USHORT MultiChar; 00984 USHORT TempMulti; 00985 00986 if ((lpCandList->dwSelection > lpCandList->dwCount)|| 00987 (lpCandList->dwSelection < 0)) { 00988 lpCandList->dwSelection = 0; 00989 } 00990 00991 for ( SepIndex = FocusedConsole->CandMax; SepIndex > 0; SepIndex--) { 00992 if (lpCandList->dwSelection >= FocusedConsole->CandSep[SepIndex]) 00993 break; 00994 } 00995 if (SepIndex == FocusedConsole->CandMax) 00996 SepIndex = 0; 00997 00998 for ( i = 0; i < dwLength; i++) { 00999 Attr[i] = 0x0000; 01000 } 01001 StrToWrite = String; 01002 AttrToSel = Attr; 01003 dwWholeLen = 0; 01004 if (FocusedConsole->ImmGetProperty & IME_PROP_CANDLIST_START_FROM_1) 01005 SelCount = 1; 01006 else 01007 SelCount = 0; 01008 01009 01010 for (i = FocusedConsole->CandSep[SepIndex]; i < FocusedConsole->CandSep[SepIndex+1]; i++) { 01011 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ i ]); 01012 dwStrLen = lstrlenW( lpStr ); 01013 dwDspLen = DispLenUnicode( lpStr ); 01014 01015 if ( dwWholeLen + dwDspLen + DELIMITERWIDTH > dwLength - CountDispWidth ){ 01016 Length = 0; 01017 lfBreak = TRUE; 01018 for (j = 0; j < dwStrLen; j++ ){ 01019 Length += IsUnicodeFullWidth(lpStr[j]) ? 2 : 1; 01020 if (dwWholeLen + Length > dwLength - (CountDispWidth + DELIMITERWIDTH)){ 01021 dwStrLen = j-1; 01022 dwDspLen = Length - IsUnicodeFullWidth(lpStr[j]) ? 2 : 1; 01023 break; 01024 } 01025 } 01026 } 01027 if ((dwWholeLen + dwDspLen + DELIMITERWIDTH + CountDispWidth ) <= dwLength ) // if minus value 01028 dwWholeLen += (dwDspLen + DELIMITERWIDTH); 01029 else { 01030 break; 01031 } 01032 01033 if (i == lpCandList->dwSelection) { 01034 for (j = 0; j < dwStrLen+2; j++) 01035 *(AttrToSel+j) = 1; 01036 } 01037 *StrToWrite = (USHORT)(SelCount + UNICODE_ZERO); 01038 StrToWrite++; 01039 *StrToWrite = UNICODE_COLON; 01040 StrToWrite++; 01041 CopyMemory(StrToWrite, lpStr, dwStrLen * sizeof(WCHAR)); 01042 StrToWrite += dwStrLen; 01043 *StrToWrite = UNICODE_SPACE; 01044 StrToWrite++; 01045 AttrToSel += dwStrLen+DELIMITERWIDTH; 01046 SelCount++; 01047 if (lfBreak) 01048 break; 01049 } 01050 *StrToWrite = 0; 01051 dwDspLen = DispLenUnicode( String ); 01052 if (dwDspLen > (dwLength - CountDispWidth)) 01053 return SepIndex; 01054 01055 *StrToWrite = UNICODE_SPACE; 01056 StrToWrite++; 01057 01058 i = (CountDispWidth-1) / 2; 01059 NumString(StrToWrite,lpCandList->dwSelection+1,i); 01060 StrToWrite+=i; 01061 *StrToWrite = UNICODE_SLASH; 01062 StrToWrite++; 01063 NumString(StrToWrite,lpCandList->dwCount, i); 01064 StrToWrite+=i; 01065 *StrToWrite = 0; 01066 01067 return SepIndex; 01068 } 01069 01070 DWORD 01071 GetSystemLineP( 01072 LPCANDIDATELIST lpCandList , 01073 LPWSTR String, 01074 LPSTR Attr, 01075 DWORD dwLength, 01076 DWORD CountDispWidth, 01077 PCONSOLE_TABLE FocusedConsole 01078 ) 01079 { 01080 DWORD dwStrLen; 01081 DWORD dwDspLen; 01082 DWORD i; 01083 DWORD j; 01084 DWORD SepIndex; 01085 DWORD SelCount; 01086 DWORD Length; 01087 DWORD dwWholeLen; 01088 BOOL lfBreak = FALSE; 01089 LPWSTR StrToWrite; 01090 LPSTR AttrToSel; 01091 LPWSTR lpStr; 01092 USHORT MultiChar; 01093 USHORT TempMulti; 01094 01095 if ((lpCandList->dwSelection > lpCandList->dwCount)|| 01096 (lpCandList->dwSelection < 0)) { 01097 lpCandList->dwSelection = 0; 01098 } 01099 01100 for ( SepIndex = FocusedConsole->CandMax; SepIndex > 0; SepIndex--) { 01101 if (lpCandList->dwSelection >= FocusedConsole->CandSep[SepIndex]) 01102 break; 01103 } 01104 if (SepIndex == FocusedConsole->CandMax) 01105 SepIndex = 0; 01106 01107 for ( i = 0; i < dwLength; i++) { 01108 Attr[i] = 0x0000; 01109 } 01110 StrToWrite = String; 01111 AttrToSel = Attr; 01112 dwWholeLen = 0; 01113 if (FocusedConsole->ImmGetProperty & IME_PROP_CANDLIST_START_FROM_1) 01114 SelCount = 1; 01115 else 01116 SelCount = 0; 01117 01118 for (i = FocusedConsole->CandSep[SepIndex]; i < FocusedConsole->CandSep[SepIndex+1]; i++) { 01119 lpStr = (LPWSTR)((LPSTR)lpCandList + lpCandList->dwOffset[ i ]); 01120 dwStrLen = lstrlenW( lpStr ); 01121 dwDspLen = DispLenUnicode( lpStr ); 01122 01123 if ( dwWholeLen + dwDspLen + DELIMITERWIDTH > dwLength - CountDispWidth ){ 01124 Length = 0; 01125 lfBreak = TRUE; 01126 for (j = 0; j < dwStrLen; j++ ){ 01127 Length += IsUnicodeFullWidth(lpStr[j]) ? 2 : 1; 01128 if (dwWholeLen + Length > dwLength - (CountDispWidth + DELIMITERWIDTH)){ 01129 dwStrLen = j-1; 01130 dwDspLen = Length - IsUnicodeFullWidth(lpStr[j]) ? 2 : 1; 01131 break; 01132 } 01133 } 01134 } 01135 if ((dwWholeLen + dwDspLen + DELIMITERWIDTH + CountDispWidth ) <= dwLength ) // if minus value 01136 dwWholeLen += (dwDspLen + DELIMITERWIDTH); 01137 else { 01138 break; 01139 } 01140 01141 if (i == lpCandList->dwSelection) { 01142 for (j = 0; j < dwStrLen+2; j++) 01143 *(AttrToSel+j) = 1; 01144 } 01145 *StrToWrite = (USHORT)(SelCount + UNICODE_ZERO); 01146 StrToWrite++; 01147 *StrToWrite = UNICODE_COLON; 01148 StrToWrite++; 01149 CopyMemory(StrToWrite, lpStr, dwStrLen * sizeof(WCHAR)); 01150 StrToWrite += dwStrLen; 01151 *StrToWrite = UNICODE_SPACE; 01152 StrToWrite++; 01153 AttrToSel += dwStrLen+DELIMITERWIDTH; 01154 SelCount++; 01155 if (lfBreak) 01156 break; 01157 } 01158 *StrToWrite = 0; 01159 dwDspLen = DispLenUnicode( String ); 01160 if (dwDspLen > (dwLength - CountDispWidth)) 01161 return SepIndex; 01162 01163 #if defined (CANDCOUNTPRC) //for wider candidate list space v-hirshi Oct.16.1996 01164 *StrToWrite = UNICODE_SPACE; 01165 StrToWrite++; 01166 01167 i = (CountDispWidth-1) / 2; 01168 NumString(StrToWrite,lpCandList->dwSelection+1,i); 01169 StrToWrite+=i; 01170 *StrToWrite = UNICODE_SLASH; 01171 StrToWrite++; 01172 NumString(StrToWrite,lpCandList->dwCount, i); 01173 StrToWrite+=i; 01174 #endif 01175 01176 *StrToWrite = 0; 01177 01178 return SepIndex; 01179 } 01180 01181 VOID 01182 NumString( 01183 LPWSTR StrToWrite, 01184 DWORD NumToDisp, 01185 DWORD CountDispWidth) 01186 { 01187 DWORD i; 01188 DWORD k; 01189 k = 1; 01190 for (i = 1; i < CountDispWidth; i++) 01191 k *= 10; 01192 for (i = k; i > 0; i /= 10){ 01193 k = (NumToDisp / i); 01194 *StrToWrite = (USHORT)(k + UNICODE_ZERO); 01195 if ((*StrToWrite == UNICODE_ZERO) && 01196 ((*(StrToWrite-1) == UNICODE_SPACE)||(*(StrToWrite-1) == UNICODE_SLASH)) ) 01197 *StrToWrite = UNICODE_SPACE; 01198 StrToWrite++; 01199 NumToDisp -= (i*k); 01200 } 01201 } 01202 01203 BOOL 01204 ImeUICloseCandidate( 01205 HWND hwnd, 01206 DWORD CandList 01207 ) 01208 { 01209 HIMC hIMC; 01210 PCONSOLE_TABLE ConTbl; 01211 01212 DBGPRINT(("CONIME: Get IMN_CLOSECANDIDATE Message\n")); 01213 01214 ConTbl = SearchConsole(LastConsole); 01215 if (ConTbl == NULL) { 01216 DBGPRINT(("CONIME: Error! Cannot found registed Console\n")); 01217 return FALSE; 01218 } 01219 01220 hIMC = ImmGetContext( hwnd ); 01221 if ( hIMC == 0 ) 01222 return FALSE; 01223 01224 // 01225 // Reset fInCandidate variables. 01226 // 01227 ConTbl->fInCandidate = FALSE; 01228 01229 switch ( HKL_TO_LANGID(ConTbl->hklActive)) 01230 { 01231 case LANG_ID_JAPAN: 01232 CloseCandidateJapan(hwnd, hIMC, ConTbl, CandList ); 01233 break; 01234 case LANG_ID_TAIWAN: 01235 CloseCandidateTaiwan(hwnd, hIMC, ConTbl, CandList ); 01236 break; 01237 case LANG_ID_PRC: 01238 CloseCandidatePRC(hwnd, hIMC, ConTbl, CandList ); 01239 break; 01240 case LANG_ID_KOREA: 01241 CloseCandidateKorea(hwnd, hIMC, ConTbl, CandList ); 01242 break; 01243 default: 01244 return FALSE; 01245 break; 01246 } 01247 ImmReleaseContext( hwnd, hIMC ); 01248 01249 return TRUE; 01250 } 01251 01252 BOOL 01253 CloseCandidateJapan( 01254 HWND hwnd, 01255 HIMC hIMC, 01256 PCONSOLE_TABLE ConTbl, 01257 DWORD CandList 01258 ) 01259 { 01260 DWORD dwIndex; 01261 COPYDATASTRUCT CopyData; 01262 01263 for (dwIndex = 0; dwIndex < MAX_LISTCAND ; dwIndex ++ ) { 01264 if ( CandList & ( 1 << dwIndex ) ) { 01265 if (ConTbl->lpCandListMem[dwIndex] != NULL ) { 01266 LocalFree(ConTbl->lpCandListMem[dwIndex]); 01267 ConTbl->lpCandListMem[dwIndex] = NULL; 01268 ConTbl->CandListMemAllocSize[dwIndex] = 0; 01269 } 01270 } 01271 } 01272 01273 CopyData.dwData = CI_CONIMECANDINFO; 01274 CopyData.cbData = 0; 01275 CopyData.lpData = NULL; 01276 ConsoleImeSendMessage( ConTbl->hWndCon, 01277 (WPARAM)hwnd, 01278 (LPARAM)&CopyData 01279 ); 01280 01281 return TRUE; 01282 } 01283 01284 BOOL 01285 CloseCandidateTaiwan( 01286 HWND hwnd, 01287 HIMC hIMC, 01288 PCONSOLE_TABLE ConTbl, 01289 DWORD CandList 01290 ) 01291 { 01292 DWORD dwIndex; 01293 COPYDATASTRUCT CopyData; 01294 LPCONIME_UIMODEINFO lpModeInfo; 01295 lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc( LPTR, sizeof(CONIME_UIMODEINFO) ); 01296 if ( lpModeInfo == NULL) { 01297 return FALSE; 01298 } 01299 01300 for (dwIndex = 0; dwIndex < MAX_LISTCAND ; dwIndex ++ ) { 01301 if ( CandList & ( 1 << dwIndex ) ) { 01302 if (ConTbl->lpCandListMem[dwIndex] != NULL ) { 01303 LocalFree(ConTbl->lpCandListMem[dwIndex]); 01304 ConTbl->lpCandListMem[dwIndex] = NULL; 01305 ConTbl->CandListMemAllocSize[dwIndex] = 0; 01306 } 01307 } 01308 } 01309 01310 CopyData.dwData = CI_CONIMEMODEINFO; 01311 CopyData.cbData = sizeof(CONIME_UIMODEINFO); 01312 CopyData.lpData = lpModeInfo; 01313 if (MakeInfoStringTaiwan(ConTbl, lpModeInfo) ) { 01314 ConsoleImeSendMessage( ConTbl->hWndCon, 01315 (WPARAM)hwnd, 01316 (LPARAM)&CopyData 01317 ); 01318 } 01319 01320 LocalFree( lpModeInfo ); 01321 return TRUE; 01322 01323 } 01324 01325 BOOL 01326 CloseCandidatePRC( 01327 HWND hwnd, 01328 HIMC hIMC, 01329 PCONSOLE_TABLE ConTbl, 01330 DWORD CandList 01331 ) 01332 { 01333 DWORD dwIndex; 01334 COPYDATASTRUCT CopyData; 01335 LPCONIME_UIMODEINFO lpModeInfo; 01336 lpModeInfo = (LPCONIME_UIMODEINFO)LocalAlloc( LPTR, sizeof(CONIME_UIMODEINFO) ); 01337 if ( lpModeInfo == NULL) { 01338 return FALSE; 01339 } 01340 01341 for (dwIndex = 0; dwIndex < MAX_LISTCAND ; dwIndex ++ ) { 01342 if ( CandList & ( 1 << dwIndex ) ) { 01343 if (ConTbl->lpCandListMem[dwIndex] != NULL ) { 01344 LocalFree(ConTbl->lpCandListMem[dwIndex]); 01345 ConTbl->lpCandListMem[dwIndex] = NULL; 01346 ConTbl->CandListMemAllocSize[dwIndex] = 0; 01347 } 01348 } 01349 } 01350 01351 CopyData.dwData = CI_CONIMEMODEINFO; 01352 CopyData.cbData = sizeof(CONIME_UIMODEINFO); 01353 CopyData.lpData = lpModeInfo; 01354 if (MakeInfoStringPRC(ConTbl, lpModeInfo) ) { 01355 ConsoleImeSendMessage( ConTbl->hWndCon, 01356 (WPARAM)hwnd, 01357 (LPARAM)&CopyData 01358 ); 01359 } 01360 01361 LocalFree( lpModeInfo ); 01362 return TRUE; 01363 01364 } 01365 01366 BOOL 01367 CloseCandidateKorea( 01368 HWND hwnd, 01369 HIMC hIMC, 01370 PCONSOLE_TABLE ConTbl, 01371 DWORD CandList 01372 ) 01373 { 01374 DWORD dwIndex; 01375 COPYDATASTRUCT CopyData; 01376 01377 for (dwIndex = 0; dwIndex < MAX_LISTCAND ; dwIndex ++ ) { 01378 if ( CandList & ( 1 << dwIndex ) ) { 01379 if (ConTbl->lpCandListMem[dwIndex] != NULL ) { 01380 LocalFree(ConTbl->lpCandListMem[dwIndex]); 01381 ConTbl->lpCandListMem[dwIndex] = NULL; 01382 ConTbl->CandListMemAllocSize[dwIndex] = 0; 01383 } 01384 } 01385 } 01386 01387 CopyData.dwData = CI_CONIMECANDINFO; 01388 CopyData.cbData = 0; 01389 CopyData.lpData = NULL; 01390 ConsoleImeSendMessage( ConTbl->hWndCon, 01391 (WPARAM)hwnd, 01392 (LPARAM)&CopyData 01393 ); 01394 01395 return TRUE; 01396 01397 }

Generated on Sat May 15 19:39:34 2004 for test by doxygen 1.3.7