home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / cshar_ml.sit < prev    next >
Encoding:
Text File  |  1988-06-20  |  75.3 KB  |  2,458 lines

  1. 18-Jun-88 14:38:33-MDT,79568;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:36:22 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA22504; Sat, 18 Jun 88 14:36:17 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA24697; Sat, 18 Jun 88 14:36:09 MDT
  8. Date: Sat, 18 Jun 88 14:36:09 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8806182036.AA24697@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: MultiPrint.c.shar
  13.  
  14. #! /bin/sh
  15. #
  16. # This is a shell archive.  Save this into a file, edit it
  17. # and delete all lines above this comment.  Then give this
  18. # file to sh by executing the command "sh file".  The files
  19. # will be extracted into the current directory owned by
  20. # you with default permissions.
  21. #
  22. # The files contained herein are:
  23. #
  24. #   59 MultiPrintv1.p
  25. #    8 MultiPrintv1.r
  26. #    3 Multiprintv1.c
  27. #    2 Multiprintv1.mf
  28. #
  29. echo 'Extracting MultiPrintv1.p'
  30. if test -f MultiPrintv1.p; then echo 'shar: will not overwrite MultiPrintv1.p'; else
  31. sed 's/^X//' << '________This_Is_The_END________' > MultiPrintv1.p
  32. X{PasMat formatting codes}
  33. X{[a-, b-, body-, c-, g-, h-, j=15+/50, k+, n+, o=98, q-, r+, rec+, u+,
  34. X v-, x-, y-, z-, :+, #-]}
  35. XPROGRAM MultiPrint;
  36. X {Written By Brent Pease}
  37. X {Copyright (c) 1987}
  38. X {
  39. X This program demonstrates:
  40. X 1) User items in dialogs
  41. X 2) Custimizing and using the standard file package
  42. X 3) Printing in general(Printing text files specifically)
  43. X 4) Using the Print Managers backround processing system.
  44. X 5) A general idea if simple file IO and keeping track of menu items involved
  45. X 6) Your basic Mac IO junk.
  46. X
  47. X Note you should not have a procedure called by the toolbox, ex. MyDlg,
  48. X MyFilter, ect. nesting within another procedure, you can not access any
  49. X variable of the containing block because the stack frame will not be the same
  50. X when your procedure is called.
  51. X
  52. X Also note that some of this stuff is pretty experimental.
  53. X
  54. X This program does not teach you how to do these things, it simply gives you an
  55. X example. It is assumed you have already read about them in "Inside Macintosh".
  56. X See Tech Note #47 for more detailed information on custimizing SFGetFile.
  57. X See Tech Note #95 for information on adding items to Print Manager Dialogs
  58. X (My AddItems procedure was influenced by Lew Rollins AppendDITL, the differnce
  59. X between the two is that he builds the Item list himself, I let the Dialog
  60. X Manager handle that for me)
  61. X If you find this program useful please send $10.00 or what every you feel
  62. X my effort is worth.
  63. X Brent Pease
  64. X 20 Lansing St.
  65. X Hinsdale IL 60521
  66. X }
  67. X
  68. X    USES
  69. X        {$LOAD MPW Programs:MultiPrint:MacIntf.LOAD}
  70. X        Memtypes, Quickdraw, OSIntf, ToolIntf, MacPrint, PackIntf;
  71. X
  72. X    CONST
  73. X        {Menus ID's}
  74. X        AppleMenu          = 1;
  75. X        FileMenu             = 2;
  76. X        EditMenu             = 3;
  77. X
  78. X        {Dialog ID's}
  79. X        SaveDlgID          = 128;                                              {Save Changes To}
  80. X        PFNDlgID             = 129;                                              {Enter the number of the print file}
  81. X        CPrintDlgID      = 130;                                              {Contine with current print job?}
  82. X        PBRDlgID             = 131;                                              {Print Backround dialog}
  83. X        AboutDlgID         = 132;                                              {About dialog}
  84. X        JobItems             = 133;                                              {MPJobDialog extra items}
  85. X        HFDlgID              = 134;                                              {Header/Footer Dialog}
  86. X        GPFDlgID             = - 4001;                                         {Custum standard file dialog}
  87. X
  88. X        {Dialog Item ID's}
  89. X        {Save Changes to}
  90. X        Yes                      = 1;
  91. X        No                         = 2;
  92. X        MyCancel             = 3;
  93. X
  94. X        {Print Backround dialog}
  95. X        Stop                     = 1;
  96. X        Pause                  = 3;
  97. X        Resume                 = 4;
  98. X        CurSet                 = 8;
  99. X        CurPFile             = 9;
  100. X        TotUser              = 10;                                                 {Total job user item}
  101. X        SPFUser              = 11;                                                 {Saving PrintFile user item}
  102. X        PFPUser              = 12;                                                 {Print PrintFile user item}
  103. X
  104. X        {Job Dialog extra Item numbers}
  105. X        DrawBorder         = 1;
  106. X        Tab                      = 2;
  107. X        PFFont                 = 3;
  108. X        PFSize                 = 4;
  109. X        HFFont                 = 5;
  110. X        HFSize                 = 6;
  111. X
  112. X        {Apple Menu menu items}
  113. X        AMAbout              = 1;
  114. X
  115. X        {File Menu menu items}
  116. X        FMSelectSet      = 1;
  117. X        FMOpenSet          = 2;
  118. X        FMCloseSet         = 4;
  119. X        FMSaveSet          = 5;
  120. X        FMPageSetUp      = 7;
  121. X        FMPrint              = 8;
  122. X        FMQuit                 = 10;
  123. X
  124. X        {Edit Menu menu items}
  125. X        EMDisplaySet     = 8;
  126. X        EMAddFile          = 10;
  127. X        EMDeleteFile     = 11;
  128. X        EMChangeFile     = 12;
  129. X        EMHeader             = 14;
  130. X        EMFooter             = 15;
  131. X
  132. X        {Enable Flags}
  133. X        {File Menu enable flags. Used instead of calling EnableItem and DisableItem}
  134. X        FMNoFileOpen     = $FFFFFC87;
  135. X        FMFileIsOpen     = $FFFFFD91;
  136. X        FMSetSelected  = $FFFFFDB5;
  137. X
  138. X        {Edit menu enable flags}
  139. X        EMNoFileOpen     = $FFFFC07B;
  140. X        EMWindActFO      = $FFFFDD01;                                  {Window active and file is open}
  141. X        EMWindDctFO      = $FFFFDD7B;                                  {Window deactive and file is open}
  142. X        EMWindActNF      = $FFFFC001;                                  {Window active and no file is open}
  143. X        EMWindDctNF      = $FFFFC07B;                                  {Window deactive and no file is open}
  144. X
  145. X    TYPE
  146. X        {Record to store info about a PrintFile}
  147. X        PrintFileRec     = RECORD
  148. X            PFName                : Str255;                                      {Title of document}
  149. X            PFvRefNum         : Integer;                                     {Volume refernce number}
  150. X            PFJobRec            : TPrJob;                                      {Print Job subrecord}
  151. X            Border                : Boolean;                                     {Print a border around the text}
  152. X            PFFontNum         : Integer;                                     {PrintFiles font number, if 0 default is used}
  153. X            PFPtSize            : Integer;                                     {PrintFiles font size}
  154. X            HFFontNum         : Integer;                                     {PrintFiles header/footer font num. 0=default}
  155. X            HFPtSize            : Integer;                                     {PrintFile header/footer font soze}
  156. X            PFTab                 : Integer;                                     {Number of spaces in tab}
  157. X            END;
  158. X
  159. X        {Record to keep track of the current and maximun setting of the user items}
  160. X        UIProsRec          = RECORD
  161. X            Total                 : LongInt;                                     {Total Number of bytes to be processed}
  162. X            Current             : LongInt;                                     {Number of bytes processed so far}
  163. X            END;
  164. X
  165. X        {Record to store info about where the Print Job was stoped}
  166. X        JobRec                 = RECORD
  167. X            InJob                 : Boolean;                                     {True if we are in a printing job}
  168. X            PFPageNum         : Integer;                                     {Page where job was stopped}
  169. X            PFNum                 : Integer;                                     {Store the Print File number where job was
  170. X                                                                                                    stopped}
  171. X            END;
  172. X
  173. X        {Record to store information about the Write Window}
  174. X        WriteInfoRec     = RECORD
  175. X            WindowCont        : ARRAY [1..50] OF Str255;     {Contents of window}
  176. X            WriteWindow     : WindowPtr;                                 {pointer to our window record}
  177. X            CurrLine            : Integer;                                     {Current line number in window}
  178. X            LineHeight        : Integer;                                     {line height of font}
  179. X            MaxLine             : Integer;                                     {Maximun number of lines displayed in window at
  180. X                                                                                                    onetime}
  181. X            END;
  182. X
  183. X        {Record to store information about the current doc}
  184. X        DocumentRec      = RECORD
  185. X            dName                 : Str255;                                      {Document name}
  186. X            FRefNum             : Integer;                                     {FIle refernce number}
  187. X            VRefNum             : Integer;                                     {Volume refernce number}
  188. X            Saved                 : Boolean;                                     {document saved since last changes}
  189. X            END;
  190. X
  191. X        ETAB                     = RECORD
  192. X            DummyInt            : Integer;
  193. X            ETABTab             : Integer;
  194. X            END;
  195. X        ETABPtr                 = ^ETAB;
  196. X        ETABHdl              = ^ETABPtr;
  197. X
  198. X        MPSR                     = RECORD
  199. X            DummyArray1     : ARRAY [1..18] OF Integer;
  200. X            MPSRTab             : Integer;
  201. X            DummyArray2     : ARRAY [1..17] OF Integer;
  202. X            END;
  203. X        MPSRPtr        = ^MPSR;
  204. X        MPSRHdl              = ^MPSRPtr;
  205. X
  206. X    VAR
  207. X        CurJob                : JobRec;
  208. X        Document            : DocumentRec;
  209. X        Write                 : WriteInfoRec;
  210. X        Menus                 : ARRAY [1..3] OF MenuHandle;
  211. X        UIPros                : ARRAY [TotUser..PFPUser] OF UIProsRec;
  212. X        NumPF                 : Integer;                                         {Number of print files in this document}
  213. X        PrintFiles        : ARRAY [1..50] OF PrintFileRec;
  214. X        Header                : Str255;
  215. X        Footer                : Str255;
  216. X        PgSetUp             : THPrint;                                         {The Page Setup print record}
  217. X        Finished            : Boolean;                                         {Used to tell the application when to quit}
  218. X        Canceled            : Boolean;                                         {Used in DoSelectSet to tell if the user
  219. X                                                                                                    canceled}
  220. X        BRDlogPtr         : DialogPtr;                                     {Used to store the pointer to our BackRound
  221. X                                                                                                    dialog}
  222. X        PrLoop                : Integer;                                         {Used to tell PrintBackround what PrintFile the
  223. X                                                                                                    job is on}
  224. X        TheStRec            : TPrStatus;                                     {Print Status record, made global to access
  225. X                                                                                                    CurBand and CurPage}
  226. X        OldPage             : Integer;                                         {Used to tell PrintBackround the old band number,
  227. X                                                                                                    so we do not draw the PFPUser item every time
  228. X                                                                                                    PrintBackround is called}
  229. X        Pg                        : Integer;                                         {Hold current page number of the PrintFile being
  230. X                                                                                                    printed}
  231. X        FirstItem         : Integer;                                         {The first MP specific item in the Job Dialog}
  232. X        PrDlgItemProc : ProcPtr;                                         {Save the Job Dialogs standard item proc}
  233. X        PrJobPFNum        : Integer;                                         {Save the number of the Print File to add the
  234. X                                                                                                    extra stuff from MPJobDialog}
  235. X
  236. X    PROCEDURE DoSaveSet;
  237. X        FORWARD;
  238. X
  239. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  240. X{Global Procedures and Functions}
  241. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  242. X
  243. X    {******************************************************************************}
  244. X    {Return the result of NumToString as a function result, this routine only
  245. X    works in very limited situations because it will return a pointer to unlinked
  246. X    stack frame}
  247. X    {******************************************************************************}
  248. X
  249. X    FUNCTION NumToStr(Num: LongInt): Str255;
  250. X
  251. X        VAR
  252. X            TempStr             : Str255;
  253. X
  254. X        BEGIN
  255. X            NumToString(Num, TempStr);
  256. X            NumToStr := TempStr;
  257. X        END;
  258. X
  259. X    {******************************************************************************}
  260. X    {Convert a string to a integer}
  261. X    {******************************************************************************}
  262. X
  263. X    FUNCTION StrToNum(Str: Str255): Integer;
  264. X
  265. X        VAR
  266. X            TempNum             : LongInt;
  267. X
  268. X        BEGIN
  269. X            StringToNum(Str, TempNum);
  270. X            StrToNum := TempNum;
  271. X        END;
  272. X
  273. X    {******************************************************************************}
  274. X    {GetItemHandle - Return just the specified items handle}
  275. X    {******************************************************************************}
  276. X
  277. X    FUNCTION GIH(theDialog: DialogPtr; ItemNum: Integer): Handle;
  278. X
  279. X        VAR
  280. X            ItemType            : Integer;
  281. X            Item                    : Handle;
  282. X            Box                     : Rect;
  283. X
  284. X        BEGIN
  285. X            GetDItem(theDialog, ItemNum, ItemType, Item, Box);
  286. X            GIH := Item;
  287. X        END;
  288. X
  289. X    {******************************************************************************}
  290. X    {Erase the main window}
  291. X    {******************************************************************************}
  292. X
  293. X    PROCEDURE EraseWindow;
  294. X
  295. X        VAR
  296. X            SavePort            : GrafPtr;
  297. X
  298. X        BEGIN
  299. X            WITH Write DO
  300. X                BEGIN
  301. X                    GetPort(SavePort);
  302. X                    SetPort(WriteWindow);
  303. X                    EraseRect(WriteWindow^.PortRect);
  304. X                    CurrLine := 1;                                                 {Reset the current line number to top of window}
  305. X                    SetPort(SavePort);
  306. X                END;
  307. X        END;
  308. X
  309. X    {******************************************************************************}
  310. X    {Draw a string in the window}
  311. X    {******************************************************************************}
  312. X
  313. X    PROCEDURE WriteLn(S: Str255);
  314. X
  315. X        VAR
  316. X            SavePort            : GrafPtr;
  317. X
  318. X        BEGIN
  319. X            WITH Write DO
  320. X                BEGIN
  321. X                    GetPort(SavePort);
  322. X                    SetPort(WriteWindow);
  323. X                    IF CurrLine > MaxLine THEN                         {Check to see if we are about to run over board}
  324. X                        BEGIN
  325. X                            MoveTo(2, CurrLine * LineHeight);  {Move to botton of screen}
  326. X                            DrawString('Press mouse button for next screen');
  327. X                            REPEAT                                                         {Wait for button}
  328. X                            UNTIL Button;
  329. X                            EraseWindow;
  330. X                        END;
  331. X                    MoveTo(2, CurrLine * LineHeight);          {Move to current line}
  332. X                    DrawString(S);
  333. X                    WindowCont[CurrLine] := S;                         {Store it for update event}
  334. X                    CurrLine := CurrLine + 1;
  335. X                    SetPort(SavePort);
  336. X                END;
  337. X        END;
  338. X
  339. X    {******************************************************************************}
  340. X    {Interecpt the result codes from IO and PrError. If it is 0 then there was no
  341. X    err, if it is iPrAbort(128) or iPrAbort + 1(129), then either cancel or stop
  342. X    was hit in the Print Backround dialog. Otherwise announce the error number
  343. X    and where it occured in the program.
  344. X    Mess contains a description of the location where the err occured.
  345. X    TheErr contains the result code.
  346. X    Result is true if an error occured}
  347. X    {******************************************************************************}
  348. X
  349. X    FUNCTION IOCheck(TheErr: OSErr; Mess: Str255): Boolean;
  350. X
  351. X        BEGIN
  352. X            {CASE used to expand the ability of intercepting errors}
  353. X            CASE TheErr OF
  354. X                0, iPrAbort:
  355. X                    IOCheck := False;
  356. X                OTHERWISE
  357. X                    BEGIN
  358. X                        WriteLn(Concat('Error #', NumToStr(TheErr), ' occured. Error Loc:', Mess));
  359. X                        IOCheck := True;
  360. X                    END;
  361. X            END;
  362. X        END;
  363. X
  364. X    {******************************************************************************}
  365. X    {Open a file with TheName on a volume with reference number ThevRefNum}
  366. X    {******************************************************************************}
  367. X
  368. X    PROCEDURE OpenFile(TheName: Str255; ThevRefNum: Integer);
  369. X
  370. X        VAR
  371. X            NumBytes            : LongInt;
  372. X            X                         : Integer;
  373. X
  374. X        BEGIN
  375. X            WITH Document DO
  376. X                BEGIN
  377. X                    dName := TheName;                                          {Save the name}
  378. X                    VRefNum := ThevRefNum;                                 {Save the ref num}
  379. X                    Saved := True;                                                 {Mark document clean}
  380. X
  381. X                    {Open the file}
  382. X                    IF IOCheck(FSOpen(dName, VRefNum, FRefNum), 'OpenFile-FSOpen') THEN
  383. X                        EXIT(OpenFile);
  384. X                    {Set the file position to begining of file}
  385. X                    IF IOCheck(SetFPos(FRefNum, FSFromStart, 0), 'OpenFile-SetFPos') THEN
  386. X                        EXIT(OpenFile);
  387. X                    {Get the number of PrintFiles}
  388. X                    NumBytes := 2;
  389. X                    IF IOCheck(FSRead(FRefNum, NumBytes, @NumPF), 'OpenFile-FSRead') THEN
  390. X                        EXIT(OpenFile);
  391. X                    {Get the header}
  392. X                    NumBytes := SizeOf(Header);
  393. X                    IF IOCheck(FSRead(FRefNum, NumBytes, @Header), 'OpenFile-SFRead2') THEN
  394. X                        EXIT(OpenFile);
  395. X                    {Get the footer}
  396. X                    NumBytes := SizeOf(Footer);
  397. X                    IF IOCheck(FSRead(FRefNum, NumBytes, @Footer), 'OpenFile-SFRead3') THEN
  398. X                        EXIT(OpenFile);
  399. X                    {Get the record for each PrintFile}
  400. X                    NumBytes := SizeOf(PrintFileRec) * NumPF;
  401. X                    IF IOCheck(FSRead(FRefNum, NumBytes, @PrintFiles), 'OpenFile-FSRead4') THEN
  402. X                        EXIT(OpenFile);
  403. X                    {Get the job record}
  404. X                    NumBytes := SizeOf(JobRec);
  405. X                    IF IOCheck(FSRead(FRefNum, NumBytes, @CurJob), 'OpenFile-FSRead5') THEN
  406. X                        EXIT(OpenFile);
  407. X                    {Get the page setup record}
  408. X                    NumBytes := SizeOf(TPrint);
  409. X                    IF IOCheck(FSRead(FRefNum, NumBytes, pointer(PgSetUp^)), 'OpenFile-FSRead6') THEN
  410. X                        EXIT(OpenFile);
  411. X                    NumBytes := SizeOf(dName);
  412. X                    {Get the title of the document}
  413. X                    IF IOCheck(FSRead(FRefNum, NumBytes, @dName), 'OpenFile-FSRead5') THEN
  414. X                        EXIT(OpenFile);
  415. X
  416. X                    {Set the menus}
  417. X                    Menus[FileMenu]^^.enableFlags := FMFileIsOpen;
  418. X                    Menus[EditMenu]^^.enableFlags := EMWindActFO;
  419. X
  420. X                    {Set the Window}
  421. X                    SetWTitle(Write.WriteWindow, dName);
  422. X                END;
  423. X        END;
  424. X
  425. X    {******************************************************************************}
  426. X    {Put up save dialog and return item hit}
  427. X    {******************************************************************************}
  428. X
  429. X    FUNCTION AskForSave: Integer;
  430. X
  431. X        VAR
  432. X            SaveDlg             : DialogPtr;
  433. X            ItemHit             : Integer;
  434. X            ItemType            : Integer;
  435. X            Item                    : Handle;
  436. X            Box                     : Rect;
  437. X
  438. X        BEGIN
  439. X            IF NOT Document.Saved THEN                                 {Need to ask user}
  440. X                BEGIN
  441. X                    SaveDlg := GetNewDialog(SaveDlgID, NIL, pointer( - 1));
  442. X                    ParamText(Document.dName, '', '', ''); {Substitute name}
  443. X                    ShowWindow(SaveDlg);
  444. X                    SelectWindow(SaveDlg);
  445. X                    SetPort(SaveDlg);
  446. X                    PenSize(3, 3);
  447. X                    GetDItem(SaveDlg, Ok, ItemType, Item, Box);
  448. X                    InsetRect(Box, - 4, - 4);
  449. X                    FrameRoundRect(Box, 16, 16);
  450. X                    ModalDialog(NIL, ItemHit);
  451. X                    AskForSave := ItemHit;
  452. X                    DisposDialog(SaveDlg);
  453. X                END
  454. X            ELSE
  455. X                AskForSave := No;                                              {Document is saved so no need}
  456. X        END;
  457. X
  458. X    {******************************************************************************}
  459. X    {Put up Get PrintFile Dialog and return the number or 0 if canceled}
  460. X    {******************************************************************************}
  461. X
  462. X    FUNCTION GetFileNum(TheMesg: Str255): Integer;
  463. X
  464. X        VAR
  465. X            DlogPtr             : DialogPtr;
  466. X            Num                     : LongInt;
  467. X            ItemHit             : Integer;
  468. X            NumStr                : Str255;
  469. X            ItemType            : Integer;
  470. X            Item                    : Handle;
  471. X            Box                     : Rect;
  472. X
  473. X        BEGIN
  474. X            DlogPtr := GetNewDialog(PFNDlgID, NIL, pointer( - 1));
  475. X            ParamText(TheMesg, '', '', '');
  476. X            ShowWindow(DlogPtr);
  477. X            SelectWindow(DlogPtr);
  478. X            SetPort(DlogPtr);
  479. X            PenSize(3, 3);
  480. X            GetDItem(DlogPtr, Ok, ItemType, Item, Box);
  481. X            InsetRect(Box, - 4, - 4);
  482. X            FrameRoundRect(Box, 16, 16);
  483. X            ModalDialog(NIL, ItemHit);
  484. X            CASE ItemHit OF
  485. X                Ok:
  486. X                    BEGIN
  487. X                        GetDItem(DlogPtr, 4, ItemType, Item, Box);
  488. X                        GetIText(Item, NumStr);
  489. X                        StringToNum(NumStr, Num);
  490. X                        GetFileNum := Num;
  491. X                    END;
  492. X                Cancel:
  493. X                    GetFileNum := 0;
  494. X            END;
  495. X            DisposDialog(DlogPtr);
  496. X        END;
  497. X
  498. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  499. X{Specialized Procedures and Functions}
  500. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  501. X
  502. X    {******************************************************************************}
  503. X    {Used to add dialog items to an existing dialog. Written in C because it's a
  504. X    heck lot easier}
  505. X    {******************************************************************************}
  506. X
  507. X    FUNCTION AddItems(theDialog: DialogPtr; ResID: Integer): Integer;
  508. X        EXTERNAL;
  509. X
  510. X    {******************************************************************************}
  511. X    {Call the default item proc handler ofr the Job Dialog}
  512. X    {******************************************************************************}
  513. X
  514. X    PROCEDURE CallItemProc(theDialog: DialogPtr; ItemNum: Integer; TheProc: ProcPtr);
  515. X        INLINE $205F, $4E90;                                                 {MOVE (SP)+, A0; JSR (A0)}
  516. X
  517. X    {******************************************************************************}
  518. X    {Draw the user bars in the Backround Dialog}
  519. X    {******************************************************************************}
  520. X
  521. X    PROCEDURE BRDlogDrawItem(TheDlog: DialogPtr; TheItem: Integer);
  522. X
  523. X        VAR
  524. X            ItemType            : Integer;
  525. X            Item                    : Handle;
  526. X            Box                     : Rect;
  527. X            Width                 : Integer;
  528. X            TRect                 : Rect;
  529. X
  530. X        BEGIN
  531. X            GetDItem(BRDlogPtr, TheItem, ItemType, Item, Box);
  532. X            TRect := Box;
  533. X            InsetRect(TRect, - 1, - 1);
  534. X            FrameRect(TRect);                                                  {Draw the frame}
  535. X            IF UIPros[TheItem].Current = 0 THEN
  536. X                EraseRect(Box)                                                     {That's our signal to erase the box}
  537. X            ELSE IF UIPros[TheItem].Total <> 0 THEN      {Avoid divide by zero}
  538. X                BEGIN
  539. X                    Box.Right := Box.Left + Trunc((UIPros[TheItem].Current / UIPros[TheItem].Total) *
  540. X                                                                                (Box.Right - Box.Left));
  541. X                    FillRect(Box, Gray);
  542. X                    MoveTo(Box.Right, Box.Top);
  543. X                    LineTo(Box.Right, Box.Bottom);
  544. X                END;
  545. X        END;
  546. X
  547. X    {******************************************************************************}
  548. X    {Get and process events for the backround dialog, draw the PFPUser bar if we are
  549. X    printing. Note that you can not use modal dialog because that keeps control until
  550. X    an event occurs. We want to return even if nothing happens so we use modeless
  551. X    dialogs}
  552. X    {******************************************************************************}
  553. X
  554. X    PROCEDURE PrintBackround;
  555. X
  556. X        VAR
  557. X            TheEvent            : EventRecord;
  558. X            TheDlog             : DialogPtr;
  559. X            ItemHit             : Integer;
  560. X            LeavePB             : Boolean;
  561. X            SavePort            : GrafPtr;
  562. X            TheErr                : OSErr;
  563. X            Dummy                 : LongInt;
  564. X
  565. X        {****************************************************************************}
  566. X        {Hilite the Resume button and the Pause button accordingly}
  567. X        {****************************************************************************}
  568. X
  569. X        PROCEDURE HiliteButtons(Res, Pus: Integer);
  570. X
  571. X            VAR
  572. X                ItemType            : Integer;
  573. X                Item                    : Handle;
  574. X                Box                     : Rect;
  575. X
  576. X            BEGIN
  577. X                GetDItem(BRDlogPtr, Pause, ItemType, Item, Box);
  578. X                SetDItem(BRDlogPtr, Pause, BtnCtrl + ItemDisable, Item, Box);
  579. X                HiliteControl(ControlHandle(Item), Pus);
  580. X                GetDItem(BRDlogPtr, Resume, ItemType, Item, Box);
  581. X                SetDItem(BRDlogPtr, Resume, BtnCtrl, Item, Box);
  582. X                HiliteControl(ControlHandle(Item), Res);
  583. X            END;
  584. X
  585. X        BEGIN
  586. X            LeavePB := True;                                                     {automatically assume we are going to exit from
  587. X                                                                                                    loop}
  588. X            REPEAT
  589. X                IF GetNextEvent(mDownMask + UpdateMask + ActivMask, TheEvent) & IsDialogEvent(TheEvent) &
  590. X                     DialogSelect(TheEvent, TheDlog, ItemHit) & (TheDlog = BRDlogPtr) THEN {An item was hit}
  591. X                    CASE ItemHit OF
  592. X                        Stop:
  593. X                            BEGIN
  594. X                                LeavePB := True;                                 {Leave loop}
  595. X                                HiliteButtons(255, 0);
  596. X                                WITH CurJob DO
  597. X                                    BEGIN
  598. X                                        InJob := True;
  599. X                                        PFNum := PrLoop;                         {Save current PF number}
  600. X                                        PFPageNum := TheStRec.iCurPage; {Save current page number}
  601. X                                        Document.Saved := False;         {Document is dirty}
  602. X                                    END;
  603. X                                PrSetError(iPrAbort);                      {Set the error}
  604. X                            END;
  605. X                        Pause:
  606. X                            BEGIN
  607. X                                LeavePB := False;                              {We are now in pause so do not leave
  608. X                                                                                                    PrintBackround}
  609. X                                HiliteButtons(0, 255);
  610. X                            END;
  611. X                        Resume:
  612. X                            BEGIN
  613. X                                LeavePB := True;                                 {We are not out of pause so leave PrintBackround}
  614. X                                HiliteButtons(255, 0);
  615. X                            END;
  616. X                        Cancel:
  617. X                            BEGIN
  618. X                                HiliteButtons(255, 0);
  619. X                                LeavePB := True;                                 {leave Print Backround}
  620. X                                CurJob.InJob := False;                     {Turn job off}
  621. X                                PrSetError(iPrAbort);                      {Return cancelation}
  622. X                            END;
  623. X                    END;
  624. X            UNTIL LeavePB;
  625. X
  626. X            {& (OldPage <> TheStRec.iCurPage) is used to avoid unnecassary draws, which takes much time}
  627. X            IF (TheStRec.iCurPage > 0) & (OldPage <> TheStRec.iCurPage) THEN
  628. X                WITH TheStRec DO
  629. X                    BEGIN
  630. X                        UIPros[PFPUser].Total := iTotPages;
  631. X                        UIPros[PFPUser].Current := iCurPage - 1;
  632. X                        GetPort(SavePort);
  633. X                        SetPort(BRDlogPtr);
  634. X                        BRDlogDrawItem(BRDlogPtr, PFPUser);
  635. X                        SetPort(SavePort);
  636. X                        OldPage := iCurPage;
  637. X                    END;
  638. X        END;
  639. X
  640. X    {******************************************************************************}
  641. X    {Handle the items in MPJobDialog}
  642. X    {******************************************************************************}
  643. X
  644. X    PROCEDURE MPJobItemProc(theDialog: DialogPtr; ItemNum: Integer);
  645. X
  646. X        VAR
  647. X            MPItem                : Integer;
  648. X            Hand                    : Handle;
  649. X            TheText             : Str255;
  650. X
  651. X        BEGIN
  652. X            MPItem := ItemNum - FirstItem;
  653. X            IF ItemNum = 1 THEN                                              {Ok was hit so get and save the results}
  654. X                WITH PrintFiles[PrJobPFNum] DO
  655. X                    BEGIN
  656. X                        Hand := GIH(theDialog, DrawBorder + FirstItem);
  657. X                        Border := Boolean(GetCtlValue(ControlHandle(Hand)));
  658. X
  659. X                        Hand := GIH(theDialog, Tab + FirstItem);
  660. X                        GetIText(Hand, TheText);
  661. X                        PFTab := StrToNum(TheText);
  662. X
  663. X                        Hand := GIH(theDialog, PFFont + FirstItem);
  664. X                        GetIText(Hand, TheText);
  665. X                        GetFNum(TheText, PFFontNum);
  666. X
  667. X                        Hand := GIH(theDialog, PFSize + FirstItem);
  668. X                        GetIText(Hand, TheText);
  669. X                        PFPtSize := StrToNum(TheText);
  670. X
  671. X                        Hand := GIH(theDialog, HFFont + FirstItem);
  672. X                        GetIText(Hand, TheText);
  673. X                        GetFNum(TheText, HFFontNum);
  674. X
  675. X                        Hand := GIH(theDialog, HFSize + FirstItem);
  676. X                        GetIText(Hand, TheText);
  677. X                        HFPtSize := StrToNum(TheText);
  678. X
  679. X                        CallItemProc(theDialog, ItemNum, PrDlgItemProc); {Now let the Print Manager do the
  680. X                                                                                                                            same}
  681. X                    END
  682. X            ELSE IF MPItem = 1 THEN                                      {It was our Draw Border item, so toggle value}
  683. X                BEGIN
  684. X                    Hand := GIH(theDialog, DrawBorder + FirstItem);
  685. X                    SetCtlValue(ControlHandle(Hand), 1 - GetCtlValue(ControlHandle(Hand)));
  686. X                END
  687. X            ELSE
  688. X                CallItemProc(theDialog, ItemNum, PrDlgItemProc); {Let the Print Manager handle it}
  689. X        END;
  690. X
  691. X    {******************************************************************************}
  692. X    {Init our Job Dialog}
  693. X    {******************************************************************************}
  694. X
  695. X    FUNCTION MPJobDlgInit(TheHPrint: THPrint): TPPrDlg;
  696. X
  697. X        VAR
  698. X            PrDialog            : TPPrDlg;
  699. X            Item                    : Handle;
  700. X            TheText             : Str255;
  701. X            FirstOffset     : Integer;
  702. X
  703. X        BEGIN
  704. X            PrDialog := PrJobInit(TheHPrint);                  {Let the Print Mananer create the dialog}
  705. X            FirstItem := AddItems(DialogPtr(PrDialog), JobItems); {Now add our items}
  706. X            PrDlgItemProc := PrDialog^.pItemProc;          {Save the Print Manager's item handler proc}
  707. X            PrDialog^.pItemProc := @MPJobItemProc;         {Give it ours}
  708. X
  709. X            {Set up all the fields with our values}
  710. X            WITH PrintFiles[PrJobPFNum] DO
  711. X                BEGIN
  712. X                    Item := GIH(DialogPtr(PrDialog), DrawBorder + FirstItem);
  713. X                    SetCtlValue(ControlHandle(Item), ord(Border));
  714. X
  715. X                    Item := GIH(DialogPtr(PrDialog), Tab + FirstItem);
  716. X                    NumToString(PFTab, TheText);
  717. X                    SetIText(Item, TheText);
  718. X
  719. X                    Item := GIH(DialogPtr(PrDialog), PFFont + FirstItem);
  720. X                    GetFontName(PFFontNum, TheText);
  721. X                    SetIText(Item, TheText);
  722. X
  723. X                    Item := GIH(DialogPtr(PrDialog), PFSize + FirstItem);
  724. X                    NumToString(PFPtSize, TheText);
  725. X                    SetIText(Item, TheText);
  726. X
  727. X                    Item := GIH(DialogPtr(PrDialog), HFFont + FirstItem);
  728. X                    GetFontName(HFFontNum, TheText);
  729. X                    SetIText(Item, TheText);
  730. X
  731. X                    Item := GIH(DialogPtr(PrDialog), HFSize + FirstItem);
  732. X                    NumToString(HFPtSize, TheText);
  733. X                    SetIText(Item, TheText);
  734. X                END;
  735. X            MPJobDlgInit := PrDialog;                                  {Return the Print Managers modified dialog}
  736. X        END;
  737. X
  738. X    {******************************************************************************}
  739. X    {Look for the cancel button}
  740. X    {******************************************************************************}
  741. X
  742. X    FUNCTION MyDlg(Item: Integer; theDialog: DialogPtr): Integer;
  743. X
  744. X        BEGIN
  745. X            IF Item = 11 THEN                                                  {Our item was selected}
  746. X                BEGIN
  747. X                    Canceled := True;                                          {Tell DoSelect files cancel was hit}
  748. X                    MyDlg := getCancel;                                      {Tell standard file to close dialog}
  749. X                END
  750. X            ELSE                                                                             {Do nothing}
  751. X                MyDlg := Item;
  752. X        END;
  753. X
  754. X    {******************************************************************************}
  755. X    {Filter out files already selected, note that you return false to have that file
  756. X    displayed}
  757. X    {******************************************************************************}
  758. X
  759. X    FUNCTION MyFilter(PBlock: ParmBlkPtr): Boolean;
  760. X
  761. X        VAR
  762. X            X                         : Integer;
  763. X
  764. X        BEGIN
  765. X            MyFilter := False;                                                 {Assume it is to be displayed}
  766. X            FOR X := 1 TO NumPF DO
  767. X                IF PrintFiles[X].PFName = PBlock^.ioNamePtr^ THEN {It was already selected}
  768. X                    MyFilter := True;
  769. X        END;
  770. X
  771. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  772. X{Procedure to handle menu commands}
  773. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  774. X
  775. X    {******************************************************************************}
  776. X    {Select PrintFiles}
  777. X    {******************************************************************************}
  778. X
  779. X    PROCEDURE DoSelectSet;
  780. X
  781. X        VAR
  782. X            TopLeft             : Point;
  783. X            Reply                 : SFReply;
  784. X            TheTypes            : SFTypeList;
  785. X            Dummy                 : Boolean;
  786. X            OldNumNames     : Integer;                                     {Save the number of PrintFile's in case of
  787. X                                                                                                    Cancel}
  788. X            TheETABHdl        : ETABHdl;
  789. X            TheMPSRHdl        : MPSRHdl;
  790. X
  791. X        BEGIN
  792. X            Canceled := False;
  793. X            OldNumNames := NumPF;                                          {Save the number of print files in case of
  794. X                                                                                                    cancel}
  795. X
  796. X            TopLeft.h := 90;
  797. X            TopLeft.v := 80;
  798. X            TheTypes[0] := 'TEXT';
  799. X            TheTypes[1] := '????';
  800. X            TheTypes[2] := '????';
  801. X            TheTypes[3] := '????';
  802. X
  803. X            SFPGetFile(TopLeft, '', @MyFilter, 1, TheTypes, @MyDlg, Reply, GPFDlgID, NIL);
  804. X            WHILE Reply.Good AND (NumPF <= 50) DO
  805. X                BEGIN
  806. X                    NumPF := NumPF + 1;
  807. X                    WITH PrintFiles[NumPF] DO
  808. X                        BEGIN
  809. X                            PFName := Reply.fName;                         {Save the name}
  810. X                            PFvRefNum := Reply.VRefNum;              {Save the volume reference number}
  811. X                            IF NOT IOCheck(SetVol(NIL, PFvRefNum), 'DoSelectSet-SetVol') THEN
  812. X                                BEGIN
  813. X                                    IF OpenResFile(PFName) <> -1 THEN
  814. X                                        BEGIN
  815. X                                            TheETABHdl := ETABHdl(GetResource('ETAB', 1004));
  816. X                                            IF TheETABHdl <> NIL THEN
  817. X                                                PFTab := TheETABHdl^^.ETABTab
  818. X                                            ELSE
  819. X                                                BEGIN
  820. X                                                    TheMPSRHdl := MPSRHdl(GetResource('MPSR', 1005));
  821. X                                                    IF TheMPSRHdl <> NIL THEN
  822. X                                                        PFTab := TheMPSRHdl^^.MPSRTab
  823. X                                                    ELSE
  824. X                                                        PFTab := 2;
  825. X                                                END;
  826. X                                        END;
  827. X                                END
  828. X                            ELSE
  829. X                                PFTab := 2;
  830. X                            {Init the Font and Size fields}
  831. X                            PFFontNum := Monaco;
  832. X                            PFPtSize := 9;
  833. X                            HFFontNum := Monaco;
  834. X                            HFPtSize := 9;
  835. X                            Border := False;
  836. X                            PrJobPFNum := NumPF;                             {Let our Job Dialog item handler now the
  837. X                                                                                                    PrintFile we are on}
  838. X                            IF NOT PrDlgMain(PgSetUp, @MPJobDlgInit) THEN {We were canceld}
  839. X                                NumPF := NumPF - 1;
  840. X                            PFJobRec := PgSetUp^^.prJob;             {Save the Job subrecord}
  841. X                        END;
  842. X                    SFPGetFile(TopLeft, '', @MyFilter, 1, TheTypes, @MyDlg, Reply, GPFDlgID, NIL);
  843. X                END;
  844. X            IF Canceled THEN
  845. X                NumPF := OldNumNames                                         {Restore original number of names}
  846. X            ELSE IF NumPF >= 1 THEN                                      {More then one file was indeed selected}
  847. X                BEGIN
  848. X                    {If we are not in a job and we are adding new files then set the job}
  849. X                    {to print out the new files}
  850. X                    WITH CurJob DO
  851. X                        IF (NOT InJob) AND (OldNumNames >= 1) THEN
  852. X                            BEGIN
  853. X                                InJob := True;
  854. X                                PFNum := OldNumNames + 1;
  855. X                                PFPageNum := 1;
  856. X                            END;
  857. X
  858. X                    {Enable and disable items in the File and Edit menus}
  859. X                    Menus[FileMenu]^^.enableFlags := FMSetSelected;
  860. X                    IF FrontWindow = Write.WriteWindow THEN
  861. X                        Menus[EditMenu]^^.enableFlags := EMWindActFO
  862. X                    ELSE
  863. X                        Menus[EditMenu]^^.enableFlags := EMWindDctFO;
  864. X
  865. X                    IF OldNumNames = 0 THEN
  866. X                        Document.dName := 'Untitled';
  867. X                    Document.Saved := False;
  868. X                END;
  869. X        END;
  870. X
  871. X    {******************************************************************************}
  872. X    {Put up Standard File's GetDialog and then call OpenFile to open selected file}
  873. X    {******************************************************************************}
  874. X
  875. X    PROCEDURE DoOpenSet;
  876. X
  877. X        VAR
  878. X            Reply                 : SFReply;
  879. X            Loc                     : Point;
  880. X            TheTypes            : SFTypeList;
  881. X
  882. X        BEGIN
  883. X            Loc.h := 90;
  884. X            Loc.v := 80;
  885. X            TheTypes[0] := 'PRDC';
  886. X            TheTypes[1] := '????';
  887. X            TheTypes[2] := '????';
  888. X            TheTypes[3] := '????';
  889. X            SFGetFile(Loc, '', NIL, 1, TheTypes, NIL, Reply); {Put up the dialog}
  890. X            IF Reply.Good THEN                                                 {Open the file}
  891. X                OpenFile(Reply.fName, Reply.VRefNum);
  892. X        END;
  893. X
  894. X    {******************************************************************************}
  895. X    {Ask the user to save the file and then close it}
  896. X    {******************************************************************************}
  897. X
  898. X    PROCEDURE DoCloseSet;
  899. X
  900. X        VAR
  901. X            SaveReply         : Integer;
  902. X
  903. X        BEGIN
  904. X            SaveReply := AskForSave;
  905. X            IF SaveReply <> MyCancel THEN
  906. X                BEGIN
  907. X                    IF SaveReply = Yes THEN
  908. X                        DoSaveSet;
  909. X                    {Close the document}
  910. X                    IF (Document.FRefNum <> 0) & IOCheck(FSClose(Document.FRefNum),
  911. X                         'DoCloseSet-FSClose') THEN
  912. X                        EXIT(DoCloseSet);
  913. X                    {Flush the volume}
  914. X                    IF IOCheck(FlushVol(NIL, Document.VRefNum), 'DoCloseSet-FlushVol') THEN
  915. X                        EXIT(DoCloseSet);
  916. X                    NumPF := 0;
  917. X                    Document.FRefNum := 0;
  918. X                    Document.Saved := True;
  919. X
  920. X                    {Modify menus}
  921. X                    Menus[FileMenu]^^.enableFlags := FMNoFileOpen;
  922. X                    IF FrontWindow = Write.WriteWindow THEN
  923. X                        Menus[EditMenu]^^.enableFlags := EMWindActNF
  924. X                    ELSE
  925. X                        Menus[EditMenu]^^.enableFlags := EMWindDctNF;
  926. X
  927. X                    {Set window title}
  928. X                    SetWTitle(Write.WriteWindow, 'Multi-Print');
  929. X                END;
  930. X        END;
  931. X
  932. X    {******************************************************************************}
  933. X    {If their is no document then put up Standard File's PutDialog and then
  934. X    save the file}
  935. X    {******************************************************************************}
  936. X
  937. X    PROCEDURE DoSaveSet;
  938. X
  939. X        VAR
  940. X            Loc                     : Point;
  941. X            Reply                 : SFReply;
  942. X            NumBytes            : LongInt;
  943. X            TotBytes            : LongInt;
  944. X
  945. X        BEGIN
  946. X            WITH Document DO
  947. X                BEGIN
  948. X                    IF FRefNum = 0 THEN                                      {We need to create a document}
  949. X                        BEGIN
  950. X                            Loc.h := 90;
  951. X                            Loc.v := 80;
  952. X                            SFPutFile(Loc, '', '', NIL, Reply);
  953. X                            IF Reply.Good THEN                                 {Create a new document}
  954. X                                BEGIN
  955. X                                    {Create the document}
  956. X                                    IF IOCheck(Create(Reply.fName, Reply.VRefNum, 'PRNT', 'PRDC'),
  957. X                                                         'DoSaveSet-Create') THEN
  958. X                                        EXIT(DoSaveSet);
  959. X                                    {Open it and save reference number in FRefNum}
  960. X                                    IF IOCheck(FSOpen(Reply.fName, Reply.VRefNum, FRefNum), 'DoSaveSet-FSOpen') THEN
  961. X                                        EXIT(DoSaveSet);
  962. X                                    {Save the documents name}
  963. X                                    dName := Reply.fName;
  964. X                                    SetWTitle(Write.WriteWindow, dName);
  965. X                                END;
  966. X                        END;
  967. X                    {Set the file position the the begining}
  968. X                    IF IOCheck(SetFPos(FRefNum, FSFromStart, 0), 'DoSaveSet-SetFPos') THEN
  969. X                        EXIT(DoSaveSet);
  970. X                    {Save the number of PrintFiles}
  971. X                    NumBytes := 2;
  972. X                    IF IOCheck(FSWrite(FRefNum, NumBytes, @NumPF), 'DoSaveSet-FSWrite') THEN
  973. X                        EXIT(DoSaveSet);
  974. X                    TotBytes := NumBytes;
  975. X                    {Save the header}
  976. X                    NumBytes := SizeOf(Header);
  977. X                    IF IOCheck(FSWrite(FRefNum, NumBytes, @Header), 'DoSaveSet-FSWrite') THEN
  978. X                        EXIT(DoSaveSet);
  979. X                    TotBytes := TotBytes + NumBytes;
  980. X                    {Save the footer}
  981. X                    NumBytes := SizeOf(Footer);
  982. X                    IF IOCheck(FSWrite(FRefNum, NumBytes, @Footer), 'DoSaveSet-FSWrite') THEN
  983. X                        EXIT(DoSaveSet);
  984. X                    TotBytes := TotBytes + NumBytes;
  985. X                    {Save each PrintFiles record}
  986. X                    NumBytes := SizeOf(PrintFileRec) * NumPF;
  987. X                    IF IOCheck(FSWrite(FRefNum, NumBytes, @PrintFiles), 'DoSaveSet-FSWrite') THEN
  988. X                        EXIT(DoSaveSet);
  989. X                    TotBytes := TotBytes + NumBytes;
  990. X                    {Save job record}
  991. X                    NumBytes := SizeOf(JobRec);
  992. X                    IF IOCheck(FSWrite(FRefNum, NumBytes, @CurJob), 'DoSaveSet-FSWrite') THEN
  993. X                        EXIT(DoSaveSet);
  994. X                    TotBytes := TotBytes + NumBytes;
  995. X                    {Save page setup print record}
  996. X                    NumBytes := SizeOf(TPrint);
  997. X                    IF IOCheck(FSWrite(FRefNum, NumBytes, pointer(PgSetUp^)), 'DoSaveSet-FSWrite') THEN
  998. X                        EXIT(DoSaveSet);
  999. X                    TotBytes := TotBytes + NumBytes;
  1000. X                    {Save document's name}
  1001. X                    NumBytes := SizeOf(dName);
  1002. X                    IF IOCheck(FSWrite(FRefNum, NumBytes, @dName), 'DoSaveSet-FSWrite') THEN
  1003. X                        EXIT(DoSaveSet);
  1004. X                    TotBytes := TotBytes + NumBytes;
  1005. X                    {Set EOF to the end of the document}
  1006. X                    IF IOCheck(SetEOF(FRefNum, TotBytes), 'DoSaveSet-SetEOF') THEN
  1007. X                        EXIT(DoSaveSet);
  1008. X
  1009. X                    Saved := True;                                                 {Mark document as clean}
  1010. X                    {Modify menus}
  1011. X                    Menus[FileMenu]^^.enableFlags := FMFileIsOpen;
  1012. X                    DisableItem(Menus[FileMenu], FMSaveSet);
  1013. X                END;
  1014. X        END;
  1015. X
  1016. X    {******************************************************************************}
  1017. X    {Display the page setup dialog}
  1018. X    {******************************************************************************}
  1019. X
  1020. X    PROCEDURE DoPageSetup;
  1021. X
  1022. X        VAR
  1023. X            Dummy                 : Boolean;
  1024. X
  1025. X        BEGIN
  1026. X            Dummy := PrValidate(PgSetUp);                          {Validate the print record}
  1027. X            IF PrStlDialog(PgSetUp) THEN                             {Put up the style dialog}
  1028. X                BEGIN
  1029. X                    Document.Saved := False;                             {Document is now dirty}
  1030. X                    EnableItem(Menus[FileMenu], FMSaveSet); {Enable save}
  1031. X                END;
  1032. X        END;
  1033. X
  1034. X    {******************************************************************************}
  1035. X    {Print out each PrintFile}
  1036. X    {******************************************************************************}
  1037. X
  1038. X    PROCEDURE DoPrint;
  1039. X
  1040. X        LABEL 0001;
  1041. X
  1042. X        CONST
  1043. X            Indent                 = 20;
  1044. X
  1045. X        VAR
  1046. X            DlogPtr             : DialogPtr;                                 {Hold a pointer to our ContinuePrintJob dialog}
  1047. X            Done                    : Boolean;                                     {True when nothing left to print}
  1048. X            Date                    : DateTimeRec;                             {Hold the date}
  1049. X            MyETABHdl         : ETABHdl;                                     {Hold the handle to Edit's format resource}
  1050. X            ItemHit             : Integer;                                     {Hold the item hit}
  1051. X            CurrentLine     : Integer;                                     {Hold current line number in page}
  1052. X            NumLines            : Integer;                                     {Hold total number of lines in page}
  1053. X            PFBaseLine        : Integer;                                     {Height of Print File text}
  1054. X            HFBaseLine        : Integer;                                     {Height of Header/Footer text}
  1055. X            NumSpacesInTab: Integer;                                     {Number of spaces in the tab}
  1056. X            X                         : Integer;                                     {General counter}
  1057. X            X2                        : Integer;                                     {General counter}
  1058. X            Index                 : Integer;                                     {General counter}
  1059. X            Secs                    : LongInt;                                     {Hold number of ticks}
  1060. X            TheLine             : Str255;                                      {Hold the current line text}
  1061. X            HeaderStr         : Str255;                                      {Hold the header text}
  1062. X            FooterStr         : Str255;                                      {Hold the footer text}
  1063. X            TimeStr             : Str255;                                      {Hold the time}
  1064. X            DateStr             : Str255;                                      {Hold the date}
  1065. X            SpaceStr            : Str255;                                      {Hold the spaces that make up a tab}
  1066. X            ThePrPort         : TPPrPort;                                  {The print port}
  1067. X            F                         : Text;                                          {The file's text}
  1068. X            ItemType            : Integer;
  1069. X            Item                    : Handle;
  1070. X            Box                     : Rect;
  1071. X            Dummy                 : Integer;
  1072. X            SavePort            : GrafPtr;
  1073. X            PErr                    : OSErr;
  1074. X            FrameRect         : Rect;                                          {Holds the Print Managers graf port's portrect}
  1075. X            MPFontInfo        : FontInfo;                                  {Hold the font information}
  1076. X            LineStart         : Integer;                                     {Hold the pixel position from the top of the
  1077. X                                                                                                    screen to start printing the lines of the page}
  1078. X            HeaderIndent    : Integer;                                     {Pixel indent for header, held to constant for
  1079. X                                                                                                    each printfile so header will not move around
  1080. X                                                                                                    and page number increases}
  1081. X            FooterIndent    : Integer;                                     {Same^}
  1082. X
  1083. X            {****************************************************************************}
  1084. X            {ReplaceWhat WithWhat in TheStr}
  1085. X            {****************************************************************************}
  1086. X
  1087. X        FUNCTION ReplaceSubStr(TheStr, ReplaceWhat, WithWhat: Str255): Str255;
  1088. X
  1089. X            VAR
  1090. X                Position            : Integer;
  1091. X
  1092. X            BEGIN
  1093. X                Position := Pos(ReplaceWhat, TheStr);
  1094. X                IF Position <> 0 THEN
  1095. X                    BEGIN
  1096. X                        Delete(TheStr, Position, Length(ReplaceWhat));
  1097. X                        Insert(WithWhat, TheStr, Position);
  1098. X                    END;
  1099. X                ReplaceSubStr := TheStr;
  1100. X            END;
  1101. X
  1102. X        BEGIN
  1103. X            {Verify the user wants to continue with job. If so then leave the job}
  1104. X            {Alone, if the user does not want to continue or we are not in a job}
  1105. X            {then reset PF and PFPageNum to 1}
  1106. X            WITH CurJob DO
  1107. X                IF InJob THEN
  1108. X                    BEGIN
  1109. X                        DlogPtr := GetNewDialog(CPrintDlgID, NIL, pointer( - 1));
  1110. X                        SetPort(DlogPtr);
  1111. X                        PenSize(3, 3);
  1112. X                        GetDItem(DlogPtr, Ok, ItemType, Item, Box);
  1113. X                        InsetRect(Box, - 4, - 4);
  1114. X                        FrameRoundRect(Box, 16, 16);
  1115. X                        ModalDialog(NIL, ItemHit);
  1116. X                        IF ItemHit <> 1 THEN
  1117. X                            BEGIN
  1118. X                                InJob := False;
  1119. X                                PFPageNum := 1;
  1120. X                                PFNum := 1;
  1121. X                            END;
  1122. X                        DisposDialog(DlogPtr);
  1123. X                    END
  1124. X                ELSE
  1125. X                    BEGIN
  1126. X                        PFPageNum := 1;
  1127. X                        PFNum := 1;
  1128. X                    END;
  1129. X
  1130. X            {Set up the PrintBackround dialog}
  1131. X            BRDlogPtr := GetNewDialog(PBRDlgID, NIL, pointer( - 1));
  1132. X            FOR X := TotUser TO PFPUser DO
  1133. X                BEGIN
  1134. X                    {Insert our draw proc}
  1135. X                    GetDItem(BRDlogPtr, X, ItemType, Item, Box);
  1136. X                    SetDItem(BRDlogPtr, X, ItemType, Handle(@BRDlogDrawItem), Box);
  1137. X                    {Reset UIPros}
  1138. X                    UIPros[X].Total := 1;
  1139. X                    UIPros[X].Current := 0;
  1140. X                END;
  1141. X
  1142. X            {Dim Resume}
  1143. X            GetDItem(BRDlogPtr, Resume, ItemType, Item, Box);
  1144. X            SetDItem(BRDlogPtr, Resume, ItemType + ItemDisable, Item, Box);
  1145. X            HiliteControl(ControlHandle(Item), 255);
  1146. X
  1147. X            {Insert our text}
  1148. X            ParamText(Document.dName, PrintFiles[CurJob.PFNum].PFName, '', '');
  1149. X            ShowWindow(BRDlogPtr);
  1150. X            SelectWindow(BRDlogPtr);                                     {Bring up our window}
  1151. X            PrintBackround;                                                      {Handle deactive for WriteWindow}
  1152. X            PrintBackround;                                                      {Handle Active for BRDlogPtr}
  1153. X            PrintBackround;                                                      {Handle Update for BRDlogPtr}
  1154. X
  1155. X            {One Time Initialization}
  1156. X            GetDateTime(Secs);
  1157. X            Secs2Date(Secs, Date);
  1158. X            DateStr := Concat(NumToStr(Date.Month), '/', NumToStr(Date.day), '/', NumToStr(Date.year -
  1159. X                                                1900));
  1160. X            TimeStr := Concat(NumToStr(Date.hour), ':', NumToStr(Date.minute), ':',
  1161. X                                                NumToStr(Date.second));
  1162. X            UIPros[TotUser].Total := NumPF;
  1163. X
  1164. X            {Go through each PrintFile}
  1165. X            FOR X := CurJob.PFNum TO NumPF DO
  1166. X                WITH PrintFiles[X] DO
  1167. X                    BEGIN
  1168. X                        IF PrValidate(PgSetUp) THEN;
  1169. X                        PgSetUp^^.prJob := PFJobRec;                 {Give PgSetup our job subrecord}
  1170. X                        PrLoop := X;                                                 {Save the number of the PrintFile we are on}
  1171. X                        TheStRec.iCurPage := 0;                          {Tell PrintBackround we are not printing yet}
  1172. X
  1173. X                        {Get the length of the PrintFile}
  1174. X                        IF IOCheck(FSOpen(PFName, PFvRefNum, Dummy), 'DoPrint-FSOpen') THEN
  1175. X                            GOTO 0001;
  1176. X                        IF IOCheck(GetEOF(Dummy, UIPros[SPFUser].Total), 'DoPrint-GetEOF') THEN
  1177. X                            GOTO 0001;
  1178. X                        IF IOCheck(FSClose(Dummy), 'DoPrint-FSClose') THEN
  1179. X                            GOTO 0001;
  1180. X
  1181. X                        ParamText(Document.dName, PFName, '', '');
  1182. X
  1183. X                        {Reset the user items}
  1184. X                        GetPort(SavePort);
  1185. X                        SetPort(BRDlogPtr);
  1186. X                        FOR X2 := SPFUser TO PFPUser DO
  1187. X                            UIPros[X2].Current := 0;
  1188. X                        FOR X2 := TotUser TO PFPUser DO
  1189. X                            BEGIN
  1190. X                                GetDItem(BRDlogPtr, X2, ItemType, Item, Box);
  1191. X                                InvalRect(Box);
  1192. X                            END;
  1193. X                        SetPort(SavePort);
  1194. X
  1195. X                        PrintBackround;
  1196. X
  1197. X                        IF PFTab = 0 THEN
  1198. X                            NumSpacesInTab := 2
  1199. X                        ELSE
  1200. X                            NumSpacesInTab := PFTab;
  1201. X
  1202. X                        {Generate the space string to handle tabs}
  1203. X                        SpaceStr := '';
  1204. X                        FOR X2 := 1 TO NumSpacesInTab DO
  1205. X                            SpaceStr := Concat(SpaceStr, ' ');
  1206. X
  1207. X                        IF X = CurJob.PFNum THEN
  1208. X                            BEGIN
  1209. X                                PgSetUp^^.prJob.iFstPage := CurJob.PFPageNum;
  1210. X                                PgSetUp^^.prJob.iLstPage := MAXINT;
  1211. X                            END;
  1212. X
  1213. X                        ThePrPort := PrOpenDoc(PgSetUp, NIL, NIL);
  1214. X                        IF IOCheck(PrError, 'DoPrint-PROpenDoc') THEN
  1215. X                            GOTO 0001;
  1216. X
  1217. X                        Open(F, PFName);
  1218. X                        Reset(F);
  1219. X                        Pg := CurJob.PFPageNum;
  1220. X                        Done := False;
  1221. X                        REPEAT
  1222. X                            PrOpenPage(ThePrPort, NIL);              {Open a new page}
  1223. X                            IF IOCheck(PrError, 'DoPrint-PrOpenPage') THEN
  1224. X                                BEGIN
  1225. X                                    Close(F);
  1226. X                                    GOTO 0001;
  1227. X                                END;
  1228. X
  1229. X {you MDS Edit user's might have experianced it's little
  1230. X problem of printing only half the page, well I think found it's
  1231. X problem. It was getting the size of the page from the gPort's portRect
  1232. X before it called PrOpenPage. Judging from this next hack any guesses on
  1233. X how I figured it out?}
  1234. X                            IF Pg = CurJob.PFPageNum THEN
  1235. X                                BEGIN
  1236. X                                    FrameRect := ThePrPort^.gPort.PortRect;
  1237. X
  1238. X                                    TextFont(PFFontNum);
  1239. X                                    TextSize(PFPtSize);
  1240. X                                    TextFace([]);
  1241. X                                    GetFontInfo(MPFontInfo);
  1242. X                                    WITH MPFontInfo DO
  1243. X                                        PFBaseLine := Ascent + Descent + Leading;
  1244. X
  1245. X                                    TextFont(HFFontNum);
  1246. X                                    TextSize(HFPtSize);
  1247. X                                    TextFace([Bold]);
  1248. X                                    WITH MPFontInfo DO
  1249. X                                        HFBaseLine := Ascent + Descent + Leading;
  1250. X
  1251. X                                    WITH FrameRect DO
  1252. X                                        BEGIN
  1253. X                                            IF Header <> '' THEN
  1254. X                                                LineStart := Top + 6 + HFBaseLine
  1255. X                                            ELSE
  1256. X                                                LineStart := Top;
  1257. X                                            Left := Left + Indent - 4;
  1258. X                                            IF Footer <> '' THEN
  1259. X                                                BEGIN
  1260. X                                                    Bottom := Bottom - HFBaseLine - 6;
  1261. X                                                    NumLines := (Bottom - 3 - LineStart) DIV PFBaseLine;
  1262. X                                                END
  1263. X                                            ELSE
  1264. X                                                NumLines := (Bottom - LineStart) DIV PFBaseLine;
  1265. X                                        END;
  1266. X                                    {Get the indent here so that the header and footer do not
  1267. X                                    change position as the page number increases}
  1268. X                                    HeaderStr := Header;
  1269. X                                    HeaderStr := ReplaceSubStr(HeaderStr, '(NAME)', PFName);
  1270. X                                    HeaderStr := ReplaceSubStr(HeaderStr, '(DATE)', DateStr);
  1271. X                                    HeaderStr := ReplaceSubStr(HeaderStr, '(TIME)', TimeStr);
  1272. X                                    HeaderStr := ReplaceSubStr(HeaderStr, '(PAGE)', NumToStr(Pg));
  1273. X                                    HeaderStr := ReplaceSubStr(HeaderStr, '(SET)', Document.dName);
  1274. X                                    HeaderIndent := (FrameRect.Right - FrameRect.Left - StringWidth(HeaderStr)) DIV
  1275. X                                                                    2 + FrameRect.Left;
  1276. X
  1277. X                                    FooterStr := Footer;
  1278. X                                    FooterStr := ReplaceSubStr(FooterStr, '(NAME)', PFName);
  1279. X                                    FooterStr := ReplaceSubStr(FooterStr, '(DATE)', DateStr);
  1280. X                                    FooterStr := ReplaceSubStr(FooterStr, '(TIME)', TimeStr);
  1281. X                                    FooterStr := ReplaceSubStr(FooterStr, '(PAGE)', NumToStr(Pg));
  1282. X                                    FooterStr := ReplaceSubStr(FooterStr, '(SET)', Document.dName);
  1283. X                                    FooterIndent := (FrameRect.Right - FrameRect.Left - StringWidth(FooterStr)) DIV
  1284. X                                                                    2 + FrameRect.Left;
  1285. X                                END;
  1286. X                            {Get and draw Header}
  1287. X                            HeaderStr := Header;
  1288. X                            HeaderStr := ReplaceSubStr(HeaderStr, '(NAME)', PFName);
  1289. X                            HeaderStr := ReplaceSubStr(HeaderStr, '(DATE)', DateStr);
  1290. X                            HeaderStr := ReplaceSubStr(HeaderStr, '(TIME)', TimeStr);
  1291. X                            HeaderStr := ReplaceSubStr(HeaderStr, '(PAGE)', NumToStr(Pg));
  1292. X                            HeaderStr := ReplaceSubStr(HeaderStr, '(SET)', Document.dName);
  1293. X                            MoveTo(HeaderIndent, HFBaseLine + 3);
  1294. X                            TextFace([Bold]);
  1295. X                            TextFont(HFFontNum);
  1296. X                            TextSize(HFPtSize);
  1297. X                            DrawString(HeaderStr);
  1298. X                            TextFace([]);
  1299. X
  1300. X                            IF Border THEN                                         {Draw a border}
  1301. X                                WITH FrameRect DO
  1302. X                                    BEGIN
  1303. X                                        FrameRoundRect(FrameRect, 20, 20);
  1304. X                                        IF Header <> '' THEN
  1305. X                                            BEGIN
  1306. X                                                MoveTo(Left, LineStart);
  1307. X                                                LineTo(Right, LineStart);
  1308. X                                            END;
  1309. X                                    END;
  1310. X
  1311. X                            TextFont(PFFontNum);
  1312. X                            TextSize(PFPtSize);
  1313. X                            {Draw lines of page}
  1314. X                            FOR CurrentLine := 1 TO NumLines DO
  1315. X                                BEGIN
  1316. X                                    readln(F, TheLine);
  1317. X
  1318. X                                    {Add the number of bytes processed so far and display it}
  1319. X                                    UIPros[SPFUser].Current := UIPros[SPFUser].Current + Length(TheLine);
  1320. X                                    GetPort(SavePort);
  1321. X                                    SetPort(BRDlogPtr);
  1322. X                                    BRDlogDrawItem(BRDlogPtr, SPFUser);
  1323. X                                    SetPort(SavePort);
  1324. X                                    PrintBackround;
  1325. X
  1326. X                                    IF PrError = iPrAbort THEN
  1327. X                                        BEGIN
  1328. X                                            Close(F);
  1329. X                                            GOTO 0001;
  1330. X                                        END;
  1331. X
  1332. X                                    MoveTo(Indent, CurrentLine * (PFBaseLine) + LineStart);
  1333. X                                    FOR Index := 1 TO Length(TheLine) DO
  1334. X                                        IF TheLine[Index] = CHR(9) THEN
  1335. X                                            DrawString(SpaceStr)
  1336. X                                        ELSE
  1337. X                                            DrawChar(TheLine[Index]);
  1338. X
  1339. X                                    IF EOF(F) THEN                                 {We are done}
  1340. X                                        BEGIN
  1341. X                                            Done := True;
  1342. X                                            LEAVE;
  1343. X                                        END;
  1344. X                                END;
  1345. X
  1346. X                            {Get and draw Footer}
  1347. X                            FooterStr := Footer;
  1348. X                            FooterStr := ReplaceSubStr(FooterStr, '(NAME)', PFName);
  1349. X                            FooterStr := ReplaceSubStr(FooterStr, '(DATE)', DateStr);
  1350. X                            FooterStr := ReplaceSubStr(FooterStr, '(TIME)', TimeStr);
  1351. X                            FooterStr := ReplaceSubStr(FooterStr, '(PAGE)', NumToStr(Pg));
  1352. X                            FooterStr := ReplaceSubStr(FooterStr, '(SET)', Document.dName);
  1353. X                            MoveTo(FooterIndent, FrameRect.Bottom + HFBaseLine + 3);
  1354. X                            TextFace([Bold]);
  1355. X                            TextFont(HFFontNum);
  1356. X                            TextSize(HFPtSize);
  1357. X                            DrawString(FooterStr);
  1358. X                            TextFace([]);
  1359. X
  1360. X                            Pg := Pg + 1;
  1361. X
  1362. X                            PrClosePage(ThePrPort);                      {Close this page}
  1363. X                            IF IOCheck(PrError, 'DoPrint-PrClosePage') THEN
  1364. X                                BEGIN
  1365. X                                    Close(F);
  1366. X                                    GOTO 0001;
  1367. X                                END;
  1368. X                        UNTIL Done;
  1369. X
  1370. X                        Close(F);                                                      {Close the file}
  1371. X                        PrCloseDoc(ThePrPort);                             {Close the print document}
  1372. X                        IF IOCheck(PrError, 'DoPrint-PrCloseDoc') THEN
  1373. X                            GOTO 0001;
  1374. X
  1375. X                        {Display a solid bar}
  1376. X                        UIPros[SPFUser].Current := UIPros[SPFUser].Total;
  1377. X                        GetPort(SavePort);
  1378. X                        SetPort(BRDlogPtr);
  1379. X                        BRDlogDrawItem(BRDlogPtr, SPFUser);
  1380. X                        SetPort(SavePort);
  1381. X
  1382. X                        {If we spooled then print it}
  1383. X                        IF (PgSetUp^^.prJob.bjDocLoop = bSpoolLoop) AND (PrError = noErr) THEN
  1384. X                            BEGIN
  1385. X                                PgSetUp^^.prJob.pIdleProc := @PrintBackround;
  1386. X
  1387. X                                IF X = CurJob.PFNum THEN
  1388. X                                    BEGIN
  1389. X                                        PgSetUp^^.prJob.iFstPage := CurJob.PFPageNum;
  1390. X                                        PgSetUp^^.prJob.iLstPage := MAXINT;
  1391. X                                    END;
  1392. X
  1393. X                                OldPage := - 1;
  1394. X                                PrPicFile(PgSetUp, NIL, NIL, NIL, TheStRec);
  1395. X                                IF PrError = iPrAbort THEN
  1396. X                                    GOTO 0001;
  1397. X                            END;
  1398. X
  1399. X                        {Display solid bar}
  1400. X                        UIPros[TotUser].Current := X;
  1401. X                        UIPros[PFPUser].Current := UIPros[PFPUser].Total;
  1402. X                        GetPort(SavePort);
  1403. X                        SetPort(BRDlogPtr);
  1404. X                        BRDlogDrawItem(BRDlogPtr, PFPUser);
  1405. X                        SetPort(SavePort);
  1406. X
  1407. X                        IF IOCheck(PrError, 'After printing') THEN
  1408. X                            LEAVE;
  1409. X                    END;
  1410. X
  1411. X        0001:
  1412. X            {Display solid bar}
  1413. X            UIPros[TotUser].Current := UIPros[TotUser].Total;
  1414. X            GetPort(SavePort);
  1415. X            SetPort(BRDlogPtr);
  1416. X            GetDItem(BRDlogPtr, TotUser, ItemType, Item, Box);
  1417. X            BRDlogDrawItem(BRDlogPtr, TotUser);
  1418. X            SetPort(SavePort);
  1419. X            FOR X := 1 TO 1000 DO;
  1420. X            DisposDialog(BRDlogPtr);
  1421. X        END;
  1422. X
  1423. X    {******************************************************************************}
  1424. X    {Display all PrintFiles}
  1425. X    {******************************************************************************}
  1426. X
  1427. X    PROCEDURE DoDisplay;
  1428. X
  1429. X        VAR
  1430. X            X                         : Integer;
  1431. X
  1432. X        BEGIN
  1433. X            EraseWindow;
  1434. X            FOR X := 1 TO NumPF DO
  1435. X                WriteLn(Concat(NumToStr(X), ': ', PrintFiles[X].PFName));
  1436. X        END;
  1437. X
  1438. X    {******************************************************************************}
  1439. X    {Remove a PrintFile}
  1440. X    {******************************************************************************}
  1441. X
  1442. X    PROCEDURE DoDeleteFile;
  1443. X
  1444. X        VAR
  1445. X            Num                     : Integer;
  1446. X            X                         : Integer;
  1447. X
  1448. X        BEGIN
  1449. X            Num := GetFileNum('Delete');
  1450. X            IF (Num > 0) AND (Num <= NumPF) THEN
  1451. X                BEGIN
  1452. X                    IF Num < NumPF THEN
  1453. X                        FOR X := Num TO NumPF - 1 DO
  1454. X                            PrintFiles[X] := PrintFiles[X + 1];
  1455. X                    NumPF := NumPF - 1;
  1456. X                    Document.Saved := False;
  1457. X                    EnableItem(Menus[FileMenu], FMSaveSet);
  1458. X                END;
  1459. X        END;
  1460. X
  1461. X    {******************************************************************************}
  1462. X    {Get the PrintFile to change and put up the Print Managers JobDialog}
  1463. X    {******************************************************************************}
  1464. X
  1465. X    PROCEDURE DoChangeFile;
  1466. X
  1467. X        VAR
  1468. X            Num                     : Integer;
  1469. X            Dummy                 : Boolean;
  1470. X
  1471. X        BEGIN
  1472. X            Num := GetFileNum('Change');
  1473. X            IF ((Num > 0) AND (Num <= NumPF)) THEN
  1474. X                BEGIN
  1475. X                    Dummy := PrValidate(PgSetUp);
  1476. X                    PgSetUp^^.prJob := PrintFiles[Num].PFJobRec;
  1477. X                    PrJobPFNum := Num;
  1478. X                    IF PrDlgMain(PgSetUp, @MPJobDlgInit) THEN
  1479. X                        BEGIN
  1480. X                            Document.Saved := False;
  1481. X                            EnableItem(Menus[FileMenu], FMSaveSet);
  1482. X                        END;
  1483. X                END;
  1484. X        END;
  1485. X
  1486. X    {******************************************************************************}
  1487. X    {Display the header dialog}
  1488. X    {******************************************************************************}
  1489. X
  1490. X    PROCEDURE DoHeader;
  1491. X
  1492. X        VAR
  1493. X            HeaderDlog        : DialogPtr;
  1494. X            ItemHit             : Integer;
  1495. X            ItemType            : Integer;
  1496. X            Item                    : Handle;
  1497. X            Box                     : Rect;
  1498. X
  1499. X        BEGIN
  1500. X            HeaderDlog := GetNewDialog(HFDlgID, NIL, pointer( - 1));
  1501. X            SetPort(HeaderDlog);
  1502. X            GetDItem(HeaderDlog, 3, ItemType, Item, Box);
  1503. X            SetIText(Item, Header);
  1504. X            PenSize(3, 3);
  1505. X            GetDItem(HeaderDlog, Ok, ItemType, Item, Box);
  1506. X            InsetRect(Box, - 4, - 4);
  1507. X            FrameRoundRect(Box, 16, 16);
  1508. X            ModalDialog(NIL, ItemHit);
  1509. X            IF ItemHit = 1 THEN
  1510. X                BEGIN
  1511. X                    GetDItem(HeaderDlog, 3, ItemType, Item, Box);
  1512. X                    GetIText(Item, Header);
  1513. X                    Document.Saved := False;                             {Document is now dirty}
  1514. X                    EnableItem(Menus[FileMenu], FMSaveSet); {Enable save}
  1515. X                END;
  1516. X            DisposDialog(HeaderDlog);
  1517. X        END;
  1518. X
  1519. X    {******************************************************************************}
  1520. X    {Display the footer dialog}
  1521. X    {******************************************************************************}
  1522. X
  1523. X    PROCEDURE DoFooter;
  1524. X
  1525. X        VAR
  1526. X            FooterDlog        : DialogPtr;
  1527. X            ItemHit             : Integer;
  1528. X            ItemType            : Integer;
  1529. X            Item                    : Handle;
  1530. X            Box                     : Rect;
  1531. X
  1532. X        BEGIN
  1533. X            FooterDlog := GetNewDialog(HFDlgID, NIL, pointer( - 1));
  1534. X            SetPort(FooterDlog);
  1535. X            GetDItem(FooterDlog, 3, ItemType, Item, Box);
  1536. X            SetIText(Item, Footer);
  1537. X            PenSize(3, 3);
  1538. X            GetDItem(FooterDlog, Ok, ItemType, Item, Box);
  1539. X            InsetRect(Box, - 4, - 4);
  1540. X            FrameRoundRect(Box, 16, 16);
  1541. X            ModalDialog(NIL, ItemHit);
  1542. X            IF ItemHit = 1 THEN
  1543. X                BEGIN
  1544. X                    GetDItem(FooterDlog, 3, ItemType, Item, Box);
  1545. X                    GetIText(Item, Footer);
  1546. X                    Document.Saved := False;                             {Document is now dirty}
  1547. X                    EnableItem(Menus[FileMenu], FMSaveSet); {Enable save}
  1548. X                END;
  1549. X            DisposDialog(FooterDlog);
  1550. X        END;
  1551. X
  1552. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  1553. X{Application specific procedures and Functions}
  1554. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  1555. X
  1556. X    {******************************************************************************}
  1557. X    {Choose the appropriate procedure to carry of menu item selection}
  1558. X    {******************************************************************************}
  1559. X
  1560. X    PROCEDURE ProcessMenu(CodeWord: LongInt);
  1561. X
  1562. X        VAR
  1563. X            MenuNum             : Integer;
  1564. X            ItemNum             : Integer;
  1565. X            DAName                : Str255;
  1566. X            Dummy                 : Integer;
  1567. X            AboutDlog         : DialogPtr;
  1568. X            SaveReply         : Integer;
  1569. X
  1570. X        BEGIN
  1571. X            MenuNum := HiWord(CodeWord);
  1572. X            ItemNum := LoWord(CodeWord);
  1573. X            CASE MenuNum OF
  1574. X                AppleMenu:
  1575. X                    IF ItemNum = AMAbout THEN
  1576. X                        BEGIN
  1577. X                            AboutDlog := GetNewDialog(AboutDlgID, NIL, pointer( - 1));
  1578. X                            ModalDialog(NIL, Dummy);
  1579. X                            CloseDialog(AboutDlog);
  1580. X                        END
  1581. X                    ELSE
  1582. X                        BEGIN
  1583. X                            GetItem(Menus[AppleMenu], ItemNum, DAName);
  1584. X                            Dummy := OpenDeskAcc(DAName);
  1585. X                        END;
  1586. X                FileMenu:
  1587. X                    CASE ItemNum OF
  1588. X                        FMSelectSet:
  1589. X                            DoSelectSet;
  1590. X                        FMOpenSet:
  1591. X                            DoOpenSet;
  1592. X                        FMCloseSet:
  1593. X                            DoCloseSet;
  1594. X                        FMSaveSet:
  1595. X                            DoSaveSet;
  1596. X                        FMPageSetUp:
  1597. X                            DoPageSetup;
  1598. X                        FMPrint:
  1599. X                            DoPrint;
  1600. X                        FMQuit:
  1601. X                            BEGIN
  1602. X                                SaveReply := AskForSave;
  1603. X                                IF SaveReply <> MyCancel THEN
  1604. X                                    BEGIN
  1605. X                                        IF SaveReply = Yes THEN
  1606. X                                            DoSaveSet;
  1607. X                                        IF (Document.FRefNum <> 0) & IOCheck(FSClose(Document.FRefNum),
  1608. X                                                                                                                 'Close-FSClose') THEN
  1609. X                                            WriteLn('Could not close document correctly.');
  1610. X                                        IF IOCheck(FlushVol(NIL, Document.VRefNum), 'Close-FlushVol') THEN
  1611. X                                            WriteLn('Could not flush volume.');
  1612. X                                        Finished := True;
  1613. X                                    END;
  1614. X                            END;
  1615. X                    END;
  1616. X                EditMenu:
  1617. X                    CASE ItemNum OF
  1618. X                        1..6:
  1619. X                            IF NOT SystemEdit(ItemNum - 1) THEN;
  1620. X                        EMDisplaySet:
  1621. X                            DoDisplay;
  1622. X                        EMAddFile:
  1623. X                            DoSelectSet;
  1624. X                        EMDeleteFile:
  1625. X                            DoDeleteFile;
  1626. X                        EMChangeFile:
  1627. X                            DoChangeFile;
  1628. X                        EMHeader:
  1629. X                            DoHeader;
  1630. X                        EMFooter:
  1631. X                            DoFooter;
  1632. X                    END;
  1633. X            END;
  1634. X            HiliteMenu(0);
  1635. X        END;
  1636. X
  1637. X    {******************************************************************************}
  1638. X    {Get and processes events}
  1639. X    {******************************************************************************}
  1640. X
  1641. X    PROCEDURE MainEventLoop;
  1642. X
  1643. X        TYPE
  1644. X            TrickType          = PACKED RECORD
  1645. X                CASE Boolean OF
  1646. X                    True:
  1647. X                        (I                         : LongInt);
  1648. X                    False:
  1649. X                        (chr3, chr2, chr1, chr0: Char);
  1650. X                END;
  1651. X
  1652. X        VAR
  1653. X            Event                 : EventRecord;
  1654. X            WindowLoc         : Integer;
  1655. X            MouseLoc            : Point;
  1656. X            TheWindow         : WindowPtr;
  1657. X            TrickVar            : TrickType;
  1658. X            CharCode            : Char;
  1659. X            X                         : Integer;
  1660. X            SavePort            : GrafPtr;
  1661. X
  1662. X        BEGIN
  1663. X            REPEAT
  1664. X                SystemTask;
  1665. X                IF GetNextEvent(everyEvent, Event) THEN
  1666. X                    CASE Event.what OF
  1667. X                        mouseDown:
  1668. X                            BEGIN
  1669. X                                MouseLoc := Event.where;
  1670. X                                WindowLoc := FindWindow(MouseLoc, TheWindow);
  1671. X                                CASE WindowLoc OF
  1672. X                                    inMenuBar:
  1673. X                                        ProcessMenu(MenuSelect(MouseLoc));
  1674. X                                    inSysWindow:
  1675. X                                        SystemClick(Event, TheWindow);
  1676. X                                    inContent, inDrag:
  1677. X                                        IF Write.WriteWindow = TheWindow THEN
  1678. X                                            SelectWindow(TheWindow);
  1679. X                                END;
  1680. X                            END;
  1681. X                        keyDown, AutoKey:
  1682. X                            BEGIN
  1683. X                                TrickVar.I := Event.Message;
  1684. X                                CharCode := TrickVar.chr0;
  1685. X                                IF BitAnd(Event.modifiers, CmdKey) = CmdKey THEN
  1686. X                                    ProcessMenu(MenuKey(CharCode));
  1687. X                            END;
  1688. X                        UpdateEvt:
  1689. X                            IF WindowPtr(Event.Message) = Write.WriteWindow THEN
  1690. X                                WITH Write DO
  1691. X                                    BEGIN
  1692. X                                        GetPort(SavePort);
  1693. X                                        SetPort(WriteWindow);
  1694. X                                        BeginUpdate(WriteWindow);
  1695. X                                        FOR X := 1 TO CurrLine - 1 DO
  1696. X                                            BEGIN
  1697. X                                                MoveTo(2, X * LineHeight);
  1698. X                                                DrawString(WindowCont[X]);
  1699. X                                            END;
  1700. X                                        EndUpdate(WriteWindow);
  1701. X                                        SetPort(SavePort);
  1702. X                                    END;
  1703. X                        ActivateEvt:                                                 {Don't worry about this bit of monstrosity}
  1704. X                            IF WindowPtr(Event.Message) = Write.WriteWindow THEN
  1705. X                                IF Odd(Event.modifiers) THEN
  1706. X                                    IF NumPF = 0 THEN
  1707. X                                        Menus[EditMenu]^^.enableFlags := EMWindActNF
  1708. X                                    ELSE
  1709. X                                        Menus[EditMenu]^^.enableFlags := EMWindActFO
  1710. X                                ELSE IF NumPF = 0 THEN
  1711. X                                    Menus[EditMenu]^^.enableFlags := EMWindDctNF
  1712. X                                ELSE
  1713. X                                    Menus[EditMenu]^^.enableFlags := EMWindDctFO;
  1714. X                    END;
  1715. X            UNTIL (Finished);
  1716. X        END;
  1717. X
  1718. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  1719. X{Initialization specific Procedures and Functions}
  1720. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  1721. X
  1722. X    {******************************************************************************}
  1723. X    {Used internally to init some junk}
  1724. X    {******************************************************************************}
  1725. X
  1726. X    PROCEDURE _DataInit;
  1727. X        EXTERNAL;
  1728. X
  1729. X    {******************************************************************************}
  1730. X    {Create the WriteWindow and display our little message}
  1731. X    {******************************************************************************}
  1732. X
  1733. X    PROCEDURE InitWriteWindow;
  1734. X
  1735. X        VAR
  1736. X            Bounds                : Rect;
  1737. X            Info                    : FontInfo;
  1738. X            SavePort            : GrafPtr;
  1739. X
  1740. X        BEGIN
  1741. X            WITH Write DO
  1742. X                BEGIN
  1743. X                    GetPort(SavePort);
  1744. X                    SetRect(Bounds, 7, 40, 503, 338);
  1745. X                    WriteWindow := NewWindow(NIL, Bounds, 'Multi-Print', True, 0, pointer( - 1), False, 0);
  1746. X                    SetPort(WriteWindow);
  1747. X                    TextFont(Monaco);
  1748. X                    TextSize(9);
  1749. X                    GetFontInfo(Info);
  1750. X                    LineHeight := Info.Ascent + Info.Descent + Info.Leading;
  1751. X                    MaxLine := ((Bounds.Bottom - Bounds.Top) DIV LineHeight) - 1;
  1752. X                    IF MaxLine > 50 THEN
  1753. X                        MaxLine := 50;
  1754. X                END;
  1755. X            EraseWindow;
  1756. X            WriteLn('Print was written by Brent Pease to demonstrate several "Advanced"');
  1757. X            WriteLn('programming techniques. It was also written to experiment with');
  1758. X            WriteLn('these techniques and see how well they worked out.');
  1759. X            WriteLn('');
  1760. X            WriteLn('The source code is available and should have been distributed');
  1761. X            WriteLn('with this program. It demonstrates:');
  1762. X            WriteLn('1) How to print using the Print Manager.');
  1763. X            WriteLn('2) How to print a lot of files.');
  1764. X            WriteLn('3) How to use the Print Managers backround processing.');
  1765. X            WriteLn('4) How to custimize the Standard File Package.');
  1766. X            WriteLn('5) User items in dialogs.');
  1767. X            WriteLn('6) Add items to an existing dialog');
  1768. X            WriteLn('7) Add items to the Print Managers Job Dialog.');
  1769. X            WriteLn('8) What you see is what you get!');
  1770. X            WriteLn('');
  1771. X            WriteLn('Please send me your comments and suggestions.');
  1772. X            WriteLn('');
  1773. X            WriteLn('Delphi -> SOCCERKING');
  1774. X            WriteLn('Brent Pease');
  1775. X            WriteLn('20 Lansing St.');
  1776. X            WriteLn('Hinsdale, IL 60521');
  1777. X            WriteLn('');
  1778. X            WriteLn('This program is 100% public domain, please pass it on.');
  1779. X            SetPort(SavePort);
  1780. X        END;
  1781. X
  1782. X    {******************************************************************************}
  1783. X    {init page set up print record}
  1784. X    {******************************************************************************}
  1785. X
  1786. X    PROCEDURE InitPage;
  1787. X
  1788. X        BEGIN
  1789. X            PgSetUp := THPrint(NewHandle(SizeOf(TPrint)));
  1790. X            PrintDefault(PgSetUp);
  1791. X            HLock(Handle(PgSetUp));
  1792. X        END;
  1793. X
  1794. X    {******************************************************************************}
  1795. X    {Create the menus}
  1796. X    {******************************************************************************}
  1797. X
  1798. X    PROCEDURE SetUpMenu;
  1799. X
  1800. X        VAR
  1801. X            Index                 : Integer;
  1802. X
  1803. X        BEGIN
  1804. X            Menus[AppleMenu] := GetMenu(AppleMenu);
  1805. X            AddResMenu(Menus[AppleMenu], 'DRVR');
  1806. X            InsertMenu(Menus[AppleMenu], 0);
  1807. X            FOR Index := FileMenu TO EditMenu DO
  1808. X                BEGIN
  1809. X                    Menus[Index] := GetMenu(Index);
  1810. X                    InsertMenu(Menus[Index], 0);
  1811. X                END;
  1812. X            DrawMenuBar;
  1813. X        END;
  1814. X
  1815. X    {******************************************************************************}
  1816. X    {Init the ToolBox}
  1817. X    {******************************************************************************}
  1818. X
  1819. X    PROCEDURE Init;
  1820. X
  1821. X        BEGIN
  1822. X            UnLoadSeg(@_DataInit);
  1823. X            InitGraf(@thePort);
  1824. X            MoreMasters;
  1825. X            MoreMasters;
  1826. X            MoreMasters;
  1827. X            InitFonts;
  1828. X            InitWindows;
  1829. X            InitMenus;
  1830. X            InitCursor;
  1831. X            InitDialogs(NIL);
  1832. X            FlushEvents(everyEvent, 0);
  1833. X
  1834. X            InitPage;
  1835. X            InitWriteWindow;
  1836. X
  1837. X            Finished := False;
  1838. X            BRDlogPtr := NIL;
  1839. X            Document.Saved := True;
  1840. X            Footer := 'Page #(PAGE)';
  1841. X            Header := 'Set: (SET)     File: (NAME)   Date: (DATE)   Time: (TIME)';
  1842. X        END;
  1843. X
  1844. X    {******************************************************************************}
  1845. X    {Open the files selected from the finder}
  1846. X    {******************************************************************************}
  1847. X
  1848. X    PROCEDURE LookAppFiles;
  1849. X
  1850. X        VAR
  1851. X            X                         : Integer;
  1852. X            Mess                    : Integer;
  1853. X            NumDocs             : Integer;
  1854. X            TheAppFile        : AppFile;
  1855. X
  1856. X        BEGIN
  1857. X            CountAppFiles(Mess, NumDocs);
  1858. X            IF Mess = AppPrint THEN
  1859. X                FOR X := 1 TO NumDocs DO
  1860. X                    BEGIN
  1861. X                        GetAppFiles(X, TheAppFile);
  1862. X                        OpenFile(TheAppFile.fName, TheAppFile.VRefNum);
  1863. X                        DoPrint;
  1864. X                    END
  1865. X            ELSE IF (Mess = AppOpen) AND (NumDocs >= 1) THEN
  1866. X                BEGIN
  1867. X                    GetAppFiles(1, TheAppFile);
  1868. X                    OpenFile(TheAppFile.fName, TheAppFile.VRefNum);
  1869. X                END
  1870. X            ELSE
  1871. X                BEGIN
  1872. X                    NumPF := 0;
  1873. X                    Document.FRefNum := 0;
  1874. X                    Menus[FileMenu]^^.enableFlags := FMNoFileOpen;
  1875. X                    Menus[EditMenu]^^.enableFlags := EMWindActNF;
  1876. X                END;
  1877. X        END;
  1878. X
  1879. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  1880. X{MAIN}
  1881. X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  1882. X
  1883. X    BEGIN
  1884. X        Init;
  1885. X        SetUpMenu;
  1886. X        LookAppFiles;
  1887. X        PrOpen;
  1888. X        IF PrError = noErr THEN
  1889. X            BEGIN
  1890. X                MainEventLoop;
  1891. X                PrClose;
  1892. X            END
  1893. X        ELSE
  1894. X            BEGIN
  1895. X                SysBeep(10);
  1896. X                WriteLn('Sorry, Print Manager is un-openable.');
  1897. X                WriteLn('Hey, its not my fault!(hee, hee, hee)');
  1898. X                WriteLn('Click button.');
  1899. X                REPEAT
  1900. X                UNTIL Button;
  1901. X            END;
  1902. X    END.
  1903. ________This_Is_The_END________
  1904. if test `wc -l < MultiPrintv1.p` -ne 1872; then
  1905.     echo 'shar: MultiPrintv1.p was damaged during transit'
  1906.   echo '      (should have been 1872 bytes)'
  1907. fi
  1908. fi        ; : end of overwriting check
  1909. echo 'Extracting MultiPrintv1.r'
  1910. if test -f MultiPrintv1.r; then echo 'shar: will not overwrite MultiPrintv1.r'; else
  1911. sed 's/^X//' << '________This_Is_The_END________' > MultiPrintv1.r
  1912. X/* MultiPrint.r
  1913. X   written by Brent Pease
  1914. X     copyright (c) 1987
  1915. X*/
  1916. X
  1917. Xinclude "MPW Programs:MultiPrint:MultiPrintv1" 'CODE';
  1918. XTYPE 'PRNT' AS 'STR ';
  1919. X
  1920. XRESOURCE 'PRNT' (0)
  1921. X    {"MultiPrint v1.0 written by Brent Pease. Copyright \2511987"};
  1922. X
  1923. XRESOURCE 'ICN#' (128)
  1924. X    {
  1925. X        {
  1926. X            $"001F F800 0010 1400 00FF DE00 0080 A200"
  1927. X            $"0080 9200 07FC F200 040A 1200 0409 1200"
  1928. X            $"040F 1200 0401 1200 0401 1200 0401 1200"
  1929. X            $"0401 1200 0401 1200 0401 1E00 0401 1000"
  1930. X            $"0401 1000 0401 F000 0401 0000 0401 0000"
  1931. X            $"07FF 0000 0000 0000 FFFF FFF8 9000 004E"
  1932. X            $"9FFF FFCE 8000 000E 8000 0008 8000 0008"
  1933. X            $"8000 0008 8000 0008 8000 0008 FFFF FFF8";
  1934. X            $"001F F800 001F FC00 00FF FE00 00FF FE00"
  1935. X            $"00FF FE00 07FF FE00 07FF FE00 07FF FE00"
  1936. X            $"07FF FE00 07FF FE00 07FF FE00 07FF FE00"
  1937. X            $"07FF FE00 07FF FE00 07FF FE00 07FF F000"
  1938. X            $"07FF F000 07FF F000 07FF 0000 07FF 0000"
  1939. X            $"07FF 0000 0000 0000 FFFF FFF8 FFFF FFFE"
  1940. X            $"FFFF FFFE FFFF FFFE FFFF FFF8 FFFF FFF8"
  1941. X            $"FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
  1942. X        }
  1943. X    };
  1944. X    
  1945. XRESOURCE 'ICN#' (129)
  1946. X    {
  1947. X        {
  1948. X            $"001F F800 0010 1400 00FF DE00 0080 A200"
  1949. X            $"00F6 9E00 07FC F200 040A 1E00 0409 D200"
  1950. X            $"05CF 1E00 0401 5200 05F9 1600 0401 D200"
  1951. X            $"05D9 1A00 0401 7200 05B1 1E00 0401 1000"
  1952. X            $"05F9 1000 0401 F000 05DD 0000 0401 0000"
  1953. X            $"07FF 0000 0000 0000 FFFF FFF8 9000 004E"
  1954. X            $"9FFF FFCE 8000 000E 8000 0008 8000 0008"
  1955. X            $"8000 0008 8000 0008 8000 0008 FFFF FFF8";
  1956. X            $"001F F800 001F FC00 00FF FE00 00FF FE00"
  1957. X            $"00FF FE00 07FF FE00 07FF FE00 07FF FE00"
  1958. X            $"07FF FE00 07FF FE00 07FF FE00 07FF FE00"
  1959. X            $"07FF FE00 07FF FE00 07FF FE00 07FF F000"
  1960. X            $"07FF F000 07FF F000 07FF 0000 07FF 0000"
  1961. X            $"07FF 0000 0000 0000 FFFF FFF8 FFFF FFFE"
  1962. X            $"FFFF FFFE FFFF FFFE FFFF FFF8 FFFF FFF8"
  1963. X            $"FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
  1964. X        }
  1965. X    };
  1966. X
  1967. XRESOURCE 'FREF' (128)
  1968. X    {
  1969. X        'APPL', 0, ""
  1970. X    };
  1971. X
  1972. XRESOURCE 'FREF' (129)
  1973. X    {
  1974. X        'PRDC', 1, ""
  1975. X    };
  1976. X
  1977. XRESOURCE 'BNDL' (128)
  1978. X    {
  1979. X        'PRNT', 0,
  1980. X            {
  1981. X                'ICN#',
  1982. X                    {
  1983. X                        0, 128;
  1984. X                        1, 129
  1985. X                    };
  1986. X                'FREF',
  1987. X                    {
  1988. X                        0, 128;
  1989. X                        1, 129
  1990. X                    }
  1991. X            }
  1992. X    };
  1993. X    
  1994. XRESOURCE 'DITL' (129)
  1995. X    {
  1996. X        {
  1997. X            {32, 56, 48, 112},
  1998. X            Button {enabled, "Ok"};
  1999. X    
  2000. X            {32, 216, 48, 272},
  2001. X            Button {enabled, "Cancel"};
  2002. X    
  2003. X            {8, 8, 24, 304},
  2004. X            StaticText {disabled, "Enter the number of the PrintFile to ^0:"};
  2005. X    
  2006. X            {8, 312, 24, 344},
  2007. X            EditText {disabled, ""}
  2008. X        }
  2009. X    };
  2010. X
  2011. XRESOURCE 'DITL' (-4001) {
  2012. X        {
  2013. X            {138, 256, 156, 336},
  2014. X            Button {enabled, "Add"};
  2015. X    
  2016. X            {0, 571, 80, 589},
  2017. X            Button {enabled, "Hidden"};
  2018. X    
  2019. X            {163, 256, 181, 336},
  2020. X            Button {enabled, "Done"};
  2021. X    
  2022. X            {39, 232, 59, 347},
  2023. X            UserItem {disabled};
  2024. X    
  2025. X            {68, 256, 86, 336},
  2026. X            Button {enabled, "Eject"};
  2027. X    
  2028. X            {93, 256, 111, 336},
  2029. X            Button {enabled, "Drive"};
  2030. X    
  2031. X            {39, 12, 185, 230},
  2032. X            UserItem {enabled};
  2033. X    
  2034. X            {39, 229, 185, 246},
  2035. X            UserItem {enabled};
  2036. X    
  2037. X            {124, 252, 125, 340},
  2038. X            UserItem {disabled};
  2039. X    
  2040. X            {0, 532, 101, 628},
  2041. X            StaticText {disabled, ""};
  2042. X    
  2043. X            {188, 256, 206, 336},
  2044. X            Button {enabled, "Cancel"}
  2045. X        }
  2046. X    };
  2047. X
  2048. XRESOURCE 'DITL' (128)
  2049. X    {
  2050. X        {    
  2051. X            {56, 8, 72, 64},
  2052. X            Button {enabled, "Yes"};
  2053. X    
  2054. X            {80, 8, 96, 64},
  2055. X            Button {enabled, "No"};
  2056. X    
  2057. X            {80, 80, 96, 136},
  2058. X            Button {enabled, "Cancel"};
  2059. X    
  2060. X            {8, 16, 40, 48},
  2061. X            Icon {enabled, 2};
  2062. X    
  2063. X            {8, 80, 72, 312},
  2064. X            StaticText {enabled,"Save changes to:\n^0"}
  2065. X        }
  2066. X    };
  2067. X
  2068. XRESOURCE 'DITL' (130)
  2069. X    {
  2070. X        {
  2071. X            {40, 40, 56, 96},
  2072. X            Button {enabled, "Ok"};
  2073. X    
  2074. X            {40, 160, 56, 216},
  2075. X            Button {enabled, "Cancel"};
  2076. X    
  2077. X            {8, 16, 24, 240},
  2078. X            StaticText {disabled,"Continue with current print job?"}
  2079. X        }
  2080. X    };
  2081. X
  2082. XRESOURCE 'DITL' (131)
  2083. X    {
  2084. X        {
  2085. X            {56, 168, 72, 224},
  2086. X            Button {enabled, "Stop"};
  2087. X    
  2088. X            {80, 168, 96, 224},
  2089. X            Button {enabled, "Cancel"};
  2090. X    
  2091. X            {56, 88, 72, 144},
  2092. X            Button {enabled, "Pause"};
  2093. X    
  2094. X            {80, 88, 96, 144},
  2095. X            Button {enabled, "Resume"};
  2096. X    
  2097. X            {104, 128, 120, 192},
  2098. X            StaticText {disabled, "Total job"};
  2099. X    
  2100. X            {153, 86, 169, 245},
  2101. X            StaticText {disabled, "Saving Current PrintFile"};
  2102. X    
  2103. X            {200, 80, 216, 248},
  2104. X            StaticText {Disabled, "Printing Current PrintFile"};
  2105. X    
  2106. X            {8, 8, 24, 304},
  2107. X            StaticText {disabled, "Currently printing set: ^0"};
  2108. X    
  2109. X            {33, 10, 49, 306},
  2110. X            StaticText {disabled, "Currently Printing PrintFile: ^1"};
  2111. X    
  2112. X            {128, 8, 144, 304},
  2113. X            UserItem {disabled};
  2114. X    
  2115. X            {176, 8, 192, 304},
  2116. X            UserItem {disabled};
  2117. X    
  2118. X            {224, 8, 240, 304},
  2119. X            UserItem {Disabled}
  2120. X        }
  2121. X    };
  2122. X    
  2123. XRESOURCE 'DITL' (132)
  2124. X    {
  2125. X        {
  2126. X            {142, 212, 165, 299}, Button {enabled, "Okay"};
  2127. X            {7, 82, 25, 283}, StaticText {disabled,
  2128. X                "The Developers At Large Group"};
  2129. X            {32, 152, 48, 216}, StaticText {disabled, "Present's"};
  2130. X            {56, 144, 72, 224}, StaticText {disabled, "Multi-Print"};
  2131. X            {96, 8, 128, 368}, StaticText {disabled,
  2132. X                "Written by Brent Pease. Copyright \251 1987"
  2133. X                " by The Developer's At Large Group. All "
  2134. X                "rights reserved."};
  2135. X            {112, 154, 132, 214}, Icon {enabled, 128}
  2136. X        }
  2137. X    };
  2138. X
  2139. XRESOURCE 'DITL' (133)
  2140. X    {
  2141. X        {
  2142. X            {8, 8, 24, 112},
  2143. X            CheckBox {enabled, "Draw Border"};
  2144. X    
  2145. X            {8, 216, 24, 248},
  2146. X            EditText {disabled, ""};
  2147. X    
  2148. X            {40, 120, 56, 264},
  2149. X            EditText {disabled, ""};
  2150. X    
  2151. X            {64, 120, 80, 176},
  2152. X            EditText {disabled, ""};
  2153. X    
  2154. X            {96, 160, 112, 304},
  2155. X            EditText {enabled, ""};
  2156. X    
  2157. X            {120, 160, 136, 216},
  2158. X            EditText {enabled, ""};
  2159. X    
  2160. X            {8, 176, 24, 208},
  2161. X            StaticText {enabled, "Tab:"};
  2162. X    
  2163. X            {40, 8, 56, 104},
  2164. X            StaticText {enabled, "PrintFile Font"};
  2165. X    
  2166. X            {64, 8, 80, 104},
  2167. X            StaticText {enabled, "PrintFile Size"};
  2168. X    
  2169. X            {96, 8, 112, 144},
  2170. X            StaticText {enabled, "Header/Footer Font"};
  2171. X    
  2172. X            {120, 8, 136, 144},
  2173. X            StaticText {enabled, "Header/Footer Size"}
  2174. X        }
  2175. X    };
  2176. X
  2177. XRESOURCE 'DITL' (134, preload)
  2178. X    {
  2179. X        {
  2180. X            {76, 160, 96, 220}, Button     {enabled, "Okay"};
  2181. X            {77, 267, 97, 327}, Button     {enabled, "Cancel"};
  2182. X            {12, 11, 28, 467},  EditText   {disabled, ""};
  2183. X            {36, 7, 70, 469},   StaticText {disabled,
  2184. X                "The strings \"(NAME)\" \"(PAGE)\" \"(DATE)\" o"
  2185. X                "r \"(TIME)\" will be replaced at print tim"
  2186. X                "e with the coresponding entity."}
  2187. X        }
  2188. X    };
  2189. X
  2190. XRESOURCE 'DLOG' (-4001)
  2191. X    {
  2192. X        {54, 66, 279, 414},
  2193. X        dBoxProc,
  2194. X        invisible,
  2195. X        noGoAway,
  2196. X        0x0,
  2197. X        -4001,
  2198. X        ""
  2199. X    };
  2200. X
  2201. XRESOURCE 'DLOG' (129)
  2202. X    {
  2203. X        {58, 74, 114, 424},
  2204. X        dBoxProc,
  2205. X        inVisible,
  2206. X        noGoAway,
  2207. X        0x0,
  2208. X        129,
  2209. X        ""
  2210. X    };
  2211. X
  2212. XRESOURCE 'DLOG' (128)
  2213. X    {
  2214. X        {104, 102, 204, 414},
  2215. X        dBoxProc,
  2216. X        inVisible,
  2217. X        goAway,
  2218. X        0x0,
  2219. X        128,
  2220. X        ""
  2221. X    };
  2222. X
  2223. XRESOURCE 'DLOG' (130)
  2224. X    {
  2225. X        {60, 136, 120, 384},
  2226. X        dBoxProc,
  2227. X        visible,
  2228. X        goAway,
  2229. X        0x0,
  2230. X        130,
  2231. X        ""
  2232. X    };
  2233. X
  2234. XRESOURCE 'DLOG' (131)
  2235. X    {
  2236. X        {58, 102, 302, 410},
  2237. X        dBoxProc,
  2238. X        invisible,
  2239. X        goAway,
  2240. X        0x0,
  2241. X        131,
  2242. X        ""
  2243. X    };
  2244. X
  2245. XRESOURCE 'DLOG' (132, preload)
  2246. X    {
  2247. X        {78, 78, 261, 436},
  2248. X        dBoxProc,
  2249. X        visible,
  2250. X        goAway,
  2251. X        0x0,
  2252. X        132,
  2253. X        ""
  2254. X    };
  2255. X
  2256. XRESOURCE 'DLOG' (134, preload)
  2257. X    {
  2258. X        {108, 14, 222, 496},
  2259. X        documentProc,
  2260. X        visible,
  2261. X        noGoAway,
  2262. X        0x0,
  2263. X        134,
  2264. X        "Header"
  2265. X    };
  2266. X
  2267. XRESOURCE 'MENU' (1, preload)
  2268. X    {
  2269. X        1,
  2270. X        textMenuProc,
  2271. X        0x7FFFFFFD,
  2272. X        enabled,
  2273. X        apple,
  2274. X        {
  2275. X            "About Print Demo...", noIcon, noKey, noMark, plain;
  2276. X            "-", noIcon, noKey, noMark, plain
  2277. X        }
  2278. X    };
  2279. X
  2280. XRESOURCE 'MENU' (2, preload)
  2281. X    {
  2282. X        2,
  2283. X        textMenuProc,
  2284. X        0B1111111111111111111111011011011,
  2285. X        enabled,
  2286. X        "File",
  2287. X        {
  2288. X            "Select Set", noIcon, "N", noMark , plain;
  2289. X            "Open Set", noIcon, "O", noMark, plain;
  2290. X            "-", noIcon, noKey, noMark, plain;
  2291. X            "Close Set",noIcon,"C",noMark,plain;
  2292. X            "Save Set",noIcon,"S",noMark,plain;
  2293. X            "-",noIcon,noKey,noMark,plain;
  2294. X            "Page Setup", noIcon, noKey, noMark, plain;
  2295. X            "Print", noIcon, "P", noMark, plain;
  2296. X            "-", noIcon, noKey, noMark, plain;
  2297. X            "Quit", noIcon, "Q", noMark, plain
  2298. X        }
  2299. X    };
  2300. X
  2301. XRESOURCE 'MENU' (3, preload)
  2302. X    {
  2303. X        3,
  2304. X        textMenuProc,
  2305. X        0B1111111111111111110111010111101,
  2306. X        enabled,
  2307. X        "Edit",
  2308. X        {
  2309. X            "Undo", noIcon, "Z", noMark, plain;
  2310. X            "-", noIcon, noKey, noMark, plain;
  2311. X            "Cut", noIcon, "X", noMark, plain;
  2312. X            "Copy", noIcon, "C", noMark, plain;
  2313. X            "Paste", noIcon, "V", noMark, plain;
  2314. X            "Clear", noIcon, noKey, noMark, plain;
  2315. X            "-", noIcon, noKey, noMark, plain;
  2316. X            "Display Set", noIcon, "D",noMark, plain;
  2317. X            "-", noIcon, noKey, noMark, plain;
  2318. X            "Add a PrintFile", noIcon, noKey, noMark, plain;
  2319. X            "Delete a PrintFile", noIcon, noKey, noMark, plain;
  2320. X            "Change a PrintFile", noIcon, noKey, noMark, plain;
  2321. X            "-", noIcon, noKey, noMark, plain;
  2322. X            "Header", noIcon, "H", noMark, plain;
  2323. X            "Footer", noIcon, "F", noMark, plain
  2324. X        }
  2325. X    };
  2326. X
  2327. X
  2328. X
  2329. ________This_Is_The_END________
  2330. if test `wc -l < MultiPrintv1.r` -ne 417; then
  2331.     echo 'shar: MultiPrintv1.r was damaged during transit'
  2332.   echo '      (should have been 417 bytes)'
  2333. fi
  2334. fi        ; : end of overwriting check
  2335. echo 'Extracting Multiprintv1.c'
  2336. if test -f Multiprintv1.c; then echo 'shar: will not overwrite Multiprintv1.c'; else
  2337. sed 's/^X//' << '________This_Is_The_END________' > Multiprintv1.c
  2338. X/* MultiPrint.c  Written by Brent Pease
  2339. X     add items to a existing DLOG */
  2340. X#include <dialogs.h>
  2341. X#include <types.h>
  2342. X#include <resources.h>
  2343. X#include <memory.h>
  2344. X#include <controls.h>
  2345. X
  2346. Xpascal short AddItems(theDialog, resID)
  2347. X    DialogRecord *theDialog;
  2348. X    short resID;
  2349. X    
  2350. X    {
  2351. X        struct {
  2352. X            short dlgMaxIndex; /* number of items minus one */
  2353. X            struct DITLItem {
  2354. X                Handle itmHdnl;
  2355. X                Rect itmRect;
  2356. X                unsigned char itmType;
  2357. X                unsigned char itmData[];
  2358. X            } items[];
  2359. X        } **hDITL = GetResource('DITL',resID), **hItems = theDialog->items;
  2360. X        /* hDITL is a handle to the items to add on
  2361. X           hItems is a handle to the dialogs items */
  2362. X             
  2363. X        /* pItem holds a pointer to the current item we are working one */
  2364. X        register struct DITLItem *pItem = &(*hDITL)->items;
  2365. X        Rect maxRect, /* maxRect holds the size of the Dialogs window */
  2366. X             DummyRect; /* Dummy rect holds the rect of our Dummy dialog */
  2367. X        Point offset; /* offset every item in hDITL by this */
  2368. X        register short x;
  2369. X        DialogPtr DummyDialog;
  2370. X        /* PtrArth is used to override C's not so often convient Pointer Arthmitic */
  2371. X        register int PtrArth;
  2372. X        ControlHandle nControl, lControl;
  2373. X        
  2374. X        /* init some garbage */
  2375. X        maxRect = theDialog->window.port.portRect;
  2376. X        SetPt(&offset,0,maxRect.bottom); SetRect(&DummyRect,0,0,10,10);
  2377. X        maxRect.bottom -= 5; maxRect.right -= 5;
  2378. X        
  2379. X        /* offset every item in hDITL and add it to maxRect */
  2380. X        for(x=0;x<=(*hDITL)->dlgMaxIndex;x++) {
  2381. X            OffsetRect(&pItem->itmRect,offset.h,offset.v);
  2382. X            UnionRect(&pItem->itmRect,&maxRect,&maxRect);
  2383. X            PtrArth = pItem; /* I hate pointer arithmetic sometimes */
  2384. X            PtrArth += ((pItem->itmData[0] + 1) & 65534) + sizeof(struct DITLItem);
  2385. X            pItem = PtrArth; /* would'n it be nice if you could say ((int) pItem) += */
  2386. X        }
  2387. X        
  2388. X        /* find the last control for theDialog */
  2389. X        nControl = (lControl = theDialog->window.controlList);
  2390. X        while(nControl) {
  2391. X            lControl = nControl; nControl = (*nControl)->nextControl;
  2392. X        }
  2393. X        
  2394. X        /* Build the item list and control list then add it to hItems and theDialog */
  2395. X        DummyDialog = NewDialog(0,&DummyRect,'',false,0,-1,false,0,hDITL);
  2396. X        (*lControl)->nextControl = DummyDialog->window.controlList;
  2397. X        DummyDialog->window.controlList = 0; ((DialogPeek) DummyDialog)->items = 0;
  2398. X        DisposDialog(DummyDialog);
  2399. X        PtrAndHand(&(*hDITL)->items,hItems,GetHandleSize(hDITL)-2);
  2400. X        
  2401. X        /* Get the offset to our first items new position in theDialog */
  2402. X        x = (*hItems)->dlgMaxIndex+1;
  2403. X        (*hItems)->dlgMaxIndex += (*hDITL)->dlgMaxIndex+1;
  2404. X        ReleaseResource(hDITL);
  2405. X        
  2406. X        /* Give all the controls a new owner */
  2407. X        nControl = (*lControl)->nextControl;
  2408. X        while(nControl) {
  2409. X            (*nControl)->contrlOwner = theDialog; nControl = (*nControl)->nextControl;
  2410. X        }
  2411. X            
  2412. X        maxRect.bottom += 5; maxRect.right += 5;
  2413. X        SizeWindow(theDialog,maxRect.right,maxRect.bottom,true);
  2414. X        
  2415. X        return x;
  2416. ________This_Is_The_END________
  2417. if test `wc -l < Multiprintv1.c` -ne 78; then
  2418.     echo 'shar: Multiprintv1.c was damaged during transit'
  2419.   echo '      (should have been 78 bytes)'
  2420. fi
  2421. fi        ; : end of overwriting check
  2422. echo 'Extracting Multiprintv1.mf'
  2423. if test -f Multiprintv1.mf; then echo 'shar: will not overwrite Multiprintv1.mf'; else
  2424. sed 's/^X//' << '________This_Is_The_END________' > Multiprintv1.mf
  2425. XLibs         = "{Libraries}Interface.o" [line continuation symbol]
  2426. X                     "{PLibraries}PasLib.o" [line continuation symbol]
  2427. X                     "{CLibraries}CRuntime.o" [line continuation symbol]
  2428. X                     "{Plibraries}SANELib.o" [line continuation symbol]
  2429. X                     "{CLibraries}CInterface.o"
  2430. X                     
  2431. XLinkOpts = -l -w
  2432. X
  2433. X"{CurProgPath}"                [dependency symbol][dependency symbol]  "{CurProgPath}".p.o "{CurProgPath}".c.o
  2434. X    LINK {LinkOpts} "{CurProgPath}.p.o" "{CurProgPath}".c.o {Libs} [line continuation symbol]
  2435. X        -o "{CurProgPath}" [redirect stderr symbol] "{CurProgPath}.l.err" [line continuation symbol]
  2436. X        > "{CurProgPath}.map" || (OPEN "{CurProgPath}.l.err"; Exit 99)
  2437. X
  2438. X"{CurProgPath}".p.o        [dependency symbol]    "{CurProgPath}".p
  2439. X    PASCAL -o "{PDir}" "{CurProgPath}.p"    [redirect stderr symbol] "{CurProgPath}.p.err" [line continuation symbol]
  2440. X        || (OPEN "{CurProgPath}.p.err"; Exit 99)
  2441. X
  2442. X"{CurProgPath}".c.o        [dependency symbol] "{CurProgPath}".c
  2443. X    C -w -o "{PDir}" "{CurProgPath}".c [redirect stderr symbol] "{CurProgPath}.c.err" [line continuation symbol]
  2444. X        || (OPEN "{CurProgPath}.c.err"; Exit 99)
  2445. X    
  2446. X"{CurProgPath}"                [dependency symbol][dependency symbol]    "{CurProgPath}".r
  2447. X    REZ Types.r "{CurProgPath}.r" -o "{CurProgPath}.temp" [redirect stderr symbol] "{CurProgPath}.r.err" [line continuation symbol]
  2448. X        || (OPEN "{CurProgPath}.r.err"; Exit 99)
  2449. X    RENAME -y "{CurProgPath}.temp" "{CurProgPath}"
  2450. ________This_Is_The_END________
  2451. if test `wc -l < Multiprintv1.mf` -ne 25; then
  2452.     echo 'shar: Multiprintv1.mf was damaged during transit'
  2453.   echo '      (should have been 25 bytes)'
  2454. fi
  2455. fi        ; : end of overwriting check
  2456. exit 0
  2457.