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.

1946 lines
69 KiB

  1. #include "hwxobj.h"
  2. #include "resource.h"
  3. #include "const.h"
  4. #include "../lib/ptt/ptt.h"
  5. #include "../lib/ddbtn/ddbtn.h"
  6. #include "../lib/exbtn/exbtn.h"
  7. #include "dbg.h"
  8. #include "../common/cfont.h"
  9. #include "hwxfe.h"
  10. #include "cexres.h"
  11. #include "cmnhdr.h"
  12. #ifdef UNDER_CE // Windows CE Stub for unsupported APIs
  13. #include "stub_ce.h"
  14. #endif // UNDER_CE
  15. // implementation of CHwxInkWindow
  16. extern TCHAR szBuf[MAX_PATH];
  17. extern TOOLINFOW ti;
  18. WCHAR wszBuf[32];
  19. CHwxInkWindow::CHwxInkWindow(BOOL bNT, BOOL b16, CApplet * pApp, HINSTANCE hInst):CHwxObject(hInst)
  20. {
  21. m_pApplet = pApp;
  22. // m_hInstance = hInst;
  23. m_pMB = NULL;
  24. m_pCAC = NULL;
  25. m_hInkWnd = NULL;
  26. m_b16Bit = b16;
  27. m_bNT = bNT;
  28. m_bCAC = TRUE;
  29. m_bSglClk = FALSE;
  30. m_bDblClk = m_b16Bit ? FALSE : TRUE;
  31. m_hwndTT = NULL;
  32. m_bMouseDown = FALSE;
  33. m_hCACMBMenu = NULL;
  34. m_hCACMBRecog = NULL;
  35. m_hCACMBRevert = NULL;
  36. m_hCACMBClear = NULL;
  37. m_hCACSwitch = NULL;
  38. m_CACMBMenuDDBtnProc = NULL;
  39. m_CACMBRecogEXBtnProc = NULL;
  40. m_CACMBRevertEXBtnProc = NULL;
  41. m_CACMBClearEXBtnProc = NULL;
  42. m_CACSwitchDDBtnProc = NULL;
  43. // m_hwxPadWidth = 0;
  44. m_wPadHeight = PadWnd_Height;
  45. m_numBoxes = 2;
  46. m_wPadWidth = m_numBoxes * m_wPadHeight;
  47. m_wInkWidth = m_wPadWidth + 4 + BUTTON_WIDTH;
  48. m_wInkHeight = m_wPadHeight;
  49. m_wCACInkHeight = PadWnd_Height;
  50. m_wCACPLVWidth = m_wCACInkHeight + 150;
  51. m_wCACPLVHeight = m_wCACInkHeight;
  52. m_wCACTMPWidth = m_wCACPLVWidth - m_wCACInkHeight;
  53. m_wCACWidth = m_wCACPLVWidth + 4 + BUTTON_WIDTH;
  54. m_wCACHeight = m_wCACPLVHeight;
  55. // m_wMaxHeight = (GetSystemMetrics(SM_CYSCREEN)*3)/4;
  56. // m_wCurrentCtrlID = 0;
  57. // m_dwLastTick = 0;
  58. // m_dwBtnUpCount = 0;
  59. // m_bRedundant = FALSE;
  60. }
  61. CHwxInkWindow::~CHwxInkWindow()
  62. {
  63. }
  64. BOOL CHwxInkWindow::Initialize(TCHAR * pClsName)
  65. {
  66. BOOL bRet = CHwxObject::Initialize(pClsName);
  67. if ( bRet )
  68. {
  69. WNDCLASS wndClass;
  70. wndClass.style = CS_HREDRAW | CS_VREDRAW;
  71. wndClass.lpfnWndProc = HWXWndProc;
  72. wndClass.cbClsExtra = 0;
  73. wndClass.cbWndExtra = sizeof(void *);
  74. wndClass.hInstance = m_hInstance;
  75. wndClass.hIcon = 0;
  76. wndClass.hCursor = 0;
  77. #ifndef UNDER_CE
  78. wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
  79. #else // UNDER_CE
  80. wndClass.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  81. #endif // UNDER_CE
  82. wndClass.lpszMenuName = NULL;
  83. wndClass.lpszClassName = TEXT("HWXPad");
  84. #if 0
  85. if (!RegisterClass(&wndClass))
  86. return FALSE;
  87. #endif
  88. //971217: ToshiaK no need to check return
  89. RegisterClass(&wndClass);
  90. if ( !m_b16Bit )
  91. {
  92. m_pMB = new CHwxMB(this,m_hInstance);
  93. if ( !m_pMB )
  94. return FALSE;
  95. bRet = m_pMB->Initialize(TEXT("CHwxMB"));
  96. if ( !bRet )
  97. {
  98. delete m_pMB;
  99. m_pMB = NULL;
  100. return FALSE;
  101. }
  102. }
  103. m_pCAC = new CHwxCAC(this,m_hInstance);
  104. if ( !m_pCAC )
  105. {
  106. if ( m_pMB )
  107. {
  108. delete m_pMB;
  109. m_pMB = NULL;
  110. }
  111. return FALSE;
  112. }
  113. bRet = m_pCAC->Initialize(TEXT("CHwxCAC"));
  114. if ( !bRet )
  115. {
  116. if ( m_pMB )
  117. {
  118. delete m_pMB;
  119. m_pMB = NULL;
  120. }
  121. delete m_pCAC;
  122. m_pCAC = NULL;
  123. return FALSE;
  124. }
  125. }
  126. InitCommonControls();
  127. return bRet;
  128. }
  129. BOOL CHwxInkWindow::CreateUI(HWND hwndParent)
  130. {
  131. //990601:kotae #434 add WS_CLIPCHILDREN to remove flicker
  132. m_hInkWnd = CreateWindowEx(0,
  133. TEXT("HWXPad"),
  134. TEXT(""),
  135. WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
  136. 0,0,0,0,
  137. hwndParent,
  138. NULL,m_hInstance,this);
  139. if ( !m_hInkWnd )
  140. {
  141. return FALSE;
  142. }
  143. if ( m_pMB ) // NULL means we have a 16-bit program
  144. {
  145. if ( !m_pMB->CreateUI(m_hInkWnd) )
  146. {
  147. DestroyWindow(m_hInkWnd);
  148. m_hInkWnd = NULL;
  149. return FALSE;
  150. }
  151. }
  152. if ( m_pCAC )
  153. {
  154. if ( !m_pCAC->CreateUI(m_hInkWnd) )
  155. {
  156. DestroyWindow(m_hInkWnd);
  157. m_hInkWnd = NULL;
  158. if ( m_pMB )
  159. {
  160. DestroyWindow(m_pMB->GetMBWindow());
  161. m_pMB->SetMBWindow(NULL);
  162. }
  163. return FALSE;
  164. }
  165. }
  166. ChangeLayout(FALSE);
  167. SetTooltipInfo();
  168. return TRUE;
  169. }
  170. BOOL CHwxInkWindow::Terminate()
  171. {
  172. Dbg(("CHwxInkWindow::Terminate\n"));
  173. if ( m_pCAC )
  174. {
  175. (m_pCAC->GetCACThread())->StopThread();
  176. }
  177. if ( m_pMB )
  178. {
  179. (m_pMB->GetMBThread())->StopThread();
  180. }
  181. if ( m_pCAC )
  182. {
  183. delete m_pCAC;
  184. m_pCAC = NULL;
  185. }
  186. if ( m_pMB )
  187. {
  188. delete m_pMB;
  189. m_pMB = NULL;
  190. }
  191. if ( m_hInkWnd )
  192. {
  193. DestroyWindow(m_hInkWnd);
  194. m_hInkWnd = NULL;
  195. }
  196. if ( m_hwndTT )
  197. {
  198. DestroyWindow(m_hwndTT);
  199. m_hwndTT = NULL;
  200. }
  201. m_pApplet = NULL;
  202. if ( m_hCACMBMenu )
  203. {
  204. DestroyWindow(m_hCACMBMenu);
  205. m_hCACMBMenu = NULL;
  206. }
  207. if ( m_hCACMBRecog )
  208. {
  209. DestroyWindow(m_hCACMBRecog);
  210. m_hCACMBRecog = NULL;
  211. }
  212. if ( m_hCACMBRevert )
  213. {
  214. DestroyWindow(m_hCACMBRevert);
  215. m_hCACMBRevert = NULL;
  216. }
  217. if ( m_hCACMBClear )
  218. {
  219. DestroyWindow(m_hCACMBClear);
  220. m_hCACMBClear = NULL;
  221. }
  222. if ( m_hCACSwitch )
  223. {
  224. DestroyWindow(m_hCACSwitch);
  225. m_hCACSwitch = NULL;
  226. }
  227. m_CACMBMenuDDBtnProc = NULL;
  228. m_CACMBRecogEXBtnProc = NULL;
  229. m_CACMBRevertEXBtnProc = NULL;
  230. m_CACMBClearEXBtnProc = NULL;
  231. m_CACSwitchDDBtnProc = NULL;
  232. #if 0
  233. m_btnMB.Destroy();
  234. m_btnMBRecog.Destroy();
  235. m_btnDelAll.Destroy();
  236. m_btnMBProp.Destroy();
  237. m_btnCAC.Destroy();
  238. m_btnRecog.Destroy();
  239. m_btnDel.Destroy();
  240. m_btnDelAllCAC.Destroy();
  241. m_btnDetail.Destroy();
  242. m_btnLarge.Destroy();
  243. #endif //0
  244. return TRUE;
  245. }
  246. BOOL CHwxInkWindow::HandleCreate(HWND hwnd)
  247. {
  248. HICON hIcon;
  249. HFONT hFont = NULL;
  250. static DDBITEM ddbItem;
  251. int i;
  252. m_hwndTT = ToolTip_CreateWindow(m_hInstance,TTS_ALWAYSTIP,hwnd);
  253. #ifdef FE_CHINESE_SIMPLIFIED
  254. //980805:ToshiaK
  255. //In Win95 PRC's DEFAULT_GUI_FONT glyph is little bit ugly.
  256. //so use SYSTEM_FONT instead.
  257. //if(TRUE) { //TEST
  258. if(IsWin95() && m_hwndTT) {
  259. SendMessage(m_hwndTT,
  260. WM_SETFONT,
  261. (WPARAM)GetStockObject(SYSTEM_FONT),
  262. MAKELPARAM(TRUE,0));
  263. }
  264. #endif
  265. m_hCACMBMenu = DDButton_CreateWindow(m_hInstance,
  266. hwnd,
  267. DDBS_ICON | DDBS_NOSEPARATED | DDBS_THINEDGE,
  268. IDC_CACMBMENU,
  269. 0,
  270. 0,
  271. BUTTON_WIDTH,
  272. BUTTON_HEIGHT);
  273. //----------------------------------------------------------------
  274. //980803:ToshiaKIn PRC H/W switch view is needless
  275. //----------------------------------------------------------------
  276. #ifdef FE_JAPANESE
  277. m_hCACSwitch = DDButton_CreateWindow(m_hInstance,
  278. hwnd,
  279. DDBS_ICON | DDBS_THINEDGE,
  280. IDC_CACSWITCHVIEW,
  281. 0,
  282. 0,
  283. BUTTON_WIDTH,
  284. BUTTON_HEIGHT+4);
  285. #elif FE_KOREAN || FE_CHINESE_SIMPLIFIED
  286. m_hCACSwitch = NULL;
  287. #endif
  288. m_hCACMBRecog = EXButton_CreateWindow(m_hInstance,
  289. hwnd,
  290. (m_bCAC && !m_b16Bit) ?
  291. (EXBS_TEXT | EXBS_TOGGLE |EXBS_DBLCLKS | EXBS_THINEDGE) : // kwada:980402:raid #852
  292. (EXBS_TEXT | EXBS_THINEDGE),
  293. IDC_CACMBRECOG,
  294. 0,
  295. 0,
  296. BUTTON_WIDTH,
  297. BUTTON_HEIGHT);
  298. m_hCACMBRevert = EXButton_CreateWindow(m_hInstance,
  299. hwnd,
  300. EXBS_TEXT | EXBS_THINEDGE,
  301. IDC_CACMBREVERT,
  302. 0,
  303. 0,
  304. BUTTON_WIDTH,
  305. BUTTON_HEIGHT);
  306. m_hCACMBClear = EXButton_CreateWindow(m_hInstance,
  307. hwnd,
  308. EXBS_TEXT | EXBS_THINEDGE,
  309. IDC_CACMBCLEAR,
  310. 0,
  311. 0,
  312. BUTTON_WIDTH,
  313. BUTTON_HEIGHT);
  314. #ifdef FE_JAPANESE
  315. if ( !m_hwndTT || !m_hCACMBMenu || !m_hCACMBRecog || !m_hCACMBRevert ||
  316. !m_hCACMBClear || !m_hCACSwitch )
  317. {
  318. goto error;
  319. }
  320. #elif FE_KOREAN || FE_CHINESE_SIMPLIFIED
  321. if(!m_hwndTT ||
  322. !m_hCACMBMenu ||
  323. !m_hCACMBRecog ||
  324. !m_hCACMBRevert||
  325. !m_hCACMBClear)
  326. {
  327. goto error;
  328. }
  329. #endif
  330. #ifdef FE_JAPANESE
  331. hIcon = (HICON)LoadImage(m_hInstance,
  332. MAKEINTRESOURCE(IDI_HWXPAD),
  333. IMAGE_ICON,
  334. 16,16,
  335. LR_DEFAULTCOLOR);
  336. #elif FE_KOREAN
  337. hIcon = (HICON)LoadImage(m_hInstance,
  338. MAKEINTRESOURCE(IDI_HWXPADKO),
  339. IMAGE_ICON,
  340. 16,16,
  341. LR_DEFAULTCOLOR);
  342. #elif FE_CHINESE_SIMPLIFIED
  343. hIcon = (HICON)LoadImage(m_hInstance,
  344. MAKEINTRESOURCE(IDI_HWXPADSC),
  345. IMAGE_ICON,
  346. 16,16,
  347. LR_DEFAULTCOLOR);
  348. #endif
  349. DDButton_SetIcon(m_hCACMBMenu, hIcon);
  350. #ifdef FE_JAPANESE
  351. hIcon = (HICON)LoadImage(m_hInstance,
  352. MAKEINTRESOURCE(IDI_CACSWITCHVIEW),
  353. IMAGE_ICON,
  354. 16,16,
  355. LR_DEFAULTCOLOR);
  356. DDButton_SetIcon(m_hCACSwitch, hIcon);
  357. #endif
  358. for(i = 0; i < 2; i++)
  359. {
  360. ddbItem.cbSize = sizeof(ddbItem);
  361. ddbItem.lpwstr = LoadCACMBString(IDS_CAC+i);
  362. DDButton_AddItem(m_hCACMBMenu, &ddbItem);
  363. #ifdef FE_JAPANESE
  364. ddbItem.lpwstr = LoadCACMBString(IDS_CACLARGE+i);
  365. DDButton_AddItem(m_hCACSwitch, &ddbItem);
  366. #endif // FE_JAPANESE
  367. }
  368. //990716:ToshiaK for Win64.
  369. WinSetUserPtr(m_hCACMBMenu, (LPVOID)this);
  370. m_CACMBMenuDDBtnProc = (FARPROC)WinSetWndProc(m_hCACMBMenu,
  371. (WNDPROC)CACMBBtnWndProc);
  372. #ifdef FE_JAPANESE
  373. //990810:ToshiaK for Win64
  374. WinSetUserPtr(m_hCACSwitch, (LPVOID)this);
  375. m_CACSwitchDDBtnProc = (FARPROC)WinSetWndProc(m_hCACSwitch,
  376. GWL_WNDPROC,
  377. (WNDPROC)CACMBBtnWndProc);
  378. #endif // FE_JAPANESE
  379. if ( m_b16Bit )
  380. {
  381. EnableWindow(m_hCACMBMenu,FALSE);
  382. }
  383. #ifdef FE_JAPANESE
  384. DDButton_SetCurSel(m_hCACSwitch,m_pCAC->IsLargeView() ? 0 : 1);
  385. #endif
  386. EXButton_SetText(m_hCACMBRecog,LoadCACMBString(IDS_CACMBRECOG));
  387. //990810:ToshiaK for Win64.
  388. WinSetUserPtr(m_hCACMBRecog, (LPVOID)this);
  389. m_CACMBRecogEXBtnProc = (FARPROC)WinSetWndProc(m_hCACMBRecog,
  390. (WNDPROC)CACMBBtnWndProc);
  391. EXButton_SetText(m_hCACMBRevert,LoadCACMBString(IDS_CACMBREVERT));
  392. WinSetUserPtr(m_hCACMBRevert, (LPVOID)this);
  393. m_CACMBRevertEXBtnProc = (FARPROC)WinSetWndProc(m_hCACMBRevert,
  394. (WNDPROC)CACMBBtnWndProc);
  395. EXButton_SetText(m_hCACMBClear,LoadCACMBString(IDS_CACMBCLEAR));
  396. WinSetUserPtr(m_hCACMBClear, (LPVOID)this);
  397. m_CACMBClearEXBtnProc = (FARPROC)WinSetWndProc(m_hCACMBClear,
  398. (WNDPROC)CACMBBtnWndProc);
  399. if ( m_bCAC )
  400. {
  401. exbtnPushedorPoped(m_bDblClk);
  402. // EXButton_SetCheck(m_hCACMBRecog, m_bDblClk);
  403. }
  404. else
  405. {
  406. EnableWindow(m_hCACMBRevert,FALSE);
  407. }
  408. #ifdef FE_JAPANESE
  409. //----------------------------------------------------------------
  410. //980728: by ToshiaK for ActiveIME support
  411. //
  412. //----------------------------------------------------------------
  413. //--------- Active IME support S T A R T --------------
  414. if(MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT) != ::GetUserDefaultLangID() &&
  415. (IsWin95() || IsWin98() || IsWinNT4())) {
  416. //990810:ToshiaK for #1030
  417. INT point = 9;
  418. hFont = CFont::CreateGUIFontByNameCharSet(TEXT("MS Gothic"),
  419. SHIFTJIS_CHARSET,
  420. point);
  421. if(!hFont) {
  422. hFont = CFont::CreateGUIFontByNameCharSet(TEXT("MS UI Gothic"),
  423. SHIFTJIS_CHARSET,
  424. point);
  425. if(!hFont) {
  426. hFont = CFont::CreateGUIFontByNameCharSet(TEXT("MS P Gothic"),
  427. SHIFTJIS_CHARSET,
  428. point);
  429. }
  430. }
  431. }
  432. if(hFont) {
  433. SendMessage(m_hwndTT, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  434. SendMessage(m_hCACMBMenu, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  435. SendMessage(m_hCACMBRecog, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  436. SendMessage(m_hCACMBRevert, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  437. SendMessage(m_hCACMBClear, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  438. SendMessage(m_hCACSwitch, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  439. //----------------------------------------------------------------
  440. //These control copy hFont in WM_SETFONT, so hFont is needless here.
  441. //----------------------------------------------------------------
  442. ::DeleteObject(hFont);
  443. }
  444. //--------- Active IME support E N D --------------
  445. #elif FE_KOREAN
  446. //----------------------------------------------------------------
  447. //980728: by ToshiaK for ActiveIME support
  448. //Korean version: CSLim
  449. //----------------------------------------------------------------
  450. //--------- Active IME support S T A R T --------------
  451. if(MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT) != ::GetUserDefaultLangID() &&
  452. (IsWin95() || IsWin98() || IsWinNT4())) {
  453. //990810:ToshiaK for #1030
  454. INT point = 9;
  455. hFont = CFont::CreateGUIFontByNameCharSet(TEXT("Gulim"),
  456. HANGUL_CHARSET,
  457. point);
  458. if(!hFont) {
  459. hFont = CFont::CreateGUIFontByNameCharSet(TEXT("GulimChe"),
  460. HANGUL_CHARSET,
  461. point);
  462. if(!hFont) {
  463. hFont = CFont::CreateGUIFontByNameCharSet(TEXT("Batang"),
  464. SHIFTJIS_CHARSET,
  465. point);
  466. }
  467. }
  468. }
  469. if(hFont) {
  470. SendMessage(m_hwndTT, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  471. SendMessage(m_hCACMBMenu, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  472. SendMessage(m_hCACMBRecog, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  473. SendMessage(m_hCACMBRevert, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  474. SendMessage(m_hCACMBClear, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  475. SendMessage(m_hCACSwitch, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
  476. //----------------------------------------------------------------
  477. //These control copy hFont in WM_SETFONT, so hFont is needless here.
  478. //----------------------------------------------------------------
  479. ::DeleteObject(hFont);
  480. }
  481. //--------- Active IME support E N D --------------
  482. #elif FE_CHINESE_SIMPLIFIED
  483. //----------------------------------------------------------------
  484. //980813:Toshiak:
  485. //Merged PRC fix.
  486. //In Win95 PRC's DEFAULT_GUI_FONT glyph is little bit ugly.
  487. //so use SYSTEM_FONT instead.
  488. //----------------------------------------------------------------
  489. if(IsWin95()) {
  490. SendMessage(m_hwndTT,
  491. WM_SETFONT,
  492. (WPARAM)GetStockObject(SYSTEM_FONT),
  493. MAKELPARAM(TRUE,0));
  494. SendMessage(m_hCACMBRecog,
  495. WM_SETFONT,
  496. (WPARAM)GetStockObject(SYSTEM_FONT),
  497. MAKELPARAM(TRUE,0));
  498. SendMessage(m_hCACMBRevert,
  499. WM_SETFONT,
  500. (WPARAM)GetStockObject(SYSTEM_FONT),
  501. MAKELPARAM(TRUE,0));
  502. SendMessage(m_hCACMBClear,
  503. WM_SETFONT,
  504. (WPARAM)GetStockObject(SYSTEM_FONT),
  505. MAKELPARAM(TRUE,0));
  506. }
  507. #endif
  508. return TRUE;
  509. error:
  510. Terminate();
  511. return FALSE;
  512. UNREFERENCED_PARAMETER(hFont);
  513. }
  514. void CHwxInkWindow::HandlePaint(HWND hwnd)
  515. {
  516. RECT rcUpdate;
  517. RECT rcBkgnd;
  518. if ( GetUpdateRect(hwnd,&rcUpdate,FALSE) )
  519. {
  520. PAINTSTRUCT ps;
  521. HDC hdc = BeginPaint(hwnd, &ps);
  522. if ( ps.fErase )
  523. {
  524. if ( m_bCAC )
  525. {
  526. rcBkgnd.left = m_wCACWidth - 4 - BUTTON_WIDTH;
  527. rcBkgnd.top = 0;
  528. rcBkgnd.right = rcBkgnd.left + 4 + BUTTON_WIDTH + 3*Box_Border;
  529. rcBkgnd.bottom = m_wCACHeight;
  530. #ifndef UNDER_CE
  531. FillRect(hdc,&rcBkgnd,(HBRUSH)(COLOR_3DFACE+1));
  532. #else // UNDER_CE
  533. FillRect(hdc,&rcBkgnd,GetSysColorBrush(COLOR_3DFACE));
  534. #endif // UNDER_CE
  535. }
  536. else
  537. {
  538. rcBkgnd.left = m_wInkWidth - 4 - BUTTON_WIDTH;
  539. rcBkgnd.top = 0;
  540. rcBkgnd.right = rcBkgnd.left + 4 + BUTTON_WIDTH + 3*Box_Border;
  541. rcBkgnd.bottom = m_wInkHeight;
  542. #ifndef UNDER_CE
  543. FillRect(hdc,&rcBkgnd,(HBRUSH)(COLOR_3DFACE+1));
  544. #else // UNDER_CE
  545. FillRect(hdc,&rcBkgnd,GetSysColorBrush(COLOR_3DFACE));
  546. #endif // UNDER_CE
  547. if ( m_wPadHeight < CACMBHEIGHT_MIN )
  548. {
  549. rcBkgnd.left = 0;
  550. rcBkgnd.top = m_wPadHeight;
  551. rcBkgnd.right = m_wPadWidth;
  552. rcBkgnd.bottom = m_wInkHeight;
  553. #ifndef UNDER_CE
  554. FillRect(hdc,&rcBkgnd,(HBRUSH)(COLOR_3DFACE+1));
  555. #else // UNDER_CE
  556. FillRect(hdc,&rcBkgnd,GetSysColorBrush(COLOR_3DFACE));
  557. #endif // UNDER_CE
  558. }
  559. }
  560. }
  561. InvalidateRect(m_hCACMBMenu,&rcUpdate,FALSE);
  562. UpdateWindow(m_hCACMBMenu);
  563. InvalidateRect(m_hCACMBRecog,&rcUpdate,FALSE);
  564. UpdateWindow(m_hCACMBRecog);
  565. InvalidateRect(m_hCACMBRevert,&rcUpdate,FALSE);
  566. UpdateWindow(m_hCACMBRevert);
  567. InvalidateRect(m_hCACMBClear,&rcUpdate,FALSE);
  568. UpdateWindow(m_hCACMBClear);
  569. #ifdef FE_JAPANESE
  570. if ( m_bCAC )
  571. {
  572. InvalidateRect(m_hCACSwitch,&rcUpdate,FALSE);
  573. UpdateWindow(m_hCACSwitch);
  574. }
  575. #endif
  576. #if 0
  577. if ( m_b16Bit )
  578. {
  579. m_btnLarge.Paint(hdc,&rcUpdate);
  580. m_btnDetail.Paint(hdc,&rcUpdate);
  581. m_btnRecog.Paint(hdc,&rcUpdate);
  582. m_btnDelAllCAC.Paint(hdc,&rcUpdate);
  583. m_btnDel.Paint(hdc,&rcUpdate);
  584. m_btnCAC.Paint(hdc,&rcUpdate);
  585. }
  586. else
  587. {
  588. if ( m_bCAC )
  589. {
  590. m_btnLarge.Paint(hdc,&rcUpdate);
  591. m_btnDetail.Paint(hdc,&rcUpdate);
  592. m_btnRecog.Paint(hdc,&rcUpdate);
  593. m_btnDelAllCAC.Paint(hdc,&rcUpdate);
  594. m_btnDel.Paint(hdc,&rcUpdate);
  595. m_btnCAC.Paint(hdc,&rcUpdate);
  596. }
  597. else
  598. {
  599. m_btnMBProp.Paint(hdc,&rcUpdate);
  600. m_btnMBRecog.Paint(hdc,&rcUpdate);
  601. m_btnDelAll.Paint(hdc,&rcUpdate);
  602. m_btnMB.Paint(hdc,&rcUpdate);
  603. }
  604. }
  605. #endif // 0
  606. EndPaint(hwnd,&ps);
  607. }
  608. }
  609. #if 0
  610. void CHwxInkWindow::HandleMouseEvent(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
  611. {
  612. POINT pt;
  613. pt.x = (short)LOWORD(lp);
  614. pt.y = (short)HIWORD(lp);
  615. if ( !m_b16Bit )
  616. {
  617. if ( m_bCAC )
  618. {
  619. LargeButton(msg,&pt,&m_btnLarge);
  620. DetailButton(msg,&pt,&m_btnDetail);
  621. RecogButton(msg,&pt,&m_btnRecog);
  622. DelAllCACButton(msg,&pt,&m_btnDelAllCAC);
  623. DelButton(msg,&pt,&m_btnDel);
  624. CACButton(msg,&pt,&m_btnCAC);
  625. }
  626. else
  627. {
  628. // PropButton(msg,&pt,&m_btnMBProp);
  629. DelAllMBButton(msg,&pt,&m_btnDelAll);
  630. MBButton(msg,&pt,&m_btnMB);
  631. MBRecogButton(msg,&pt,&m_btnMBRecog);
  632. }
  633. }
  634. else
  635. {
  636. LargeButton(msg,&pt,&m_btnLarge);
  637. DetailButton(msg,&pt,&m_btnDetail);
  638. DelAllCACButton(msg,&pt,&m_btnDelAllCAC);
  639. DelButton(msg,&pt,&m_btnDel);
  640. RecogButton(msg,&pt,&m_btnRecog);
  641. }
  642. static MSG rmsg;
  643. rmsg.lParam = lp;
  644. rmsg.wParam = wp;
  645. rmsg.message = msg;
  646. rmsg.hwnd = hwnd;
  647. SendMessage(m_hwndTT,TTM_RELAYEVENT,0,(LPARAM)(LPMSG)&rmsg);
  648. }
  649. #endif // 0
  650. LRESULT CHwxInkWindow::HandleCommand(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
  651. {
  652. switch ( LOWORD(wp) )
  653. {
  654. case IDC_CACMBMENU:
  655. {
  656. switch ( HIWORD(wp) )
  657. {
  658. case DDBN_DROPDOWN:
  659. ToolTip_Enable(m_hwndTT, FALSE);
  660. DDButton_SetCurSel((HWND)lp,m_bCAC ? 0 : 1);
  661. break;
  662. case DDBN_CLOSEUP:
  663. ToolTip_Enable(m_hwndTT, TRUE);
  664. break;
  665. case DDBN_SELCHANGE:
  666. m_bCAC = ( 0 == DDButton_GetCurSel((HWND)lp) ) ? TRUE : FALSE;
  667. if ( m_bCAC )
  668. {
  669. DWORD dwStyle;
  670. (GetAppletPtr()->GetIImePad())->Request(GetAppletPtr(),
  671. IMEPADREQ_GETAPPLETUISTYLE,
  672. (WPARAM)&dwStyle,
  673. (LPARAM)0);
  674. dwStyle &= ~IPAWS_VERTICALFIXED;
  675. (GetAppletPtr()->GetIImePad())->Request(GetAppletPtr(),
  676. IMEPADREQ_SETAPPLETUISTYLE,
  677. (WPARAM)dwStyle,
  678. (LPARAM)0);
  679. //----------------------------------------------------------------
  680. //ToshiaK:980324: for #651 GPF in 16 bit
  681. //Thest instruction will never come on 16bit application
  682. //becaus DDBtn is Disabled. so it is safe code.
  683. //----------------------------------------------------------------
  684. if(!m_pMB) {
  685. return 0;
  686. }
  687. //HWND hwndMB = m_pMB->GetMBWindow();
  688. //HWND hwndCAC = m_pCAC->GetCACWindow();
  689. m_pCAC->SetInkSize(m_wPadHeight);
  690. SendMessage(m_pMB->GetMBWindow(), MB_WM_COPYINK, 0, 0);
  691. SendMessage(m_pMB->GetMBWindow(), MB_WM_ERASE, 0, 0);
  692. EnableWindow(m_pMB->GetMBWindow(),FALSE);
  693. ShowWindow(m_pMB->GetMBWindow(),SW_HIDE);
  694. EnableWindow(m_pCAC->GetCACWindow(),TRUE);
  695. ShowWindow(m_pCAC->GetCACWindow(),SW_SHOW);
  696. if ( !m_b16Bit )
  697. EXButton_SetStyle(m_hCACMBRecog,
  698. EXBS_TEXT | EXBS_THINEDGE | EXBS_DBLCLKS | EXBS_TOGGLE); // kwada:980402:raid #852
  699. EnableWindow(m_hCACMBRevert,TRUE);
  700. EnableWindow(m_hCACSwitch,TRUE);
  701. ShowWindow(m_hCACSwitch,SW_SHOW);
  702. m_wCACInkHeight = m_wPadHeight;
  703. m_wCACPLVWidth = m_wCACInkHeight + m_wCACTMPWidth;
  704. ChangeIMEPADSize(FALSE);
  705. changeCACLayout(TRUE);
  706. }
  707. else
  708. {
  709. DWORD dwStyle;
  710. (GetAppletPtr()->GetIImePad())->Request(GetAppletPtr(),
  711. IMEPADREQ_GETAPPLETUISTYLE,
  712. (WPARAM)&dwStyle,
  713. (LPARAM)0);
  714. dwStyle |= IPAWS_VERTICALFIXED;
  715. (GetAppletPtr()->GetIImePad())->Request(GetAppletPtr(),
  716. IMEPADREQ_SETAPPLETUISTYLE,
  717. (WPARAM)dwStyle,
  718. (LPARAM)0);
  719. (m_pCAC->GetCACCHwxStroke())->DeleteAllStroke();
  720. EnableWindow(m_pCAC->GetCACWindow(),FALSE);
  721. ShowWindow(m_pCAC->GetCACWindow(),SW_HIDE);
  722. EnableWindow(m_hCACSwitch,FALSE);
  723. ShowWindow(m_hCACSwitch,SW_HIDE);
  724. EnableWindow(m_hCACMBRevert,FALSE);
  725. EXButton_SetStyle(m_hCACMBRecog,EXBS_TEXT | EXBS_THINEDGE);
  726. EnableWindow(m_pMB->GetMBWindow(),TRUE);
  727. ShowWindow(m_pMB->GetMBWindow(),SW_SHOW);
  728. m_wPadHeight = m_wCACInkHeight;
  729. m_wPadWidth = m_numBoxes * m_wPadHeight;
  730. //----------------------------------------------------------------
  731. //ToshiaK:980324: for #651 GPF in 16 bit
  732. if(m_pMB) {
  733. m_pMB->SetBoxSize((USHORT)m_wPadHeight);
  734. }
  735. ChangeIMEPADSize(FALSE);
  736. changeMBLayout(TRUE);
  737. }
  738. if ( !m_b16Bit )
  739. UpdateRegistry(FALSE); // recog button is recovered after style change. kwada:980402
  740. break;
  741. case DDBN_CLICKED:
  742. default:
  743. break;
  744. }
  745. break;
  746. }
  747. case IDC_CACMBRECOG:
  748. {
  749. switch ( HIWORD(wp) )
  750. {
  751. case EXBN_DOUBLECLICKED:
  752. if ( m_bCAC && !m_b16Bit )
  753. {
  754. m_bDblClk = !m_bDblClk;
  755. m_bSglClk = FALSE;
  756. // EXButton_SetCheck((HWND)lp,m_bDblClk);
  757. if ( m_bDblClk )
  758. {
  759. exbtnPushedorPoped(TRUE);
  760. m_pCAC->recognize();
  761. }
  762. else
  763. {
  764. exbtnPushedorPoped(FALSE);
  765. }
  766. UpdateRegistry(TRUE); // update recog button state. kwada:980402
  767. }
  768. break;
  769. case EXBN_CLICKED:
  770. if ( m_bCAC )
  771. {
  772. if ( m_b16Bit )
  773. {
  774. m_pCAC->NoThreadRecognize(m_wCACInkHeight);
  775. }
  776. else
  777. {
  778. if ( !m_bDblClk )
  779. {
  780. m_bSglClk = !m_bSglClk;
  781. if ( m_bSglClk )
  782. {
  783. exbtnPushedorPoped(TRUE);
  784. m_pCAC->recognize();
  785. }
  786. else
  787. {
  788. exbtnPushedorPoped(FALSE);
  789. }
  790. }
  791. else
  792. {
  793. exbtnPushedorPoped(TRUE);
  794. // EXButton_SetCheck((HWND)lp,TRUE);
  795. }
  796. }
  797. }
  798. else
  799. {
  800. //ToshiaK:980324: for #651 GPF in 16 bit
  801. if(m_pMB) {
  802. SendMessage(m_pMB->GetMBWindow(), MB_WM_DETERMINE, 0, 0);
  803. }
  804. }
  805. break;
  806. case EXBN_ARMED:
  807. case EXBN_DISARMED:
  808. {
  809. if ( m_bCAC && !m_b16Bit )
  810. {
  811. if ( m_bDblClk || m_bSglClk )
  812. {
  813. exbtnPushedorPoped(TRUE);
  814. }
  815. else
  816. {
  817. exbtnPushedorPoped(FALSE);
  818. }
  819. }
  820. }
  821. default:
  822. break;
  823. }
  824. break;
  825. }
  826. case IDC_CACMBREVERT:
  827. {
  828. switch ( HIWORD(wp) )
  829. {
  830. case EXBN_CLICKED:
  831. if ( m_bCAC )
  832. {
  833. m_pCAC->HandleDeleteOneStroke();
  834. if ( m_pCAC->GetStrokeCount() == 0 && !m_bDblClk && m_bSglClk )
  835. {
  836. m_bSglClk = FALSE;
  837. exbtnPushedorPoped(FALSE);
  838. // EXButton_SetCheck(m_hCACMBRecog,m_bSglClk);
  839. }
  840. }
  841. break;
  842. case EXBN_DOUBLECLICKED:
  843. case EXBN_ARMED:
  844. case EXBN_DISARMED:
  845. default:
  846. break;
  847. }
  848. break;
  849. }
  850. case IDC_CACMBCLEAR:
  851. {
  852. switch ( HIWORD(wp) )
  853. {
  854. case EXBN_CLICKED:
  855. if ( m_bCAC )
  856. {
  857. m_pCAC->HandleDeleteAllStroke();
  858. if ( m_pCAC->GetStrokeCount() == 0 && !m_bDblClk && m_bSglClk )
  859. {
  860. m_bSglClk = FALSE;
  861. exbtnPushedorPoped(FALSE);
  862. // EXButton_SetCheck(m_hCACMBRecog,m_bSglClk);
  863. }
  864. }
  865. else
  866. {
  867. SendMessage(m_pMB->GetMBWindow(), MB_WM_ERASE, 0, 0);
  868. }
  869. break;
  870. case EXBN_DOUBLECLICKED:
  871. case EXBN_ARMED:
  872. case EXBN_DISARMED:
  873. default:
  874. break;
  875. }
  876. break;
  877. }
  878. case IDC_CACSWITCHVIEW:
  879. {
  880. switch ( HIWORD(wp) )
  881. {
  882. case DDBN_DROPDOWN:
  883. ToolTip_Enable(m_hwndTT, FALSE);
  884. // DDButton_SetCurSel((HWND)lp,m_pCAC->IsLargeView() ? 0 : 1);
  885. break;
  886. case DDBN_CLOSEUP:
  887. ToolTip_Enable(m_hwndTT, TRUE);
  888. break;
  889. case DDBN_CLICKED:
  890. case DDBN_SELCHANGE:
  891. m_pCAC->SetLargeView((0 == DDButton_GetCurSel((HWND)lp)) ? TRUE : FALSE);
  892. PadListView_SetStyle(m_pCAC->GetCACLVWindow(),
  893. m_pCAC->IsLargeView() ? PLVSTYLE_ICON : PLVSTYLE_REPORT);
  894. break;
  895. default:
  896. break;
  897. }
  898. break;
  899. }
  900. default:
  901. return DefWindowProc(hwnd, msg, wp, lp);
  902. }
  903. return 0;
  904. }
  905. //----------------------------------------------------------------
  906. //990618:ToshiaK for KOTAE #1329
  907. //----------------------------------------------------------------
  908. LRESULT
  909. CHwxInkWindow::HandleSettingChange(HWND hwnd, UINT uMsg, WPARAM wp, LPARAM lp)
  910. {
  911. if(m_pMB) {
  912. m_pMB->OnSettingChange(uMsg, wp, lp);
  913. }
  914. if(m_pCAC) {
  915. m_pCAC->OnSettingChange(uMsg, wp, lp);
  916. }
  917. return 0;
  918. UNREFERENCED_PARAMETER(hwnd);
  919. }
  920. void CHwxInkWindow::ChangeLayout(BOOL b)
  921. {
  922. if ( !m_bCAC )
  923. changeMBLayout(b);
  924. else
  925. changeCACLayout(b);
  926. }
  927. void CHwxInkWindow::SetTooltipInfo()
  928. {
  929. ti.cbSize = sizeof(TOOLINFOW);
  930. ti.uFlags = TTF_IDISHWND;
  931. ti.hwnd = m_hInkWnd;
  932. ti.hinst = m_hInstance;
  933. ti.lpszText = LPSTR_TEXTCALLBACKW;
  934. ti.uId = (UINT_PTR)m_hCACMBMenu;
  935. SendMessage(m_hwndTT,TTM_ADDTOOLW,0,(LPARAM)(LPTOOLINFOW)&ti);
  936. ti.uId = (UINT_PTR)m_hCACMBRecog;
  937. SendMessage(m_hwndTT,TTM_ADDTOOLW,0,(LPARAM)(LPTOOLINFOW)&ti);
  938. ti.uId = (UINT_PTR)m_hCACMBRevert;
  939. SendMessage(m_hwndTT,TTM_ADDTOOLW,0,(LPARAM)(LPTOOLINFOW)&ti);
  940. ti.uId = (UINT_PTR)m_hCACMBClear;
  941. SendMessage(m_hwndTT,TTM_ADDTOOLW,0,(LPARAM)(LPTOOLINFOW)&ti);
  942. ti.uId = (UINT_PTR)m_hCACSwitch;
  943. SendMessage(m_hwndTT,TTM_ADDTOOLW,0,(LPARAM)(LPTOOLINFOW)&ti);
  944. }
  945. void CHwxInkWindow::SetTooltipText(LPARAM lp)
  946. {
  947. LPTOOLTIPTEXTW lpttt = (LPTOOLTIPTEXTW)lp;
  948. UINT stringID = 0;
  949. switch ( (((LPNMHDR)lp)->idFrom) )
  950. {
  951. case IDC_CACMBMENU:
  952. stringID = IDS_CACMBBTN2;
  953. break;
  954. case IDC_CACMBRECOG:
  955. stringID = m_bCAC ? IDS_CACMBBTN6 : IDS_CACMBBTN1;
  956. break;
  957. case IDC_CACMBREVERT:
  958. stringID = IDS_CACMBBTN3;
  959. break;
  960. case IDC_CACMBCLEAR:
  961. stringID = IDS_CACMBBTN4;
  962. break;
  963. case IDC_CACSWITCHVIEW:
  964. stringID = IDS_CACMBBTN5;
  965. break;
  966. default:
  967. break;
  968. }
  969. lpttt->lpszText = stringID == 0 ? NULL : LoadCACMBString(stringID);
  970. }
  971. void CHwxInkWindow::CopyInkFromMBToCAC(CHwxStroke & str,long deltaX,long deltaY)
  972. {
  973. m_pCAC->GetInkFromMB(str,deltaX,deltaY);
  974. }
  975. CHwxStroke * CHwxInkWindow::GetCACCHwxStroke()
  976. {
  977. return m_pCAC->GetCACCHwxStroke();
  978. }
  979. void CHwxInkWindow::changeCACLayout(BOOL bRepaint /*bFirst*/)
  980. {
  981. POINT pt;
  982. RECT rcUpdate;
  983. // BOOL bRepaint = !bFirst;
  984. // Recompute the layout and re-arrange the windows
  985. // First we need to find out all the dimensions
  986. // m_wCACWidth = m_wCACPLVWidth + 4 + BUTTON_WIDTH;
  987. // m_wCACHeight = m_wCACInkHeight > m_wCACPLVHeight ? m_wCACInkHeight : m_wCACPLVHeight;
  988. GetWindowRect( m_hInkWnd, &rcUpdate );
  989. pt.x = rcUpdate.left;
  990. pt.y = rcUpdate.top;
  991. ScreenToClient( GetParent(m_hInkWnd), &pt );
  992. #if 0
  993. m_btnCAC.SetRect(m_wCACPLVWidth+8, 4,m_wCACPLVWidth+8+BUTTON_WIDTH,
  994. 4+BUTTON_HEIGHT);
  995. m_btnRecog.SetRect(m_wCACPLVWidth+8, BUTTON_HEIGHT+4+8,
  996. m_wCACPLVWidth+8+BUTTON_WIDTH,
  997. 2*BUTTON_HEIGHT+4+8);
  998. m_btnDel.SetRect(m_wCACPLVWidth+8, 2*BUTTON_HEIGHT+10+4,
  999. m_wCACPLVWidth+8+BUTTON_WIDTH,
  1000. 3*BUTTON_HEIGHT+10+4);
  1001. m_btnDelAllCAC.SetRect(m_wCACPLVWidth+8, 3*BUTTON_HEIGHT+12+4,
  1002. m_wCACPLVWidth+8+BUTTON_WIDTH,
  1003. 4*BUTTON_HEIGHT+12+4);
  1004. m_btnLarge.SetRect(m_wCACPLVWidth+8, 4*BUTTON_HEIGHT+18+4,
  1005. m_wCACPLVWidth+8+23,
  1006. 5*BUTTON_HEIGHT+21+4);
  1007. m_btnDetail.SetRect(m_wCACPLVWidth+32, 4*BUTTON_HEIGHT+18+4,
  1008. m_wCACPLVWidth+32+12,
  1009. 5*BUTTON_HEIGHT+21+4);
  1010. #endif // 0
  1011. MoveWindow( m_hInkWnd,pt.x, pt.y, m_wCACWidth+3*Box_Border, m_wCACHeight, bRepaint);
  1012. MoveWindow( m_pCAC->GetCACWindow(), 0, 0, m_wCACPLVWidth, m_wCACHeight, bRepaint);
  1013. MoveWindow( m_pCAC->GetCACLVWindow(),m_wCACInkHeight+5, 4, m_wCACTMPWidth-4, m_wCACPLVHeight-8, bRepaint);
  1014. MoveWindow( m_hCACMBMenu,m_wCACPLVWidth+8, 4,
  1015. BUTTON_WIDTH,
  1016. BUTTON_HEIGHT,bRepaint);
  1017. MoveWindow( m_hCACMBRecog,m_wCACPLVWidth+8, BUTTON_HEIGHT+4+8,
  1018. BUTTON_WIDTH,
  1019. BUTTON_HEIGHT,bRepaint);
  1020. MoveWindow( m_hCACMBRevert,m_wCACPLVWidth+8, 2*BUTTON_HEIGHT+10+4,
  1021. BUTTON_WIDTH,
  1022. BUTTON_HEIGHT,bRepaint);
  1023. MoveWindow( m_hCACMBClear,m_wCACPLVWidth+8, 3*BUTTON_HEIGHT+12+4,
  1024. BUTTON_WIDTH,
  1025. BUTTON_HEIGHT,bRepaint);
  1026. #ifdef FE_JAPANESE
  1027. MoveWindow( m_hCACSwitch,m_wCACPLVWidth+8, 4*BUTTON_HEIGHT+18+4,
  1028. BUTTON_WIDTH,
  1029. BUTTON_HEIGHT+4,bRepaint);
  1030. #endif
  1031. //----------------------------------------------------------------
  1032. //990810:ToshiaK for KOTAE #1609
  1033. //fixed control repaint problem.
  1034. //To fix perfectly, We should use Begin(End)DeferWindowPos(),
  1035. //SetWindwPos() to re-layout.
  1036. //But there are many part to change the code.
  1037. //So, I only add following line to repaint again.
  1038. //----------------------------------------------------------------
  1039. if(m_hCACMBMenu) {
  1040. ::InvalidateRect(m_hCACMBMenu, NULL, NULL);
  1041. }
  1042. if(m_hCACMBRecog) {
  1043. ::InvalidateRect(m_hCACMBRecog, NULL, NULL);
  1044. }
  1045. if(m_hCACMBRevert) {
  1046. ::InvalidateRect(m_hCACMBRevert,NULL, NULL);
  1047. }
  1048. if(m_hCACMBClear) {
  1049. ::InvalidateRect(m_hCACMBClear, NULL, NULL);
  1050. }
  1051. #ifdef FE_JAPANESE
  1052. if(m_hCACSwitch) {
  1053. ::InvalidateRect(m_hCACSwitch, NULL, NULL);
  1054. }
  1055. #endif
  1056. }
  1057. void CHwxInkWindow::changeMBLayout(BOOL bRepaint /*bFirst*/)
  1058. {
  1059. POINT pt;
  1060. RECT rcUpdate;
  1061. // BOOL bRepaint = !bFirst;
  1062. // Recompute the layout and re-arrange the windows
  1063. // First we need to find out all the dimensions
  1064. // m_wInkWidth = m_wPadWidth + 4+ BUTTON_WIDTH;
  1065. // m_wInkHeight = m_wPadHeight > PadWnd_Height ? m_wPadHeight : PadWnd_Height;
  1066. GetWindowRect( m_hInkWnd, &rcUpdate );
  1067. pt.x = rcUpdate.left;
  1068. pt.y = rcUpdate.top;
  1069. ScreenToClient( GetParent(m_hInkWnd), &pt );
  1070. #if 0
  1071. m_btnMB.SetRect(m_wPadWidth+8, 4,m_wPadWidth+8+BUTTON_WIDTH,
  1072. 4+BUTTON_HEIGHT);
  1073. m_btnMBRecog.SetRect(m_wPadWidth+8, BUTTON_HEIGHT+4+8,
  1074. m_wPadWidth+8+BUTTON_WIDTH,
  1075. 2*BUTTON_HEIGHT+4+8);
  1076. m_btnDelAll.SetRect(m_wPadWidth+8, 3*BUTTON_HEIGHT+12+4,
  1077. m_wPadWidth+8+BUTTON_WIDTH,
  1078. 4*BUTTON_HEIGHT+12+4);
  1079. m_btnMBProp.SetRect(m_wPadWidth+8, 2*BUTTON_HEIGHT+10+4,
  1080. m_wPadWidth+8+BUTTON_WIDTH,
  1081. 3*BUTTON_HEIGHT+10+4);
  1082. #endif // 0
  1083. MoveWindow( m_hInkWnd, pt.x, pt.y, m_wInkWidth+3*Box_Border, m_wInkHeight, bRepaint);
  1084. if(m_pMB) {
  1085. MoveWindow( m_pMB->GetMBWindow(), 0, 0, m_wPadWidth, m_wPadHeight, bRepaint);
  1086. }
  1087. MoveWindow( m_hCACMBMenu,m_wPadWidth+8, 4,
  1088. BUTTON_WIDTH,
  1089. BUTTON_HEIGHT,bRepaint);
  1090. MoveWindow( m_hCACMBRecog,m_wPadWidth+8, BUTTON_HEIGHT+4+8,
  1091. BUTTON_WIDTH,
  1092. BUTTON_HEIGHT,bRepaint);
  1093. MoveWindow( m_hCACMBRevert,m_wPadWidth+8, 2*BUTTON_HEIGHT+10+4,
  1094. BUTTON_WIDTH,
  1095. BUTTON_HEIGHT,bRepaint);
  1096. MoveWindow( m_hCACMBClear,m_wPadWidth+8, 3*BUTTON_HEIGHT+12+4,
  1097. BUTTON_WIDTH,
  1098. BUTTON_HEIGHT,bRepaint);
  1099. //----------------------------------------------------------------
  1100. //990810:ToshiaK for KOTAE #1609
  1101. //fixed control repaint problem.
  1102. //To fix perfectly, We should use Begin(End)DeferWindowPos(),
  1103. //SetWindwPos() to re-layout.
  1104. //But there are many part to change the code.
  1105. //So, I only add following line to repaint again.
  1106. //----------------------------------------------------------------
  1107. //990810:ToshiaK.
  1108. //In resizing, sometime "WPad" window is not redrawn..
  1109. if(m_pMB) {
  1110. ::InvalidateRect(m_pMB->GetMBWindow(), NULL, NULL);
  1111. }
  1112. if(m_hCACMBMenu) {
  1113. ::InvalidateRect(m_hCACMBMenu, NULL, NULL);
  1114. }
  1115. if(m_hCACMBRecog) {
  1116. ::InvalidateRect(m_hCACMBRecog, NULL, NULL);
  1117. }
  1118. if(m_hCACMBRevert) {
  1119. ::InvalidateRect(m_hCACMBRevert,NULL, NULL);
  1120. }
  1121. if(m_hCACMBClear) {
  1122. ::InvalidateRect(m_hCACMBClear, NULL, NULL);
  1123. }
  1124. }
  1125. #if 0
  1126. void CHwxInkWindow::clearCACLayout()
  1127. {
  1128. m_btnCAC.SetRect(0,0,0,0);
  1129. m_btnRecog.SetRect(0,0,0,0);
  1130. m_btnDel.SetRect(0,0,0,0);
  1131. m_btnDelAllCAC.SetRect(0,0,0,0);
  1132. m_btnLarge.SetRect(0,0,0,0);
  1133. m_btnDetail.SetRect(0,0,0,0);
  1134. }
  1135. void CHwxInkWindow::clearMBLayout()
  1136. {
  1137. m_btnMB.SetRect(0,0,0,0);
  1138. m_btnMBRecog.SetRect(0,0,0,0);
  1139. m_btnDelAll.SetRect(0,0,0,0);
  1140. m_btnMBProp.SetRect(0,0,0,0);
  1141. m_btnMB.SetRect(0,0,0,0);
  1142. }
  1143. #endif // 0
  1144. void CHwxInkWindow::DrawHwxGuide(HDC hDC, LPRECT prc)
  1145. {
  1146. HPEN hPen,hPenOld;
  1147. RECT rcUpdate = *prc;
  1148. hPen = CreatePen( PS_SOLID, 0, GetSysColor(COLOR_3DSHADOW) );
  1149. hPenOld = (HPEN)SelectObject( hDC, hPen );
  1150. #define DXW 10
  1151. // center cross
  1152. #ifndef UNDER_CE // Windows CE does not support MoveToEx/LineTo. Use Polyline.
  1153. // MoveToEx( hDC, rcUpdate.right/2-DXW, rcUpdate.bottom/2, NULL );
  1154. // LineTo( hDC, rcUpdate.right/2+DXW, rcUpdate.bottom/2 );
  1155. // MoveToEx( hDC, rcUpdate.right/2, rcUpdate.bottom/2-DXW, NULL );
  1156. // LineTo( hDC, rcUpdate.right/2, rcUpdate.bottom/2+DXW );
  1157. MoveToEx( hDC, ( rcUpdate.left + (rcUpdate.right-rcUpdate.left)/2 )-DXW, rcUpdate.bottom/2, NULL );
  1158. LineTo( hDC, ( rcUpdate.left + (rcUpdate.right-rcUpdate.left)/2 )+DXW, rcUpdate.bottom/2 );
  1159. MoveToEx( hDC, ( rcUpdate.left + (rcUpdate.right-rcUpdate.left)/2 ), rcUpdate.bottom/2-DXW, NULL );
  1160. LineTo( hDC, ( rcUpdate.left + (rcUpdate.right-rcUpdate.left)/2 ), rcUpdate.bottom/2+DXW );
  1161. #else // UNDER_CE
  1162. {
  1163. POINT pts[] ={{(rcUpdate.left + (rcUpdate.right-rcUpdate.left)/2)-DXW, rcUpdate.bottom/2},
  1164. {(rcUpdate.left + (rcUpdate.right-rcUpdate.left)/2)+DXW, rcUpdate.bottom/2}};
  1165. Polyline(hDC, pts, ArrayCount(pts));
  1166. }
  1167. {
  1168. POINT pts[] ={{(rcUpdate.left + (rcUpdate.right-rcUpdate.left)/2), rcUpdate.bottom/2-DXW},
  1169. {(rcUpdate.left + (rcUpdate.right-rcUpdate.left)/2), rcUpdate.bottom/2+DXW}};
  1170. Polyline(hDC, pts, ArrayCount(pts));
  1171. }
  1172. #endif // UNDER_CE
  1173. // top left
  1174. #ifndef UNDER_CE // Windows CE does not support MoveToEx/LineTo. Use Polyline.
  1175. MoveToEx( hDC, rcUpdate.left+DXW, rcUpdate.top+DXW, NULL );
  1176. LineTo( hDC, rcUpdate.left+DXW, rcUpdate.top+(DXW+DXW) );
  1177. MoveToEx( hDC, rcUpdate.left+DXW, rcUpdate.top+DXW, NULL );
  1178. LineTo( hDC, rcUpdate.left+(DXW+DXW), rcUpdate.top+DXW );
  1179. #else // UNDER_CE
  1180. {
  1181. POINT pts[] ={{rcUpdate.left+(DXW+DXW), rcUpdate.top+DXW},
  1182. {rcUpdate.left+DXW, rcUpdate.top+DXW},
  1183. {rcUpdate.left+DXW, rcUpdate.top+(DXW+DXW)}};
  1184. Polyline(hDC, pts, ArrayCount(pts));
  1185. }
  1186. #endif // UNDER_CE
  1187. // bottom left
  1188. #ifndef UNDER_CE // Windows CE does not support MoveToEx/LineTo. Use Polyline.
  1189. MoveToEx( hDC, rcUpdate.left+DXW, rcUpdate.bottom-DXW, NULL );
  1190. LineTo( hDC, rcUpdate.left+DXW, rcUpdate.bottom-(DXW+DXW) );
  1191. MoveToEx( hDC, rcUpdate.left+DXW, rcUpdate.bottom-DXW, NULL );
  1192. LineTo( hDC, rcUpdate.left+(DXW+DXW), rcUpdate.bottom-DXW );
  1193. #else // UNDER_CE
  1194. {
  1195. POINT pts[] ={{rcUpdate.left+DXW, rcUpdate.bottom-(DXW+DXW)},
  1196. {rcUpdate.left+DXW, rcUpdate.bottom-DXW},
  1197. {rcUpdate.left+(DXW+DXW), rcUpdate.bottom-DXW}};
  1198. Polyline(hDC, pts, ArrayCount(pts));
  1199. }
  1200. #endif // UNDER_CE
  1201. // top right
  1202. #ifndef UNDER_CE // Windows CE does not support MoveToEx/LineTo. Use Polyline.
  1203. MoveToEx( hDC, rcUpdate.right-DXW, rcUpdate.top+DXW, NULL );
  1204. LineTo( hDC, rcUpdate.right-DXW, rcUpdate.top+(DXW+DXW) );
  1205. MoveToEx( hDC, rcUpdate.right-DXW, rcUpdate.top+DXW, NULL );
  1206. LineTo( hDC, rcUpdate.right-(DXW+DXW), rcUpdate.top+DXW );
  1207. #else // UNDER_CE
  1208. {
  1209. POINT pts[] ={{rcUpdate.right-(DXW+DXW), rcUpdate.top+DXW},
  1210. {rcUpdate.right-DXW, rcUpdate.top+DXW},
  1211. {rcUpdate.right-DXW, rcUpdate.top+(DXW+DXW)}};
  1212. Polyline(hDC, pts, ArrayCount(pts));
  1213. }
  1214. #endif // UNDER_CE
  1215. // bottom right
  1216. #ifndef UNDER_CE // Windows CE does not support MoveToEx/LineTo. Use Polyline.
  1217. MoveToEx( hDC, rcUpdate.right-DXW, rcUpdate.bottom-DXW, NULL );
  1218. LineTo( hDC, rcUpdate.right-DXW, rcUpdate.bottom-(DXW+DXW) );
  1219. MoveToEx( hDC, rcUpdate.right-DXW, rcUpdate.bottom-DXW, NULL );
  1220. LineTo( hDC, rcUpdate.right-(DXW+DXW), rcUpdate.bottom-DXW );
  1221. #else // UNDER_CE
  1222. {
  1223. POINT pts[] ={{rcUpdate.right-(DXW+DXW), rcUpdate.bottom-DXW},
  1224. {rcUpdate.right-DXW, rcUpdate.bottom-DXW},
  1225. {rcUpdate.right-DXW, rcUpdate.bottom-(DXW+DXW)}};
  1226. Polyline(hDC, pts, ArrayCount(pts));
  1227. }
  1228. #endif // UNDER_CE
  1229. SelectObject( hDC, hPenOld );
  1230. DeleteObject( hPen );
  1231. }
  1232. // applet size changing
  1233. // inkbox size should remain unchanged
  1234. // both MB inkbox and CAC inkbox should be the same
  1235. void CHwxInkWindow::HandleSize(WPARAM wp, LPARAM lp)
  1236. {
  1237. Dbg(("CHwxInkWindow::HandleSize\n"));
  1238. int w = LOWORD(lp);
  1239. int h = HIWORD(lp);
  1240. int wdefaultSize;
  1241. int hdefaultSize;
  1242. int newWidth,newHeight;
  1243. BOOL bChanged = FALSE;
  1244. if ( m_bCAC )
  1245. {
  1246. if ( !w )
  1247. {
  1248. wdefaultSize = PadWnd_Height + 150 + (3*Box_Border) + (4+BUTTON_WIDTH);
  1249. // wdefaultSize = PadWnd_Height + 120 + (3*Box_Border) + (4+BUTTON_WIDTH);
  1250. }
  1251. else
  1252. {
  1253. wdefaultSize = m_wCACInkHeight + LISTVIEWWIDTH_MIN + (3*Box_Border) + (4+BUTTON_WIDTH); // minimum width
  1254. }
  1255. // hdefaultSize = PadWnd_Height; // minimum height
  1256. hdefaultSize = m_wCACInkHeight > CACMBHEIGHT_MIN ? m_wCACInkHeight : CACMBHEIGHT_MIN;
  1257. newWidth = w > wdefaultSize ? w : wdefaultSize;
  1258. newHeight = h > hdefaultSize ? h : hdefaultSize;
  1259. if ( newWidth != m_wCACWidth || newHeight != m_wCACHeight )
  1260. {
  1261. m_wCACPLVWidth = newWidth - (3*Box_Border) - (4+BUTTON_WIDTH);
  1262. m_wCACTMPWidth = m_wCACPLVWidth - m_wCACInkHeight;
  1263. m_wCACPLVHeight = newHeight;
  1264. m_pCAC->SetInkSize(m_wCACInkHeight);
  1265. m_wCACWidth = m_wCACPLVWidth + 4 + BUTTON_WIDTH;
  1266. m_wCACHeight = m_wCACInkHeight > m_wCACPLVHeight ? m_wCACInkHeight : m_wCACPLVHeight;
  1267. ChangeIMEPADSize(FALSE);
  1268. changeCACLayout(TRUE);
  1269. // changeCACLayout(FALSE);
  1270. // SetTooltipInfo(m_hInkWnd,FALSE);
  1271. }
  1272. }
  1273. else
  1274. {
  1275. wdefaultSize = (m_numBoxes * INKBOXSIZE_MIN) + (3*Box_Border) + (4+BUTTON_WIDTH);
  1276. hdefaultSize = PadWnd_Height;
  1277. // 0. decide if we need to resize
  1278. // 1. need to decide ink-box size and numbers of boxes
  1279. // m_wPadHeight, m_numBoxes, and m_wPadWidth
  1280. // 2. notify m_boxSize in CHwxMB
  1281. // 3. scale the ink if there is the ink before resizing
  1282. newWidth = w > wdefaultSize ? w : wdefaultSize;
  1283. newHeight = h > hdefaultSize ? h : hdefaultSize;
  1284. int wInkWidth = m_wPadWidth + (3*Box_Border) + (4+BUTTON_WIDTH);
  1285. int wInkHeight = m_wPadHeight;
  1286. int num;
  1287. if ( newWidth != wInkWidth && newHeight == wInkHeight )
  1288. {
  1289. m_numBoxes = ((num = (newWidth- (3*Box_Border) - (4+BUTTON_WIDTH)) / m_wInkHeight) && num > 1) ? num : 2;
  1290. m_wPadWidth = m_numBoxes * m_wInkHeight;
  1291. bChanged = TRUE;
  1292. }
  1293. if ( newWidth == wInkWidth && newHeight != wInkHeight )
  1294. {
  1295. //----------------------------------------------------------------
  1296. //990723:ToshiaK for KOTAE #1615.
  1297. //Raid Description:
  1298. // Try to decrease the number of boxes by dragging the left edge to the right.
  1299. // Result: You can't decrease the number of boxes. (You can add more boxes, though.)
  1300. //This is VERY VERY UGLY CODE.
  1301. //Too many auto variable, and not intuitive....
  1302. //Anyway, if box size is minimize, it's in to this condition.
  1303. //----------------------------------------------------------------
  1304. //1. First calc m_numBoxes.
  1305. m_numBoxes = ((num = (newWidth- (3*Box_Border) - (4+BUTTON_WIDTH)) / m_wInkHeight) && num > 1) ? num : 2;
  1306. //2. calc new m_wPadWidth
  1307. m_wPadWidth = m_numBoxes * m_wInkHeight;
  1308. //3. LiZhang use too many magic number, I cannot understand...
  1309. // compare real width(WM_SIZE parameter width)
  1310. // and computed width.
  1311. // Real Applet's size seems to compute like this.
  1312. // "m_wPadWidth + 3*Box_Border + 4 + BUTTON_WIDTH" :-(
  1313. //
  1314. if( (m_wPadWidth + 3*Box_Border+ 4+ BUTTON_WIDTH) > w && m_numBoxes > 2) {
  1315. if(m_wPadWidth > 0) {
  1316. m_numBoxes = (w - (3*Box_Border+ 4+ BUTTON_WIDTH))/m_wInkHeight;
  1317. if(m_numBoxes < 2) {
  1318. m_numBoxes = 2;
  1319. }
  1320. }
  1321. m_wPadWidth = m_numBoxes * m_wInkHeight;
  1322. }
  1323. Dbg((" --> new m_numBoxes [%d]\n", m_numBoxes));
  1324. Dbg((" --> new m_wPadWidth[%d]\n", m_wPadWidth));
  1325. bChanged = TRUE;
  1326. }
  1327. if ( newWidth != wInkWidth && newHeight != wInkHeight )
  1328. {
  1329. newWidth = newWidth - (3*Box_Border) - (4+BUTTON_WIDTH);
  1330. m_numBoxes = ((num = newWidth / m_wPadHeight) && num > 1) ? num : 2;
  1331. m_wPadWidth = m_numBoxes * m_wPadHeight;
  1332. bChanged = TRUE;
  1333. }
  1334. if ( bChanged )
  1335. {
  1336. if(m_pMB) { //ToshiaK:980324
  1337. m_pMB->SetBoxSize((USHORT)m_wPadHeight);
  1338. }
  1339. m_wInkWidth = m_wPadWidth + 4+ BUTTON_WIDTH;
  1340. m_wInkHeight = m_wPadHeight > CACMBHEIGHT_MIN ? m_wPadHeight : CACMBHEIGHT_MIN;
  1341. ChangeIMEPADSize(FALSE);
  1342. changeMBLayout(TRUE);
  1343. }
  1344. }
  1345. Unref(wp);
  1346. }
  1347. //////////////////////////////////////////////////////////////////
  1348. // Function : CHwxInkWindow::HandleSizeNotify
  1349. // Type : BOOL
  1350. // Purpose : check *pWidth, *pHeight, these are proper size or not.
  1351. // Args :
  1352. // : INT * pWidth [in/out] new width comes
  1353. // : INT * pHeight [in/out] new height comes
  1354. // Return :
  1355. // DATE : Fri Jun 05 20:42:02 1998
  1356. // Author : ToshiaK
  1357. //////////////////////////////////////////////////////////////////
  1358. BOOL CHwxInkWindow::HandleSizeNotify(INT *pWidth, INT *pHeight)
  1359. {
  1360. Dbg(("HandleSizeNotify *pWidth[%d] *pHeight[%d]\n", *pWidth, *pHeight));
  1361. if(!pWidth || !pHeight) {
  1362. return FALSE;
  1363. }
  1364. int w = *pWidth;
  1365. int h = *pHeight;
  1366. int wdefaultSize;
  1367. int hdefaultSize;
  1368. if ( m_bCAC )
  1369. {
  1370. if ( !w )
  1371. {
  1372. wdefaultSize = PadWnd_Height + 150 + (3*Box_Border) + (4+BUTTON_WIDTH);
  1373. // wdefaultSize = PadWnd_Height + 120 + (3*Box_Border) + (4+BUTTON_WIDTH);
  1374. }
  1375. else
  1376. {
  1377. wdefaultSize = m_wCACInkHeight + LISTVIEWWIDTH_MIN + (3*Box_Border) + (4+BUTTON_WIDTH); // minimum width
  1378. }
  1379. hdefaultSize = m_wCACInkHeight > CACMBHEIGHT_MIN ? m_wCACInkHeight : CACMBHEIGHT_MIN;
  1380. //----------------------------------------------------------------
  1381. //980903:for #4892. if new size is less than default size, set default.
  1382. //----------------------------------------------------------------
  1383. if(*pWidth < wdefaultSize) {
  1384. *pWidth = wdefaultSize;
  1385. }
  1386. if(*pHeight < hdefaultSize) {
  1387. *pHeight = hdefaultSize;
  1388. }
  1389. return TRUE;
  1390. }
  1391. else
  1392. {
  1393. Dbg(("Multibox size changing\n"));
  1394. wdefaultSize = (m_numBoxes * INKBOXSIZE_MIN) + (3*Box_Border) + (4+BUTTON_WIDTH);
  1395. hdefaultSize = PadWnd_Height;
  1396. Dbg(("w[%d] h[%d] wdef[%d] hdef[%d]\n", w, h, wdefaultSize, hdefaultSize));
  1397. Dbg(("m_wPadWidth[%d] m_wPadHeight[%d]\n", m_wPadWidth, m_wPadHeight));
  1398. //----------------------------------------------------------------
  1399. //980903:for #4892
  1400. //check num box with new size.
  1401. //Ink with & height is same.
  1402. //----------------------------------------------------------------
  1403. if(m_wInkHeight > 0) { //check to prevent Div0.
  1404. //Calc new numbox from new Width. InkHeight is not changed.
  1405. INT numBox = (*pWidth - (3*Box_Border)-(4+BUTTON_WIDTH))/ m_wInkHeight;
  1406. //check Smooth Drag or only Frame drag flag.
  1407. BOOL fDragFull=FALSE;
  1408. #ifndef UNDER_CE // Windows CE does not support SPI_GETDRAGFULLWINDOWS
  1409. ::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &fDragFull, 0);
  1410. #endif // UNDER_CE
  1411. if(fDragFull) {
  1412. //Do not change multibox size if numBox is same as old value.
  1413. if(numBox < 2 || numBox == m_numBoxes) {
  1414. return FALSE;
  1415. }
  1416. }
  1417. else {
  1418. if(numBox < 2) { //Box count should be greater than 1
  1419. *pWidth = 2 * m_wInkHeight + (3*Box_Border)+(4+BUTTON_WIDTH);
  1420. }
  1421. if(m_wPadHeight != h) {
  1422. *pHeight = m_wPadHeight;
  1423. }
  1424. }
  1425. }
  1426. return TRUE;
  1427. }
  1428. //return TRUE;
  1429. }
  1430. #if 0
  1431. void CHwxInkWindow::HandleTimer()
  1432. {
  1433. if ( m_dwBtnUpCount == 1 ) // single click detected
  1434. {
  1435. if ( !m_bDblClk )
  1436. {
  1437. SetSglClk(!m_bSglClk);
  1438. if ( m_bSglClk )
  1439. m_pCAC->recognize();
  1440. }
  1441. }
  1442. m_wCurrentCtrlID = 0; // no control selected
  1443. }
  1444. #endif // 0
  1445. void CHwxInkWindow::SetMBHeight(int h)
  1446. {
  1447. // h = h > m_wMaxHeight? m_wMaxHeight : h;
  1448. m_wPadHeight = h;
  1449. m_wCACInkHeight = h;
  1450. m_wPadWidth = m_numBoxes * m_wPadHeight;
  1451. m_pCAC->SetInkSize(h);
  1452. if(m_pMB) { //ToshiaK:980324
  1453. m_pMB->SetBoxSize((USHORT)h);
  1454. }
  1455. m_wInkWidth = m_wPadWidth + 4 + BUTTON_WIDTH;
  1456. m_wInkHeight = m_wPadHeight > CACMBHEIGHT_MIN ? m_wPadHeight : CACMBHEIGHT_MIN;
  1457. }
  1458. void CHwxInkWindow::SetCACInkHeight(int w)
  1459. {
  1460. // w = w > m_wMaxHeight? m_wMaxHeight : w;
  1461. m_wCACInkHeight = w;
  1462. m_wCACPLVWidth = m_wCACTMPWidth + m_wCACInkHeight;
  1463. m_wPadHeight = m_wCACInkHeight;
  1464. m_pCAC->SetInkSize(w);
  1465. if(m_pMB) { //ToshiaK:980324
  1466. m_pMB->SetBoxSize((USHORT)w);
  1467. }
  1468. m_wCACWidth = m_wCACPLVWidth + 4 + BUTTON_WIDTH;
  1469. m_wCACHeight = m_wCACInkHeight > m_wCACPLVHeight ? m_wCACInkHeight : m_wCACPLVHeight;
  1470. }
  1471. void CHwxInkWindow::HandleConfigNotification()
  1472. {
  1473. LANGID langId;
  1474. //----------------------------------------------------------------
  1475. //980803:ToshiaK
  1476. //If environment is ActiveIME,
  1477. //Invoke Dialog with English string.
  1478. //----------------------------------------------------------------
  1479. if(CHwxFE::IsActiveIMEEnv()) {
  1480. langId = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
  1481. }
  1482. else {
  1483. langId = CHwxFE::GetAppLangID();
  1484. }
  1485. if ( !m_b16Bit ) {
  1486. if(IsNT()) {
  1487. CExres::DialogBoxParamW(langId,
  1488. m_hInstance,
  1489. MAKEINTRESOURCEW(IDD_MBPROP),
  1490. m_hInkWnd,
  1491. CACMBPropDlgProc,
  1492. (LPARAM)this);
  1493. }
  1494. else {
  1495. #ifndef UNDER_CE // Windows CE always Unicode
  1496. CExres::DialogBoxParamA(langId,
  1497. m_hInstance,
  1498. MAKEINTRESOURCEA(IDD_MBPROP),
  1499. m_hInkWnd,
  1500. CACMBPropDlgProc,
  1501. (LPARAM)this);
  1502. #endif // UNDER_CE
  1503. }
  1504. }
  1505. }
  1506. void CHwxInkWindow::UpdateRegistry(BOOL bSet)
  1507. {
  1508. static PROPDATA pd;
  1509. if ( !m_b16Bit ) // kwada:980402
  1510. if ( bSet )
  1511. {
  1512. pd.uTimerValue = m_pMB->GetTimeOutValue();
  1513. pd.bAlwaysRecog = m_bDblClk;
  1514. (GetAppletPtr()->GetIImePad())->Request(GetAppletPtr(),IMEPADREQ_SETAPPLETDATA,(WPARAM)&pd,(LPARAM)sizeof(PROPDATA));
  1515. }
  1516. else
  1517. {
  1518. ZeroMemory(&pd, sizeof(pd)); //ToshiaK:971024
  1519. if ( S_FALSE == (GetAppletPtr()->GetIImePad())->Request(GetAppletPtr(),IMEPADREQ_GETAPPLETDATA,(WPARAM)&pd,(LPARAM)sizeof(PROPDATA) ) )
  1520. {
  1521. //980921:for Raid#4981
  1522. pd.uTimerValue = 2000; //Wait 2000msec
  1523. pd.bAlwaysRecog = TRUE;
  1524. (GetAppletPtr()->GetIImePad())->Request(GetAppletPtr(),IMEPADREQ_SETAPPLETDATA,(WPARAM)&pd,(LPARAM)sizeof(PROPDATA));
  1525. }
  1526. m_pMB->SetTimeOutValue(pd.uTimerValue);
  1527. m_pMB->SetTimerStarted(pd.uTimerValue ? TRUE : FALSE );
  1528. SetDblClk(pd.bAlwaysRecog);
  1529. }
  1530. }
  1531. void CHwxInkWindow::HandleDlgMsg(HWND hdlg,BOOL bInit)
  1532. {
  1533. LANGID langId;
  1534. INT codePage;
  1535. //980803:ToshiaK for ActiveIME
  1536. if(CHwxFE::IsActiveIMEEnv()) {
  1537. langId = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
  1538. codePage = CP_ACP;
  1539. }
  1540. else {
  1541. langId = CHwxFE::GetAppLangID();
  1542. codePage = CHwxFE::GetAppCodePage();
  1543. }
  1544. int index;
  1545. if ( bInit )
  1546. {
  1547. #ifndef UNDER_CE // Windows CE always Unicode
  1548. if(::IsWindowUnicode(hdlg)) {
  1549. #endif // UNDER_CE
  1550. for ( int i = 0; i < 11; i++) {
  1551. CExres::LoadStringW(langId,
  1552. m_hInstance,
  1553. IDS_TIMER0+i,
  1554. wszBuf,
  1555. sizeof(wszBuf)/sizeof(wszBuf[0]));
  1556. ::SendMessageW(::GetDlgItem(hdlg,IDC_MBCOMBO),CB_ADDSTRING,0,(LPARAM)wszBuf);
  1557. }
  1558. ::SendMessageW(::GetDlgItem(hdlg,IDC_CACCHECK),BM_SETCHECK, m_bDblClk,0);
  1559. UpdateRegistry(TRUE); // update recog button state. kwada:980402
  1560. if(m_pMB) { //ToshiaK:980324
  1561. ::SendMessageW(GetDlgItem(hdlg,IDC_MBCOMBO),CB_SETCURSEL,
  1562. (WPARAM)(m_pMB->GetTimeOutValue()/1000),0);
  1563. }
  1564. #ifndef UNDER_CE // Windows CE always Unicode
  1565. }
  1566. else {
  1567. for ( int i = 0; i < 11; i++) {
  1568. CExres::LoadStringA(codePage,
  1569. langId,
  1570. m_hInstance,
  1571. IDS_TIMER0+i,
  1572. szBuf,
  1573. sizeof(szBuf)/sizeof(TCHAR));
  1574. SendMessage(GetDlgItem(hdlg,IDC_MBCOMBO),CB_ADDSTRING,0,(LPARAM)szBuf);
  1575. }
  1576. SendMessage(GetDlgItem(hdlg,IDC_CACCHECK),BM_SETCHECK,m_bDblClk,0);
  1577. UpdateRegistry(TRUE); // update recog button state. kwada:980402
  1578. if(m_pMB) { //ToshiaK:980324
  1579. SendMessage(GetDlgItem(hdlg,IDC_MBCOMBO),CB_SETCURSEL,
  1580. (WPARAM)(m_pMB->GetTimeOutValue()/1000),0);
  1581. }
  1582. }
  1583. #endif // UNDER_CE
  1584. }
  1585. else
  1586. {
  1587. #ifndef UNDER_CE // Windows CE always Unicode
  1588. if(::IsWindowUnicode(hdlg)) {
  1589. #endif // UNDER_CE
  1590. index = ::SendMessageW(::GetDlgItem(hdlg,IDC_MBCOMBO),CB_GETCURSEL,0,0);
  1591. if ( index != CB_ERR ) {
  1592. index *= 1000;
  1593. if(m_pMB) { //ToshiaK:980324
  1594. m_pMB->SetTimeOutValue(index);
  1595. m_pMB->SetTimerStarted(index ? TRUE : FALSE);
  1596. }
  1597. m_bDblClk = (BOOL)::SendMessageW(GetDlgItem(hdlg,IDC_CACCHECK),BM_GETCHECK,0,0);
  1598. SetDblClk(m_bDblClk);
  1599. UpdateRegistry(TRUE);
  1600. }
  1601. #ifndef UNDER_CE // Windows CE always Unicode
  1602. }
  1603. else {
  1604. index = SendMessage(GetDlgItem(hdlg,IDC_MBCOMBO),CB_GETCURSEL,0,0);
  1605. if ( index != CB_ERR ) {
  1606. index *= 1000;
  1607. if(m_pMB) { //ToshiaK:980324
  1608. m_pMB->SetTimeOutValue(index);
  1609. m_pMB->SetTimerStarted(index ? TRUE : FALSE);
  1610. }
  1611. m_bDblClk = (BOOL)SendMessage(GetDlgItem(hdlg,IDC_CACCHECK),BM_GETCHECK,0,0);
  1612. SetDblClk(m_bDblClk);
  1613. UpdateRegistry(TRUE);
  1614. }
  1615. }
  1616. #endif // UNDER_CE
  1617. }
  1618. }
  1619. void CHwxInkWindow::ChangeIMEPADSize(BOOL bChangePos)
  1620. {
  1621. Dbg(("CHwxInkWindow::ChangeIMEPADSize START bChangePos %d\n", bChangePos));
  1622. int w;
  1623. int h;
  1624. if ( m_bCAC )
  1625. {
  1626. w = m_wCACWidth+3*Box_Border;
  1627. h = m_wCACHeight;
  1628. }
  1629. else
  1630. {
  1631. Dbg(("for multibox\n"));
  1632. w = m_wInkWidth+3*Box_Border;
  1633. h = m_wInkHeight;
  1634. }
  1635. (GetAppletPtr()->GetIImePad())->Request(GetAppletPtr(),
  1636. IMEPADREQ_SETAPPLETSIZE,
  1637. MAKEWPARAM(w,h),
  1638. (LPARAM)bChangePos);
  1639. }
  1640. void CHwxInkWindow::HandleHelp(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
  1641. {
  1642. #ifndef UNDER_CE // Windows CE does not support WinHelp
  1643. LPHELPINFO lpInfo = (LPHELPINFO)lp;
  1644. Dbg(("CHwxInkWindow::HandleHelp() msg[%s]START\n",
  1645. msg == WM_HELP ? "WM_HELP" :
  1646. msg == WM_CONTEXTMENU ? "WM_CONTEXTMENU" : "unknown"));
  1647. if ( msg == WM_HELP )
  1648. {
  1649. Dbg(("hwnd [0x%08x][%s]\n", hwnd, DBGGetWinClass(hwnd)));
  1650. Dbg(("hItemHandle [0x%08x][%s]\n", lpInfo->hItemHandle,
  1651. DBGGetWinClass((HWND)lpInfo->hItemHandle)));
  1652. Dbg(("m_hInkWnd [0x%08x][%s]\n", m_hInkWnd, DBGGetWinClass(m_hInkWnd)));
  1653. #ifdef _DEBUG
  1654. if(m_pCAC) {
  1655. Dbg(("GetCACWindow [0x%08x][%s]\n",
  1656. m_pCAC->GetCACWindow(),
  1657. DBGGetWinClass(m_pCAC->GetCACWindow())));
  1658. }
  1659. if(m_pMB) {
  1660. Dbg(("GetMBWindow [0x%08x][%s]\n",
  1661. m_pMB->GetMBWindow(),
  1662. DBGGetWinClass(m_pMB->GetMBWindow())));
  1663. }
  1664. #endif
  1665. if ( m_bCAC && lpInfo->hItemHandle == m_pCAC->GetCACWindow() )
  1666. {
  1667. CHwxFE::HandleWmHelp((HWND)lpInfo->hItemHandle, TRUE);
  1668. }
  1669. else if ( !m_bCAC && m_pMB && lpInfo->hItemHandle == m_pMB->GetMBWindow() )
  1670. {
  1671. CHwxFE::HandleWmHelp((HWND)lpInfo->hItemHandle, FALSE);
  1672. }
  1673. else if ( lpInfo->hItemHandle != m_hInkWnd )
  1674. {
  1675. CHwxFE::HandleWmHelp((HWND)lpInfo->hItemHandle, (BOOL)m_bCAC);
  1676. }
  1677. }
  1678. else if ( msg == WM_CONTEXTMENU )
  1679. {
  1680. if (( m_bCAC && (HWND)wp == m_pCAC->GetCACWindow() )
  1681. || ( !m_bCAC && m_pMB && (HWND)wp == m_pMB->GetMBWindow() )
  1682. || ( (HWND)wp != m_hInkWnd ))
  1683. {
  1684. CHwxFE::HandleWmContextMenu((HWND)wp, (BOOL)m_bCAC);
  1685. }
  1686. }
  1687. #endif // UNDER_CE
  1688. Unref(hwnd);
  1689. }
  1690. LRESULT CHwxInkWindow::HandleBtnSubWnd(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
  1691. {
  1692. static FARPROC fn;
  1693. static MSG rmsg;
  1694. //981006:In 16bit appliatioin,
  1695. //hwnd's hiword is 0. so cannot specified the hwnd
  1696. if(m_bNT && CHwxFE::Is16bitApplication()) {
  1697. INT id = GetDlgCtrlID(hwnd);
  1698. switch(id) {
  1699. case IDC_CACMBMENU:
  1700. fn = m_CACMBMenuDDBtnProc;
  1701. break;
  1702. case IDC_CACSWITCHVIEW:
  1703. fn = m_CACSwitchDDBtnProc;
  1704. break;
  1705. case IDC_CACMBRECOG:
  1706. fn = m_CACMBRecogEXBtnProc;
  1707. break;
  1708. case IDC_CACMBREVERT:
  1709. fn = m_CACMBRevertEXBtnProc;
  1710. break;
  1711. case IDC_CACMBCLEAR:
  1712. fn = m_CACMBClearEXBtnProc;
  1713. break;
  1714. default:
  1715. fn = NULL;
  1716. break;
  1717. }
  1718. if(NULL == fn) {
  1719. return 0;
  1720. }
  1721. }
  1722. else {
  1723. if ( NULL == (fn = getCACMBBtnProc(hwnd)) )
  1724. return 0;
  1725. }
  1726. switch(msg)
  1727. {
  1728. case WM_MOUSEMOVE:
  1729. // case WM_LBUTTONDOWN:
  1730. // case WM_LBUTTONUP:
  1731. rmsg.lParam = lp;
  1732. rmsg.wParam = wp;
  1733. rmsg.message = msg;
  1734. rmsg.hwnd = hwnd;
  1735. SendMessage(m_hwndTT,TTM_RELAYEVENT,0,(LPARAM)(LPMSG)&rmsg);
  1736. break;
  1737. case WM_LBUTTONDOWN:
  1738. m_bMouseDown = TRUE;
  1739. break;
  1740. case WM_LBUTTONUP:
  1741. case WM_LBUTTONDBLCLK:
  1742. m_bMouseDown = FALSE;
  1743. break;
  1744. case WM_DESTROY:
  1745. if( m_hwndTT )
  1746. {
  1747. ti.cbSize = sizeof(TOOLINFOW);
  1748. ti.uFlags = TTF_IDISHWND;
  1749. ti.hwnd = m_hInkWnd;
  1750. ti.uId = (UINT_PTR)hwnd;
  1751. SendMessage(m_hwndTT,TTM_DELTOOLW,0,(LPARAM)(LPTOOLINFOW)&ti);
  1752. }
  1753. //990810:ToshiaK for Win64
  1754. WinSetUserPtr(hwnd, (LPVOID)NULL);
  1755. break;
  1756. default:
  1757. break;
  1758. }
  1759. return CallWindowProc((WNDPROC)fn, hwnd, msg, wp, lp);
  1760. }
  1761. LPWSTR CHwxInkWindow::LoadCACMBString(UINT idStr)
  1762. {
  1763. static WCHAR wchStr[60];
  1764. ZeroMemory(wchStr, sizeof(wchStr));
  1765. CHwxFE::LoadStrWithLangId(CHwxFE::GetAppLangID(),
  1766. m_hInstance,
  1767. idStr,
  1768. wchStr,
  1769. sizeof(wchStr)/sizeof(WCHAR));
  1770. return wchStr;
  1771. }
  1772. // this is a special function to handle m_hCACMBRecog
  1773. // button drawing(pushed or poped) in CAC mode only(not 16bit app)
  1774. void CHwxInkWindow::exbtnPushedorPoped(BOOL bPushed)
  1775. {
  1776. #ifndef UNDER_CE // Windows CE does not support GetCursorPos
  1777. POINT pt;
  1778. RECT rcUpdate;
  1779. GetCursorPos(&pt);
  1780. GetWindowRect(m_hCACMBRecog,&rcUpdate);
  1781. if ( PtInRect(&rcUpdate,pt) && m_bMouseDown )
  1782. #else // UNDER_CE
  1783. if(m_bMouseDown)
  1784. #endif // UNDER_CE
  1785. {
  1786. EXButton_SetCheck(m_hCACMBRecog,!bPushed);
  1787. }
  1788. else
  1789. {
  1790. EXButton_SetCheck(m_hCACMBRecog,bPushed);
  1791. }
  1792. }
  1793. //////////////////////////////////////////////////////////////////
  1794. // Function : CHwxInkWindow_OnChangeView
  1795. // Type : INT
  1796. // Purpose : Notify view changes.
  1797. // Args :
  1798. // : BOOL fLarge
  1799. // Return :
  1800. // DATE : Tue Jul 28 18:43:06 1998
  1801. // Histroy :
  1802. //////////////////////////////////////////////////////////////////
  1803. INT CHwxInkWindow::OnChangeView(BOOL fLarge)
  1804. {
  1805. if(m_hCACSwitch && ::IsWindow(m_hCACSwitch)) {
  1806. DDButton_SetCurSel(m_hCACSwitch, fLarge ? 0 : 1);
  1807. }
  1808. return 0;
  1809. }