Source code of Windows XP (NT5)
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.

1852 lines
45 KiB

  1. /**************************************************/
  2. /* */
  3. /* */
  4. /* MDI Mainframe window class */
  5. /* */
  6. /* */
  7. /* */
  8. /* Copyright (c) 1997-1999 Microsoft Corporation. */
  9. /**************************************************/
  10. #include "stdafx.h"
  11. #include "eudcedit.h"
  12. #include "mainfrm.h"
  13. #include "editwnd.h"
  14. #include "refrwnd.h"
  15. #include "eudcdlg.h"
  16. #include "refrdlg.h"
  17. #include "registry.h"
  18. #include "assocdlg.h"
  19. #include "imprtdlg.h"
  20. #include "gagedlg.h"
  21. #include "blinkdlg.h"
  22. #include "util.h"
  23. #include "rotatdlg.h"
  24. #include "extfunc.h"
  25. extern "C"
  26. {
  27. #include "imelist.h"
  28. }
  29. #define BUFFERMAX 800
  30. #ifdef _DEBUG
  31. #undef THIS_FILE
  32. static char BASED_CODE THIS_FILE[] = __FILE__;
  33. #endif
  34. // Global paramter
  35. BOOL TitleFlag;
  36. extern CPoint PalettePt;
  37. CEditWnd *pEditChild;
  38. CRefrWnd *pRefrChild;
  39. extern BOOL SetCountryInfo(UINT LocalCP);
  40. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  41. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  42. //{{AFX_MSG_MAP(CMainFrame)
  43. ON_WM_CREATE()
  44. ON_WM_SIZE()
  45. ON_COMMAND_EX(IDW_STYLES, OnStylesBar)
  46. ON_UPDATE_COMMAND_UI(IDW_STYLES, OnUpdateStylesBar)
  47. ON_UPDATE_COMMAND_UI(ID_TOOLBAR, OnUpdateToolbar)
  48. ON_WM_DESTROY()
  49. ON_COMMAND(ID_REFFERFILE_NEW, OnRefferfileNew)
  50. ON_COMMAND(ID_READ_CHAR, OnReadChar)
  51. ON_UPDATE_COMMAND_UI(ID_REFFERFILE_NEW, OnUpdateRefferfileNew)
  52. ON_COMMAND(ID_TOOLBAR, OnToolbar)
  53. ON_COMMAND(ID_REFFER_CLOSE, OnRefferClose)
  54. ON_UPDATE_COMMAND_UI(ID_REFFER_CLOSE, OnUpdateRefferClose)
  55. ON_WM_CLOSE()
  56. ON_COMMAND(ID_SHOW_GRID, OnShowGrid)
  57. ON_UPDATE_COMMAND_UI(ID_SHOW_GRID, OnUpdateShowGrid)
  58. ON_COMMAND(ID_SELECTFAMILY, OnSelectfamily)
  59. ON_COMMAND(ID_SAVECHAR, OnSavechar)
  60. ON_UPDATE_COMMAND_UI(ID_SAVECHAR, OnUpdateSavechar)
  61. ON_COMMAND(ID_SAVE_CHARAS, OnSaveCharas)
  62. ON_UPDATE_COMMAND_UI(ID_SAVE_CHARAS, OnUpdateSaveCharas)
  63. ON_COMMAND(ID_LINKIME, OnLinkime)
  64. ON_WM_INITMENU()
  65. ON_UPDATE_COMMAND_UI(ID_READ_CHAR, OnUpdateReadChar)
  66. ON_UPDATE_COMMAND_UI(ID_LINKIME, OnUpdateLinkime)
  67. ON_COMMAND(ID_NEXTCODE, OnNextcode)
  68. ON_UPDATE_COMMAND_UI(ID_NEXTCODE, OnUpdateNextcode)
  69. ON_COMMAND(ID_PREVCODE, OnPrevcode)
  70. ON_UPDATE_COMMAND_UI(ID_PREVCODE, OnUpdatePrevcode)
  71. ON_COMMAND(ID_CALL_CHAR, OnCallChar)
  72. ON_UPDATE_COMMAND_UI(ID_CALL_CHAR, OnUpdateCallChar)
  73. ON_COMMAND(ID_IMPORT_FILE, OnImportFile)
  74. ON_UPDATE_COMMAND_UI(ID_IMPORT_FILE, OnUpdateImportFile)
  75. ON_COMMAND(ID_LINKBATCHMODE, OnLinkbatchmode)
  76. ON_UPDATE_COMMAND_UI(ID_LINKBATCHMODE, OnUpdateLinkbatchmode)
  77. ON_COMMAND(ID_HELP, OnHelp)
  78. ON_COMMAND(ID_FIT_CURVE, OnFitCurve)
  79. ON_UPDATE_COMMAND_UI(ID_FIT_CURVE, OnUpdateFitCurve)
  80. ON_COMMAND(ID_ROTATE, OnRotate)
  81. ON_UPDATE_COMMAND_UI(ID_ROTATE, OnUpdateRotate)
  82. ON_COMMAND(ID_PALETTEBRUSH, OnPalettebrush)
  83. ON_UPDATE_COMMAND_UI(ID_PALETTEBRUSH, OnUpdatePalettebrush)
  84. ON_COMMAND(ID_PALETTECIRCLE, OnPalettecircle)
  85. ON_UPDATE_COMMAND_UI(ID_PALETTECIRCLE, OnUpdatePalettecircle)
  86. ON_COMMAND(ID_PALETTECIRCLEFILL, OnPalettecirclefill)
  87. ON_UPDATE_COMMAND_UI(ID_PALETTECIRCLEFILL, OnUpdatePalettecirclefill)
  88. ON_COMMAND(ID_PALETTEFREEFORM, OnPalettefreeform)
  89. ON_UPDATE_COMMAND_UI(ID_PALETTEFREEFORM, OnUpdatePalettefreeform)
  90. ON_COMMAND(ID_PALETTEERASER, OnPaletteeraser)
  91. ON_UPDATE_COMMAND_UI(ID_PALETTEERASER, OnUpdatePaletteeraser)
  92. ON_COMMAND(ID_PALETTEPEN, OnPalettepen)
  93. ON_UPDATE_COMMAND_UI(ID_PALETTEPEN, OnUpdatePalettepen)
  94. ON_COMMAND(ID_PALETTERECT, OnPaletterect)
  95. ON_UPDATE_COMMAND_UI(ID_PALETTERECT, OnUpdatePaletterect)
  96. ON_COMMAND(ID_PALETTERECTBAND, OnPaletterectband)
  97. ON_UPDATE_COMMAND_UI(ID_PALETTERECTBAND, OnUpdatePaletterectband)
  98. ON_COMMAND(ID_PALETTERECTFILL, OnPaletterectfill)
  99. ON_UPDATE_COMMAND_UI(ID_PALETTERECTFILL, OnUpdatePaletterectfill)
  100. ON_COMMAND(ID_PALETTESLOPE, OnPaletteslope)
  101. ON_UPDATE_COMMAND_UI(ID_PALETTESLOPE, OnUpdatePaletteslope)
  102. ON_CBN_SELCHANGE(IDC_SELECTCHARSET, OnSelectCharSet)
  103. //}}AFX_MSG_MAP
  104. END_MESSAGE_MAP()
  105. static UINT BASED_CODE Palette[] =
  106. {
  107. // Correspond to palette bitmap data
  108. ID_PALETTEPEN,
  109. ID_PALETTEBRUSH,
  110. ID_PALETTESLOPE,
  111. ID_PALETTERECT,
  112. ID_PALETTERECTFILL,
  113. ID_PALETTECIRCLE,
  114. ID_PALETTECIRCLEFILL,
  115. ID_PALETTERECTBAND,
  116. ID_PALETTEFREEFORM,
  117. ID_PALETTEERASER
  118. };
  119. /************************************************/
  120. /* */
  121. /* Constructor */
  122. /* */
  123. /************************************************/
  124. CMainFrame::CMainFrame()
  125. {
  126. CustomWndOpen = FALSE; // Whether edit open or not
  127. RefferWndVisible = FALSE; // Whether referrence visible or not
  128. ToolBarVisible = TRUE; // Whether toolbox visible or not
  129. GuideBarVisible = TRUE; // Whether guidebar visible or not
  130. }
  131. /************************************************/
  132. /* */
  133. /* Destructor */
  134. /* */
  135. /************************************************/
  136. CMainFrame::~CMainFrame()
  137. {
  138. }
  139. /************************************************/
  140. /* */
  141. /* Create MDI mainframe window */
  142. /* */
  143. /************************************************/
  144. BOOL
  145. CMainFrame::Create(
  146. LPCTSTR WndTitle,
  147. DWORD WndStyle,
  148. RECT MainWndRect,
  149. LPCTSTR nID)
  150. {
  151. // Register MDI mainframe window class
  152. const TCHAR *MainWndClass =
  153. AfxRegisterWndClass( 0, AfxGetApp()->LoadStandardCursor(IDC_ARROW),
  154. (HBRUSH)(COLOR_WINDOW+1),
  155. AfxGetApp()->LoadIcon(IDR_MAINFRAME));
  156. if( !CFrameWnd::Create( MainWndClass,
  157. WndTitle, WndStyle, MainWndRect, NULL, nID))
  158. return FALSE;
  159. return TRUE;
  160. }
  161. /************************************************/
  162. /* */
  163. /* Process before MDI mainframe create */
  164. /* */
  165. /************************************************/
  166. int
  167. CMainFrame::OnCreate(
  168. LPCREATESTRUCT lpCreateStruct)
  169. {
  170. if( CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  171. return -1;
  172. if( !LoadAccelTable( MAKEINTRESOURCE(IDR_MAINFRAME)))
  173. return -1;
  174. if( !CreateGuideBar())
  175. return -1;
  176. if( !CreateToolBar())
  177. return -1;
  178. EnableDocking(CBRS_ALIGN_ANY);
  179. if( !CreateReferWnd())
  180. return -1;
  181. m_wndToolBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_LEFT);
  182. DockControlBar(&m_wndToolBar);
  183. return 0;
  184. }
  185. /************************************************/
  186. /* */
  187. /* Create client area */
  188. /* */
  189. /************************************************/
  190. BOOL
  191. CMainFrame::OnCreateClient(
  192. LPCREATESTRUCT lpcs,
  193. CCreateContext *pContext)
  194. {
  195. if( !CMDIFrameWnd::CreateClient( lpcs, NULL))
  196. return FALSE;
  197. return TRUE;
  198. }
  199. /************************************************/
  200. /* */
  201. /* Create tool bar ( left side) */
  202. /* */
  203. /************************************************/
  204. BOOL
  205. CMainFrame::CreateToolBar()
  206. {
  207. if( !m_wndToolBar.Create( this, WS_CHILD | WS_VISIBLE | CBRS_LEFT |
  208. CBRS_TOOLTIPS, 0)||
  209. !m_wndToolBar.LoadBitmap( IDR_MAINFRAME) ||
  210. !m_wndToolBar.SetButtons( Palette,
  211. sizeof( Palette)/sizeof( UINT)))
  212. return FALSE;
  213. else
  214. return TRUE;
  215. }
  216. /************************************************/
  217. /* */
  218. /* Create Guideline bar ( upper side) */
  219. /* */
  220. /************************************************/
  221. BOOL
  222. CMainFrame::CreateGuideBar()
  223. {
  224. const UINT nIndicators[] = {IDS_CHARSET_STR,
  225. IDS_CODE_STR,
  226. IDS_FONT_STR,
  227. IDS_FILE_STR};
  228. if( !m_wndGuideBar.Create( this, ID_TOOLBAR) ||
  229. !m_wndGuideBar.SetIndicators(nIndicators,
  230. sizeof(nIndicators)/sizeof(UINT)))
  231. return FALSE;
  232. else{
  233. m_wndGuideBar.PositionStatusPane();
  234. return TRUE;
  235. }
  236. }
  237. /************************************************/
  238. /* */
  239. /* COMMAND "ASSOCIATIONS" */
  240. /* */
  241. /************************************************/
  242. void
  243. CMainFrame::OnSelectfamily()
  244. {
  245. CAssocDlg dlg;
  246. if( CustomWndOpen){
  247. if( !OutputSaveMessage())
  248. return;
  249. }
  250. if( dlg.DoModal() == IDOK){
  251. if( CustomWndOpen){
  252. pEditChild->UpdateBitmap();
  253. pEditChild->SelectCodes();
  254. }
  255. m_wndGuideBar.PositionStatusPane();
  256. }
  257. }
  258. /************************************************/
  259. /* */
  260. /* COMMAND "SELECTCODE" */
  261. /* */
  262. /************************************************/
  263. void
  264. CMainFrame::OnReadChar()
  265. {
  266. CEudcDlg dlg;
  267. if( CustomWndOpen){
  268. if( !OutputSaveMessage())
  269. return;
  270. }
  271. dlg.WorRFlag = FALSE;
  272. if( dlg.DoModal() == IDOK){
  273. AfxGetApp()->DoWaitCursor(1);
  274. EudcWndRect.SetRectEmpty();
  275. if( !CustomWndOpen){
  276. // CalcEudcWndRect();
  277. CEditWnd *pEudcWnd = new CEditWnd;
  278. if( !pEudcWnd->Create( TEXT("EDITWINDOW"),
  279. WS_CHILD | WS_VISIBLE | WS_BORDER,
  280. EudcWndRect,this))
  281. return;
  282. pEditChild = pEudcWnd;
  283. SetEudcWndPos();
  284. pEudcWnd->ShowWindow( SW_SHOWNORMAL);
  285. pEudcWnd->UpdateWindow();
  286. CustomWndOpen = TRUE;
  287. }
  288. pEditChild->UpdateBitmap();
  289. pEditChild->UpdateCode = dlg.m_EditList.SelectCode;
  290. pEditChild->SelectCodes();
  291. wsprintf( SelectEUDC.m_Code, TEXT("%X"), dlg.m_EditList.SelectCode);
  292. CountryInfo.CurrentRange = dlg.m_EditList.cRange;
  293. m_wndGuideBar.PositionStatusPane();
  294. AfxGetApp()->DoWaitCursor( -1);
  295. }
  296. }
  297. /************************************************/
  298. /* */
  299. /* COMMAND "SELECTCODE" (Update) */
  300. /* */
  301. /************************************************/
  302. void
  303. CMainFrame::OnUpdateReadChar(
  304. CCmdUI* pCmdUI)
  305. {
  306. if( SelectEUDC.m_Font[0] != TEXT('\0') &&
  307. InqTypeFace((TCHAR *)SelectEUDC.m_Font,
  308. ( TCHAR *)SelectEUDC.m_File, sizeof( SelectEUDC.m_File)/sizeof(TCHAR)))
  309. pCmdUI->Enable( TRUE);
  310. else pCmdUI->Enable( FALSE);
  311. }
  312. /************************************************/
  313. /* */
  314. /* COMMAND "REGISTER" */
  315. /* */
  316. /************************************************/
  317. void
  318. CMainFrame::OnSavechar()
  319. {
  320. AfxGetApp()->DoWaitCursor(1);
  321. pEditChild->SaveEUDCCode(MB_OK);
  322. AfxGetApp()->DoWaitCursor(-1);
  323. }
  324. /************************************************/
  325. /* */
  326. /* COMMAND "REGISTER" (Update) */
  327. /* */
  328. /************************************************/
  329. void
  330. CMainFrame::OnUpdateSavechar(
  331. CCmdUI* pCmdUI)
  332. {
  333. if( InqTypeFace((TCHAR *)SelectEUDC.m_Font,
  334. ( TCHAR *)SelectEUDC.m_File,
  335. sizeof( SelectEUDC.m_File )/sizeof(TCHAR)) && CustomWndOpen)
  336. pCmdUI->Enable( TRUE);
  337. else pCmdUI->Enable( FALSE);
  338. }
  339. /************************************************/
  340. /* */
  341. /* COMMAND "REGISTER AS" */
  342. /* */
  343. /************************************************/
  344. void
  345. CMainFrame::OnSaveCharas()
  346. {
  347. CEudcDlg dlg;
  348. dlg.WorRFlag = TRUE;
  349. if( dlg.DoModal() == IDOK){
  350. AfxGetApp()->DoWaitCursor(1);
  351. pEditChild->UpdateCode = dlg.m_EditList.SelectCode;
  352. pEditChild->SaveEUDCCode(MB_OK);
  353. wsprintf( SelectEUDC.m_Code, TEXT("%X"), dlg.m_EditList.SelectCode);
  354. CountryInfo.CurrentRange = dlg.m_EditList.cRange;
  355. m_wndGuideBar.PositionStatusPane();
  356. AfxGetApp()->DoWaitCursor(-1);
  357. }
  358. }
  359. /************************************************/
  360. /* */
  361. /* COMMAND "REGISTER AS" (Update) */
  362. /* */
  363. /************************************************/
  364. void
  365. CMainFrame::OnUpdateSaveCharas(
  366. CCmdUI* pCmdUI)
  367. {
  368. if( InqTypeFace((TCHAR *)SelectEUDC.m_Font,
  369. ( TCHAR *)SelectEUDC.m_File,
  370. sizeof( SelectEUDC.m_File )/sizeof(TCHAR)) && CustomWndOpen)
  371. pCmdUI->Enable( TRUE);
  372. else pCmdUI->Enable( FALSE);
  373. }
  374. /************************************************/
  375. /* */
  376. /* COMMAND "IMPORT" */
  377. /* */
  378. /************************************************/
  379. void
  380. CMainFrame::OnImportFile()
  381. {
  382. CImportDlg dlg1;
  383. BOOL Tmp;
  384. if( CustomWndOpen){
  385. if( !OutputSaveMessage())
  386. return;
  387. }
  388. if (!OExistTTF(SelectEUDC.m_File))
  389. {
  390. OutputMessageBox(this->GetSafeHwnd(), IDS_MAINFRAMETITLE, IDS_NOTTE, TRUE);
  391. return;
  392. }
  393. if( dlg1.DoModal() == IDOK){
  394. if( CustomWndOpen){
  395. Tmp = FALSE;
  396. if( pEditChild->FlagTmp){
  397. Tmp = TRUE;
  398. this->SendMessage( WM_COMMAND,
  399. ID_FIT_CURVE, 0L);
  400. }
  401. }
  402. CGageDlg dlg2;
  403. if( dlg2.DoModal() == IDOK){
  404. ;
  405. }
  406. if( CustomWndOpen){
  407. if( Tmp){
  408. this->SendMessage( WM_COMMAND,
  409. ID_FIT_CURVE, 0L);
  410. }
  411. }
  412. }else ;
  413. }
  414. /************************************************/
  415. /* */
  416. /* COMMAND "IMPORT" (Update) */
  417. /* */
  418. /************************************************/
  419. void
  420. CMainFrame::OnUpdateImportFile(
  421. CCmdUI* pCmdUI)
  422. {
  423. if(InqTypeFace((TCHAR *)SelectEUDC.m_Font,
  424. (TCHAR *)SelectEUDC.m_File,
  425. sizeof( SelectEUDC.m_File)/sizeof(TCHAR)))
  426. pCmdUI->Enable( TRUE);
  427. else pCmdUI->Enable( FALSE);
  428. }
  429. /************************************************/
  430. /* */
  431. /* COMMAND "Select Charset" */
  432. /* */
  433. /************************************************/
  434. void
  435. CMainFrame::OnSelectCharSet()
  436. {
  437. CHAR CPCode[2];
  438. WCHAR UCode[1];
  439. CEudcDlg dlg;
  440. UINT LocalCP =GetACP();
  441. if (m_wndGuideBar.m_comboCharset.GetCurSel() ==
  442. m_wndGuideBar.m_comboCharset.GetCount()-1){
  443. //We are switching to unicode.
  444. if ( CountryInfo.bUnicodeMode )
  445. // We are already in unicode mode. No change.
  446. return;
  447. CountryInfo.CurrentRange = CountryInfo.nRange-1;
  448. CountryInfo.bUnicodeMode =TRUE;
  449. SetTrailByteRange(LocalCP);
  450. if( SelectEUDC.m_Code[0] != '\0'){
  451. CPCode[0]= HIBYTE(Mytcstol(SelectEUDC.m_Code, (TCHAR **)0, 16));
  452. CPCode[1]= LOBYTE(Mytcstol(SelectEUDC.m_Code, (TCHAR **)0, 16));
  453. MultiByteToWideChar(LocalCP, 0, CPCode,2, UCode,1);
  454. wsprintf( SelectEUDC.m_Code, TEXT("%X"),UCode[0]);
  455. m_wndGuideBar.PositionStatusPane();
  456. pEditChild->UpdateCode = UCode[0];
  457. dlg.m_EditList.SelectCode = UCode[0];
  458. }
  459. }else{
  460. //We are switching to code page
  461. if ( !CountryInfo.bUnicodeMode )
  462. // We are already in code page mode. No change.
  463. return;
  464. CountryInfo.bUnicodeMode = FALSE;
  465. SetTrailByteRange(LocalCP);
  466. if( SelectEUDC.m_Code[0] != '\0'){
  467. BOOL bNotConverted;
  468. UCode[0] = (WCHAR)Mytcstol(SelectEUDC.m_Code, (TCHAR **)0, 16);
  469. WideCharToMultiByte(LocalCP, 0,UCode,1, CPCode,2, NULL, &bNotConverted);
  470. TCHAR CodeTmp[16] = {0};
  471. // fix for 7831
  472. BOOL bValidCode = TRUE;
  473. if (CountryInfo.LangID == EUDC_CHS)
  474. {
  475. bValidCode = FALSE;
  476. WORD wdCode = MAKEWORD(CPCode[1], CPCode[0]);
  477. BYTE sOffset = LOBYTE(wdCode);
  478. int kk;
  479. for (kk = 0; kk < CountryInfo.nRange-1; kk++)
  480. {
  481. if ((wdCode >= CountryInfo.sRange[kk]) &&
  482. (wdCode <= CountryInfo.eRange[kk]))
  483. break;
  484. }
  485. CorrectTrailByteRange(kk);
  486. for( kk = 0; kk < CountryInfo.nTralByte; kk++)
  487. {
  488. if( sOffset >= CountryInfo.sTralByte[kk] &&
  489. sOffset <= CountryInfo.eTralByte[kk])
  490. {
  491. bValidCode = TRUE;
  492. break;
  493. }
  494. }
  495. }
  496. // end of fix for 7831
  497. if (bNotConverted || !bValidCode){
  498. OutputMessageBox( this->GetSafeHwnd(),
  499. IDS_MAINFRAMETITLE,
  500. IDS_INVALID_CODE_MSG, TRUE);
  501. if( CustomWndOpen){
  502. CountryInfo.bUnicodeMode = TRUE;
  503. OutputSaveMessage();
  504. CountryInfo.bUnicodeMode = FALSE;
  505. }
  506. CountryInfo.CurrentRange = 0;
  507. dlg.m_EditList.SetInitEUDCCodeRange(CountryInfo.CurrentRange);
  508. dlg.m_EditList.SelectCode=CountryInfo.sRange[CountryInfo.CurrentRange];
  509. pEditChild->SelectCodes();
  510. wsprintf( SelectEUDC.m_Code, TEXT("%X"), dlg.m_EditList.SelectCode);
  511. OnReadChar();
  512. return;
  513. }else{
  514. wsprintf( CodeTmp, TEXT("%X"), (BYTE)CPCode[0]);
  515. SelectEUDC.m_Code[0] = CodeTmp[0];
  516. SelectEUDC.m_Code[1] = CodeTmp[1];
  517. wsprintf( CodeTmp, TEXT("%X"), (BYTE)CPCode[1]);
  518. SelectEUDC.m_Code[2] = CodeTmp[0];
  519. SelectEUDC.m_Code[3] = CodeTmp[1];
  520. dlg.m_EditList.SelectCode = (WORD)Mytcstol(SelectEUDC.m_Code, (TCHAR **)0, 16);
  521. for (int i=0;i<CountryInfo.nRange - 1; i++)
  522. {
  523. if (dlg.m_EditList.SelectCode >= CountryInfo.sRange[i] &&
  524. dlg.m_EditList.SelectCode <= CountryInfo.eRange[i])
  525. {
  526. CountryInfo.CurrentRange = i;
  527. }
  528. }
  529. }
  530. m_wndGuideBar.PositionStatusPane();
  531. pEditChild->UpdateCode = dlg.m_EditList.SelectCode;
  532. }
  533. else
  534. {
  535. CountryInfo.CurrentRange = 0;
  536. }
  537. }
  538. dlg.m_EditList.SetInitEUDCCodeRange( CountryInfo.CurrentRange);
  539. }
  540. /************************************************/
  541. /* */
  542. /* COMMAND "CALL" */
  543. /* */
  544. /************************************************/
  545. void
  546. CMainFrame::OnCallChar()
  547. {
  548. UINT Result;
  549. if( CustomWndOpen){
  550. if( !OutputSaveMessage())
  551. return;
  552. }
  553. if(( Result = SetReffCode( TRUE)) == IDOK){
  554. pEditChild->UpdateBitmap();
  555. pEditChild->CallCharTextOut();
  556. }
  557. }
  558. /************************************************/
  559. /* */
  560. /* COMMAND "CALL" (Update) */
  561. /* */
  562. /************************************************/
  563. void
  564. CMainFrame::OnUpdateCallChar(
  565. CCmdUI* pCmdUI)
  566. {
  567. if( CustomWndOpen)
  568. pCmdUI->Enable( TRUE);
  569. else pCmdUI->Enable( FALSE);
  570. }
  571. /************************************************/
  572. /* */
  573. /* COMMAND "LINK" */
  574. /* */
  575. /************************************************/
  576. void
  577. CMainFrame::OnLinkime()
  578. {
  579. #if 0
  580. CIMEDlg dlg;
  581. dlg.EudcCode = pEditChild->UpdateCode;
  582. dlg.DoModal();
  583. #endif
  584. ImeLink( this->GetSafeHwnd(),
  585. pEditChild->UpdateCode,
  586. CountryInfo.bUnicodeMode ? TRUE : FALSE,
  587. AfxGetInstanceHandle());
  588. }
  589. /************************************************/
  590. /* */
  591. /* COMMAND "LINK" (Update) */
  592. /* */
  593. /************************************************/
  594. void
  595. CMainFrame::OnUpdateLinkime(
  596. CCmdUI* pCmdUI)
  597. {
  598. if( CustomWndOpen &&
  599. ( CountryInfo.LangID == EUDC_CHT ||
  600. CountryInfo.LangID == EUDC_CHS )){
  601. pCmdUI->Enable(TRUE);
  602. }else pCmdUI->Enable(FALSE);
  603. }
  604. /************************************************/
  605. /* */
  606. /* COMMAND "BATCHLINK" */
  607. /* */
  608. /************************************************/
  609. void
  610. CMainFrame::OnLinkbatchmode()
  611. {
  612. CBLinkDlg dlg;
  613. dlg.DoModal();
  614. }
  615. /************************************************/
  616. /* */
  617. /* COMMAND "BATCHLINK" (Update) */
  618. /* */
  619. /************************************************/
  620. void
  621. CMainFrame::OnUpdateLinkbatchmode(
  622. CCmdUI* pCmdUI)
  623. {
  624. #ifdef BUILD_ON_WINNT
  625. //
  626. // IME batch link should be font independent feature
  627. // and available after launch EUDCEDIT. The batch link
  628. // menu item is grayed after launching EUDCEDIT.
  629. // It will be enabled after font association and EUDC
  630. // code are selected.
  631. // But font association and EUDC code selection do not
  632. // have any relationship with IME batch link.
  633. // The user does not need to select font association
  634. // and EUDC code if they want to do IME batch link only.
  635. //
  636. // NTRaid #19424.
  637. //
  638. if( CountryInfo.LangID == EUDC_CHT ||
  639. CountryInfo.LangID == EUDC_CHS ){
  640. pCmdUI->Enable(TRUE);
  641. }else pCmdUI->Enable(FALSE);
  642. #else
  643. if( CustomWndOpen &&
  644. ( CountryInfo.LangID == EUDC_CHT ||
  645. CountryInfo.LangID == EUDC_CHS )){
  646. pCmdUI->Enable(TRUE);
  647. }else pCmdUI->Enable(FALSE);
  648. #endif // BUILD_ON_WINNT
  649. }
  650. /************************************************/
  651. /* */
  652. /* COMMAND "GUIDEBAR" */
  653. /* */
  654. /************************************************/
  655. BOOL
  656. CMainFrame::OnStylesBar(
  657. UINT nID)
  658. {
  659. GuideBarVisible = !GuideBarVisible;
  660. if( GuideBarVisible)
  661. m_wndGuideBar.ShowWindow(SW_SHOWNA);
  662. else m_wndGuideBar.ShowWindow(SW_HIDE);
  663. m_wndGuideBar.PositionStatusPane();
  664. this->SendMessage( WM_SIZE);
  665. return TRUE;
  666. }
  667. /************************************************/
  668. /* */
  669. /* COMMAND "GUIDEBAR" (Update) */
  670. /* */
  671. /************************************************/
  672. void
  673. CMainFrame::OnUpdateStylesBar(
  674. CCmdUI* pCmdUI)
  675. {
  676. pCmdUI->SetCheck(GuideBarVisible);
  677. }
  678. /************************************************/
  679. /* */
  680. /* COMMAND "TOOLBOX" */
  681. /* */
  682. /************************************************/
  683. void
  684. CMainFrame::OnToolbar()
  685. {
  686. ToolBarVisible = !ToolBarVisible;
  687. if( ToolBarVisible)
  688. {
  689. DockControlBar(&m_wndToolBar);
  690. m_wndToolBar.ShowWindow( SW_SHOWNORMAL);
  691. }else{
  692. if (m_wndToolBar.IsFloating())
  693. {
  694. m_wndToolBar.GetParentOwner()->ShowWindow( SW_HIDE);
  695. }
  696. else
  697. {
  698. m_wndToolBar.ShowWindow( SW_HIDE);
  699. }
  700. }
  701. this->SendMessage(WM_SIZE);
  702. }
  703. /************************************************/
  704. /* */
  705. /* COMMAND "TOOLBOX" (Update) */
  706. /* */
  707. /************************************************/
  708. void
  709. CMainFrame::OnUpdateToolbar(
  710. CCmdUI* pCmdUI)
  711. {
  712. ToolBarVisible = m_wndToolBar.IsWindowVisible();
  713. pCmdUI->SetCheck(ToolBarVisible);
  714. }
  715. /************************************************/
  716. /* */
  717. /* COMMAND "GRID" */
  718. /* */
  719. /************************************************/
  720. void
  721. CMainFrame::OnShowGrid()
  722. {
  723. pEditChild->GridShow = !pEditChild->GridShow;
  724. pEditChild->Invalidate( FALSE);
  725. pEditChild->UpdateWindow();
  726. if( RefferWndVisible){
  727. pRefrChild->GridShow = !pRefrChild->GridShow;
  728. pRefrChild->Invalidate(FALSE);
  729. pRefrChild->UpdateWindow();
  730. }
  731. }
  732. /************************************************/
  733. /* */
  734. /* COMMAND "GRID" (Update) */
  735. /* */
  736. /************************************************/
  737. void
  738. CMainFrame::OnUpdateShowGrid(
  739. CCmdUI* pCmdUI)
  740. {
  741. if( CustomWndOpen){
  742. pCmdUI->Enable(1);
  743. pCmdUI->SetCheck( pEditChild->GridShow);
  744. }else pCmdUI->Enable(0);
  745. }
  746. /************************************************/
  747. /* */
  748. /* COMMAND "NEXT CODE" */
  749. /* */
  750. /************************************************/
  751. void
  752. CMainFrame::OnNextcode()
  753. {
  754. if( CustomWndOpen){
  755. if( !OutputSaveMessage())
  756. return;
  757. }
  758. EudcWndRect.SetRectEmpty();
  759. pEditChild->UpdateBitmap();
  760. pEditChild->UpdateCode++;
  761. pEditChild->UpdateCode = CorrectCode( pEditChild->UpdateCode, TRUE);
  762. pEditChild->SelectCodes();
  763. wsprintf( SelectEUDC.m_Code, TEXT("%X"), pEditChild->UpdateCode);
  764. m_wndGuideBar.PositionStatusPane();
  765. }
  766. /************************************************/
  767. /* */
  768. /* COMMAND "NEXT CODE" (Update) */
  769. /* */
  770. /************************************************/
  771. void
  772. CMainFrame::OnUpdateNextcode(
  773. CCmdUI* pCmdUI)
  774. {
  775. if( CustomWndOpen &&
  776. ( InqTypeFace((TCHAR *)SelectEUDC.m_Font,
  777. (TCHAR *)SelectEUDC.m_File, sizeof( SelectEUDC.m_File)/sizeof(TCHAR)))){
  778. if( CountryInfo.eRange[CountryInfo.CurrentRange]
  779. <= pEditChild->UpdateCode)
  780. pCmdUI->Enable( FALSE);
  781. else pCmdUI->Enable( TRUE);
  782. }else pCmdUI->Enable( FALSE);
  783. }
  784. /************************************************/
  785. /* */
  786. /* COMMAND "PREV CODE" */
  787. /* */
  788. /************************************************/
  789. void
  790. CMainFrame::OnPrevcode()
  791. {
  792. if( CustomWndOpen){
  793. if( !OutputSaveMessage())
  794. return;
  795. }
  796. EudcWndRect.SetRectEmpty();
  797. pEditChild->UpdateBitmap();
  798. pEditChild->UpdateCode--;
  799. pEditChild->UpdateCode = CorrectCode( pEditChild->UpdateCode, FALSE);
  800. pEditChild->SelectCodes();
  801. wsprintf( SelectEUDC.m_Code, TEXT("%X"), pEditChild->UpdateCode);
  802. m_wndGuideBar.PositionStatusPane();
  803. }
  804. /************************************************/
  805. /* */
  806. /* COMMAND "PREV CODE" (Update) */
  807. /* */
  808. /************************************************/
  809. void
  810. CMainFrame::OnUpdatePrevcode(
  811. CCmdUI* pCmdUI)
  812. {
  813. if( CustomWndOpen &&
  814. ( InqTypeFace((TCHAR *)SelectEUDC.m_Font,
  815. (TCHAR *)SelectEUDC.m_File, sizeof( SelectEUDC.m_File)/sizeof(TCHAR)))){
  816. if( CountryInfo.sRange[CountryInfo.CurrentRange]
  817. >= pEditChild->UpdateCode)
  818. pCmdUI->Enable( FALSE);
  819. else pCmdUI->Enable( TRUE);
  820. }else pCmdUI->Enable( FALSE);
  821. }
  822. /************************************************/
  823. /* */
  824. /* COMMAND "SHOW OUTLINE" */
  825. /* */
  826. /************************************************/
  827. void
  828. CMainFrame::OnFitCurve()
  829. {
  830. if( CustomWndOpen){
  831. pEditChild->FlagTmp = !pEditChild->FlagTmp;
  832. pEditChild->Invalidate(FALSE);
  833. pEditChild->UpdateWindow();
  834. }
  835. }
  836. /************************************************/
  837. /* */
  838. /* COMMAND "SHOW OUTLINE"(Update) */
  839. /* */
  840. /************************************************/
  841. void
  842. CMainFrame::OnUpdateFitCurve(
  843. CCmdUI* pCmdUI)
  844. {
  845. if( CustomWndOpen){
  846. pCmdUI->Enable(TRUE);
  847. pCmdUI->SetCheck( pEditChild->FlagTmp);
  848. }else pCmdUI->Enable(FALSE);
  849. }
  850. /************************************************/
  851. /* */
  852. /* COMMAND "PEN" */
  853. /* */
  854. /************************************************/
  855. void
  856. CMainFrame::OnPalettepen()
  857. {
  858. pEditChild->SelectItem = PEN;
  859. pEditChild->WriteSelRectBitmap();
  860. pEditChild->MDIActivate();
  861. }
  862. /************************************************/
  863. /* */
  864. /* COMMAND "PEN" (Update) */
  865. /* */
  866. /************************************************/
  867. void
  868. CMainFrame::OnUpdatePalettepen(
  869. CCmdUI* pCmdUI)
  870. {
  871. if( CustomWndOpen){
  872. pCmdUI->Enable( TRUE);
  873. if( pEditChild->SelectItem == PEN)
  874. pCmdUI->SetRadio( TRUE);
  875. else pCmdUI->SetRadio( FALSE);
  876. }else pCmdUI->Enable( FALSE);
  877. }
  878. /************************************************/
  879. /* */
  880. /* COMMAND "BRUSh" */
  881. /* */
  882. /************************************************/
  883. void
  884. CMainFrame::OnPalettebrush()
  885. {
  886. pEditChild->SelectItem = BRUSH;
  887. pEditChild->WriteSelRectBitmap();
  888. pEditChild->MDIActivate();
  889. }
  890. /************************************************/
  891. /* */
  892. /* COMMAND "BRUSH" (Update) */
  893. /* */
  894. /************************************************/
  895. void
  896. CMainFrame::OnUpdatePalettebrush(
  897. CCmdUI* pCmdUI)
  898. {
  899. if( CustomWndOpen){
  900. pCmdUI->Enable( TRUE);
  901. if( pEditChild->SelectItem == BRUSH)
  902. pCmdUI->SetRadio( TRUE);
  903. else pCmdUI->SetRadio( FALSE);
  904. }else pCmdUI->Enable( FALSE);
  905. }
  906. /************************************************/
  907. /* */
  908. /* COMMAND "STRAIGHT LINE" */
  909. /* */
  910. /************************************************/
  911. void
  912. CMainFrame::OnPaletteslope()
  913. {
  914. pEditChild->SelectItem = SLOPE;
  915. pEditChild->WriteSelRectBitmap();
  916. pEditChild->MDIActivate();
  917. }
  918. /************************************************/
  919. /* */
  920. /* COMMAND "STRAIGHT LINE"(Update) */
  921. /* */
  922. /************************************************/
  923. void
  924. CMainFrame::OnUpdatePaletteslope(
  925. CCmdUI* pCmdUI)
  926. {
  927. if( CustomWndOpen){
  928. pCmdUI->Enable( TRUE);
  929. if( pEditChild->SelectItem == SLOPE)
  930. pCmdUI->SetRadio( TRUE);
  931. else pCmdUI->SetRadio( FALSE);
  932. }else pCmdUI->Enable( FALSE);
  933. }
  934. /************************************************/
  935. /* */
  936. /* COMMAND "RECTANGLE" */
  937. /* */
  938. /************************************************/
  939. void
  940. CMainFrame::OnPaletterect()
  941. {
  942. pEditChild->SelectItem = RECTBAND;
  943. pEditChild->WriteSelRectBitmap();
  944. pEditChild->MDIActivate();
  945. }
  946. /************************************************/
  947. /* */
  948. /* COMMAND "RECTANGLE" (Update) */
  949. /* */
  950. /************************************************/
  951. void
  952. CMainFrame::OnUpdatePaletterect(
  953. CCmdUI* pCmdUI)
  954. {
  955. if( CustomWndOpen){
  956. pCmdUI->Enable( TRUE);
  957. if( pEditChild->SelectItem == RECTBAND)
  958. pCmdUI->SetRadio( TRUE);
  959. else pCmdUI->SetRadio( FALSE);
  960. }else pCmdUI->Enable( FALSE);
  961. }
  962. /************************************************/
  963. /* */
  964. /* COMMAND "FILRECTANGLE" */
  965. /* */
  966. /************************************************/
  967. void
  968. CMainFrame::OnPaletterectfill()
  969. {
  970. pEditChild->SelectItem = RECTFILL;
  971. pEditChild->WriteSelRectBitmap();
  972. pEditChild->MDIActivate();
  973. }
  974. /************************************************/
  975. /* */
  976. /* COMMAND "FILRECTANGLE" (Update) */
  977. /* */
  978. /************************************************/
  979. void
  980. CMainFrame::OnUpdatePaletterectfill(
  981. CCmdUI* pCmdUI)
  982. {
  983. if( CustomWndOpen){
  984. pCmdUI->Enable( TRUE);
  985. if( pEditChild->SelectItem == RECTFILL)
  986. pCmdUI->SetRadio( TRUE);
  987. else pCmdUI->SetRadio( FALSE);
  988. }else pCmdUI->Enable( FALSE);
  989. }
  990. /************************************************/
  991. /* */
  992. /* COMMAND "CIRCLE" */
  993. /* */
  994. /************************************************/
  995. void
  996. CMainFrame::OnPalettecircle()
  997. {
  998. pEditChild->SelectItem = CIRCLE;
  999. pEditChild->WriteSelRectBitmap();
  1000. pEditChild->MDIActivate();
  1001. }
  1002. /************************************************/
  1003. /* */
  1004. /* COMMAND "CIRCLE" (Update) */
  1005. /* */
  1006. /************************************************/
  1007. void
  1008. CMainFrame::OnUpdatePalettecircle(
  1009. CCmdUI* pCmdUI)
  1010. {
  1011. if( CustomWndOpen){
  1012. pCmdUI->Enable( TRUE);
  1013. if( pEditChild->SelectItem == CIRCLE)
  1014. pCmdUI->SetRadio( TRUE);
  1015. else pCmdUI->SetRadio( FALSE);
  1016. }else pCmdUI->Enable( FALSE);
  1017. }
  1018. /************************************************/
  1019. /* */
  1020. /* COMMAND "FILCIRCLE" */
  1021. /* */
  1022. /************************************************/
  1023. void
  1024. CMainFrame::OnPalettecirclefill()
  1025. {
  1026. pEditChild->SelectItem = CIRCLEFILL;
  1027. pEditChild->WriteSelRectBitmap();
  1028. pEditChild->MDIActivate();
  1029. }
  1030. /************************************************/
  1031. /* */
  1032. /* COMMAND "FILCIRCLE" (Update) */
  1033. /* */
  1034. /************************************************/
  1035. void
  1036. CMainFrame::OnUpdatePalettecirclefill(
  1037. CCmdUI* pCmdUI)
  1038. {
  1039. if( CustomWndOpen){
  1040. pCmdUI->Enable( TRUE);
  1041. if( pEditChild->SelectItem == CIRCLEFILL)
  1042. pCmdUI->SetRadio( TRUE);
  1043. else pCmdUI->SetRadio( FALSE);
  1044. }else pCmdUI->Enable( FALSE);
  1045. }
  1046. /************************************************/
  1047. /* */
  1048. /* COMMAND "FREEFORM" */
  1049. /* */
  1050. /************************************************/
  1051. void
  1052. CMainFrame::OnPalettefreeform()
  1053. {
  1054. pEditChild->SelectItem = FREEFORM;
  1055. pRefrChild->SelectItems = FREEFORM;
  1056. pEditChild->WriteSelRectBitmap();
  1057. pEditChild->MDIActivate();
  1058. }
  1059. /************************************************/
  1060. /* */
  1061. /* COMMAND "FREEFORM" (Update) */
  1062. /* */
  1063. /************************************************/
  1064. void
  1065. CMainFrame::OnUpdatePalettefreeform(
  1066. CCmdUI* pCmdUI)
  1067. {
  1068. if( CustomWndOpen){
  1069. pCmdUI->Enable( TRUE);
  1070. if( pEditChild->SelectItem == FREEFORM)
  1071. pCmdUI->SetRadio( TRUE);
  1072. else pCmdUI->SetRadio( FALSE);
  1073. }else pCmdUI->Enable( FALSE);
  1074. }
  1075. /************************************************/
  1076. /* */
  1077. /* COMMAND "ERASER" */
  1078. /* */
  1079. /************************************************/
  1080. void
  1081. CMainFrame::OnPaletteeraser()
  1082. {
  1083. pEditChild->SelectItem = ERASER;
  1084. pEditChild->WriteSelRectBitmap();
  1085. pEditChild->MDIActivate();
  1086. }
  1087. /************************************************/
  1088. /* */
  1089. /* COMMAND "ERASER" (Update) */
  1090. /* */
  1091. /************************************************/
  1092. void
  1093. CMainFrame::OnUpdatePaletteeraser(
  1094. CCmdUI* pCmdUI)
  1095. {
  1096. if( CustomWndOpen){
  1097. pCmdUI->Enable( TRUE);
  1098. if( pEditChild->SelectItem == ERASER)
  1099. pCmdUI->SetRadio( TRUE);
  1100. else pCmdUI->SetRadio( FALSE);
  1101. }else pCmdUI->Enable( FALSE);
  1102. }
  1103. /************************************************/
  1104. /* */
  1105. /* COMMAND "RECTBAND" */
  1106. /* */
  1107. /************************************************/
  1108. void
  1109. CMainFrame::OnPaletterectband()
  1110. {
  1111. pEditChild->SelectItem = RECTCLIP;
  1112. pRefrChild->SelectItems = RECTCLIP;
  1113. pEditChild->WriteSelRectBitmap();
  1114. pEditChild->MDIActivate();
  1115. }
  1116. /************************************************/
  1117. /* */
  1118. /* COMMAND "RECTBAND"(Update) */
  1119. /* */
  1120. /************************************************/
  1121. void
  1122. CMainFrame::OnUpdatePaletterectband(
  1123. CCmdUI* pCmdUI)
  1124. {
  1125. if( CustomWndOpen){
  1126. pCmdUI->Enable( TRUE);
  1127. if( pEditChild->SelectItem == RECTCLIP)
  1128. pCmdUI->SetRadio( TRUE);
  1129. else pCmdUI->SetRadio( FALSE);
  1130. }else pCmdUI->Enable( FALSE);
  1131. }
  1132. /************************************************/
  1133. /* */
  1134. /* COMMAND "FLIP/ROTATE" */
  1135. /* */
  1136. /************************************************/
  1137. void
  1138. CMainFrame::OnRotate()
  1139. {
  1140. CRotateDlg dlg;
  1141. if( CustomWndOpen){
  1142. if( dlg.DoModal() == IDOK){
  1143. pEditChild->FlipRotate( dlg.RadioItem);
  1144. }
  1145. }
  1146. }
  1147. /************************************************/
  1148. /* */
  1149. /* COMMAND "FLIP/ROTATE" (Update) */
  1150. /* */
  1151. /************************************************/
  1152. void
  1153. CMainFrame::OnUpdateRotate(
  1154. CCmdUI* pCmdUI)
  1155. {
  1156. if( CustomWndOpen){
  1157. pCmdUI->Enable(TRUE);
  1158. }else pCmdUI->Enable(FALSE);
  1159. }
  1160. /************************************************/
  1161. /* */
  1162. /* COMMAND "REFERRENCE" */
  1163. /* */
  1164. /************************************************/
  1165. void
  1166. CMainFrame::OnRefferfileNew()
  1167. {
  1168. UINT Result;
  1169. if( !RefferWndVisible){
  1170. if(( Result = SetReffCode( FALSE)) == IDOK){
  1171. SetReffWndPos();
  1172. pRefrChild->UpdateBitmap();
  1173. pRefrChild->GridShow = pEditChild->GridShow;
  1174. pRefrChild->ShowWindow(SW_SHOWNORMAL);
  1175. pRefrChild->UpdateWindow();
  1176. RefferWndVisible = TRUE;
  1177. if( CustomWndOpen)
  1178. SetEudcWndPos();
  1179. }
  1180. }else{
  1181. if(( Result = SetReffCode( FALSE)) == IDOK){
  1182. pRefrChild->UpdateBitmap();
  1183. }
  1184. }
  1185. }
  1186. /************************************************/
  1187. /* */
  1188. /* COMMAND "REFERRENCE" (Update) */
  1189. /* */
  1190. /************************************************/
  1191. void
  1192. CMainFrame::OnUpdateRefferfileNew(
  1193. CCmdUI* pCmdUI)
  1194. {
  1195. pCmdUI->Enable( CustomWndOpen);
  1196. }
  1197. /************************************************/
  1198. /* */
  1199. /* COMMAND "CLOSE REF" */
  1200. /* */
  1201. /************************************************/
  1202. void
  1203. CMainFrame::OnRefferClose()
  1204. {
  1205. RefferWndVisible = FALSE;
  1206. pRefrChild->ShowWindow( SW_HIDE);
  1207. pRefrChild->UpdateWindow();
  1208. SetEudcWndPos();
  1209. }
  1210. /************************************************/
  1211. /* */
  1212. /* COMMAND "CLOSE REF"(Update) */
  1213. /* */
  1214. /************************************************/
  1215. void
  1216. CMainFrame::OnUpdateRefferClose(
  1217. CCmdUI* pCmdUI)
  1218. {
  1219. pCmdUI->Enable(RefferWndVisible);
  1220. }
  1221. /************************************************/
  1222. /* */
  1223. /* COMMAND "HELP TOPICS" */
  1224. /* */
  1225. /************************************************/
  1226. void
  1227. CMainFrame::OnHelp()
  1228. {
  1229. if( this->IsWindowEnabled())
  1230. {
  1231. // BUGBUG: work around for bug in HtmlHelp API (unicode version doesn't work)
  1232. //::HtmlHelp (this->GetSafeHwnd(), ChmHelpPath, HH_DISPLAY_TOPIC,(DWORD)0);
  1233. ::HtmlHelpA (::GetDesktopWindow(), "eudcedit.chm", HH_DISPLAY_TOPIC,(DWORD)0);
  1234. }
  1235. }
  1236. /************************************************/
  1237. /* */
  1238. /* if bitmap is dirty, output message */
  1239. /* */
  1240. /************************************************/
  1241. BOOL
  1242. CMainFrame::OutputSaveMessage()
  1243. {
  1244. int Result;
  1245. Result = IDYES;
  1246. if( pEditChild->GetBitmapDirty()){
  1247. Result = OutputMessageBox( this->GetSafeHwnd(),
  1248. IDS_MAINFRAMETITLE,
  1249. IDS_SAVEORNOT, FALSE);
  1250. if( Result == IDYES){
  1251. AfxGetApp()->DoWaitCursor(1);
  1252. if (!pEditChild->SaveEUDCCode(MB_OKCANCEL))
  1253. Result = IDCANCEL;
  1254. AfxGetApp()->DoWaitCursor(-1);
  1255. }else if( Result == IDNO){
  1256. pEditChild->SetBitmapDirty( FALSE);
  1257. }
  1258. }
  1259. if( Result == IDCANCEL)
  1260. return FALSE;
  1261. else return TRUE;
  1262. }
  1263. /************************************************/
  1264. /* */
  1265. /* Create refferrence window */
  1266. /* */
  1267. /************************************************/
  1268. BOOL
  1269. CMainFrame::CreateReferWnd()
  1270. {
  1271. ReffWndRect.SetRectEmpty();
  1272. CalcReffWndRect();
  1273. CRefrWnd *pReffWnd = new CRefrWnd;
  1274. if( !pReffWnd->Create( TEXT("REFERWINDOW"),
  1275. WS_CHILD | WS_BORDER, ReffWndRect, this))
  1276. return FALSE;
  1277. pRefrChild = pReffWnd;
  1278. RefferWndVisible = FALSE;
  1279. return TRUE;
  1280. }
  1281. /************************************************/
  1282. /* */
  1283. /* Change size of edit window */
  1284. /* */
  1285. /************************************************/
  1286. void
  1287. CMainFrame::SetEudcWndPos()
  1288. {
  1289. CalcEudcWndRect();
  1290. pEditChild->MoveWindow( EudcWndRect.left, EudcWndRect.top,
  1291. EudcWndRect.Width(), EudcWndRect.Height(), TRUE);
  1292. }
  1293. /************************************************/
  1294. /* */
  1295. /* Calcurate size of edit window */
  1296. /* */
  1297. /************************************************/
  1298. void
  1299. CMainFrame::CalcEudcWndRect()
  1300. {
  1301. CRect CalcRect;
  1302. CSize Frame;
  1303. int Twice;
  1304. int Remain;
  1305. //
  1306. // Try to determine the proper value of the Frame. Can be
  1307. // different depending with Theme is used. The Luna Theme
  1308. // take more prixel for the width of the frame.
  1309. //
  1310. CRect* FrameBefore = new CRect(0, 0, BITMAP_WIDTH, BITMAP_HEIGHT);
  1311. CRect FrameAfter;
  1312. pEditChild->MoveWindow(FrameBefore, TRUE);
  1313. pEditChild->GetClientRect(&FrameAfter);
  1314. Frame.cx = FrameBefore->Width() - FrameAfter.Width();
  1315. Frame.cy = FrameBefore->Height() - FrameAfter.Height();
  1316. GetClientRect( &EudcWndRect);
  1317. if( GuideBarVisible){
  1318. m_wndGuideBar.GetWindowRect( &CalcRect);
  1319. EudcWndRect.bottom -= CalcRect.Height();
  1320. }
  1321. if( ToolBarVisible){
  1322. m_wndToolBar.GetWindowRect( &CalcRect);
  1323. EudcWndRect.right -= CalcRect.Width();
  1324. }
  1325. if( RefferWndVisible)
  1326. EudcWndRect.right = EudcWndRect.right /2;
  1327. if( EudcWndRect.Width() < EudcWndRect.Height()){
  1328. Twice = EudcWndRect.Width() /BITMAP_WIDTH;
  1329. Remain = EudcWndRect.Width() %BITMAP_WIDTH;
  1330. if( Remain < Frame.cx )
  1331. Twice -= 1;
  1332. if( Twice <= 0) Twice = 1;
  1333. EudcWndRect.left = 0;
  1334. EudcWndRect.right = EudcWndRect.left + BITMAP_WIDTH *Twice
  1335. + Frame.cx;
  1336. EudcWndRect.bottom = BITMAP_HEIGHT*Twice + Frame.cy
  1337. + CAPTION_HEIGHT;
  1338. }else{
  1339. Twice = EudcWndRect.Height() /BITMAP_HEIGHT;
  1340. Remain = EudcWndRect.Height() %BITMAP_HEIGHT;
  1341. if( Remain < CAPTION_HEIGHT + Frame.cy )
  1342. Twice -= 1;
  1343. if( Twice <= 0) Twice = 1;
  1344. EudcWndRect.left = 0;
  1345. EudcWndRect.right = EudcWndRect.left + BITMAP_WIDTH *Twice
  1346. + Frame.cx;
  1347. EudcWndRect.bottom = BITMAP_HEIGHT*Twice + Frame.cy + CAPTION_HEIGHT;
  1348. }
  1349. }
  1350. /************************************************/
  1351. /* */
  1352. /* Change size of referrence window */
  1353. /* */
  1354. /************************************************/
  1355. void
  1356. CMainFrame::SetReffWndPos()
  1357. {
  1358. CalcReffWndRect();
  1359. pRefrChild->MoveWindow( ReffWndRect.left, ReffWndRect.top,
  1360. ReffWndRect.Width(), ReffWndRect.Height(), TRUE);
  1361. }
  1362. /************************************************/
  1363. /* */
  1364. /* Calcurate size of referrence window */
  1365. /* */
  1366. /************************************************/
  1367. void
  1368. CMainFrame::CalcReffWndRect()
  1369. {
  1370. CRect CalcRect;
  1371. CSize Frame;
  1372. int Twice;
  1373. int Remain;
  1374. Frame.cx = ( GetSystemMetrics( SM_CXFRAME)
  1375. - GetSystemMetrics( SM_CXBORDER)) * 2;
  1376. Frame.cy = ( GetSystemMetrics( SM_CYFRAME)
  1377. - GetSystemMetrics( SM_CYBORDER)) * 2;
  1378. GetClientRect( &ReffWndRect);
  1379. if( GuideBarVisible){
  1380. m_wndGuideBar.GetWindowRect( &CalcRect);
  1381. ReffWndRect.bottom -= CalcRect.Height();
  1382. }
  1383. if( ToolBarVisible){
  1384. m_wndToolBar.GetWindowRect( &CalcRect);
  1385. ReffWndRect.right -= CalcRect.Width();
  1386. }
  1387. ReffWndRect.left = ReffWndRect.right /2;
  1388. if( ReffWndRect.Width() < ReffWndRect.Height()){
  1389. Twice = ReffWndRect.Width() /BITMAP_WIDTH;
  1390. Remain = ReffWndRect.Width() %BITMAP_WIDTH;
  1391. if( Remain < Frame.cx + 4)
  1392. Twice -= 1;
  1393. if( Twice <= 0){/*
  1394. if( RefferWndVisible){
  1395. pRefrChild->ShowWindow( SW_HIDE);
  1396. pRefrChild->UpdateWindow();
  1397. RefferWndVisible = FALSE;
  1398. }*/
  1399. }
  1400. ReffWndRect.right = ReffWndRect.left + BITMAP_WIDTH*Twice
  1401. + Frame.cx;
  1402. ReffWndRect.bottom = BITMAP_HEIGHT*Twice + Frame.cy
  1403. + CAPTION_HEIGHT;
  1404. }else{
  1405. Twice = ReffWndRect.Height() /BITMAP_HEIGHT;
  1406. Remain = ReffWndRect.Height() %BITMAP_HEIGHT;
  1407. if( Remain < CAPTION_HEIGHT + Frame.cy + 4)
  1408. Twice -= 1;
  1409. if( Twice <= 0) Twice = 1;
  1410. ReffWndRect.right = ReffWndRect.left + BITMAP_WIDTH*Twice
  1411. + Frame.cx;
  1412. ReffWndRect.bottom = BITMAP_HEIGHT*Twice + Frame.cy
  1413. + CAPTION_HEIGHT;
  1414. }
  1415. }
  1416. /************************************************/
  1417. /* */
  1418. /* MESSAGE "WM_SIZE" */
  1419. /* */
  1420. /************************************************/
  1421. void
  1422. CMainFrame::OnSize(
  1423. UINT nType,
  1424. int cx,
  1425. int cy)
  1426. {
  1427. CMDIFrameWnd::OnSize(nType, cx, cy);
  1428. if( RefferWndVisible){
  1429. SetReffWndPos();
  1430. }
  1431. if( CustomWndOpen){
  1432. SetEudcWndPos();
  1433. }
  1434. if( !ToolBarVisible){
  1435. m_wndToolBar.Invalidate( FALSE);
  1436. m_wndToolBar.UpdateWindow();
  1437. }
  1438. }
  1439. /************************************************/
  1440. /* */
  1441. /* MESSAGE "WM_DESTROY" */
  1442. /* Write "EUDCEDIT.INI" */
  1443. /* */
  1444. /************************************************/
  1445. void
  1446. CMainFrame::OnDestroy()
  1447. {
  1448. TCHAR ProfileBuf[BUFFERMAX];
  1449. TCHAR SelectName1[] = TEXT("WindowSize");
  1450. TCHAR SelectName2[] = TEXT("Bitmap");
  1451. TCHAR SelectName3[] = TEXT("Color");
  1452. TCHAR EntryName1[] = TEXT("MainWindowSize");
  1453. TCHAR EntryName2[] = TEXT("MinMaxFlag");
  1454. TCHAR EntryName3[] = TEXT("BitmapSize");
  1455. TCHAR EntryName4[] = TEXT("Grid");
  1456. TCHAR EntryName5[] = TEXT("Curve");
  1457. TCHAR EntryName6[] = TEXT("Fitting");
  1458. TCHAR EudcIniFile[] = TEXT("Eudcedit.ini");
  1459. CRect rect;
  1460. short MaxWndFlag;
  1461. if( IsZoomed())
  1462. MaxWndFlag = 1;
  1463. else MaxWndFlag = 0;
  1464. wsprintf( ProfileBuf,TEXT("%d %d %d"), GetRValue(COLOR_GRID),
  1465. GetGValue(COLOR_GRID), GetBValue(COLOR_GRID));
  1466. ::WritePrivateProfileString( SelectName3, EntryName4,
  1467. ProfileBuf, EudcIniFile);
  1468. wsprintf( ProfileBuf,TEXT("%d %d %d"), GetRValue(COLOR_CURVE),
  1469. GetGValue(COLOR_CURVE), GetBValue(COLOR_CURVE));
  1470. ::WritePrivateProfileString( SelectName3, EntryName5,
  1471. ProfileBuf, EudcIniFile);
  1472. wsprintf( ProfileBuf,TEXT("%d %d %d"), GetRValue(COLOR_FITTING),
  1473. GetGValue(COLOR_FITTING), GetBValue(COLOR_FITTING));
  1474. ::WritePrivateProfileString( SelectName3, EntryName6,
  1475. ProfileBuf, EudcIniFile);
  1476. wsprintf( ProfileBuf, TEXT("%d"), BITMAP_WIDTH);
  1477. ::WritePrivateProfileString( SelectName2, EntryName3,
  1478. ProfileBuf, EudcIniFile);
  1479. wsprintf( ProfileBuf, TEXT("%d"), MaxWndFlag);
  1480. ::WritePrivateProfileString( SelectName1, EntryName2,
  1481. ProfileBuf, EudcIniFile);
  1482. if( !MaxWndFlag && !IsIconic()){
  1483. GetWindowRect( &rect);
  1484. wsprintf( ProfileBuf, TEXT("%d %d %d %d"), rect.left, rect.top,
  1485. rect.right, rect.bottom);
  1486. ::WritePrivateProfileString( SelectName1, EntryName1,
  1487. ProfileBuf, EudcIniFile);
  1488. }
  1489. CMDIFrameWnd::OnDestroy();
  1490. }
  1491. /************************************************/
  1492. /* */
  1493. /* MESSAGE "WM_CLOSE" */
  1494. /* */
  1495. /************************************************/
  1496. void
  1497. CMainFrame::OnClose()
  1498. {
  1499. CString MsgTitle;
  1500. CString Msg;
  1501. int result;
  1502. if( CustomWndOpen){
  1503. if(( pEditChild->GetBitmapDirty()) &&
  1504. ( InqTypeFace((TCHAR *)SelectEUDC.m_Font,
  1505. (TCHAR *)SelectEUDC.m_File, sizeof( SelectEUDC.m_File)/sizeof(TCHAR)))){
  1506. MsgTitle.LoadString( IDS_MAINFRAMETITLE);
  1507. Msg.LoadString( IDS_SAVEORNOT);
  1508. result = MessageBox( Msg, MsgTitle,
  1509. MB_ICONQUESTION | MB_YESNOCANCEL);
  1510. if( result == IDYES){
  1511. AfxGetApp()->DoWaitCursor(1);
  1512. if (!pEditChild->SaveEUDCCode(MB_OKCANCEL))
  1513. result = IDCANCEL;
  1514. AfxGetApp()->DoWaitCursor(-1);
  1515. }
  1516. if( result == IDCANCEL)
  1517. return;
  1518. }
  1519. }
  1520. CMDIFrameWnd::OnClose();
  1521. }
  1522. /************************************************/
  1523. /* */
  1524. /* MESSAGE "WM_INITMENU" */
  1525. /* */
  1526. /************************************************/
  1527. void
  1528. CMainFrame::OnInitMenu(
  1529. CMenu* pMenu)
  1530. {
  1531. CMDIFrameWnd::OnInitMenu(pMenu);
  1532. if( CountryInfo.LangID != EUDC_CHT &&
  1533. CountryInfo.LangID != EUDC_CHS ){
  1534. pMenu->DeleteMenu( ID_LINKIME, MF_BYCOMMAND);
  1535. pMenu->DeleteMenu( ID_LINKBATCHMODE, MF_BYCOMMAND);
  1536. if (CountryInfo.LangID != EUDC_JPN)
  1537. pMenu->DeleteMenu( ID_IMPORT_FILE, MF_BYCOMMAND);
  1538. this->DrawMenuBar();
  1539. }
  1540. }
  1541. /************************************************/
  1542. /* */
  1543. /* Correct it if code is illegal range */
  1544. /* */
  1545. /************************************************/
  1546. WORD
  1547. CMainFrame::CorrectCode(
  1548. WORD Code,
  1549. BOOL UporDown)
  1550. {
  1551. COUNTRYINFO Info;
  1552. WORD wCode;
  1553. BYTE LByte, HByte;
  1554. int TralPos = 0;
  1555. LByte = LOBYTE( Code);
  1556. HByte = HIBYTE( Code);
  1557. Info = CountryInfo;
  1558. for( int i = 0; i < Info.nTralByte; i++){
  1559. if( LByte >= (Info.sTralByte[i]) &&
  1560. LByte <= (Info.eTralByte[i])){
  1561. goto RET;
  1562. }else if( LByte < (Info.sTralByte[i])){
  1563. TralPos = i;
  1564. break;
  1565. }else TralPos = i+1;
  1566. }
  1567. if( UporDown)
  1568. if( TralPos == Info.nTralByte){
  1569. LByte = (Info.sTralByte[0]);
  1570. HByte += 0x1;
  1571. }else LByte = (Info.sTralByte[TralPos]);
  1572. else{
  1573. if( !TralPos){
  1574. LByte = (Info.eTralByte[Info.nTralByte-1]);
  1575. HByte -= 0x1;
  1576. }else LByte = (Info.eTralByte[TralPos-1]);
  1577. }
  1578. RET:
  1579. wCode = MAKEWORD( LByte, HByte);
  1580. return wCode;
  1581. }
  1582. /************************************************/
  1583. /* */
  1584. /* Set Reference dialog */
  1585. /* */
  1586. /************************************************/
  1587. UINT
  1588. CMainFrame::SetReffCode( BOOL EditorRefer)
  1589. {
  1590. CRefrDlg dlg;
  1591. UINT Result;
  1592. TitleFlag = EditorRefer;
  1593. if(( Result = (UINT)dlg.DoModal()) == IDOK){
  1594. if( !EditorRefer){
  1595. if( dlg.m_CodeList.SelectCode){
  1596. pRefrChild->ReferCode =
  1597. dlg.m_CodeList.SelectCode;
  1598. }else pRefrChild->ReferCode = 0;
  1599. }else{
  1600. if( dlg.m_CodeList.SelectCode)
  1601. pEditChild->CallCode =
  1602. dlg.m_CodeList.SelectCode;
  1603. else pEditChild->CallCode = 0;
  1604. }
  1605. }else{
  1606. if( !EditorRefer)
  1607. pRefrChild->ReferCode = 0;
  1608. else pEditChild->CallCode = 0;
  1609. }
  1610. return Result;
  1611. }
  1612. /************************************************/
  1613. /* */
  1614. /* Window procedure */
  1615. /* */
  1616. /************************************************/
  1617. LRESULT
  1618. CMainFrame::WindowProc(
  1619. UINT message,
  1620. WPARAM wParam,
  1621. LPARAM lParam)
  1622. {
  1623. CRect WorkRect;
  1624. CRect rect;
  1625. CRect Dummy;
  1626. RECT *Rect;
  1627. POINT *Point;
  1628. int Zm;
  1629. if( message == WM_DUPLICATE){
  1630. Zm = pEditChild->ZoomRate;
  1631. pEditChild->GetClientRect( &WorkRect);
  1632. pEditChild->ClientToScreen( &WorkRect);
  1633. Point = (LPPOINT)lParam;
  1634. Rect = (LPRECT)wParam;
  1635. pEditChild->ScreenToClient( Point);
  1636. Rect->left = ((Point->x - Rect->left) /Zm) *Zm;
  1637. Rect->top = ((Point->y - Rect->top - CAPTION_HEIGHT)
  1638. /Zm) *Zm + CAPTION_HEIGHT;
  1639. Rect->right = Rect->left + Rect->right;
  1640. Rect->bottom = Rect->top + Rect->bottom;
  1641. pEditChild->ClientToScreen( Rect);
  1642. if( Dummy.IntersectRect( &WorkRect, Rect)){
  1643. if( Dummy.EqualRect( Rect)){
  1644. pEditChild->ScreenToClient( Rect);
  1645. pEditChild->SetDuplicateRect( Rect, Point);
  1646. }else{
  1647. int Tmp;
  1648. rect.SetRect( Rect->left, Rect->top,
  1649. Rect->right, Rect->bottom);
  1650. if( rect.left < WorkRect.left){
  1651. Tmp = WorkRect.left - rect.left;
  1652. rect.OffsetRect( Tmp, 0);
  1653. }
  1654. if( rect.top < WorkRect.top + CAPTION_HEIGHT){
  1655. Tmp = WorkRect.top + CAPTION_HEIGHT
  1656. - rect.top;
  1657. rect.OffsetRect( 0, Tmp);
  1658. }
  1659. if( rect.right > WorkRect.right){
  1660. Tmp = WorkRect.right - rect.right + 1;
  1661. rect.OffsetRect( Tmp, 0);
  1662. }
  1663. if( rect.bottom > WorkRect.bottom){
  1664. Tmp = WorkRect.bottom - rect.bottom + 1;
  1665. rect.OffsetRect( 0, Tmp);
  1666. }
  1667. pEditChild->ScreenToClient( &rect);
  1668. pEditChild->SetDuplicateRect( &rect, Point);
  1669. }
  1670. pRefrChild->RectVisible = FALSE;
  1671. pEditChild->MDIActivate();
  1672. if( pRefrChild->SelectItems == FREEFORM)
  1673. pEditChild->SelectItem = FREEFORM;
  1674. else pEditChild->SelectItem = RECTCLIP;
  1675. }else{
  1676. pRefrChild->Invalidate( FALSE);
  1677. pRefrChild->UpdateWindow();
  1678. }
  1679. return (0L);
  1680. }else return CFrameWnd::WindowProc( message, wParam, lParam);
  1681. }
  1682. /************************************************/
  1683. /* */
  1684. /* Activate Edit Window */
  1685. /* */
  1686. /************************************************/
  1687. BOOL CMainFrame::CustomActivate()
  1688. {
  1689. pEditChild->MDIActivate();
  1690. return TRUE;
  1691. }
  1692. #ifdef _DEBUG
  1693. void CMainFrame::AssertValid() const
  1694. {
  1695. CMDIFrameWnd::AssertValid();
  1696. }
  1697. void CMainFrame::Dump(CDumpContext& dc) const
  1698. {
  1699. CMDIFrameWnd::Dump(dc);
  1700. }
  1701. #endif //_DEBUG