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.

1833 lines
57 KiB

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "hwxobj.h"
  4. #include "resource.h"
  5. #include "../lib/plv/plv.h"
  6. #include "../lib/ptt/ptt.h"
  7. #ifdef FE_KOREAN
  8. #include "hanja.h"
  9. #else
  10. #include "../imeskdic/imeskdic.h"
  11. #endif
  12. #include "hwxfe.h"
  13. #include "cmnhdr.h"
  14. #ifdef UNDER_CE // Windows CE Stub for unsupported APIs
  15. #include "stub_ce.h"
  16. #endif // UNDER_CE
  17. // implementation of CHwxCAC
  18. TCHAR szBuf[MAX_PATH];
  19. TOOLINFOW ti;
  20. static HPEN ghOldPen = NULL;
  21. static HBITMAP ghOldBitmap = NULL;
  22. static WCHAR wchChar[8][40]; // use to query the dictionary
  23. #ifdef FE_JAPANESE
  24. static KANJIINFO kanji;
  25. const WORD wSamplePt[] =
  26. {0x350d,0x350e,0x3510,0x3513,0x3514,0x3515,0x3516,0x3517,0x3518,0,
  27. 0x191f,0x1822,0x1626,0x142a,0x132d,0x122f,0x1131,0x1033,0,
  28. 0x1a21,0x2420,0x301f,0x3a1f,0x441f,0x481f,0x4c1e,0x4f1e,
  29. 0x531d,0x5d1d,0x611d,0x621d,0x621e,0x621f,0x6221,0x6122,0x6023,0x5f25,
  30. 0x5d26,0x5a29,0x582c,0x562f,0,
  31. 0};
  32. const wchar_t wSampleChar[24] =
  33. {
  34. 0x5B80,0x30A6,0x30A5,0x6587,0x4E4B,0x3048,0x3047,0x5DFE,
  35. 0x5B57,0x5BF5,0x5BB9,0x5B9A,0x7A7A,0x5BF0,0x6848,0x5BC4,
  36. 0x5BA4,0x7AAE,0x5B9B,0x5BB3,0x7A81,0x5BDD,0x5BC7,0x5B8B
  37. };
  38. #endif // FE_JAPANESE
  39. CHwxCAC::CHwxCAC(CHwxInkWindow * pInk,HINSTANCE hInst):CHwxObject(hInst)
  40. {
  41. m_pInk = pInk;
  42. m_pCHwxThreadCAC = NULL;
  43. m_pCHwxStroke = NULL;
  44. m_hCACWnd = NULL;
  45. // m_hInstance = hInst;
  46. m_bLargeView = TRUE;
  47. m_gbDown = FALSE;
  48. m_bRightClick = FALSE;
  49. memset(m_gawch, '\0', sizeof(m_gawch));
  50. m_cnt = 0;
  51. if ( pInk )
  52. m_inkSize = pInk->GetCACInkHeight();
  53. else
  54. m_inkSize = PadWnd_Height;
  55. m_ghdc = NULL;
  56. m_ghbm = NULL;
  57. m_ghfntTT = NULL;
  58. m_hLVWnd = NULL;
  59. #ifdef FE_JAPANESE
  60. m_pIImeSkdic = NULL;
  61. m_hSkdic = NULL;
  62. #endif // FE_JAPANESE
  63. m_lpPlvInfo = NULL;
  64. m_hCursor = LoadCursor(NULL,IDC_ARROW);
  65. m_bResize = FALSE;
  66. #ifdef FE_JAPANESE
  67. memset(m_wchOther,'\0',sizeof(m_wchOther));
  68. #endif
  69. m_bDrawSample = FALSE;
  70. }
  71. CHwxCAC::~CHwxCAC()
  72. {
  73. m_pInk = NULL;
  74. // m_hInstance = NULL;
  75. if ( m_hCACWnd )
  76. {
  77. DestroyWindow(m_hCACWnd);
  78. m_hCACWnd = NULL;
  79. }
  80. if ( m_pCHwxThreadCAC )
  81. {
  82. delete m_pCHwxThreadCAC;
  83. m_pCHwxThreadCAC = NULL;
  84. }
  85. if ( m_pCHwxStroke )
  86. {
  87. delete m_pCHwxStroke;
  88. m_pCHwxStroke = NULL;
  89. }
  90. if ( m_ghdc )
  91. {
  92. if ( m_ghbm )
  93. {
  94. ghOldBitmap = SelectBitmap(m_ghdc,ghOldBitmap);
  95. DeleteBitmap(ghOldBitmap);
  96. ghOldBitmap = NULL;
  97. m_ghbm = NULL;
  98. }
  99. DeleteDC(m_ghdc);
  100. m_ghdc = NULL;
  101. }
  102. if ( m_ghfntTT )
  103. {
  104. DeleteObject(m_ghfntTT);
  105. m_ghfntTT = NULL;
  106. }
  107. if ( m_hLVWnd )
  108. {
  109. DestroyWindow(m_hLVWnd);
  110. m_hLVWnd = NULL;
  111. }
  112. #ifdef FE_KOREAN
  113. CloseLex();
  114. #else
  115. if ( m_pIImeSkdic )
  116. {
  117. m_pIImeSkdic->Release();
  118. m_pIImeSkdic = NULL;
  119. }
  120. if ( m_hSkdic )
  121. {
  122. FreeLibrary(m_hSkdic);
  123. m_hSkdic = NULL;
  124. }
  125. #endif
  126. m_lpPlvInfo = NULL;
  127. }
  128. BOOL CHwxCAC::Initialize(TCHAR * pClsName)
  129. {
  130. BOOL bRet = CHwxObject::Initialize(pClsName);
  131. if ( bRet )
  132. {
  133. WNDCLASS wc;
  134. wc.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS;
  135. wc.lpfnWndProc = CACWndProc;
  136. wc.cbClsExtra = 0;
  137. wc.cbWndExtra = sizeof(void *);
  138. wc.hInstance = m_hInstance;
  139. wc.hIcon = NULL;
  140. wc.hCursor = LoadCursor(NULL,MAKEINTRESOURCE(32631));
  141. #ifndef UNDER_CE
  142. wc.hbrBackground = (HBRUSH)(COLOR_3DFACE +1);
  143. #else // UNDER_CE
  144. wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  145. #endif // UNDER_CE
  146. wc.lpszMenuName = NULL;
  147. wc.lpszClassName = TEXT("MACAW");
  148. RegisterClass(&wc);
  149. bRet = Init();
  150. if ( !bRet )
  151. return FALSE;
  152. m_pCHwxThreadCAC = new CHwxThreadCAC(this);
  153. if ( !m_pCHwxThreadCAC )
  154. return FALSE;
  155. m_pCHwxStroke = new CHwxStroke(FALSE,32);
  156. if ( !m_pCHwxStroke )
  157. {
  158. delete m_pCHwxThreadCAC;
  159. m_pCHwxThreadCAC = NULL;
  160. return FALSE;
  161. }
  162. bRet = m_pCHwxThreadCAC->Initialize(TEXT("CHwxThreadCAC"));
  163. if ( !bRet && Is16BitApp() && m_pCHwxThreadCAC->IsHwxjpnLoaded() )
  164. {
  165. bRet = TRUE;
  166. }
  167. if ( !bRet )
  168. {
  169. delete m_pCHwxThreadCAC;
  170. m_pCHwxThreadCAC = NULL;
  171. delete m_pCHwxStroke;
  172. m_pCHwxStroke = NULL;
  173. return FALSE;
  174. }
  175. bRet = m_pCHwxStroke->Initialize(TEXT("CHwxStrokeCAC"));
  176. if ( !bRet )
  177. {
  178. delete m_pCHwxThreadCAC;
  179. m_pCHwxThreadCAC = NULL;
  180. delete m_pCHwxStroke;
  181. m_pCHwxStroke = NULL;
  182. return FALSE;
  183. }
  184. }
  185. return bRet;
  186. }
  187. typedef HRESULT (WINAPI * PFN)(void **);
  188. static TCHAR szDisp[2][60];
  189. static WCHAR wchDisp[2][60];
  190. BOOL CHwxCAC::Init()
  191. {
  192. // Create the font handles
  193. if ( IsNT() ) {
  194. #ifndef UNDER_CE // Windows CE does not support CreateFont
  195. static WCHAR wchFont[LF_FACESIZE];
  196. CHwxFE::GetDispFontW(m_hInstance, wchFont, sizeof(wchFont)/sizeof(wchFont[0]));
  197. m_ghfntTT = CreateFontW(-FONT_SIZE*2,
  198. 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
  199. OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
  200. DEFAULT_PITCH | FF_DONTCARE,
  201. wchFont);
  202. #else // UNDER_CE
  203. static LOGFONT lf = {-FONT_SIZE*2, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE,
  204. DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
  205. DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, {TEXT('\0')}};
  206. CHwxFE::GetDispFontW(m_hInstance, lf.lfFaceName,
  207. sizeof(lf.lfFaceName)/sizeof(lf.lfFaceName[0]));
  208. m_ghfntTT = CreateFontIndirect(&lf);
  209. #endif // UNDER_CE
  210. }
  211. else {
  212. #ifndef UNDER_CE // Windows CE always Unicode
  213. static CHAR chFont[LF_FACESIZE];
  214. CHwxFE::GetDispFontA(m_hInstance, chFont, sizeof(chFont));
  215. m_ghfntTT = CreateFontA(-FONT_SIZE*2,
  216. 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
  217. OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
  218. DEFAULT_PITCH | FF_DONTCARE, chFont);
  219. #endif // UNDER_CE
  220. }
  221. if ( !m_ghfntTT )
  222. {
  223. return FALSE;
  224. }
  225. //980324:by ToshiaK
  226. if(IsNT()) {
  227. CHwxFE::GetInkExpTextW(m_hInstance,
  228. wchDisp[0],
  229. sizeof(wchDisp[0])/sizeof(wchDisp[0][0]));
  230. CHwxFE::GetListExpTextW(m_hInstance,
  231. wchDisp[1],
  232. sizeof(wchDisp[1])/sizeof(wchDisp[1][0]));
  233. }
  234. else {
  235. #ifndef UNDER_CE // Windows CE always Unicode
  236. CHwxFE::GetInkExpTextA(m_hInstance,
  237. szDisp[0],
  238. sizeof(szDisp[0])/sizeof(szDisp[0][0]));
  239. CHwxFE::GetListExpTextA(m_hInstance,
  240. szDisp[1],
  241. sizeof(szDisp[1])/sizeof(szDisp[1][0]));
  242. #endif // UNDER_CE
  243. }
  244. //----------------------------------------------------------------
  245. //Below code is Japanese only
  246. //----------------------------------------------------------------
  247. #ifdef FE_JAPANESE
  248. m_hSkdic = NULL;
  249. m_pIImeSkdic = NULL;
  250. GetModuleFileName(m_hInstance, szBuf, sizeof(szBuf)/sizeof(szBuf[0]));
  251. #ifndef UNDER_CE
  252. TCHAR *p = strrchr(szBuf, (TCHAR)'\\');
  253. #else // UNDER_CE
  254. TCHAR *p = _tcsrchr(szBuf, TEXT('\\'));
  255. #endif // UNDER_CE
  256. p[1] = (TCHAR)0x00;
  257. #ifdef _DEBUG
  258. lstrcat(szBuf, TEXT("dbgskdic.dll"));
  259. #else
  260. lstrcat(szBuf, TEXT("imeskdic.dll"));
  261. #endif // !_DEBUG
  262. m_hSkdic = LoadLibrary(szBuf);
  263. m_pIImeSkdic = NULL;
  264. if (m_hSkdic ) {
  265. #ifndef UNDER_CE
  266. PFN lpfn =(PFN)GetProcAddress(m_hSkdic,"CreateIImeSkdicInstance");
  267. #else // UNDER_CE
  268. PFN lpfn =(PFN)GetProcAddress(m_hSkdic,TEXT("CreateIImeSkdicInstance"));
  269. #endif // UNDER_CE
  270. if(lpfn) {
  271. if(S_OK != (*lpfn)((void **)&m_pIImeSkdic) ) {
  272. FreeLibrary(m_hSkdic);
  273. m_hSkdic = NULL;
  274. }
  275. }
  276. else {
  277. FreeLibrary(m_hSkdic);
  278. m_hSkdic = NULL;
  279. }
  280. }
  281. #endif //FE_JAPANESE
  282. return TRUE;
  283. }
  284. void CHwxCAC::InitBitmap(DWORD nMask, int nItem)
  285. {
  286. RECT rc;
  287. if (nMask & MACAW_REDRAW_BACKGROUND)
  288. {
  289. rc.left = rc.top = 0;
  290. rc.right = rc.bottom = m_inkSize;
  291. #ifndef UNDER_CE
  292. FillRect(m_ghdc,&rc,(HBRUSH)(COLOR_3DFACE+1));
  293. #else // UNDER_CE
  294. FillRect(m_ghdc,&rc,GetSysColorBrush(COLOR_3DFACE));
  295. #endif // UNDER_CE
  296. InitBitmapBackground();
  297. if ( !nItem )
  298. {
  299. InitBitmapText();
  300. }
  301. ghOldPen = SelectPen(m_ghdc, GetStockObject(BLACK_PEN));
  302. return;
  303. }
  304. if (nMask & MACAW_REDRAW_INK)
  305. {
  306. InitBitmapBackground();
  307. if ( m_pCHwxStroke->GetNumStrokes() )
  308. {
  309. m_pCHwxStroke->DrawStroke(m_ghdc,0,TRUE);
  310. }
  311. else
  312. {
  313. InitBitmapText();
  314. }
  315. return;
  316. }
  317. }
  318. void CHwxCAC::InitBitmapText()
  319. {
  320. HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
  321. HFONT hOldFont = (HFONT)SelectObject( m_ghdc, hFont );
  322. RECT rc;
  323. rc.left = rc.top = 20;
  324. rc.right = rc.bottom = m_inkSize - 20;
  325. COLORREF colOld = SetTextColor( m_ghdc, GetSysColor(COLOR_3DSHADOW) );
  326. COLORREF colBkOld = SetBkColor( m_ghdc, GetSysColor(COLOR_WINDOW) );
  327. //980324: by ToshiaK
  328. if(IsNT()) {
  329. DrawTextW(m_ghdc, wchDisp[0], lstrlenW(wchDisp[0]), &rc, DT_VCENTER|DT_WORDBREAK );
  330. }
  331. else {
  332. DrawText( m_ghdc, szDisp[0], lstrlen(szDisp[0]), &rc,DT_VCENTER|DT_WORDBREAK );
  333. }
  334. SetTextColor( m_ghdc, colOld );
  335. SetBkColor( m_ghdc, colBkOld );
  336. SelectObject( m_ghdc, hOldFont );
  337. //980803:by ToshiaK. no need to delete. hFont is DEFAULT_GUI_FONT.
  338. //DeleteFont(hFont);
  339. }
  340. void CHwxCAC::InitBitmapBackground()
  341. {
  342. RECT rc;
  343. HBRUSH hOldBrush, hBrush;
  344. HPEN hOldPen;
  345. //----------------------------------------------------------------
  346. //980803:ToshiaK. PRC's merge. Use COLOR_WINDOW instead of WHITE_BRUSH
  347. //----------------------------------------------------------------
  348. #ifdef OLD980803
  349. hOldBrush = SelectBrush(m_ghdc, GetStockObject(WHITE_BRUSH));
  350. #endif
  351. hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
  352. hOldBrush = SelectBrush(m_ghdc, hBrush);
  353. hOldPen = SelectPen(m_ghdc, GetStockObject(BLACK_PEN));
  354. Rectangle(m_ghdc, 4, 4, m_inkSize-4, m_inkSize-4);
  355. rc.top = rc.left = 4;
  356. rc.bottom = rc.right = m_inkSize-4;
  357. DrawEdge(m_ghdc,&rc,EDGE_SUNKEN,BF_RECT);
  358. m_pInk->DrawHwxGuide(m_ghdc,&rc);
  359. hOldBrush = SelectBrush(m_ghdc, hOldBrush);
  360. hOldPen = SelectPen(m_ghdc, hOldPen);
  361. DeleteBrush(hOldBrush);
  362. DeletePen(hOldPen);
  363. }
  364. void CHwxCAC::HandleResizePaint(HWND hwnd)
  365. {
  366. if ( m_ghdc )
  367. {
  368. if ( ghOldPen )
  369. {
  370. ghOldPen = SelectPen(m_ghdc,ghOldPen);
  371. DeletePen(ghOldPen);
  372. ghOldPen = NULL;
  373. }
  374. if ( ghOldBitmap )
  375. {
  376. ghOldBitmap = SelectBitmap(m_ghdc,ghOldBitmap);
  377. DeleteBitmap(ghOldBitmap);
  378. ghOldBitmap = NULL;
  379. }
  380. DeleteDC(m_ghdc);
  381. }
  382. HDC hdc = GetDC(hwnd);
  383. m_ghbm = CreateCompatibleBitmap(hdc, m_inkSize,m_inkSize);
  384. m_ghdc = CreateCompatibleDC(hdc);
  385. ReleaseDC(hwnd, hdc);
  386. ghOldBitmap = SelectBitmap(m_ghdc, m_ghbm);
  387. InitBitmap(MACAW_REDRAW_BACKGROUND,m_gbDown ? 1 : 0);
  388. if ( GetStrokeCount() )
  389. InitBitmap(MACAW_REDRAW_INK,0);
  390. }
  391. BOOL CHwxCAC::CreateUI(HWND hwnd)
  392. {
  393. //990602:kotae #434: to remove flicker, add WS_CLIPCHILDREN
  394. m_hCACWnd = CreateWindowEx(0,
  395. TEXT("Macaw"),
  396. TEXT(""),
  397. WS_CHILD | WS_VISIBLE |WS_CLIPCHILDREN,
  398. 0,
  399. 0,
  400. 0,
  401. 0,
  402. hwnd,
  403. (HMENU)IDC_CACINPUT, //980706:for #1624. for "?" help.
  404. m_hInstance,
  405. this);
  406. if( !m_hCACWnd )
  407. {
  408. return FALSE;
  409. }
  410. m_hLVWnd = PadListView_CreateWindow(m_hInstance,
  411. m_hCACWnd, IDC_CACLISTVIEW,
  412. CW_USEDEFAULT,
  413. CW_USEDEFAULT,
  414. 500,
  415. CW_USEDEFAULT,
  416. CAC_WM_SENDRESULT);
  417. if ( !m_hLVWnd )
  418. {
  419. DestroyWindow(m_hCACWnd);
  420. m_hCACWnd = NULL;
  421. return FALSE;
  422. }
  423. // set style,callbacks,font,column
  424. PadListView_SetItemCount(m_hLVWnd, 0);
  425. PadListView_SetIconItemCallback(m_hLVWnd, (LPARAM)this, (LPFNPLVICONITEMCALLBACK)GetItemForIcon);
  426. #ifdef FE_JAPANESE
  427. PadListView_SetReportItemCallback(m_hLVWnd, (LPARAM)this,(LPFNPLVREPITEMCALLBACK)GetItemForReport);
  428. #endif
  429. //----------------------------------------------------------------
  430. //980727: by ToshiaK for ActiveIME support
  431. //----------------------------------------------------------------
  432. //980803:ToshiaK. FE merge.
  433. #ifndef UNDER_CE //#ifndef UNICODE
  434. static CHAR chFontName[LF_FACESIZE];
  435. CHwxFE::GetDispFontA(m_hInstance, chFontName, sizeof(chFontName));
  436. #else // UNDER_CE
  437. static TCHAR chFontName[LF_FACESIZE];
  438. CHwxFE::GetDispFontW(m_hInstance, chFontName, sizeof chFontName/sizeof chFontName[0]);
  439. #endif // UNDER_CE
  440. if(CHwxFE::IsActiveIMEEnv()) {
  441. PadListView_SetCodePage(m_hLVWnd, CHwxFE::GetAppCodePage());
  442. PadListView_SetHeaderFont(m_hLVWnd, chFontName);
  443. }
  444. //----------------------------------------------------------------
  445. //990810:ToshiaK KOTAE #1030.
  446. // Font's BUG. You should check Font's Charset.
  447. // Add new api for this. do not change PRC's code.
  448. //----------------------------------------------------------------
  449. #ifdef FE_JAPANESE
  450. PadListView_SetIconFontEx(m_hLVWnd, chFontName, SHIFTJIS_CHARSET, 16);
  451. PadListView_SetReportFontEx(m_hLVWnd, chFontName, SHIFTJIS_CHARSET, 12);
  452. #elif FE_KOREAN
  453. PadListView_SetIconFontEx(m_hLVWnd, chFontName, HANGUL_CHARSET, 12);
  454. PadListView_SetReportFontEx(m_hLVWnd, chFontName, HANGUL_CHARSET, 12);
  455. #else
  456. PadListView_SetIconFont(m_hLVWnd, chFontName, 16);
  457. PadListView_SetReportFont(m_hLVWnd, chFontName, 12);
  458. #endif
  459. PadListView_SetStyle(m_hLVWnd,PLVSTYLE_ICON);
  460. if(IsNT()) { //980324:by ToshiaK #526 for WinNT50
  461. PadListView_SetExplanationTextW(m_hLVWnd,wchDisp[1]);
  462. }
  463. else {
  464. #ifndef UNDER_CE // Windows CE always Unicode
  465. PadListView_SetExplanationText(m_hLVWnd,szDisp[1]);
  466. #endif // UNDER_CE
  467. }
  468. //----------------------------------------------------------------
  469. //Detail View is only implemented in Japanese Handwriting
  470. //----------------------------------------------------------------
  471. #ifdef FE_JAPANESE
  472. int i;
  473. for(i = 0; i < LISTVIEW_COLUMN; i++)
  474. {
  475. PLV_COLUMN plvCol;
  476. //980803:ToshiaK: moved to CHwxfe::GetHeaderStringA()
  477. #ifndef UNDER_CE //#ifndef UNICODE
  478. CHwxFE::GetHeaderStringA(m_hInstance, i, szBuf, sizeof(szBuf)/sizeof(szBuf[0]));
  479. #else // UNDER_CE
  480. CHwxFE::GetHeaderStringW(m_hInstance, i, szBuf, sizeof(szBuf)/sizeof(szBuf[0]));
  481. #endif // UNDER_CE
  482. plvCol.mask = PLVCF_FMT | PLVCF_WIDTH | PLVCF_TEXT;
  483. plvCol.fmt = PLVCFMT_LEFT;
  484. plvCol.pszText = szBuf;
  485. plvCol.cx = 60;
  486. plvCol.cchTextMax = lstrlen(szBuf);
  487. PadListView_InsertColumn(m_hLVWnd, i, &plvCol);
  488. }
  489. #endif //FE_JAPANESE
  490. SetToolTipInfo(TRUE);
  491. HandleResizePaint(m_hCACWnd);
  492. return TRUE;
  493. }
  494. void CHwxCAC::HandlePaint(HWND hwnd)
  495. {
  496. PAINTSTRUCT ps;
  497. RECT rcBkgnd;
  498. BeginPaint(hwnd, &ps);
  499. if ( ps.fErase )
  500. {
  501. rcBkgnd.left = m_inkSize;
  502. rcBkgnd.top = 0;
  503. rcBkgnd.right = m_pInk->GetCACWidth();
  504. rcBkgnd.bottom = m_pInk->GetCACHeight();
  505. #ifndef UNDER_CE
  506. FillRect(ps.hdc,&rcBkgnd,(HBRUSH)(COLOR_3DFACE+1));
  507. #else // UNDER_CE
  508. FillRect(ps.hdc,&rcBkgnd,GetSysColorBrush(COLOR_3DFACE));
  509. #endif // UNDER_CE
  510. if ( m_pInk->GetCACHeight() > m_inkSize )
  511. {
  512. rcBkgnd.left = 0;
  513. rcBkgnd.top = m_inkSize;
  514. rcBkgnd.right = m_inkSize;
  515. rcBkgnd.bottom = m_pInk->GetCACHeight();
  516. #ifndef UNDER_CE
  517. FillRect(ps.hdc,&rcBkgnd,(HBRUSH)(COLOR_3DFACE+1));
  518. #else // UNDER_CE
  519. FillRect(ps.hdc,&rcBkgnd,GetSysColorBrush(COLOR_3DFACE));
  520. #endif // UNDER_CE
  521. }
  522. }
  523. HandleResizePaint(hwnd);
  524. BitBlt(ps.hdc, 0, 0, m_inkSize, m_inkSize, m_ghdc, 0,0, SRCCOPY);
  525. if (m_gbDown)
  526. m_pCHwxStroke->DrawStroke(ps.hdc,-1,FALSE);
  527. EndPaint(hwnd, &ps);
  528. PadListView_Update(m_hLVWnd);
  529. }
  530. BOOL CHwxCAC::checkRange(int x, int y )
  531. {
  532. #if 1 //for KOTAE #818
  533. //Too ugly code...
  534. if(x < (4+2) ||(m_inkSize - (4+4-1)) < x) {
  535. return FALSE;
  536. }
  537. if(y < (4+2) || (m_inkSize - (4+4-1)) < y) {
  538. return FALSE;
  539. }
  540. return TRUE;
  541. #endif
  542. #if 0 //OLD CODE 990601;
  543. int inkSize = m_inkSize - 4;
  544. if ((x <= 2) || (x >= inkSize) || (y <= 2) || (y >= inkSize))
  545. return FALSE;
  546. return TRUE;
  547. #endif
  548. }
  549. BOOL CHwxCAC::IsPointInResizeBox(int x,int y)
  550. {
  551. int inkSize = m_inkSize - 4;
  552. if ((x <= inkSize) || (x >= (m_inkSize+4 )) || (y <= 4) || (y >= (m_pInk->GetCACHeight()-8)))
  553. return FALSE;
  554. return TRUE;
  555. }
  556. void CHwxCAC::recognize()
  557. {
  558. memset(m_gawch, '\0', sizeof(m_gawch));
  559. PadListView_SetItemCount(m_hLVWnd,0);
  560. if(IsNT()) { //980324:by ToshiaK #526 for WinNT50
  561. PadListView_SetExplanationTextW(m_hLVWnd, NULL);
  562. }
  563. else {
  564. PadListView_SetExplanationText(m_hLVWnd,NULL);
  565. }
  566. m_cnt = 0;
  567. int inkSize = m_inkSize - 4;
  568. PostThreadMessage(m_pCHwxThreadCAC->GetID(), THRDMSG_SETGUIDE, inkSize, 0);
  569. PostThreadMessage(m_pCHwxThreadCAC->GetID(), THRDMSG_RECOGNIZE, 0, 0);
  570. }
  571. void CHwxCAC::NoThreadRecognize(int boxSize)
  572. {
  573. memset(m_gawch, '\0', sizeof(m_gawch));
  574. PadListView_SetItemCount(m_hLVWnd,0);
  575. if(IsNT()) { //980324:toshiaK for #526
  576. PadListView_SetExplanationTextW(m_hLVWnd,NULL);
  577. }
  578. else {
  579. PadListView_SetExplanationText(m_hLVWnd,NULL);
  580. }
  581. PadListView_Update(m_hLVWnd);
  582. m_cnt = 0;
  583. m_pCHwxThreadCAC->RecognizeNoThread(boxSize);
  584. }
  585. void CHwxCAC::HandleMouseEvent(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
  586. {
  587. RECT rc;
  588. POINT pt;
  589. pt.x = (short) LOWORD(lp);
  590. pt.y = (short) HIWORD(lp);
  591. switch ( msg )
  592. {
  593. case WM_LBUTTONDBLCLK:
  594. case WM_LBUTTONDOWN:
  595. if (!m_gbDown && checkRange(pt.x,pt.y) )
  596. {
  597. if ( m_bRightClick )
  598. return;
  599. if ( m_pCHwxStroke->AddPoint(pt) )
  600. {
  601. m_gbDown = TRUE;
  602. if ( !GetStrokeCount() )
  603. {
  604. InvalidateRect(hwnd, NULL, FALSE);
  605. UpdateWindow(hwnd);
  606. }
  607. m_pCHwxStroke->GetUpdateRect(&rc);
  608. InvalidateRect(hwnd, &rc, FALSE);
  609. m_pCHwxStroke->IncStrokeCount();
  610. SetCapture(hwnd);
  611. if ( m_cnt && !m_pInk->IsSglClk() && !m_pInk->IsDblClk() )
  612. {
  613. memset(m_gawch, '\0', sizeof(m_gawch));
  614. m_cnt = 0;
  615. PadListView_SetItemCount(m_hLVWnd,0);
  616. if(IsNT()) { //ToshiaK:983024
  617. PadListView_SetExplanationTextW(m_hLVWnd,NULL);
  618. }
  619. else {
  620. PadListView_SetExplanationText(m_hLVWnd,NULL);
  621. }
  622. PadListView_Update(m_hLVWnd);
  623. }
  624. }
  625. }
  626. else if (IsPointInResizeBox(pt.x,pt.y) )
  627. {
  628. if ( !m_bResize )
  629. {
  630. m_pInk->SetCACInkHeight( m_inkSize = pt.x > INKBOXSIZE_MIN ? pt.x : INKBOXSIZE_MIN );
  631. m_pCHwxStroke->DeleteAllStroke();
  632. m_pInk->ChangeIMEPADSize(FALSE);
  633. m_pInk->ChangeLayout(FALSE);
  634. SetCapture(hwnd);
  635. m_bResize = TRUE;
  636. }
  637. }
  638. break;
  639. case WM_LBUTTONUP:
  640. if (m_gbDown)
  641. {
  642. //990602:Kotae #818
  643. if (pt.x < (4+2)) {
  644. pt.x = 4+2;
  645. }
  646. else if (pt.x >= (m_inkSize-(4+4-1))) {
  647. pt.x = m_inkSize-(4+4-1);
  648. }
  649. if (pt.y < (4+2)) {
  650. pt.y = 4+2;
  651. }
  652. else if (pt.y >= (m_inkSize-(4+4-1))) {
  653. pt.y = (m_inkSize-(4+4-1));
  654. }
  655. #if 0
  656. if (pt.x <= 2)
  657. pt.x = 4;
  658. else if (pt.x >= (m_inkSize-4))
  659. pt.x = (m_inkSize-4) - 1;
  660. if (pt.y <= 2)
  661. pt.y = 4;
  662. else if (pt.y >= (m_inkSize-4) )
  663. pt.y = (m_inkSize-4) - 1;
  664. #endif
  665. if ( m_pCHwxStroke->AddPoint(pt) )
  666. {
  667. m_pCHwxStroke->GetUpdateRect(&rc);
  668. InvalidateRect(hwnd, &rc, FALSE);
  669. m_gbDown = FALSE;
  670. ReleaseCapture();
  671. }
  672. m_pCHwxStroke->DecStrokeCount();
  673. if ( m_pCHwxStroke->AddBoxStroke(0,0,0) )
  674. {
  675. m_pCHwxStroke->DrawStroke(m_ghdc, -2, FALSE);
  676. if ( !Is16BitApp() && !m_bDrawSample && (m_pInk->IsSglClk() || m_pInk->IsDblClk()) )
  677. recognize();
  678. }
  679. }
  680. else if ( IsPointInResizeBox(pt.x,pt.y) )
  681. {
  682. if ( m_bResize )
  683. {
  684. m_pInk->SetCACInkHeight( m_inkSize = pt.x > INKBOXSIZE_MIN ? pt.x : INKBOXSIZE_MIN );
  685. m_pInk->ChangeIMEPADSize(FALSE);
  686. m_pInk->ChangeLayout(FALSE);
  687. ReleaseCapture();
  688. m_bResize = FALSE;
  689. }
  690. }
  691. else
  692. {
  693. if ( m_bResize )
  694. {
  695. if ( hwnd == GetCapture() )
  696. ReleaseCapture();
  697. m_hCursor = LoadCursor(NULL,IDC_ARROW);
  698. SetCursor(m_hCursor);
  699. m_bResize = FALSE;
  700. }
  701. }
  702. break;
  703. case WM_MOUSEMOVE:
  704. if (m_gbDown)
  705. {
  706. //fixed KOTAE #818
  707. if (pt.x < (4+2)) {
  708. pt.x = 4+2;
  709. }
  710. else if (pt.x >= (m_inkSize-(4+4-1))) {
  711. pt.x = m_inkSize-(4+4-1);
  712. }
  713. if (pt.y < (4+2)) {
  714. pt.y = 4+2;
  715. }
  716. else if (pt.y >= (m_inkSize-(4+4-1))) {
  717. pt.y = (m_inkSize-(4+4-1));
  718. }
  719. //These are original code.
  720. //Original code uses too much Magic Number
  721. //and miscalc rectangle size.
  722. #if 0
  723. if (pt.x <= 2)
  724. pt.x = 4;
  725. else if (pt.x >= (m_inkSize-4))
  726. pt.x = (m_inkSize-4) - 1;
  727. if (pt.y <= 2)
  728. pt.y = 4;
  729. else if (pt.y >= (m_inkSize-4))
  730. pt.y = (m_inkSize-4) - 1;
  731. #endif
  732. if ( m_gbDown = m_pCHwxStroke->AddPoint(pt) )
  733. {
  734. m_pCHwxStroke->GetUpdateRect(&rc);
  735. InvalidateRect(hwnd, &rc, FALSE);
  736. }
  737. }
  738. else if (hwnd == GetCapture() || IsPointInResizeBox(pt.x,pt.y) )
  739. {
  740. HCURSOR hCur = LoadCursor(NULL,IDC_SIZEWE);
  741. #ifndef UNDER_CE // CE specific
  742. m_hCursor = SetCursor(hCur);
  743. #else // UNDER_CE
  744. SetCursor(hCur);
  745. #endif // UNDER_CE
  746. if ( m_bResize )
  747. {
  748. //990810:ToshiaK for KOTAE #1661.
  749. //Limit's maximum size of ink box.
  750. INT cxScreen = ::GetSystemMetrics(SM_CXFULLSCREEN)/2;
  751. //INT cyScreen = ::GetSystemMetrics(SM_CYFULLSCREEN)/2;
  752. //OLD CODE
  753. //m_pInk->SetCACInkHeight( m_inkSize = pt.x > INKBOXSIZE_MIN ? pt.x : INKBOXSIZE_MIN );
  754. if(pt.x < INKBOXSIZE_MIN) {
  755. m_inkSize = INKBOXSIZE_MIN;
  756. }
  757. else if( cxScreen < pt.x) {
  758. m_inkSize = cxScreen;
  759. }
  760. else {
  761. m_inkSize = pt.x;
  762. }
  763. m_pInk->SetCACInkHeight(m_inkSize);
  764. m_pInk->ChangeIMEPADSize(FALSE);
  765. m_pInk->ChangeLayout(FALSE);
  766. }
  767. }
  768. else
  769. {
  770. if ( !m_bResize )
  771. SetCursor(m_hCursor);
  772. }
  773. break;
  774. case WM_RBUTTONDOWN:
  775. {
  776. if ( checkRange(pt.x,pt.y) )
  777. {
  778. m_bRightClick = TRUE;
  779. }
  780. }
  781. break;
  782. case WM_RBUTTONUP:
  783. {
  784. //----------------------------------------------------------------
  785. //971219:by ToshiaK for IME98 #1163:
  786. //If already WM_LBUTTONDOWN has come
  787. //Do not invoke popup menu.
  788. //----------------------------------------------------------------
  789. if(m_gbDown) {
  790. m_bRightClick = FALSE;
  791. break;
  792. }
  793. if ( checkRange(pt.x,pt.y) )
  794. {
  795. HMENU hMenu;
  796. HMENU hMenuTrackPopup;
  797. //----------------------------------------------------------------
  798. //fixed MSKK #5035.Need to load specified language's menu resource
  799. //BUGBUG::hMenu = LoadMenu (m_hInstance, MAKEINTRESOURCE(IDR_CACINK));
  800. //----------------------------------------------------------------
  801. hMenu = CHwxFE::GetMenu(m_hInstance, MAKEINTRESOURCE(IDR_CACINK));
  802. if (hMenu)
  803. {
  804. hMenuTrackPopup = GetSubMenu (hMenu, 0);
  805. if ( Is16BitApp() )
  806. {
  807. EnableMenuItem(hMenuTrackPopup,4,MF_BYPOSITION | MF_GRAYED);
  808. }
  809. else
  810. {
  811. if ( m_pInk->IsDblClk() )
  812. {
  813. CheckMenuItem(hMenuTrackPopup,4,MF_BYPOSITION | MF_CHECKED);
  814. }
  815. else
  816. {
  817. CheckMenuItem(hMenuTrackPopup,4,MF_BYPOSITION | MF_UNCHECKED);
  818. }
  819. }
  820. ClientToScreen(m_hCACWnd,&pt);
  821. #ifndef UNDER_CE // Windows CE does not support TPM_LEFTBUTTON on TrackPopupMenu
  822. TrackPopupMenu (hMenuTrackPopup, TPM_LEFTALIGN | TPM_LEFTBUTTON, pt.x, pt.y, 0,m_hCACWnd, NULL);
  823. #else // UNDER_CE
  824. TrackPopupMenu(hMenuTrackPopup, TPM_LEFTALIGN, pt.x, pt.y, 0,m_hCACWnd, NULL);
  825. #endif // UNDER_CE
  826. DestroyMenu (hMenu);
  827. }
  828. m_bRightClick = FALSE;
  829. }
  830. }
  831. break;
  832. }
  833. Unref(wp);
  834. }
  835. BOOL CHwxCAC::IsDupResult(WORD wd)
  836. {
  837. BOOL bRet = FALSE;
  838. for ( int i = 0; i < m_cnt; i++)
  839. {
  840. if ( m_gawch[i] == wd )
  841. {
  842. bRet = TRUE;
  843. break;
  844. }
  845. }
  846. return bRet;
  847. }
  848. void CHwxCAC::HandleRecogResult(HWND hwnd,WPARAM wp, LPARAM lp)
  849. {
  850. DWORD cstr;
  851. int list;
  852. int nItem = HIWORD(lp);
  853. list = (wp >> 8) & 0x00ff;
  854. cstr = wp & 0x00ff;
  855. if ( cstr == (DWORD)GetStrokeCount() )
  856. {
  857. WCHAR wch = (WCHAR)lp;
  858. if ( list )
  859. {
  860. if ( !IsDupResult( wch ) )
  861. {
  862. m_gawch[m_cnt++] = wch;
  863. }
  864. }
  865. else
  866. {
  867. m_gawch[nItem] = wch;
  868. m_cnt = nItem + 1;
  869. }
  870. }
  871. Unref(hwnd);
  872. }
  873. void CHwxCAC::HandleShowRecogResult(HWND hwnd,WPARAM wp, LPARAM lp)
  874. {
  875. if ( m_cnt )
  876. {
  877. PadListView_SetItemCount(m_hLVWnd,m_cnt);
  878. if(IsNT()) { //ToshiaK:980324
  879. PadListView_SetExplanationTextW(m_hLVWnd,NULL);
  880. }
  881. else {
  882. PadListView_SetExplanationText(m_hLVWnd,NULL);
  883. }
  884. PadListView_Update(m_hLVWnd);
  885. }
  886. Unref(hwnd);
  887. Unref(wp);
  888. Unref(lp);
  889. }
  890. void CHwxCAC::pickUpChar(LPPLVINFO lpPlvInfo)
  891. {
  892. WCHAR wch;
  893. wch = GetWCHAR(m_lpPlvInfo->index);
  894. if ( wch )
  895. {
  896. pickUpCharHelper(wch);
  897. }
  898. Unref(lpPlvInfo);
  899. }
  900. void CHwxCAC::pickUpCharHelper(WCHAR wch)
  901. {
  902. (m_pInk->GetAppletPtr())->SendHwxChar(wch);
  903. // 16 bit app, single/double click on recog button
  904. if ( Is16BitApp() )
  905. {
  906. HandleDeleteAllStroke();
  907. }
  908. else
  909. {
  910. if ( m_pInk->IsSglClk() )
  911. {
  912. m_pInk->SetSglClk(FALSE);
  913. HandleDeleteAllStroke();
  914. }
  915. if ( m_pInk->IsDblClk() )
  916. HandleDeleteAllStroke();
  917. if ( !m_pInk->IsSglClk() && !m_pInk->IsDblClk() )
  918. HandleDeleteAllStroke();
  919. }
  920. }
  921. HBITMAP CHwxCAC::makeCharBitmap(WCHAR wch)
  922. {
  923. HDC hdcTmp;
  924. RECT rc ={0,0,32,32};
  925. HDC hdc;
  926. HBITMAP hBmp;
  927. HBITMAP hBmpOld;
  928. HFONT hFontOld;
  929. hBmp = LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDB_CHARBMP));
  930. hdc = GetDC( (HWND)m_hCACWnd );
  931. hdcTmp = CreateCompatibleDC( hdc );
  932. hBmpOld = (HBITMAP)SelectObject( hdcTmp, hBmp );
  933. hFontOld = (HFONT)SelectObject( hdcTmp, m_ghfntTT );
  934. ExtTextOutW( hdcTmp, rc.left+2,rc.top+2,ETO_CLIPPED,&rc,&wch,1,NULL);
  935. SelectObject( hdcTmp, hFontOld );
  936. SelectObject( hdcTmp , hBmpOld );
  937. DeleteDC( hdcTmp );
  938. ReleaseDC( (HWND)m_hCACWnd, hdc );
  939. return hBmp;
  940. }
  941. void CHwxCAC::HandleSendResult(HWND hwnd,WPARAM wp,LPARAM lp)
  942. {
  943. m_lpPlvInfo = (LPPLVINFO)lp;
  944. switch (m_lpPlvInfo->code)
  945. {
  946. case PLVN_ITEMPOPED:
  947. #ifdef UNDER_CE // ButtonDown/Up ToolTip
  948. case PLVN_ITEMDOWN:
  949. #endif // UNDER_CE
  950. {
  951. if ( m_bLargeView )
  952. {
  953. SetToolTipInfo(FALSE);
  954. //970902: ToshiaK for #1215, #1231
  955. TOOLTIPUSERINFO ttInfo;
  956. #ifndef UNDER_CE // CE Specific(ptt use ClientToScreen(ttInfo.hwnd,&ttInfo.pt) )
  957. ttInfo.hwnd = m_hCACWnd;
  958. #else // UNDER_CE
  959. ttInfo.hwnd = m_hLVWnd;
  960. #endif // UNDER_CE
  961. ttInfo.pt = m_lpPlvInfo->pt;
  962. ttInfo.rect = m_lpPlvInfo->itemRect;
  963. ttInfo.lParam = (LPARAM)m_lpPlvInfo->index;
  964. SendMessage(m_pInk->GetToolTipWindow(),
  965. TTM_RELAYEVENT_WITHUSERINFO,
  966. 0,(LPARAM)(LPTOOLTIPUSERINFO)&ttInfo);
  967. }
  968. }
  969. break;
  970. #ifdef UNDER_CE // ButtonDown/Up ToolTip
  971. case PLVN_ITEMUP:
  972. {
  973. if ( m_bLargeView )
  974. {
  975. SetToolTipInfo(FALSE);
  976. TOOLTIPUSERINFO ttInfo;
  977. ZeroMemory(&ttInfo, sizeof(ttInfo));
  978. SendMessage(m_pInk->GetToolTipWindow(),
  979. TTM_RELAYEVENT_WITHUSERINFO,
  980. 0,(LPARAM)&ttInfo);
  981. }
  982. }
  983. break;
  984. #endif // UNDER_CE
  985. case PLVN_ITEMCLICKED:
  986. if ( m_lpPlvInfo ) {
  987. //971219:fixed #3466
  988. if(m_lpPlvInfo->colIndex == 0) {
  989. pickUpChar(m_lpPlvInfo);
  990. }
  991. }
  992. break;
  993. case PLVN_ITEMCOLUMNCLICKED:
  994. break;
  995. case PLVN_ITEMDBLCLICKED:
  996. break;
  997. case PLVN_ITEMCOLUMNDBLCLICKED:
  998. break;
  999. //////////////////////////////////////////////////////////////////////////////
  1000. // !!! CAC context menu Start !!!
  1001. #ifdef FE_JAPANESE
  1002. case PLVN_R_ITEMCLICKED:
  1003. {
  1004. HMENU hMenu;
  1005. HMENU hMenuTrackPopup,hMenuSub;
  1006. POINT pt = m_lpPlvInfo->pt;
  1007. //----------------------------------------------------------------
  1008. //fixed MSKK #5035.Need to load specified language's menu resource
  1009. //BUGBUG::hMenu = LoadMenu (m_hInstance, MAKEINTRESOURCE(IDR_CACLV));
  1010. //----------------------------------------------------------------
  1011. hMenu = CHwxFE::GetMenu(m_hInstance, MAKEINTRESOURCE(IDR_CACLV));
  1012. if (hMenu)
  1013. {
  1014. hMenuTrackPopup = GetSubMenu (hMenu, 0);
  1015. ClientToScreen(m_hLVWnd,&pt);
  1016. hMenuSub = GetSubMenu(hMenuTrackPopup,2);
  1017. if ( m_bLargeView )
  1018. {
  1019. CheckMenuItem(hMenuSub,1,MF_BYPOSITION | MF_UNCHECKED);
  1020. CheckMenuItem(hMenuSub,0,MF_BYPOSITION | MF_CHECKED);
  1021. }
  1022. else
  1023. {
  1024. CheckMenuItem(hMenuSub,0,MF_BYPOSITION | MF_UNCHECKED);
  1025. CheckMenuItem(hMenuSub,1,MF_BYPOSITION | MF_CHECKED);
  1026. }
  1027. WCHAR wch;
  1028. wch = GetWCHAR(m_lpPlvInfo->index);
  1029. #ifdef OLD_970811 //ToshiaK. do not load radical bitmap for #1231
  1030. kanji.mask = KIF_ALL;
  1031. #else
  1032. kanji.mask = KIF_YOMI | KIF_ITAIJI;
  1033. #endif
  1034. kanji.cItaijiCount = 0;
  1035. memset(kanji.wchItaiji,'\0',sizeof(kanji.wchItaiji));
  1036. memset(m_wchOther,'\0',sizeof(m_wchOther));
  1037. if ( wch && m_pIImeSkdic )
  1038. {
  1039. m_pIImeSkdic->GetKanjiInfo(wch,&kanji);
  1040. }
  1041. HBITMAP hBmp[MAX_ITAIJI_COUNT+1]= {NULL};
  1042. if ( kanji.cItaijiCount )
  1043. {
  1044. DeleteMenu( hMenuTrackPopup, IDM_CACLVSENDOTHER_NONE, MF_BYCOMMAND );
  1045. for ( int ibmp = 0; ibmp < kanji.cItaijiCount; ibmp++)
  1046. {
  1047. #ifndef UNDER_CE // Windows CE does not support MF_BITMAP on AppendMenu
  1048. hBmp[ibmp] = makeCharBitmap(kanji.wchItaiji[ibmp]);
  1049. m_wchOther[ibmp] = kanji.wchItaiji[ibmp];
  1050. AppendMenu(GetSubMenu(hMenuTrackPopup,1) , MF_BITMAP, IDM_CACLVSENDOTHER_NONE+100+ibmp, (LPCTSTR)hBmp[ibmp] );
  1051. #else // UNDER_CE
  1052. TCHAR chItaiji[2] = {kanji.wchItaiji[ibmp], TEXT('\0')};
  1053. AppendMenu(GetSubMenu(hMenuTrackPopup,1), MF_STRING,
  1054. IDM_CACLVSENDOTHER_NONE+100+ibmp, chItaiji);
  1055. #endif // UNDER_CE
  1056. }
  1057. }
  1058. else
  1059. {
  1060. EnableMenuItem(hMenuTrackPopup,1,MF_BYPOSITION | MF_GRAYED);
  1061. }
  1062. #if 1 // kwada : bold menu item
  1063. #ifndef UNDER_CE // Windows CE does not support SetMenuDefaultItem
  1064. SetMenuDefaultItem(hMenuTrackPopup,IDM_CACLVSENDCHAR,FALSE);
  1065. #endif // UNDER_CE
  1066. #endif
  1067. #ifndef UNDER_CE // Windows CE does not support TPM_LEFTBUTTON on TrackPopupMenu
  1068. TrackPopupMenu (hMenuTrackPopup, TPM_LEFTALIGN | TPM_LEFTBUTTON, pt.x, pt.y, 0,m_hCACWnd, NULL);
  1069. #else // UNDER_CE
  1070. TrackPopupMenu(hMenuTrackPopup, TPM_LEFTALIGN, pt.x, pt.y, 0,m_hCACWnd, NULL);
  1071. #endif // UNDER_CE
  1072. DestroyMenu (hMenu);
  1073. if( hBmp[0] )
  1074. {
  1075. for( int i=0; i<kanji.cItaijiCount; i++ )
  1076. {
  1077. if( hBmp[i] )
  1078. {
  1079. DeleteObject( hBmp[i] );
  1080. }
  1081. }
  1082. }
  1083. }
  1084. }
  1085. break;
  1086. #endif // FE_JAPANESE
  1087. // !!! CAC context menu END !!!
  1088. //////////////////////////////////////////////////////////////////////////////
  1089. case PLVN_R_ITEMCOLUMNCLICKED:
  1090. break;
  1091. case PLVN_R_ITEMDBLCLICKED:
  1092. break;
  1093. case PLVN_R_ITEMCOLUMNDBLCLICKED:
  1094. break;
  1095. case PLVN_HDCOLUMNCLICKED:
  1096. #ifdef FE_JAPANESE
  1097. if ( m_lpPlvInfo )
  1098. sortKanjiInfo(m_lpPlvInfo->colIndex - 0);
  1099. PadListView_Update(m_hLVWnd);
  1100. #endif
  1101. break;
  1102. default:
  1103. break;
  1104. }
  1105. Unref(hwnd);
  1106. Unref(wp);
  1107. }
  1108. void CHwxCAC::GetInkFromMB(CHwxStroke & str,long deltaX,long deltaY)
  1109. {
  1110. *m_pCHwxStroke = str;
  1111. if ( !GetStrokeCount() )
  1112. {
  1113. return;
  1114. }
  1115. m_pCHwxStroke->ScaleInkXY(deltaX,deltaY);
  1116. long X = (m_pInk->GetMBHeight() - m_inkSize)/2;
  1117. long Y = (m_pInk->GetMBHeight() - m_inkSize)/2;
  1118. if ( X || Y )
  1119. m_pCHwxStroke->ScaleInkXY(X,Y);
  1120. HandleResizePaint(m_hCACWnd);
  1121. if ( m_pInk->IsSglClk() || m_pInk->IsDblClk() )
  1122. recognize();
  1123. }
  1124. void CHwxCAC::HandleDeleteOneStroke()
  1125. {
  1126. if ( GetStrokeCount() )
  1127. m_pCHwxStroke->EraseCurrentStroke();
  1128. if ( !GetStrokeCount() )
  1129. {
  1130. memset(m_gawch, '\0', sizeof(m_gawch));
  1131. m_cnt = 0;
  1132. PadListView_SetItemCount(m_hLVWnd,0);
  1133. if(IsNT()) { //ToshiaK:980324
  1134. PadListView_SetExplanationTextW(m_hLVWnd,wchDisp[1]);
  1135. }
  1136. else {
  1137. #ifndef UNDER_CE // Windows CE always Unicode
  1138. PadListView_SetExplanationText(m_hLVWnd,szDisp[1]);
  1139. #endif // UNDER_CE
  1140. }
  1141. PadListView_Update(m_hLVWnd);
  1142. InitBitmap(MACAW_REDRAW_BACKGROUND, 0);
  1143. InitBitmap(MACAW_REDRAW_INK, 0);
  1144. InvalidateRect(m_hCACWnd, NULL, FALSE);
  1145. return;
  1146. }
  1147. if ( !Is16BitApp() && ( m_pInk->IsSglClk() || m_pInk->IsDblClk()) )
  1148. recognize();
  1149. PadListView_Update(m_hLVWnd);
  1150. InitBitmap(MACAW_REDRAW_INK, 0);
  1151. InvalidateRect(m_hCACWnd, NULL, FALSE);
  1152. }
  1153. void CHwxCAC::HandleDeleteAllStroke()
  1154. {
  1155. if ( GetStrokeCount() )
  1156. {
  1157. m_pCHwxStroke->DeleteAllStroke();
  1158. InitBitmap(MACAW_REDRAW_BACKGROUND, 0);
  1159. InvalidateRect(m_hCACWnd, NULL, FALSE);
  1160. }
  1161. }
  1162. LRESULT CHwxCAC::HandleCommand(HWND hwnd, UINT msg, WPARAM wp,LPARAM lp)
  1163. {
  1164. UINT uCode =(UINT)LOWORD(wp);
  1165. WCHAR wch;
  1166. switch ( uCode )
  1167. {
  1168. case IDM_CACRECOG:
  1169. if ( Is16BitApp() )
  1170. {
  1171. m_pCHwxThreadCAC->RecognizeNoThread(m_inkSize);
  1172. }
  1173. else
  1174. {
  1175. if ( !m_pInk->IsDblClk() && !m_pInk->IsSglClk() )
  1176. {
  1177. m_pInk->SetSglClk(TRUE);
  1178. recognize();
  1179. }
  1180. }
  1181. return 0;
  1182. case IDM_CACDELETEONE:
  1183. HandleDeleteOneStroke();
  1184. return 0;
  1185. case IDM_CACDELETEALL:
  1186. HandleDeleteAllStroke();
  1187. return 0;
  1188. case IDM_CACAUTORECOG:
  1189. // no 16 bit app events here
  1190. if ( !Is16BitApp() )
  1191. {
  1192. m_pInk->SetDblClk(!m_pInk->IsDblClk());
  1193. m_pInk->UpdateRegistry(TRUE/*fSet*/); //SATORI #73 by HiroakiK
  1194. if ( m_pInk->IsDblClk() )
  1195. recognize();
  1196. }
  1197. return 0;
  1198. case IDM_CACLVSENDCHAR:
  1199. if ( m_lpPlvInfo )
  1200. pickUpChar(m_lpPlvInfo);
  1201. return 0;
  1202. case IDM_CACLVSENDOTHER_NONE+100:
  1203. case IDM_CACLVSENDOTHER_NONE+101:
  1204. case IDM_CACLVSENDOTHER_NONE+102:
  1205. case IDM_CACLVSENDOTHER_NONE+103:
  1206. case IDM_CACLVSENDOTHER_NONE+104:
  1207. case IDM_CACLVSENDOTHER_NONE+105:
  1208. case IDM_CACLVSENDOTHER_NONE+106:
  1209. case IDM_CACLVSENDOTHER_NONE+107:
  1210. case IDM_CACLVSENDOTHER_NONE+108:
  1211. case IDM_CACLVSENDOTHER_NONE+109:
  1212. case IDM_CACLVSENDOTHER_NONE+110:
  1213. case IDM_CACLVSENDOTHER_NONE+111:
  1214. case IDM_CACLVSENDOTHER_NONE+112:
  1215. case IDM_CACLVSENDOTHER_NONE+113:
  1216. case IDM_CACLVSENDOTHER_NONE+114:
  1217. case IDM_CACLVSENDOTHER_NONE+115:
  1218. case IDM_CACLVSENDOTHER_NONE+116:
  1219. #ifdef FE_JAPANESE
  1220. if ( wch = m_wchOther[uCode-(IDM_CACLVSENDOTHER_NONE+100)] )
  1221. pickUpCharHelper(wch);
  1222. memset(m_wchOther,'\0',sizeof(m_wchOther));
  1223. #endif
  1224. return 0;
  1225. case IDM_CACLVDISPLAY_LARGE:
  1226. if ( !m_bLargeView )
  1227. {
  1228. PadListView_SetStyle(m_hLVWnd,PLVSTYLE_ICON);
  1229. // m_pInk->SetLargeBtn();
  1230. m_bLargeView = TRUE;
  1231. if(m_pInk) {
  1232. m_pInk->OnChangeView(TRUE);
  1233. }
  1234. }
  1235. return 0;
  1236. case IDM_CACLVDISPLAY_DETAIL:
  1237. if ( m_bLargeView )
  1238. {
  1239. PadListView_SetStyle(m_hLVWnd,PLVSTYLE_REPORT);
  1240. m_bLargeView = FALSE;
  1241. if(m_pInk) {
  1242. m_pInk->OnChangeView(FALSE);
  1243. }
  1244. }
  1245. return 0;
  1246. #ifdef FE_JAPANESE
  1247. case IDM_CACLVDISPLAYOTHER_KANJI:
  1248. case IDM_CACLVDISPLAYOTHER_STROKE:
  1249. case IDM_CACLVDISPLAYOTHER_RADICAL:
  1250. case IDM_CACLVDISPLAYOTHER_R1:
  1251. case IDM_CACLVDISPLAYOTHER_R2:
  1252. case IDM_CACLVDISPLAYOTHER_K1:
  1253. case IDM_CACLVDISPLAYOTHER_K2:
  1254. case IDM_CACLVDISPLAYOTHER_OTHER:
  1255. sortKanjiInfo(uCode-IDM_CACLVDISPLAYOTHER_KANJI);
  1256. PadListView_Update(m_hLVWnd);
  1257. return 0;
  1258. #endif // FE_JAPANESE
  1259. default:
  1260. break;
  1261. }
  1262. return DefWindowProc(hwnd, msg, wp, lp);
  1263. }
  1264. //----------------------------------------------------------------
  1265. //990618:ToshiaK for KOTAE #1329
  1266. //----------------------------------------------------------------
  1267. void
  1268. CHwxCAC::OnSettingChange(UINT msg, WPARAM wp,LPARAM lp)
  1269. {
  1270. #ifndef UNDER_CE // Unsupported.
  1271. if(wp == SPI_SETNONCLIENTMETRICS) {
  1272. if(m_pCHwxStroke) {
  1273. m_pCHwxStroke->ResetPen();
  1274. }
  1275. }
  1276. #else // UNDER_CE
  1277. if(m_pCHwxStroke) {
  1278. m_pCHwxStroke->ResetPen();
  1279. }
  1280. #endif // UNDER_CE
  1281. UNREFERENCED_PARAMETER(msg);
  1282. UNREFERENCED_PARAMETER(lp);
  1283. }
  1284. int WINAPI GetItemForIcon(LPARAM lParam, int index, LPPLVITEM lpPlvItem)
  1285. {
  1286. CHwxCAC * pCac = (CHwxCAC *)lParam;
  1287. if ( pCac )
  1288. {
  1289. wchChar[0][0] = pCac->GetWCHAR(index);
  1290. wchChar[0][1] = (WCHAR)0x0000;
  1291. if ( wchChar[0][0] )
  1292. {
  1293. lpPlvItem->lpwstr = wchChar[0];
  1294. }
  1295. else
  1296. {
  1297. lpPlvItem->lpwstr = NULL;
  1298. }
  1299. }
  1300. return 0;
  1301. }
  1302. #ifdef FE_JAPANESE
  1303. int WINAPI GetItemForReport(LPARAM lParam, int index, INT indexCol, LPPLVITEM lpPlvItem)
  1304. {
  1305. CHwxCAC * pCac = (CHwxCAC *)lParam;
  1306. WCHAR wch;
  1307. if ( pCac && (wch = pCac->GetWCHAR(index)) && indexCol <= 8 )
  1308. {
  1309. memset(&kanji,'\0',sizeof(kanji));
  1310. kanji.mask = KIF_ALL;
  1311. //981119: for KK RAID #6435
  1312. //case for imeskdic.dll does not exist.
  1313. if(pCac->GetIIMESKDIC()){
  1314. (pCac->GetIIMESKDIC())->GetKanjiInfo(wch,&kanji);
  1315. }
  1316. for ( int i = 0; i < indexCol; i++)
  1317. {
  1318. switch(i)
  1319. {
  1320. case 0:
  1321. lpPlvItem[i].fmt = PLVFMT_TEXT;
  1322. wchChar[i][0] = wch;
  1323. wchChar[i][1] = (WCHAR)0x0000;
  1324. lpPlvItem[i].lpwstr = wchChar[i];
  1325. break;
  1326. case 1:
  1327. lpPlvItem[i].fmt = PLVFMT_TEXT;
  1328. if ( kanji.usTotalStroke )
  1329. {
  1330. swprintf(wchChar[i], L"%d", kanji.usTotalStroke);
  1331. }
  1332. else
  1333. {
  1334. wchChar[i][0] = (WCHAR)0x0000;
  1335. }
  1336. lpPlvItem[i].lpwstr = wchChar[i];
  1337. break;
  1338. case 2:
  1339. lpPlvItem[i].fmt = PLVFMT_BITMAP;
  1340. lpPlvItem[i].hBitmap = kanji.hBmpRadical;
  1341. break;
  1342. case 3:
  1343. lpPlvItem[i].fmt = PLVFMT_TEXT;
  1344. lpPlvItem[i].lpwstr = kanji.wchOnYomi1;
  1345. break;
  1346. case 4:
  1347. lpPlvItem[i].fmt = PLVFMT_TEXT;
  1348. lpPlvItem[i].lpwstr = kanji.wchOnYomi2;
  1349. break;
  1350. case 5:
  1351. lpPlvItem[i].fmt = PLVFMT_TEXT;
  1352. lpPlvItem[i].lpwstr = kanji.wchKunYomi1;
  1353. break;
  1354. case 6:
  1355. lpPlvItem[i].fmt = PLVFMT_TEXT;
  1356. lpPlvItem[i].lpwstr = kanji.wchKunYomi2;
  1357. break;
  1358. case 7:
  1359. lpPlvItem[i].fmt = PLVFMT_TEXT;
  1360. lpPlvItem[i].lpwstr = kanji.wchItaiji;
  1361. break;
  1362. default:
  1363. break;
  1364. }
  1365. }
  1366. }
  1367. return 0;
  1368. }
  1369. #endif //FE_JAPANESE
  1370. void CHwxCAC::SetToolTipInfo(BOOL bAdd)
  1371. {
  1372. ti.cbSize = sizeof(TOOLINFOW);
  1373. ti.uFlags = 0;
  1374. ti.hwnd = m_hCACWnd;
  1375. ti.hinst = m_hInstance;
  1376. ti.lpszText = LPSTR_TEXTCALLBACKW;
  1377. ti.uId = IDC_CACLISTVIEW;
  1378. UINT message = bAdd ? TTM_ADDTOOLW : TTM_NEWTOOLRECTW;
  1379. HWND hwndTT = m_pInk->GetToolTipWindow();
  1380. if ( bAdd )
  1381. {
  1382. ti.rect.left = ti.rect.top = ti.rect.right = ti.rect.bottom = 0;
  1383. SendMessage(hwndTT,message,0,(LPARAM)(LPTOOLINFOW)&ti);
  1384. }
  1385. else
  1386. {
  1387. ti.rect = m_lpPlvInfo->itemRect;
  1388. SendMessage(hwndTT,message,0,(LPARAM)(LPTOOLINFOW)&ti);
  1389. }
  1390. }
  1391. void CHwxCAC::SetToolTipText(LPARAM lp)
  1392. {
  1393. WCHAR wch;
  1394. //BOOL bEmpty = FALSE;
  1395. static WCHAR tip[60];
  1396. LPTOOLTIPTEXTUSERINFO lpttt = (LPTOOLTIPTEXTUSERINFO)lp;
  1397. int index = (int)((lpttt->userInfo).lParam);
  1398. wch = GetWCHAR(index);
  1399. //----------------------------------------------------------------
  1400. //980805:ToshiaK. creating Tip string function has Moved to CHwxFE
  1401. //----------------------------------------------------------------
  1402. //980813:ToshiaK. merged with PRC fix
  1403. memset(tip,'\0', sizeof(tip));
  1404. if (-1 == CHwxFE::GetTipText(wch,
  1405. tip,
  1406. sizeof(tip)/sizeof(tip[0]),
  1407. #ifdef FE_KOREAN
  1408. NULL))
  1409. #else
  1410. m_pIImeSkdic))
  1411. #endif
  1412. {
  1413. lpttt->lpszText = NULL;
  1414. } else {
  1415. lpttt->lpszText = tip;
  1416. }
  1417. }
  1418. #ifdef FE_JAPANESE
  1419. // increasing order
  1420. int _cdecl CompareChar(const void * lp1, const void * lp2)
  1421. {
  1422. LPKANJIINFO p1= (LPKANJIINFO)lp1;
  1423. LPKANJIINFO p2= (LPKANJIINFO)lp2;
  1424. if ( p1->wchKanji < p2->wchKanji )
  1425. return -1;
  1426. else if ( p1->wchKanji > p2->wchKanji )
  1427. return 1;
  1428. return 0;
  1429. }
  1430. // increasing order
  1431. int _cdecl CompareStroke(const void * lp1, const void * lp2)
  1432. {
  1433. LPKANJIINFO p1= (LPKANJIINFO)lp1;
  1434. LPKANJIINFO p2= (LPKANJIINFO)lp2;
  1435. if ( p1->usTotalStroke < p2->usTotalStroke )
  1436. return -1;
  1437. else if ( p1->usTotalStroke > p2->usTotalStroke )
  1438. return 1;
  1439. return 0;
  1440. }
  1441. // increasing order
  1442. int _cdecl CompareRadical(const void * lp1, const void * lp2)
  1443. {
  1444. LPKANJIINFO p1= (LPKANJIINFO)lp1;
  1445. LPKANJIINFO p2= (LPKANJIINFO)lp2;
  1446. if ( p1->lRadicalIndex < p2->lRadicalIndex )
  1447. return -1;
  1448. else if ( p1->lRadicalIndex > p2->lRadicalIndex )
  1449. return 1;
  1450. return 0;
  1451. }
  1452. // decreasing order
  1453. int _cdecl CompareR1(const void * lp1, const void * lp2)
  1454. {
  1455. LPKANJIINFO p1= (LPKANJIINFO)lp1;
  1456. LPKANJIINFO p2= (LPKANJIINFO)lp2;
  1457. int i;
  1458. for( i = 0; i < MAX_YOMI_COUNT+1; i++)
  1459. {
  1460. if ( p2->wchOnYomi1[i] < p1->wchOnYomi1[i] )
  1461. return -1;
  1462. else if ( p2->wchOnYomi1[i] > p1->wchOnYomi1[i] )
  1463. return 1;
  1464. }
  1465. return 0;
  1466. }
  1467. // decreasing order
  1468. int _cdecl CompareR2(const void * lp1, const void * lp2)
  1469. {
  1470. LPKANJIINFO p1= (LPKANJIINFO)lp1;
  1471. LPKANJIINFO p2= (LPKANJIINFO)lp2;
  1472. int i;
  1473. for( i = 0; i < MAX_YOMI_COUNT+1; i++)
  1474. {
  1475. if ( p2->wchOnYomi2[i] < p1->wchOnYomi2[i] )
  1476. return -1;
  1477. else if ( p2->wchOnYomi2[i] > p1->wchOnYomi2[i] )
  1478. return 1;
  1479. }
  1480. return 0;
  1481. }
  1482. // decreasing order
  1483. int _cdecl CompareK1(const void * lp1, const void * lp2)
  1484. {
  1485. LPKANJIINFO p1= (LPKANJIINFO)lp1;
  1486. LPKANJIINFO p2= (LPKANJIINFO)lp2;
  1487. int i;
  1488. for( i = 0; i < MAX_YOMI_COUNT+1; i++)
  1489. {
  1490. if ( p2->wchKunYomi1[i] < p1->wchKunYomi1[i] )
  1491. return -1;
  1492. else if ( p2->wchKunYomi1[i] > p1->wchKunYomi1[i] )
  1493. return 1;
  1494. }
  1495. return 0;
  1496. }
  1497. // decreasing order
  1498. int _cdecl CompareK2(const void * lp1, const void * lp2)
  1499. {
  1500. LPKANJIINFO p1= (LPKANJIINFO)lp1;
  1501. LPKANJIINFO p2= (LPKANJIINFO)lp2;
  1502. int i;
  1503. for( i = 0; i < MAX_YOMI_COUNT+1; i++)
  1504. {
  1505. if ( p2->wchKunYomi2[i] < p1->wchKunYomi2[i] )
  1506. return -1;
  1507. else if ( p2->wchKunYomi2[i] > p1->wchKunYomi2[i] )
  1508. return 1;
  1509. }
  1510. return 0;
  1511. }
  1512. // decreasing order
  1513. int _cdecl CompareOther(const void * lp1, const void * lp2)
  1514. {
  1515. LPKANJIINFO p1= (LPKANJIINFO)lp1;
  1516. LPKANJIINFO p2= (LPKANJIINFO)lp2;
  1517. int i;
  1518. for( i = 0; i < MAX_ITAIJI_COUNT; i++)
  1519. {
  1520. if ( p2->wchItaiji[i] < p1->wchItaiji[i] )
  1521. return -1;
  1522. else if ( p2->wchItaiji[i] > p1->wchItaiji[i] )
  1523. return 1;
  1524. }
  1525. return 0;
  1526. }
  1527. #endif // FE_JAPANESE
  1528. #ifdef FE_JAPANESE
  1529. void CHwxCAC::sortKanjiInfo(int sortID)
  1530. {
  1531. KANJIINFO kanjiData[LISTTOTAL];
  1532. int i;
  1533. if ( m_cnt <= LISTTOTAL && m_cnt > 0 && sortID >= 0 && sortID < LISTVIEW_COLUMN )
  1534. {
  1535. // get data
  1536. memset(kanjiData,'\0',sizeof(KANJIINFO) * LISTTOTAL);
  1537. for ( i = 0; i < m_cnt; i++ )
  1538. {
  1539. kanjiData[i].mask = KIF_STROKECOUNT | KIF_YOMI | KIF_ITAIJI | KIF_RADICALINDEX;
  1540. kanjiData[i].wchKanji = m_gawch[i];
  1541. m_pIImeSkdic->GetKanjiInfo(m_gawch[i],&kanjiData[i]);
  1542. }
  1543. // sort data
  1544. switch ( sortID )
  1545. {
  1546. case 0:
  1547. qsort(kanjiData,m_cnt,sizeof(KANJIINFO),CompareChar);
  1548. break;
  1549. case 1:
  1550. qsort(kanjiData,m_cnt,sizeof(KANJIINFO),CompareStroke);
  1551. break;
  1552. case 2:
  1553. qsort(kanjiData,m_cnt,sizeof(KANJIINFO),CompareRadical);
  1554. break;
  1555. case 3:
  1556. qsort(kanjiData,m_cnt,sizeof(KANJIINFO),CompareR1);
  1557. break;
  1558. case 4:
  1559. qsort(kanjiData,m_cnt,sizeof(KANJIINFO),CompareR2);
  1560. break;
  1561. case 5:
  1562. qsort(kanjiData,m_cnt,sizeof(KANJIINFO),CompareK1);
  1563. break;
  1564. case 6:
  1565. qsort(kanjiData,m_cnt,sizeof(KANJIINFO),CompareK2);
  1566. break;
  1567. case 7:
  1568. qsort(kanjiData,m_cnt,sizeof(KANJIINFO),CompareOther);
  1569. break;
  1570. }
  1571. // copy sorted UNICODE
  1572. for ( i = 0; i < m_cnt; i ++)
  1573. {
  1574. m_gawch[i] = kanjiData[i].wchKanji;
  1575. }
  1576. }
  1577. }
  1578. #endif // FE_JAPANESE
  1579. void CHwxCAC::SetInkSize(int n)
  1580. {
  1581. m_inkSize = n;
  1582. }
  1583. void CHwxCAC::HandleDrawSample()
  1584. {
  1585. #ifdef FE_JAPANESE
  1586. int i = 0;
  1587. POINT pt;
  1588. if ( !m_bDrawSample )
  1589. {
  1590. return;
  1591. }
  1592. while( wSamplePt[i] )
  1593. {
  1594. while( wSamplePt[i] )
  1595. {
  1596. pt.x = HIBYTE(wSamplePt[i]);
  1597. pt.y = LOBYTE(wSamplePt[i]);
  1598. // scaling
  1599. pt.x = (m_inkSize*pt.x)/120;
  1600. pt.y = (m_inkSize*pt.y)/120;
  1601. m_pCHwxStroke->AddPoint(pt);
  1602. i++;
  1603. }
  1604. m_pCHwxStroke->AddBoxStroke(0,0,0);
  1605. i++;
  1606. }
  1607. InvalidateRect(m_hCACWnd,NULL,FALSE);
  1608. UpdateWindow(m_hCACWnd);
  1609. // too slow when calling this function
  1610. // NoThreadRecognize(m_inkSize);
  1611. // cache recognition results
  1612. memcpy(m_gawch, wSampleChar, sizeof(wSampleChar));
  1613. m_cnt = sizeof(wSampleChar)/sizeof(wchar_t);
  1614. PadListView_SetItemCount(m_hLVWnd,m_cnt);
  1615. if(IsNT())
  1616. {
  1617. PadListView_SetExplanationTextW(m_hLVWnd,NULL);
  1618. }
  1619. else
  1620. {
  1621. PadListView_SetExplanationText(m_hLVWnd,NULL);
  1622. }
  1623. PadListView_Update(m_hLVWnd);
  1624. #endif // FE_JAPANESE
  1625. m_bDrawSample = FALSE;
  1626. }
  1627. #if 0
  1628. void CHwxCAC::HandleMeasureItem(HWND hwnd, LPARAM lp)
  1629. {
  1630. LPMEASUREITEMSTRUCT lpmi = (LPMEASUREITEMSTRUCT)lp;
  1631. if ( lpmi->CtlType == ODT_MENU )
  1632. {
  1633. HDC hDC = GetDC(hwnd);
  1634. SIZE size;
  1635. LPTSTR lptstr = (LPTSTR)lpmi->itemData;
  1636. GetTextExtentPoint32(hDC, lptstr, strlen(lptstr), &size);
  1637. lpmi->itemWidth = size.cx + 22;
  1638. lpmi->itemHeight = 20;
  1639. ReleaseDC(hwnd, hDC);
  1640. }
  1641. }
  1642. void CHwxCAC::HandleDrawItem(HWND hwnd, LPARAM lp)
  1643. {
  1644. LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lp;
  1645. if( lpdis->CtlType == ODT_MENU )
  1646. {
  1647. if ( lpdis->itemAction & ODA_DRAWENTIRE ||
  1648. lpdis->itemAction & ODA_SELECT ||
  1649. lpdis->itemAction & ODA_FOCUS )
  1650. {
  1651. HBRUSH hBrush;
  1652. RECT rcItem;
  1653. DWORD dwOldTextColor, dwOldBkColor;
  1654. HICON hIcon;
  1655. if(lpdis->itemState & ODS_SELECTED)
  1656. {
  1657. hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
  1658. dwOldBkColor = SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
  1659. dwOldTextColor = SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
  1660. hIcon = LoadIcon( m_hInstance, MAKEINTRESOURCE(IDI_SELECTED));
  1661. }
  1662. else
  1663. {
  1664. hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
  1665. dwOldBkColor = SetBkColor(lpdis->hDC, GetSysColor(COLOR_BTNFACE));
  1666. dwOldTextColor = SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
  1667. hIcon = LoadIcon( m_hInstance, MAKEINTRESOURCE(IDI_UNSELECT));
  1668. }
  1669. FillRect(lpdis->hDC, (LPRECT)&lpdis->rcItem, hBrush);
  1670. CopyRect(&rcItem, &lpdis->rcItem);
  1671. SIZE size;
  1672. if(lpdis->itemID == IDM_CACAUTORECOG && lpdis->itemState != ODS_GRAYED )
  1673. {
  1674. DrawIconEx(lpdis->hDC,
  1675. rcItem.left+2,
  1676. rcItem.top+2,
  1677. hIcon,
  1678. 16,
  1679. 16,
  1680. 0,
  1681. NULL,
  1682. DI_NORMAL);
  1683. }
  1684. CopyRect(&rcItem, &lpdis->rcItem);
  1685. GetTextExtentPoint32(lpdis->hDC,
  1686. (LPTSTR)lpdis->itemData,
  1687. strlen((LPTSTR)lpdis->itemData),
  1688. &size);
  1689. ExtTextOut(lpdis->hDC,
  1690. rcItem.left+22,
  1691. rcItem.top + (rcItem.bottom - rcItem.top - size.cy)/2,
  1692. ETO_CLIPPED,
  1693. &rcItem,
  1694. (LPTSTR)lpdis->itemData,
  1695. strlen((LPTSTR)lpdis->itemData),
  1696. NULL);
  1697. DeleteObject(hBrush);
  1698. SetBkColor(lpdis->hDC, dwOldBkColor);
  1699. SetTextColor(lpdis->hDC, dwOldTextColor);
  1700. }
  1701. }
  1702. }
  1703. #endif // 0