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.

1420 lines
42 KiB

  1. /************************************************************/
  2. /* Windows Write, Copyright 1985-1992 Microsoft Corporation */
  3. /************************************************************/
  4. /* menu.c -- WRITE menu handling routines */
  5. #define NOGDICAPMASKS
  6. #define NOVIRTUALKEYCODES
  7. #define NOWINMESSAGES
  8. #define NOWINSTYLES
  9. #define NOCTLMGR
  10. #define NOSYSMETRICS
  11. #define NOICON
  12. #define NOKEYSTATE
  13. #define NORASTEROPS
  14. #define NOSHOWWINDOW
  15. //#define NOATOM
  16. #define NOCREATESTRUCT
  17. #define NODRAWTEXT
  18. #define NOMETAFILE
  19. #define NOSOUND
  20. #define NOSCROLL
  21. #define NOWH
  22. #define NOOPENFILE
  23. #define NOCOMM
  24. #define NOMSG
  25. #define NOREGION
  26. #define NORECT
  27. #include <windows.h>
  28. #include "mw.h"
  29. #include "cmddefs.h"
  30. #include "filedefs.h"
  31. #include "wwdefs.h"
  32. #include "docdefs.h"
  33. #include "propdefs.h"
  34. #include "prmdefs.h"
  35. #define NOKCCODES
  36. #include "ch.h"
  37. #include "editdefs.h"
  38. #include "menudefs.h"
  39. #include "str.h"
  40. #include "fontdefs.h"
  41. #include "dlgdefs.h"
  42. #include "dispdefs.h"
  43. #include <shellapi.h>
  44. #if defined(OLE)
  45. #include "obj.h"
  46. #endif
  47. #ifdef JAPAN //T-HIROYN Win3.1
  48. #include "kanji.h"
  49. #endif
  50. extern int FAR PASCAL ShellAbout(HWND hWnd, LPSTR szApp, LPSTR szOtherStuff, HICON hIcon);
  51. extern typeCP cpMinCur, cpMacCur;
  52. extern struct WWD rgwwd[];
  53. extern CHAR stBuf[];
  54. extern int docCur;
  55. extern struct DOD (**hpdocdod)[];
  56. extern struct SEL selCur;
  57. extern int vfOutOfMemory;
  58. extern BOOL vfWinFailure;
  59. extern int vfSysFull;
  60. extern int vfDiskError;
  61. extern struct CHP vchpAbs;
  62. extern struct PAP vpapAbs;
  63. extern struct CHP vchpFetch;
  64. extern struct CHP vchpSel;
  65. extern int vfSeeSel;
  66. extern typeCP vcpFetch;
  67. extern int vccpFetch;
  68. extern typeCP cpMacCur;
  69. extern typeCP vcpLimParaCache;
  70. extern HMENU vhMenu; /* global handle to the top level menu */
  71. extern HANDLE hParentWw;
  72. extern HCURSOR vhcHourGlass;
  73. extern HANDLE hMmwModInstance;
  74. extern HANDLE vhDlgFind;
  75. extern HANDLE vhDlgChange;
  76. extern HANDLE vhDlgChange;
  77. extern CHAR (**hszSearch)[]; /* Default search string */
  78. #ifdef CASHMERE
  79. extern int vfVisiMode;
  80. extern HWND vhWndGlos;
  81. extern HWND vhWndScrap;
  82. #endif /* CASHMERE */
  83. #ifdef ONLINEHELP
  84. extern fnHelp(void);
  85. #endif /* ONLINEHELP */
  86. /* These values are comprised of one bit for each menu item in the
  87. applicable menu (for example, there are bitcount(0xfff)==12 menu
  88. items under Character) ..pault */
  89. static int rgmfAllItems[CMENUS] = {
  90. 0x01ff, /* FILE */
  91. 0x003f, /* EDIT */
  92. 0x000f, /* FIND */
  93. #if defined(JAPAN) & defined(IME_HIDDEN) //IME3.1J
  94. 0x03ff, /* CHARACTER */
  95. #else
  96. 0x01ff, /* CHARACTER */
  97. #endif
  98. 0x01ff, /* PARA */
  99. 0x001f, /* DOCU */
  100. 0x000f /* HELP */
  101. };
  102. /* When we're editing a running header or footer, use this */
  103. static int rgmfRunning[CMENUS] = {
  104. 0x0020, /* FILE -- enable printer-setup only */
  105. 0x003F, /* EDIT -- everything */
  106. 0x0007, /* FIND -- enable find/again and change */
  107. #if defined(JAPAN) & defined(IME_HIDDEN) //IME3.1J
  108. 0x03ff, /* CHARACTER -- everything */
  109. #else
  110. 0x01FF, /* CHARACTER -- everything */
  111. #endif
  112. 0x01FF, /* PARAGRAPH -- everything */
  113. 0x001F, /* DOCUMENT -- everything */
  114. 0x000f /* HELP -- everything */
  115. };
  116. int viffnMenuMac;
  117. NEAR PutSzUndoInMenu(void);
  118. NEAR GetChpVals (struct CHP *, TSV *);
  119. NEAR GetPapVals (struct PAP *, TSV *);
  120. NEAR GetHffn (struct CHP *, TSV *);
  121. NEAR SetChUndef(TSV *, struct CHP *, int *);
  122. NEAR SetParaUndef(TSV *, struct PAP *, int *);
  123. NEAR FNoSearchStr(HWND);
  124. SetAppMenu(hMenu, index)
  125. HMENU hMenu; /* handle to popup menu */
  126. int index; /* index to popup menu */
  127. {
  128. /* Mark greying and checks on menus as appropriate to current state. */
  129. extern BOOL vfPrinterValid;
  130. extern CHAR (**hszPrPort)[];
  131. extern CHAR szNul[];
  132. extern int vfPictSel;
  133. extern int vfOwnClipboard;
  134. extern int docScrap;
  135. extern struct UAB vuab;
  136. extern HWND vhWnd;
  137. typeCP CpMacText();
  138. register int rgmfT[CMENUS]; /* Our workspace for menu greying */
  139. int imi;
  140. int imiMin = 0;
  141. int imiMax = 0;
  142. int *pflags;
  143. TSV rgtsv[itsvchMax]; /* gets attributes and gray flags from CHP, PAP */
  144. unsigned wPrintBitPos = ~(0x0001 << (imiPrint - imiFileMin));
  145. /* If we are out of memory or the disk is full, then... */
  146. if (vfOutOfMemory || vfSysFull || vfDiskError || vfWinFailure)
  147. {
  148. bltc( rgmfT, 0, CMENUS );
  149. #if WINVER >= 0x300
  150. /* Disable the print stuff, but leave New/Open/Save/SaveAs/Exit */
  151. rgmfT[FILE] = 0x008f;
  152. #else
  153. /* Disable everything except Save & SaveAs */
  154. rgmfT[FILE] = 0x0018;
  155. #endif
  156. }
  157. else
  158. {
  159. /* Start with all items or subset if editing running head/foot */
  160. blt( (wwdCurrentDoc.fEditHeader || wwdCurrentDoc.fEditFooter) ? rgmfRunning
  161. : rgmfAllItems, rgmfT, CMENUS );
  162. #if defined(JAPAN) & defined(IME_HIDDEN) //IME3.1J
  163. {
  164. extern int vfImeHidden; /*T-HIROYN ImeHidden Mode flag*/
  165. if(index == CHARACTER) {
  166. /* Version 3.1 or more ok */
  167. if(FALSE == GetIMEVersioOk(vhWnd)) {
  168. rgmfT[CHARACTER] = 0x1ff; //Set Ime mode memu gray
  169. vfImeHidden = 0;
  170. }
  171. if(TRUE == GetIMEOpenMode(vhWnd))
  172. rgmfT[CHARACTER] = 0x1ff; //Set Ime mode memu gray
  173. }
  174. }
  175. #endif
  176. }
  177. pflags = &rgmfT[index];
  178. switch (index)
  179. {
  180. case FILE:
  181. imiMin = imiFileMin;
  182. imiMax = imiFileMax;
  183. /* Disallow print, if the printer or the port is not valid. */
  184. if (!vfPrinterValid || hszPrPort == NULL ||
  185. WCompSz( *hszPrPort, szNul ) == 0)
  186. *pflags &= wPrintBitPos;
  187. break;
  188. case EDIT:
  189. imiMin = imiEditMin;
  190. imiMax = imiEditMax;
  191. /* Disallow cut, copy if the selection is empty */
  192. if (selCur.cpFirst == selCur.cpLim)
  193. {
  194. *pflags &= 0xfff9;
  195. }
  196. /* Move and Size picture are only allowed if a picture is selected */
  197. if (!vfPictSel)
  198. *pflags &= 0xFFCF;
  199. /* Disallow Paste if we can determine that the scrap is empty.
  200. Regrettably, we can be fooled into thinking it is not by
  201. another instance of MEMO that is the clipboard owner and has
  202. an empty scrap. */
  203. /* Disallow UNDO if appropriate; set UNDO string into menu */
  204. {
  205. if ((vuab.uac == uacNil) || vfOutOfMemory)
  206. {
  207. /* Gray out undo */
  208. *pflags &= 0xfffe;
  209. }
  210. PutSzUndoInMenu();
  211. }
  212. break;
  213. case FIND:
  214. imiMin = imiFindMin;
  215. imiMax = imiFindMax;
  216. if ((GetActiveWindow() == hParentWw && CchSz(**hszSearch) == 1) ||
  217. (!vhDlgFind && !vhDlgChange && (CchSz(**hszSearch) == 1)) ||
  218. (vhDlgFind && FNoSearchStr(vhDlgFind)) ||
  219. (vhDlgChange && FNoSearchStr(vhDlgChange)))
  220. *pflags &= 0xfffd; /* disable find again */
  221. if (CpMacText( docCur ) == cp0)
  222. *pflags &= 0xfff0; /* disable find, search, change, goto page */
  223. break;
  224. case CHARACTER:
  225. imiMin = imiCharMin;
  226. imiMax = imiCharMax;
  227. if (!(vfOutOfMemory || vfWinFailure))
  228. {
  229. int iffn, iffnCurFont, fSetFontList;
  230. struct FFN **hffn, *pffn;
  231. union FCID fcid;
  232. extern struct FFN **MpFcidHffn();
  233. /* GetRgtsvChpSel() fills up rgtsv */
  234. GetRgtsvChpSel(rgtsv);
  235. CheckMenuItem(hMenu, imiBold,
  236. (rgtsv[itsvBold].fGray == 0 && rgtsv[itsvBold].wTsv != 0) ?
  237. MF_CHECKED : MF_UNCHECKED);
  238. CheckMenuItem(hMenu, imiItalic,
  239. (rgtsv[itsvItalic].fGray == 0 && rgtsv[itsvItalic].wTsv != 0) ?
  240. MF_CHECKED : MF_UNCHECKED);
  241. CheckMenuItem(hMenu, imiUnderline,
  242. (rgtsv[itsvUline].fGray == 0 && rgtsv[itsvUline].wTsv != 0) ?
  243. MF_CHECKED : MF_UNCHECKED);
  244. /* note that the value stored in rgtsv[itsvPosition].wTsv
  245. is really a signed integer, so we can just check for
  246. 0, > 0, and < 0 */
  247. CheckMenuItem(hMenu, imiSuper,
  248. (rgtsv[itsvPosition].fGray == 0
  249. && (int)(rgtsv[itsvPosition].wTsv) > 0) ?
  250. MF_CHECKED : MF_UNCHECKED);
  251. CheckMenuItem(hMenu, imiSub,
  252. (rgtsv[itsvPosition].fGray == 0
  253. && (int)(rgtsv[itsvPosition].wTsv) < 0) ?
  254. MF_CHECKED : MF_UNCHECKED);
  255. #if defined(JAPAN) & defined(IME_HIDDEN) //IME3.1J
  256. //IME3.1J
  257. {
  258. extern int vfImeHidden; /*T-HIROYN ImeHidden Mode flag*/
  259. CheckMenuItem(hMenu, imiImeHidden,
  260. vfImeHidden ? MF_CHECKED : MF_UNCHECKED);
  261. }
  262. #endif
  263. #if 0
  264. /* SetFontMenuItems() pulled on line */
  265. {
  266. /* make sure that the right font names are on the character dropdown */
  267. /* These two lines avoid calculating bdodCur twice */
  268. unsigned int bdodCur = docCur * sizeof (struct DOD);
  269. #define pdodCur ( (struct DOD *) ( (CHAR *)(&(**hpdocdod) [0]) + bdodCur))
  270. fSetFontList = !(*(pdodCur->hffntb))->fFontMenuValid;
  271. if (fSetFontList)
  272. {
  273. /* need to get the current list */
  274. viffnMenuMac = 0;
  275. if (FInitFontEnum(docCur, 3, TRUE))
  276. {
  277. for (iffn = 0; iffn < 3; iffn++)
  278. {
  279. if (!FEnumFont((struct FFN *)rgffnFontMenu[iffn]))
  280. break;
  281. viffnMenuMac++;
  282. }
  283. EndFontEnum();
  284. (*(pdodCur->hffntb))->fFontMenuValid = TRUE;
  285. }
  286. }
  287. /* make sure the current font is on the list - ok, so it's kind of
  288. a hack */
  289. mfFonts = 0xffff; /* template to mask "no font" entries */
  290. iffnCurFont = -1;
  291. hffn = (struct FFN **)rgtsv[itsvFfn].wTsv;
  292. for (iffn = 0; iffn < 3; iffn++)
  293. {
  294. if (iffn >= viffnMenuMac)
  295. mfFonts ^= (0x0040 << iffn); /* disable this entry */
  296. else if (iffnCurFont < 0 && !rgtsv[itsvFfn].fGray)
  297. {
  298. pffn = (struct FFN *)rgffnFontMenu[iffn];
  299. if (WCompSz((*hffn)->szFfn, pffn->szFfn) == 0)
  300. iffnCurFont = iffn;
  301. }
  302. }
  303. if (!rgtsv[itsvFfn].fGray && iffnCurFont < 0)
  304. {
  305. /* no match for this font - ram it in */
  306. if (viffnMenuMac < 3)
  307. viffnMenuMac++;
  308. iffnCurFont = viffnMenuMac - 1;
  309. bltbyte(*hffn, rgffnFontMenu[iffnCurFont],
  310. CbFfn(CchSz((*hffn)->szFfn)));
  311. mfFonts |= (0x0040 << iffnCurFont); /* enable this entry */
  312. /* invalidate cache since we're messing it up */
  313. (*pdodCur->hffntb)->fFontMenuValid = FALSE;
  314. fSetFontList = TRUE;
  315. }
  316. if (fSetFontList)
  317. /* font name cache has changed - update the menu dropdown */
  318. for (iffn = 0; iffn < 3; iffn++)
  319. {
  320. int imi;
  321. #ifdef KOREA
  322. int i;
  323. CHAR rgb[LF_FACESIZE + 8];
  324. #else
  325. CHAR rgb[LF_FACESIZE + 4];
  326. #endif
  327. if (iffn < viffnMenuMac)
  328. {
  329. #ifdef KOREA /* sangl 91.6.19 */
  330. i = CchCopySz(((struct FFN *)rgffnFontMenu [iffn])->szFfn,
  331. &rgb [0]);
  332. rgb[i] = '(';
  333. rgb[i+1] = '\036';
  334. rgb[i+2] = '1' + iffn;
  335. rgb[i+3] = '\037';
  336. rgb[i+4] = '';
  337. rgb[i+5] = '' + iffn;
  338. rgb[i+6] = ')';
  339. rgb[i+7] = '\0';
  340. #else
  341. rgb[0] = '&';
  342. rgb[1] = '1' + iffn;
  343. rgb[2] = '.';
  344. rgb[3] = ' ';
  345. CchCopySz(((struct FFN *)rgffnFontMenu [iffn])->szFfn,
  346. &rgb [4]);
  347. #endif
  348. }
  349. else
  350. {
  351. /* empty font name -- don't display it */
  352. rgb [0] = '\0';
  353. }
  354. /* Set the menu */
  355. imi = imiFont1 + iffn;
  356. ChangeMenu( vhMenu, imi, (LPSTR)rgb, imi, MF_CHANGE );
  357. }
  358. }
  359. *pflags &= mfFonts;
  360. /* see which (if any) fonts apply */
  361. /* note that the value stored in rgtsv[itsvFfn].wTsv
  362. is the font name handle, rather than the ftc */
  363. for (iffn = 0; iffn < 3; iffn++)
  364. {
  365. CheckMenuItem(hMenu, imiFont1 + iffn,
  366. iffn == iffnCurFont ? MF_CHECKED : MF_UNCHECKED);
  367. }
  368. #endif
  369. }
  370. break;
  371. case PARA:
  372. imiMin = imiParaMin;
  373. imiMax = imiParaMax;
  374. if (!(vfOutOfMemory || vfWinFailure))
  375. {
  376. int jc;
  377. /* GetRgtsvPapSel() fills up rgtsv with paragraph properties */
  378. GetRgtsvPapSel(rgtsv);
  379. /* if gray, set jc to invalid value */
  380. jc = (rgtsv[itsvJust].fGray == 0) ? rgtsv[itsvJust].wTsv : jcNil;
  381. CheckMenuItem(hMenu, imiParaNormal, MF_UNCHECKED);
  382. CheckMenuItem(hMenu, imiLeft, jc == jcLeft ? MF_CHECKED : MF_UNCHECKED);
  383. CheckMenuItem(hMenu, imiCenter, jc == jcCenter ? MF_CHECKED :
  384. MF_UNCHECKED);
  385. CheckMenuItem(hMenu, imiRight, jc == jcRight ? MF_CHECKED :
  386. MF_UNCHECKED);
  387. CheckMenuItem(hMenu, imiJustified, jc == jcBoth ? MF_CHECKED :
  388. MF_UNCHECKED);
  389. CheckMenuItem(hMenu, imiSingleSpace,
  390. (rgtsv[itsvSpacing].fGray == 0
  391. && rgtsv[itsvSpacing].wTsv == czaLine) ?
  392. MF_CHECKED : MF_UNCHECKED);
  393. CheckMenuItem(hMenu, imiOneandhalfSpace,
  394. (rgtsv[itsvSpacing].fGray == 0
  395. && rgtsv[itsvSpacing].wTsv == (3 * czaLine / 2)) ?
  396. MF_CHECKED : MF_UNCHECKED);
  397. CheckMenuItem(hMenu, imiDoubleSpace,
  398. (rgtsv[itsvSpacing].fGray == 0
  399. && rgtsv[itsvSpacing].wTsv == (2 * czaLine)) ?
  400. MF_CHECKED : MF_UNCHECKED);
  401. }
  402. break;
  403. case DIV:
  404. imiMin = imiDocuMin;
  405. imiMax = imiDocuMax;
  406. if (wwdCurrentDoc.fEditHeader)
  407. *pflags &= ~2; /* disable footer */
  408. else if (wwdCurrentDoc.fEditFooter)
  409. *pflags &= ~1; /* disable header */
  410. break;
  411. default:
  412. break;
  413. } /* end of switch */
  414. { /* enable or gray menu items */
  415. register WORD wFlagMask = 1;
  416. for (imi = imiMin; imi < imiMax; imi++)
  417. {
  418. EnableMenuItem(hMenu, imi, (*pflags & wFlagMask ? MF_ENABLED :
  419. MF_GRAYED));
  420. wFlagMask <<= 1;
  421. }
  422. }
  423. #if defined(OLE)
  424. if (index == EDIT)
  425. ObjUpdateMenu(hMenu);
  426. #endif
  427. }
  428. NEAR PutSzUndoInMenu()
  429. {
  430. /* Put the proper string for the current undo into the EDIT menu.
  431. idstrCurrentUndo gives the resource id for the current undo string. An
  432. idstrCurrentUndo value of -1 means use the last value loaded.
  433. This routine caches Undo strings so resource loads are needed only
  434. when the string changes. */
  435. extern struct UAB vuab;
  436. extern int idstrCurrentUndo; /* Current UNDO's string ID */
  437. extern CHAR szAltBS[];
  438. #ifdef JAPAN //T-HIROYN Win3.1
  439. static CHAR szUndo[ cchSzUndo + 5];
  440. #else
  441. static CHAR szUndo[ cchSzUndo ];
  442. #endif
  443. static int idstrUndoCache = -1;
  444. if (vuab.uac == uacNil)
  445. {
  446. idstrCurrentUndo = IDSTRUndoBase;
  447. }
  448. if (idstrCurrentUndo < 0)
  449. {
  450. /* This means we should use the last Undo string */
  451. Assert(idstrUndoCache > 0);
  452. idstrCurrentUndo = idstrUndoCache;
  453. }
  454. if (idstrCurrentUndo != idstrUndoCache)
  455. {
  456. /* Cached string is no good, build another */
  457. CHAR *PchFillPchId();
  458. CHAR *pch = szUndo;
  459. #if defined(KOREA)
  460. if (idstrCurrentUndo != IDSTRUndoBase)
  461. {
  462. /* need the tail part */
  463. pch = PchFillPchId(pch, idstrCurrentUndo, (int)sizeof(szUndo) );
  464. }
  465. pch += LoadString(hMmwModInstance, IDSTRUndoBase, (LPSTR)pch,
  466. (int)(szUndo + sizeof(szUndo) - pch));
  467. CchCopySz((PCH)szAltBS, pch);
  468. #else
  469. pch += LoadString(hMmwModInstance, IDSTRUndoBase, (LPSTR)szUndo,
  470. cchSzUndo);
  471. if (idstrCurrentUndo != IDSTRUndoBase)
  472. {
  473. /* need the tail part */
  474. pch = PchFillPchId(pch, idstrCurrentUndo,
  475. (int)(szUndo + sizeof(szUndo) - pch));
  476. }
  477. CchCopySz((PCH)szAltBS, pch);
  478. #endif
  479. /* Set the menu */
  480. ChangeMenu( vhMenu, imiUndo, (LPSTR)szUndo, imiUndo, MF_CHANGE );
  481. /* Set cache for next time */
  482. idstrUndoCache = idstrCurrentUndo;
  483. }
  484. }
  485. GetRgtsvChpSel (prgtsv)
  486. TSV *prgtsv;
  487. {
  488. /* Return properties for the character menu. */
  489. typeCP cpLim;
  490. typeCP cpStartRun;
  491. struct CHP chp;
  492. int cchGray = 0; /* number of undefined (grayed) character attributes */
  493. int ccpFetch = 0; /* number of calls made to FetchCp */
  494. /* max number of calls to FetchCp */
  495. #define ccpFetchMax 50
  496. #ifndef SAND
  497. if (selCur.cpLim > cpMacCur)
  498. {
  499. bltbc(prgtsv, 1, (cchTSV * itsvchMax)); /* turn all grays on */
  500. return;
  501. }
  502. #endif /* NOT SAND */
  503. bltbc(prgtsv, 0, (cchTSV * itsvchMax)); /* initializw rgtsv */
  504. CachePara(docCur, selCur.cpFirst);
  505. if (selCur.cpFirst == selCur.cpLim)
  506. {
  507. GetChpVals (&vchpSel,prgtsv); /* load up chp values */
  508. GetHffn (&vchpSel,prgtsv); /* load up handle for font name */
  509. }
  510. else
  511. {
  512. typeCP CpLimNoSpaces(typeCP, typeCP);
  513. cpLim = CpLimNoSpaces(selCur.cpFirst, selCur.cpLim);
  514. FetchCp(docCur, selCur.cpFirst, 0, fcmProps);
  515. blt(&vchpFetch, &chp, cwCHP); /* CHP for use in comparisons */
  516. GetChpVals (&vchpFetch,prgtsv); /* load up chp values */
  517. while ((vcpFetch + vccpFetch) < cpLim && ++ccpFetch <= ccpFetchMax)
  518. {
  519. /* Indicate which attributes should be grayed */
  520. FetchCp(docNil, cpNil, 0, fcmProps);
  521. chp.fSpecial = vchpFetch.fSpecial;
  522. if (CchDiffer (&chp, &vchpFetch, cchCHP) != 0)
  523. {
  524. SetChUndef(prgtsv, &vchpFetch, &cchGray);
  525. if (cchGray == itsvchMax) /* all gray - don't bother */
  526. break;
  527. }
  528. }
  529. if (ccpFetch > ccpFetchMax)
  530. {
  531. /* never finished - make everything gray */
  532. bltbc(prgtsv, 1, (cchTSV * itsvchMax));
  533. }
  534. else
  535. GetHffn (&chp,prgtsv); /* load up handle for font name */
  536. }
  537. }
  538. GetRgtsvPapSel (prgtsv)
  539. TSV *prgtsv;
  540. {
  541. /* Return properties for the paragraph menu. */
  542. /* Using selCur, the current para props are left in vpapAbs and the paragraph
  543. attributes in rgtsv are set to gray if that attribute differs from that
  544. in the previous paragraph. Up to cparaMax paragraphs will be checked */
  545. int cparaGray = 0; /* number of undefined (grayed) paragraph attributes */
  546. /* max number of calls to CachePara */
  547. #define cparaMax 50
  548. int cpara = 0;
  549. struct PAP pap;
  550. CachePara(docCur, selCur.cpFirst);
  551. #ifdef ENABLE /* we will show defaults even if the cursor is next to endmark */
  552. if (selCur.cpFirst == cpMacCur)
  553. {
  554. bltbc(prgtsv, 1, (cchTSV * itsvparaMax)); /* turn all grays on */
  555. return;
  556. }
  557. #endif
  558. bltbc(prgtsv, 0, (cchTSV * itsvparaMax)); /* initializw rgtsv */
  559. blt(&vpapAbs, &pap, cwPAP); /* save 1st paragraph for compares */
  560. GetPapVals (&pap,prgtsv); /* load rgtsv with pap values */
  561. while (vcpLimParaCache < selCur.cpLim && ++cpara <= cparaMax)
  562. {
  563. /* If any props are different, set appropriate flags */
  564. CachePara(docCur, vcpLimParaCache);
  565. if (CchDiffer(&pap, &vpapAbs, (cwPAPBase * cchINT)) != 0)
  566. {
  567. SetParaUndef(prgtsv, &vpapAbs, &cparaGray);
  568. if (cparaGray == itsvparaMax) /* all gray - don't bother */
  569. break;
  570. }
  571. }
  572. if (cpara > cparaMax)
  573. /* never finished - make everything gray */
  574. bltbc(prgtsv, 1, (cchTSV * itsvparaMax));
  575. }
  576. NEAR GetChpVals (pchp,prgtsv) /* load chp values into rgtsv */
  577. register struct CHP *pchp;
  578. register TSV *prgtsv;
  579. {
  580. (prgtsv+itsvBold)->wTsv = pchp->fBold;
  581. (prgtsv+itsvItalic)->wTsv = pchp->fItalic;
  582. (prgtsv+itsvUline)->wTsv = pchp->fUline;
  583. (prgtsv+itsvFfn)->wTsv = pchp->ftc;
  584. (prgtsv+itsvSize)->wTsv = pchp->hps;
  585. /* sub/superscripts - note that value is stored
  586. as a signed integer, so we can just check for
  587. the value relative to 0 */
  588. (int)((prgtsv+itsvPosition)->wTsv) = (char)pchp->hpsPos;
  589. }
  590. NEAR GetPapVals (ppap,prgtsv) /* load pap values into rgtsv */
  591. register struct PAP *ppap;
  592. register TSV *prgtsv;
  593. {
  594. (prgtsv+itsvJust)->wTsv = ppap->jc;
  595. (prgtsv+itsvSpacing)->wTsv = ppap->dyaLine;
  596. (prgtsv+itsvLIndent)->wTsv = ppap->dxaLeft;
  597. (prgtsv+itsvFIndent)->wTsv = ppap->dxaLeft1;
  598. (prgtsv+itsvRIndent)->wTsv = ppap->dxaRight;
  599. }
  600. NEAR GetHffn (pchp,prgtsv) /* load font name handle into rgtsv */
  601. register struct CHP *pchp;
  602. register TSV *prgtsv;
  603. {
  604. union FCID fcid;
  605. extern struct FFN **MpFcidHffn();
  606. /* store handle for font name in font name entry */
  607. Assert(sizeof(struct FFN **) == sizeof(prgtsv->wTsv));
  608. fcid.strFcid.doc = docCur;
  609. fcid.strFcid.ftc = pchp->ftc + (pchp->ftcXtra << 6);
  610. (struct FFN **)((prgtsv+itsvFfn)->wTsv) = MpFcidHffn(&fcid);
  611. }
  612. NEAR SetChUndef(prgtsv, pchp, pcchGray)
  613. register TSV *prgtsv;
  614. register struct CHP *pchp;
  615. int *pcchGray;
  616. {
  617. /* compare chp to values stored in rgtsv and set undefined
  618. flags for differing fields of interest. */
  619. /* BOLD */
  620. if ((prgtsv+itsvBold)->fGray == 0)
  621. if (pchp->fBold != (prgtsv+itsvBold)->wTsv)
  622. {
  623. (prgtsv+itsvBold)->fGray = 1;
  624. (*pcchGray)++;
  625. }
  626. /* ITALIC */
  627. if ((prgtsv+itsvItalic)->fGray == 0)
  628. if (pchp->fItalic != (prgtsv+itsvItalic)->wTsv)
  629. {
  630. (prgtsv+itsvItalic)->fGray = 1;
  631. (*pcchGray)++;
  632. }
  633. /* UNDERLINE */
  634. if ((prgtsv+itsvUline)->fGray == 0)
  635. if (pchp->fUline != (prgtsv+itsvUline)->wTsv)
  636. {
  637. (prgtsv+itsvUline)->fGray = 1;
  638. (*pcchGray)++;
  639. }
  640. /* Position (SUBSCRIPT OR SUPERSCRIPT) */
  641. /* if different: gray both sub and superscript.
  642. The properties are really mutually exclusive,
  643. even though they appear on the menu as separate
  644. items. Also, for Write, off and gray are the
  645. same, so if either is grayed, the other must be
  646. either off or gray, so the appearance is the
  647. same. */
  648. if ((prgtsv+itsvPosition)->fGray == 0)
  649. if (pchp->hpsPos != (prgtsv+itsvPosition)->wTsv)
  650. {
  651. (prgtsv+itsvPosition)->fGray = 1;
  652. (*pcchGray)++;
  653. }
  654. /* FONT NAME */
  655. if ((prgtsv+itsvFfn)->fGray == 0)
  656. if (pchp->ftc != (prgtsv+itsvFfn)->wTsv)
  657. {
  658. (prgtsv+itsvFfn)->fGray = 1;
  659. (*pcchGray)++;
  660. }
  661. /* FONT SIZE */
  662. if ((prgtsv+itsvSize)->fGray == 0)
  663. if (pchp->hps != (prgtsv+itsvSize)->wTsv)
  664. {
  665. (prgtsv+itsvSize)->fGray = 1;
  666. (*pcchGray)++;
  667. }
  668. }
  669. NEAR SetParaUndef(prgtsv, ppap, pcparaGray)
  670. register TSV *prgtsv;
  671. register struct PAP *ppap;
  672. int *pcparaGray;
  673. {
  674. /* compare pap to values stored in rgtsv and set undefined
  675. flags for differing fields of interest. */
  676. /* JUSTIFICATION */
  677. if ((prgtsv+itsvJust)->fGray == 0)
  678. if (ppap->jc != (prgtsv+itsvJust)->wTsv)
  679. {
  680. (prgtsv+itsvJust)->fGray = 1;
  681. (*pcparaGray)++;
  682. }
  683. /* LINE SPACING */
  684. if ((prgtsv+itsvSpacing)->fGray == 0)
  685. if (ppap->dyaLine != (prgtsv+itsvSpacing)->wTsv)
  686. {
  687. (prgtsv+itsvSpacing)->fGray = 1;
  688. (*pcparaGray)++;
  689. }
  690. /* LEFT INDENT */
  691. if ((prgtsv+itsvLIndent)->fGray == 0)
  692. if (ppap->dxaLeft != (prgtsv+itsvLIndent)->wTsv)
  693. {
  694. (prgtsv+itsvLIndent)->fGray = 1;
  695. (*pcparaGray)++;
  696. }
  697. /* FIRST LINE INDENT */
  698. if ((prgtsv+itsvFIndent)->fGray == 0)
  699. if (ppap->dxaLeft1 != (prgtsv+itsvFIndent)->wTsv)
  700. {
  701. (prgtsv+itsvFIndent)->fGray = 1;
  702. (*pcparaGray)++;
  703. }
  704. /* RIGHT INDENT */
  705. if ((prgtsv+itsvRIndent)->fGray == 0)
  706. if (ppap->dxaRight != (prgtsv+itsvRIndent)->wTsv)
  707. {
  708. (prgtsv+itsvRIndent)->fGray = 1;
  709. (*pcparaGray)++;
  710. }
  711. }
  712. /* C P L I M N O S P A C E S */
  713. typeCP CpLimNoSpaces(cpFirst, cpLim)
  714. typeCP cpFirst, cpLim;
  715. {
  716. /* Truncate trailing spaces unless only spaces are in sel. */
  717. int cch;
  718. typeCP cpLimOrig;
  719. CHAR rgch[cchMaxSz];
  720. cpLimOrig = cpLim;
  721. FetchRgch(&cch, rgch, docCur, CpMax(cpFirst + cchMaxSz, cpLim) - cchMaxSz,
  722. cpLim, cchMaxSz);
  723. while (cch-- > 0 && rgch[cch] == chSpace)
  724. {
  725. --cpLim;
  726. }
  727. return cch < 0 ? cpLimOrig : cpLim;
  728. } /* end of CpLimNoSpaces */
  729. NEAR FNoSearchStr(hDlg)
  730. HWND hDlg;
  731. {
  732. CHAR szBuf[255];
  733. HWND hWndFrom = GetActiveWindow();
  734. if (hDlg == hWndFrom || hDlg == (HANDLE)GetWindowWord(hWndFrom, GWW_HWNDPARENT))
  735. {
  736. if (GetDlgItemText(hDlg, idiFind, (LPSTR)szBuf, 255) == 0)
  737. return(TRUE);
  738. }
  739. return(FALSE);
  740. }
  741. PhonyMenuAccelerator( menu, imi, lpfn )
  742. int menu;
  743. int imi;
  744. FARPROC lpfn;
  745. {
  746. HMENU hSubmenu = GetSubMenu(vhMenu,menu);
  747. SetAppMenu( hSubmenu , menu );
  748. if (FIsMenuItemEnabled( hSubmenu , imi ))
  749. {
  750. HiliteMenuItem( hParentWw, vhMenu, menu, MF_BYPOSITION | MF_HILITE );
  751. (*lpfn) ();
  752. HiliteMenuItem( hParentWw, vhMenu, menu, MF_BYPOSITION );
  753. }
  754. }
  755. FIsMenuItemEnabled (HMENU hMenu , int id )
  756. { /* Find out if a menu item in vhMenu is enabled. */
  757. return !(GetMenuState(hMenu, id, MF_BYCOMMAND ) & (MF_DISABLED|MF_GRAYED));
  758. }
  759. int FAR PASCAL NewFont(HWND hwnd);
  760. void MmwCommand(hWnd, wParam, hWndCtl, codeCtl)
  761. HWND hWnd;
  762. WORD wParam;
  763. HWND hWndCtl;
  764. WORD codeCtl;
  765. {
  766. #ifdef INEFFLOCKDOWN
  767. extern FARPROC lpDialogHelp;
  768. extern FARPROC lpDialogGoTo;
  769. extern FARPROC lpDialogCharFormats;
  770. extern FARPROC lpDialogParaFormats;
  771. extern FARPROC lpDialogTabs;
  772. extern FARPROC lpDialogDivision;
  773. extern FARPROC lpDialogPrinterSetup;
  774. #else
  775. extern BOOL far PASCAL DialogPrinterSetup(HWND, unsigned, WORD, LONG);
  776. extern BOOL far PASCAL DialogHelp(HWND, unsigned, WORD, LONG);
  777. extern BOOL far PASCAL DialogGoTo(HWND, unsigned, WORD, LONG);
  778. extern BOOL far PASCAL DialogCharFormats(HWND, unsigned, WORD, LONG);
  779. extern BOOL far PASCAL DialogParaFormats(HWND, unsigned, WORD, LONG);
  780. extern BOOL far PASCAL DialogTabs(HWND, unsigned, WORD, LONG);
  781. extern BOOL far PASCAL DialogDivision(HWND, unsigned, WORD, LONG);
  782. #endif
  783. extern int vfPictSel;
  784. extern CHAR *vpDlgBuf;
  785. int DialogOk = 0;
  786. int fQuit = fFalse;
  787. if (wParam & fMenuItem)
  788. {
  789. switch (wParam & MENUMASK)
  790. {
  791. case FILEMENU:
  792. switch(wParam)
  793. {
  794. case imiNew:
  795. fnNewFile();
  796. break;
  797. case imiOpen:
  798. fnOpenFile((LPSTR)NULL);
  799. break;
  800. case imiSave:
  801. #if defined(OLE)
  802. if (CloseUnfinishedObjects(TRUE) == FALSE)
  803. return;
  804. #endif
  805. fnSave();
  806. break;
  807. case imiSaveAs:
  808. #if defined(OLE)
  809. if (CloseUnfinishedObjects(TRUE) == FALSE)
  810. return;
  811. #endif
  812. fnSaveAs();
  813. break;
  814. case imiPrint:
  815. fnPrPrinter();
  816. break;
  817. case imiPrintSetup:
  818. /* Bring up the Change Printer dialog box. */
  819. PrinterSetupDlg(FALSE);
  820. break;
  821. case imiRepaginate:
  822. fnRepaginate();
  823. break;
  824. case imiQuit:
  825. fnQuit(hWnd);
  826. fQuit = fTrue;
  827. break;
  828. default:
  829. break;
  830. }
  831. break;
  832. case EDITMENU:
  833. switch(wParam)
  834. {
  835. case imiUndo:
  836. CmdUndo();
  837. break;
  838. case imiCut:
  839. fnCutEdit();
  840. break;
  841. case imiCopy:
  842. fnCopyEdit();
  843. break;
  844. case imiPaste:
  845. #if defined(OLE)
  846. vbObjLinkOnly = FALSE;
  847. #endif
  848. fnPasteEdit();
  849. break;
  850. #if defined(OLE)
  851. case imiPasteSpecial:
  852. vbObjLinkOnly = FALSE;
  853. fnObjPasteSpecial();
  854. break;
  855. case imiPasteLink:
  856. vbObjLinkOnly = TRUE;
  857. fnPasteEdit();
  858. break;
  859. case imiInsertNew:
  860. fnObjInsertNew();
  861. break;
  862. #endif
  863. case imiMovePicture:
  864. fnMovePicture();
  865. break;
  866. case imiSizePicture:
  867. fnSizePicture();
  868. break;
  869. #if defined(OLE)
  870. case imiProperties:
  871. fnObjProperties();
  872. break;
  873. #endif
  874. default:
  875. break;
  876. }
  877. break;
  878. #if defined(OLE)
  879. case VERBMENU:
  880. fnObjDoVerbs(wParam);
  881. break;
  882. #endif
  883. case FINDMENU:
  884. if (wParam != imiGoTo && wParam != imiFindAgain)
  885. StartLongOp();
  886. switch(wParam)
  887. {
  888. case imiFind:
  889. fnFindText();
  890. break;
  891. case imiFindAgain:
  892. fnFindAgain();
  893. break;
  894. case imiChange:
  895. fnReplaceText();
  896. break;
  897. case imiGoTo:
  898. {
  899. #ifndef INEFFLOCKDOWN
  900. FARPROC lpDialogGoTo = MakeProcInstance(DialogGoTo, hMmwModInstance);
  901. if (!lpDialogGoTo)
  902. goto LNotEnufMem;
  903. #endif
  904. DialogOk = OurDialogBox(hMmwModInstance, MAKEINTRESOURCE(dlgGoTo),
  905. hParentWw, lpDialogGoTo);
  906. #ifndef INEFFLOCKDOWN
  907. FreeProcInstance(lpDialogGoTo);
  908. #endif
  909. /* the following block has been commentted out because
  910. the corresponding file(DISP.C) doesn't inlcude MmwCatSt
  911. routine anymore */
  912. #if 0
  913. {
  914. extern void far MmwCatSt( HWND, BOOL );
  915. MmwCatSt(hParentWw, FALSE);
  916. }
  917. #endif
  918. break;
  919. }
  920. default:
  921. break;
  922. }
  923. break;
  924. case CHARMENU:
  925. if (wParam != imiCharFormats)
  926. StartLongOp();
  927. {
  928. /* rgtsv gets attributes and gray flags from CHP */
  929. TSV rgtsv[itsvchMax];
  930. CHAR rgbDlgBuf[sizeof(BOOL)];
  931. void NEAR fnCharSelectFont(int);
  932. /* GetRgtsvChpSel() fills up rgtsv */
  933. GetRgtsvChpSel(rgtsv);
  934. switch(wParam)
  935. {
  936. case imiCharNormal:
  937. ApplyCLooks(0, sprmCPlain, 0);
  938. break;
  939. case imiBold:
  940. ApplyCLooks(0, sprmCBold, (rgtsv[itsvBold].fGray != 0) ? TRUE :
  941. !rgtsv[itsvBold].wTsv);
  942. break;
  943. case imiItalic:
  944. ApplyCLooks(0, sprmCItalic, (rgtsv[itsvItalic].fGray != 0) ?
  945. TRUE : !rgtsv[itsvItalic].wTsv);
  946. break;
  947. case imiUnderline:
  948. ApplyCLooks(0, sprmCUline, (rgtsv[itsvUline].fGray != 0) ? TRUE
  949. : !rgtsv[itsvUline].wTsv);
  950. break;
  951. case imiSuper:
  952. /* Note that the value stored in rgtsv[itsvPosition].wTsv is
  953. really a signed integer, so we can just check for 0, > 0, and <
  954. 0. */
  955. ApplyCLooks(0, sprmCPos, !(rgtsv[itsvPosition].fGray == 0 &&
  956. (int)rgtsv[itsvPosition].wTsv > 0) ? ypSubSuper : 0);
  957. break;
  958. case imiSub:
  959. ApplyCLooks(0, sprmCPos, !(rgtsv[itsvPosition].fGray == 0 &&
  960. (int)rgtsv[itsvPosition].wTsv < 0) ? -ypSubSuper : 0);
  961. break;
  962. #if 0
  963. case imiFont1:
  964. fnCharSelectFont(0);
  965. break;
  966. case imiFont2:
  967. fnCharSelectFont(1);
  968. break;
  969. case imiFont3:
  970. fnCharSelectFont(2);
  971. break;
  972. #endif
  973. case imiSmFont:
  974. if (CanChangeFont(-1))
  975. {
  976. ApplyCLooks(0, sprmCChgHps, -1);
  977. vfSeeSel = TRUE;
  978. }
  979. break;
  980. case imiLgFont:
  981. if (CanChangeFont(1))
  982. {
  983. ApplyCLooks(0, sprmCChgHps, 1);
  984. vfSeeSel = TRUE;
  985. }
  986. break;
  987. case imiCharFormats:
  988. {
  989. #if 0
  990. #ifndef INEFFLOCKDOWN
  991. FARPROC lpDialogCharFormats = MakeProcInstance(DialogCharFormats, hMmwModInstance);
  992. if (!lpDialogCharFormats)
  993. goto LNotEnufMem;
  994. #endif
  995. vpDlgBuf = &rgbDlgBuf[0];
  996. DialogOk = OurDialogBox(hMmwModInstance,
  997. MAKEINTRESOURCE(dlgCharFormats),
  998. hParentWw, lpDialogCharFormats);
  999. #ifndef INEFFLOCKDOWN
  1000. FreeProcInstance(lpDialogCharFormats);
  1001. #endif
  1002. #else
  1003. DialogOk = NewFont(hParentWw);
  1004. #endif
  1005. break;
  1006. }
  1007. #if defined(JAPAN) & defined(IME_HIDDEN) //IME3.1J
  1008. //IME3.1J
  1009. case imiImeHidden:
  1010. ChangeImeConversionMode();
  1011. break;
  1012. #endif
  1013. default:
  1014. break;
  1015. }
  1016. #if defined(JAPAN) & defined(DBCS_IME) //Win3.1J
  1017. SetImeFont(vhWnd);
  1018. #endif
  1019. break;
  1020. }
  1021. case PARAMENU:
  1022. switch(wParam)
  1023. {
  1024. case imiParaNormal:
  1025. ApplyLooksParaS(0, sprmPNormal, 0);
  1026. if (vfPictSel)
  1027. {
  1028. CmdUnscalePic();
  1029. }
  1030. break;
  1031. case imiLeft:
  1032. ApplyLooksParaS(0, sprmPJc, jcLeft);
  1033. break;
  1034. case imiCenter:
  1035. ApplyLooksParaS(0, sprmPJc, jcCenter);
  1036. break;
  1037. case imiRight:
  1038. ApplyLooksParaS(0, sprmPJc, jcRight);
  1039. break;
  1040. case imiJustified:
  1041. ApplyLooksParaS(0, sprmPJc, jcBoth);
  1042. break;
  1043. case imiSingleSpace:
  1044. ApplyLooksPara(0, sprmPDyaLine, czaLine);
  1045. break;
  1046. case imiOneandhalfSpace:
  1047. ApplyLooksPara(0, sprmPDyaLine, czaLine * 3 / 2);
  1048. break;
  1049. case imiDoubleSpace:
  1050. ApplyLooksPara(0, sprmPDyaLine, czaLine * 2);
  1051. break;
  1052. case imiParaFormats:
  1053. {
  1054. #ifndef INEFFLOCKDOWN
  1055. FARPROC lpDialogParaFormats = MakeProcInstance(DialogParaFormats, hMmwModInstance);
  1056. if (!lpDialogParaFormats)
  1057. goto LNotEnufMem;
  1058. #endif
  1059. DialogOk = OurDialogBox(hMmwModInstance,
  1060. MAKEINTRESOURCE(dlgParaFormats),
  1061. hParentWw, lpDialogParaFormats);
  1062. #ifndef INEFFLOCKDOWN
  1063. FreeProcInstance(lpDialogParaFormats);
  1064. #endif
  1065. break;
  1066. }
  1067. default:
  1068. break;
  1069. }
  1070. break;
  1071. case DOCUMENU:
  1072. switch(wParam)
  1073. {
  1074. case imiFooter:
  1075. case imiHeader:
  1076. fnEditRunning(wParam);
  1077. break;
  1078. case imiShowRuler:
  1079. fnShowRuler();
  1080. break;
  1081. case imiTabs:
  1082. {
  1083. #ifndef INEFFLOCKDOWN
  1084. FARPROC lpDialogTabs = MakeProcInstance(DialogTabs, hMmwModInstance);
  1085. if (!lpDialogTabs)
  1086. goto LNotEnufMem;
  1087. #endif
  1088. DialogOk = OurDialogBox(hMmwModInstance, MAKEINTRESOURCE(dlgTabs),
  1089. hParentWw, lpDialogTabs);
  1090. #ifndef INEFFLOCKDOWN
  1091. FreeProcInstance(lpDialogTabs);
  1092. #endif
  1093. break;
  1094. }
  1095. case imiDivFormats:
  1096. {
  1097. #ifndef INEFFLOCKDOWN
  1098. FARPROC lpDialogDivision = MakeProcInstance(DialogDivision, hMmwModInstance);
  1099. if (!lpDialogDivision)
  1100. goto LNotEnufMem;
  1101. #endif
  1102. DialogOk = OurDialogBox(hMmwModInstance,
  1103. MAKEINTRESOURCE(dlgDivision),
  1104. hParentWw, lpDialogDivision);
  1105. #ifndef INEFFLOCKDOWN
  1106. FreeProcInstance(lpDialogDivision);
  1107. #endif
  1108. break;
  1109. }
  1110. default:
  1111. break;
  1112. }
  1113. break;
  1114. case HELPMENU:
  1115. {
  1116. int wHelpCode;
  1117. extern WORD wWinVer;
  1118. CHAR sz[ cchMaxFile ];
  1119. LDefaultHelp:
  1120. PchFillPchId( sz, IDSTRHELPF, sizeof(sz) );
  1121. switch(wParam)
  1122. {
  1123. case imiIndex:
  1124. WinHelp(hParentWw, (LPSTR)sz, HELP_INDEX, NULL);
  1125. break;
  1126. case imiHelpSearch:
  1127. WinHelp(hParentWw, (LPSTR)sz, HELP_PARTIALKEY, (DWORD)(LPSTR)"");
  1128. break;
  1129. case imiUsingHelp:
  1130. WinHelp(hParentWw, (LPSTR)NULL, HELP_HELPONHELP, NULL);
  1131. break;
  1132. default:
  1133. case imiAbout:
  1134. if (((wWinVer & 0xFF) >= 3) && ((wWinVer & 0xFF00) >= 0x0A00))
  1135. {
  1136. extern CHAR szMw_icon[];
  1137. extern CHAR szAppName[];
  1138. ShellAbout(hParentWw, szAppName, "",
  1139. LoadIcon( hMmwModInstance, (LPSTR)szMw_icon ));
  1140. }
  1141. break;
  1142. }
  1143. break;
  1144. }
  1145. default:
  1146. if (wParam == imiHelp)
  1147. {
  1148. #ifdef WIN30
  1149. wParam = imiIndex; /* For all Win3 applets, pressing F1
  1150. should bring up the Help Index */
  1151. #endif
  1152. goto LDefaultHelp;
  1153. }
  1154. }
  1155. if (DialogOk == -1)
  1156. {
  1157. LNotEnufMem:
  1158. #ifdef WIN30
  1159. WinFailure();
  1160. #else
  1161. Error(IDPMTNoMemory);
  1162. #endif
  1163. }
  1164. }
  1165. if (!fQuit)
  1166. UpdateInvalid(); /* To be sure we update the area behind dialogs */
  1167. }
  1168. #if 0
  1169. void NEAR fnCharSelectFont(iffn)
  1170. /* select the specified font from the three listed on char dropdown */
  1171. int iffn;
  1172. {
  1173. struct FFN *pffn;
  1174. int ftc;
  1175. extern CHAR rgffnFontMenu[3][ibFfnMax];
  1176. extern int docCur;
  1177. pffn = (struct FFN *)rgffnFontMenu[iffn];
  1178. ftc = FtcChkDocFfn(docCur, pffn);
  1179. if (ftc != ftcNil)
  1180. ApplyCLooks(0, sprmCFtc, ftc);
  1181. vfSeeSel = TRUE;
  1182. }
  1183. #endif
  1184. #ifdef JAPAN //Win3.1J
  1185. int KanjiFtc = ftcNil;
  1186. GetKanjiFtc(pchp)
  1187. struct CHP *pchp;
  1188. {
  1189. int ftc;
  1190. int CharSet;
  1191. CharSet = GetCharSetFromChp(pchp);
  1192. if (NATIVE_CHARSET == CharSet) {
  1193. KanjiFtc = GetFtcFromPchp(pchp);
  1194. return(ftcNil);
  1195. } else {
  1196. if(KanjiFtc == ftcNil)
  1197. ftc = SearchKanjiFtc(docCur); //Get set New szFfn chs
  1198. else
  1199. ftc = KanjiFtc;
  1200. return(ftc);
  1201. }
  1202. }
  1203. GetCharSetFromChp(pchp)
  1204. struct CHP *pchp;
  1205. {
  1206. TSV rgtsv[itsvchMax]; /* gets attributes and gray flags from CHP, PAP */
  1207. struct FFN **hffn;
  1208. GetHffn (pchp,rgtsv); /* load up handle for font name */
  1209. hffn = (struct FFN **)rgtsv[itsvFfn].wTsv;
  1210. return((*hffn)->chs);
  1211. }
  1212. extern CHAR saveKanjiDefFfn[ibFfnMax];
  1213. SearchKanjiFtc(doc)
  1214. /* looks for described font in docs ffntb - returns ftcNil if not found */
  1215. int doc;
  1216. {
  1217. int ftc;
  1218. int iffn, iffnMac;
  1219. struct FFNTB **hffntb;
  1220. struct FFN ***mpftchffn;
  1221. struct FFN *pffn;
  1222. ftc = ftcNil;
  1223. hffntb = HffntbGet(doc);
  1224. if (hffntb != 0) {
  1225. mpftchffn = (*hffntb)->mpftchffn;
  1226. iffnMac = (*hffntb)->iffnMac;
  1227. for (iffn = 0; iffn < iffnMac; iffn++) {
  1228. if ( (*mpftchffn[iffn])->chs == NATIVE_CHARSET &&
  1229. (*mpftchffn[iffn])->szFfn[0] != chGhost)
  1230. return(iffn);
  1231. }
  1232. }
  1233. pffn = (struct FFN *)saveKanjiDefFfn;
  1234. ftc = FtcChkDocFfn(doc, pffn);
  1235. if (ftc != ftcNil)
  1236. return(ftc);
  1237. return(ftcNil);
  1238. }
  1239. #endif
  1240.