home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-06-20 | 75.3 KB | 2,458 lines |
- 18-Jun-88 14:38:33-MDT,79568;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:36:22 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA22504; Sat, 18 Jun 88 14:36:17 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA24697; Sat, 18 Jun 88 14:36:09 MDT
- Date: Sat, 18 Jun 88 14:36:09 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8806182036.AA24697@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: MultiPrint.c.shar
-
- #! /bin/sh
- #
- # This is a shell archive. Save this into a file, edit it
- # and delete all lines above this comment. Then give this
- # file to sh by executing the command "sh file". The files
- # will be extracted into the current directory owned by
- # you with default permissions.
- #
- # The files contained herein are:
- #
- # 59 MultiPrintv1.p
- # 8 MultiPrintv1.r
- # 3 Multiprintv1.c
- # 2 Multiprintv1.mf
- #
- echo 'Extracting MultiPrintv1.p'
- if test -f MultiPrintv1.p; then echo 'shar: will not overwrite MultiPrintv1.p'; else
- sed 's/^X//' << '________This_Is_The_END________' > MultiPrintv1.p
- X{PasMat formatting codes}
- X{[a-, b-, body-, c-, g-, h-, j=15+/50, k+, n+, o=98, q-, r+, rec+, u+,
- X v-, x-, y-, z-, :+, #-]}
- XPROGRAM MultiPrint;
- X {Written By Brent Pease}
- X {Copyright (c) 1987}
- X {
- X This program demonstrates:
- X 1) User items in dialogs
- X 2) Custimizing and using the standard file package
- X 3) Printing in general(Printing text files specifically)
- X 4) Using the Print Managers backround processing system.
- X 5) A general idea if simple file IO and keeping track of menu items involved
- X 6) Your basic Mac IO junk.
- X
- X Note you should not have a procedure called by the toolbox, ex. MyDlg,
- X MyFilter, ect. nesting within another procedure, you can not access any
- X variable of the containing block because the stack frame will not be the same
- X when your procedure is called.
- X
- X Also note that some of this stuff is pretty experimental.
- X
- X This program does not teach you how to do these things, it simply gives you an
- X example. It is assumed you have already read about them in "Inside Macintosh".
- X See Tech Note #47 for more detailed information on custimizing SFGetFile.
- X See Tech Note #95 for information on adding items to Print Manager Dialogs
- X (My AddItems procedure was influenced by Lew Rollins AppendDITL, the differnce
- X between the two is that he builds the Item list himself, I let the Dialog
- X Manager handle that for me)
- X
- X If you find this program useful please send $10.00 or what every you feel
- X my effort is worth.
- X Brent Pease
- X 20 Lansing St.
- X Hinsdale IL 60521
- X }
- X
- X USES
- X {$LOAD MPW Programs:MultiPrint:MacIntf.LOAD}
- X Memtypes, Quickdraw, OSIntf, ToolIntf, MacPrint, PackIntf;
- X
- X CONST
- X {Menus ID's}
- X AppleMenu = 1;
- X FileMenu = 2;
- X EditMenu = 3;
- X
- X {Dialog ID's}
- X SaveDlgID = 128; {Save Changes To}
- X PFNDlgID = 129; {Enter the number of the print file}
- X CPrintDlgID = 130; {Contine with current print job?}
- X PBRDlgID = 131; {Print Backround dialog}
- X AboutDlgID = 132; {About dialog}
- X JobItems = 133; {MPJobDialog extra items}
- X HFDlgID = 134; {Header/Footer Dialog}
- X GPFDlgID = - 4001; {Custum standard file dialog}
- X
- X {Dialog Item ID's}
- X {Save Changes to}
- X Yes = 1;
- X No = 2;
- X MyCancel = 3;
- X
- X {Print Backround dialog}
- X Stop = 1;
- X Pause = 3;
- X Resume = 4;
- X CurSet = 8;
- X CurPFile = 9;
- X TotUser = 10; {Total job user item}
- X SPFUser = 11; {Saving PrintFile user item}
- X PFPUser = 12; {Print PrintFile user item}
- X
- X {Job Dialog extra Item numbers}
- X DrawBorder = 1;
- X Tab = 2;
- X PFFont = 3;
- X PFSize = 4;
- X HFFont = 5;
- X HFSize = 6;
- X
- X {Apple Menu menu items}
- X AMAbout = 1;
- X
- X {File Menu menu items}
- X FMSelectSet = 1;
- X FMOpenSet = 2;
- X FMCloseSet = 4;
- X FMSaveSet = 5;
- X FMPageSetUp = 7;
- X FMPrint = 8;
- X FMQuit = 10;
- X
- X {Edit Menu menu items}
- X EMDisplaySet = 8;
- X EMAddFile = 10;
- X EMDeleteFile = 11;
- X EMChangeFile = 12;
- X EMHeader = 14;
- X EMFooter = 15;
- X
- X {Enable Flags}
- X {File Menu enable flags. Used instead of calling EnableItem and DisableItem}
- X FMNoFileOpen = $FFFFFC87;
- X FMFileIsOpen = $FFFFFD91;
- X FMSetSelected = $FFFFFDB5;
- X
- X {Edit menu enable flags}
- X EMNoFileOpen = $FFFFC07B;
- X EMWindActFO = $FFFFDD01; {Window active and file is open}
- X EMWindDctFO = $FFFFDD7B; {Window deactive and file is open}
- X EMWindActNF = $FFFFC001; {Window active and no file is open}
- X EMWindDctNF = $FFFFC07B; {Window deactive and no file is open}
- X
- X TYPE
- X {Record to store info about a PrintFile}
- X PrintFileRec = RECORD
- X PFName : Str255; {Title of document}
- X PFvRefNum : Integer; {Volume refernce number}
- X PFJobRec : TPrJob; {Print Job subrecord}
- X Border : Boolean; {Print a border around the text}
- X PFFontNum : Integer; {PrintFiles font number, if 0 default is used}
- X PFPtSize : Integer; {PrintFiles font size}
- X HFFontNum : Integer; {PrintFiles header/footer font num. 0=default}
- X HFPtSize : Integer; {PrintFile header/footer font soze}
- X PFTab : Integer; {Number of spaces in tab}
- X END;
- X
- X {Record to keep track of the current and maximun setting of the user items}
- X UIProsRec = RECORD
- X Total : LongInt; {Total Number of bytes to be processed}
- X Current : LongInt; {Number of bytes processed so far}
- X END;
- X
- X {Record to store info about where the Print Job was stoped}
- X JobRec = RECORD
- X InJob : Boolean; {True if we are in a printing job}
- X PFPageNum : Integer; {Page where job was stopped}
- X PFNum : Integer; {Store the Print File number where job was
- X stopped}
- X END;
- X
- X {Record to store information about the Write Window}
- X WriteInfoRec = RECORD
- X WindowCont : ARRAY [1..50] OF Str255; {Contents of window}
- X WriteWindow : WindowPtr; {pointer to our window record}
- X CurrLine : Integer; {Current line number in window}
- X LineHeight : Integer; {line height of font}
- X MaxLine : Integer; {Maximun number of lines displayed in window at
- X onetime}
- X END;
- X
- X {Record to store information about the current doc}
- X DocumentRec = RECORD
- X dName : Str255; {Document name}
- X FRefNum : Integer; {FIle refernce number}
- X VRefNum : Integer; {Volume refernce number}
- X Saved : Boolean; {document saved since last changes}
- X END;
- X
- X ETAB = RECORD
- X DummyInt : Integer;
- X ETABTab : Integer;
- X END;
- X ETABPtr = ^ETAB;
- X ETABHdl = ^ETABPtr;
- X
- X MPSR = RECORD
- X DummyArray1 : ARRAY [1..18] OF Integer;
- X MPSRTab : Integer;
- X DummyArray2 : ARRAY [1..17] OF Integer;
- X END;
- X MPSRPtr = ^MPSR;
- X MPSRHdl = ^MPSRPtr;
- X
- X VAR
- X CurJob : JobRec;
- X Document : DocumentRec;
- X Write : WriteInfoRec;
- X Menus : ARRAY [1..3] OF MenuHandle;
- X UIPros : ARRAY [TotUser..PFPUser] OF UIProsRec;
- X NumPF : Integer; {Number of print files in this document}
- X PrintFiles : ARRAY [1..50] OF PrintFileRec;
- X Header : Str255;
- X Footer : Str255;
- X PgSetUp : THPrint; {The Page Setup print record}
- X Finished : Boolean; {Used to tell the application when to quit}
- X Canceled : Boolean; {Used in DoSelectSet to tell if the user
- X canceled}
- X BRDlogPtr : DialogPtr; {Used to store the pointer to our BackRound
- X dialog}
- X PrLoop : Integer; {Used to tell PrintBackround what PrintFile the
- X job is on}
- X TheStRec : TPrStatus; {Print Status record, made global to access
- X CurBand and CurPage}
- X OldPage : Integer; {Used to tell PrintBackround the old band number,
- X so we do not draw the PFPUser item every time
- X PrintBackround is called}
- X Pg : Integer; {Hold current page number of the PrintFile being
- X printed}
- X FirstItem : Integer; {The first MP specific item in the Job Dialog}
- X PrDlgItemProc : ProcPtr; {Save the Job Dialogs standard item proc}
- X PrJobPFNum : Integer; {Save the number of the Print File to add the
- X extra stuff from MPJobDialog}
- X
- X PROCEDURE DoSaveSet;
- X FORWARD;
- X
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X{Global Procedures and Functions}
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X
- X {******************************************************************************}
- X {Return the result of NumToString as a function result, this routine only
- X works in very limited situations because it will return a pointer to unlinked
- X stack frame}
- X {******************************************************************************}
- X
- X FUNCTION NumToStr(Num: LongInt): Str255;
- X
- X VAR
- X TempStr : Str255;
- X
- X BEGIN
- X NumToString(Num, TempStr);
- X NumToStr := TempStr;
- X END;
- X
- X {******************************************************************************}
- X {Convert a string to a integer}
- X {******************************************************************************}
- X
- X FUNCTION StrToNum(Str: Str255): Integer;
- X
- X VAR
- X TempNum : LongInt;
- X
- X BEGIN
- X StringToNum(Str, TempNum);
- X StrToNum := TempNum;
- X END;
- X
- X {******************************************************************************}
- X {GetItemHandle - Return just the specified items handle}
- X {******************************************************************************}
- X
- X FUNCTION GIH(theDialog: DialogPtr; ItemNum: Integer): Handle;
- X
- X VAR
- X ItemType : Integer;
- X Item : Handle;
- X Box : Rect;
- X
- X BEGIN
- X GetDItem(theDialog, ItemNum, ItemType, Item, Box);
- X GIH := Item;
- X END;
- X
- X {******************************************************************************}
- X {Erase the main window}
- X {******************************************************************************}
- X
- X PROCEDURE EraseWindow;
- X
- X VAR
- X SavePort : GrafPtr;
- X
- X BEGIN
- X WITH Write DO
- X BEGIN
- X GetPort(SavePort);
- X SetPort(WriteWindow);
- X EraseRect(WriteWindow^.PortRect);
- X CurrLine := 1; {Reset the current line number to top of window}
- X SetPort(SavePort);
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Draw a string in the window}
- X {******************************************************************************}
- X
- X PROCEDURE WriteLn(S: Str255);
- X
- X VAR
- X SavePort : GrafPtr;
- X
- X BEGIN
- X WITH Write DO
- X BEGIN
- X GetPort(SavePort);
- X SetPort(WriteWindow);
- X IF CurrLine > MaxLine THEN {Check to see if we are about to run over board}
- X BEGIN
- X MoveTo(2, CurrLine * LineHeight); {Move to botton of screen}
- X DrawString('Press mouse button for next screen');
- X REPEAT {Wait for button}
- X UNTIL Button;
- X EraseWindow;
- X END;
- X MoveTo(2, CurrLine * LineHeight); {Move to current line}
- X DrawString(S);
- X WindowCont[CurrLine] := S; {Store it for update event}
- X CurrLine := CurrLine + 1;
- X SetPort(SavePort);
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Interecpt the result codes from IO and PrError. If it is 0 then there was no
- X err, if it is iPrAbort(128) or iPrAbort + 1(129), then either cancel or stop
- X was hit in the Print Backround dialog. Otherwise announce the error number
- X and where it occured in the program.
- X Mess contains a description of the location where the err occured.
- X TheErr contains the result code.
- X Result is true if an error occured}
- X {******************************************************************************}
- X
- X FUNCTION IOCheck(TheErr: OSErr; Mess: Str255): Boolean;
- X
- X BEGIN
- X {CASE used to expand the ability of intercepting errors}
- X CASE TheErr OF
- X 0, iPrAbort:
- X IOCheck := False;
- X OTHERWISE
- X BEGIN
- X WriteLn(Concat('Error #', NumToStr(TheErr), ' occured. Error Loc:', Mess));
- X IOCheck := True;
- X END;
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Open a file with TheName on a volume with reference number ThevRefNum}
- X {******************************************************************************}
- X
- X PROCEDURE OpenFile(TheName: Str255; ThevRefNum: Integer);
- X
- X VAR
- X NumBytes : LongInt;
- X X : Integer;
- X
- X BEGIN
- X WITH Document DO
- X BEGIN
- X dName := TheName; {Save the name}
- X VRefNum := ThevRefNum; {Save the ref num}
- X Saved := True; {Mark document clean}
- X
- X {Open the file}
- X IF IOCheck(FSOpen(dName, VRefNum, FRefNum), 'OpenFile-FSOpen') THEN
- X EXIT(OpenFile);
- X {Set the file position to begining of file}
- X IF IOCheck(SetFPos(FRefNum, FSFromStart, 0), 'OpenFile-SetFPos') THEN
- X EXIT(OpenFile);
- X {Get the number of PrintFiles}
- X NumBytes := 2;
- X IF IOCheck(FSRead(FRefNum, NumBytes, @NumPF), 'OpenFile-FSRead') THEN
- X EXIT(OpenFile);
- X {Get the header}
- X NumBytes := SizeOf(Header);
- X IF IOCheck(FSRead(FRefNum, NumBytes, @Header), 'OpenFile-SFRead2') THEN
- X EXIT(OpenFile);
- X {Get the footer}
- X NumBytes := SizeOf(Footer);
- X IF IOCheck(FSRead(FRefNum, NumBytes, @Footer), 'OpenFile-SFRead3') THEN
- X EXIT(OpenFile);
- X {Get the record for each PrintFile}
- X NumBytes := SizeOf(PrintFileRec) * NumPF;
- X IF IOCheck(FSRead(FRefNum, NumBytes, @PrintFiles), 'OpenFile-FSRead4') THEN
- X EXIT(OpenFile);
- X {Get the job record}
- X NumBytes := SizeOf(JobRec);
- X IF IOCheck(FSRead(FRefNum, NumBytes, @CurJob), 'OpenFile-FSRead5') THEN
- X EXIT(OpenFile);
- X {Get the page setup record}
- X NumBytes := SizeOf(TPrint);
- X IF IOCheck(FSRead(FRefNum, NumBytes, pointer(PgSetUp^)), 'OpenFile-FSRead6') THEN
- X EXIT(OpenFile);
- X NumBytes := SizeOf(dName);
- X {Get the title of the document}
- X IF IOCheck(FSRead(FRefNum, NumBytes, @dName), 'OpenFile-FSRead5') THEN
- X EXIT(OpenFile);
- X
- X {Set the menus}
- X Menus[FileMenu]^^.enableFlags := FMFileIsOpen;
- X Menus[EditMenu]^^.enableFlags := EMWindActFO;
- X
- X {Set the Window}
- X SetWTitle(Write.WriteWindow, dName);
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Put up save dialog and return item hit}
- X {******************************************************************************}
- X
- X FUNCTION AskForSave: Integer;
- X
- X VAR
- X SaveDlg : DialogPtr;
- X ItemHit : Integer;
- X ItemType : Integer;
- X Item : Handle;
- X Box : Rect;
- X
- X BEGIN
- X IF NOT Document.Saved THEN {Need to ask user}
- X BEGIN
- X SaveDlg := GetNewDialog(SaveDlgID, NIL, pointer( - 1));
- X ParamText(Document.dName, '', '', ''); {Substitute name}
- X ShowWindow(SaveDlg);
- X SelectWindow(SaveDlg);
- X SetPort(SaveDlg);
- X PenSize(3, 3);
- X GetDItem(SaveDlg, Ok, ItemType, Item, Box);
- X InsetRect(Box, - 4, - 4);
- X FrameRoundRect(Box, 16, 16);
- X ModalDialog(NIL, ItemHit);
- X AskForSave := ItemHit;
- X DisposDialog(SaveDlg);
- X END
- X ELSE
- X AskForSave := No; {Document is saved so no need}
- X END;
- X
- X {******************************************************************************}
- X {Put up Get PrintFile Dialog and return the number or 0 if canceled}
- X {******************************************************************************}
- X
- X FUNCTION GetFileNum(TheMesg: Str255): Integer;
- X
- X VAR
- X DlogPtr : DialogPtr;
- X Num : LongInt;
- X ItemHit : Integer;
- X NumStr : Str255;
- X ItemType : Integer;
- X Item : Handle;
- X Box : Rect;
- X
- X BEGIN
- X DlogPtr := GetNewDialog(PFNDlgID, NIL, pointer( - 1));
- X ParamText(TheMesg, '', '', '');
- X ShowWindow(DlogPtr);
- X SelectWindow(DlogPtr);
- X SetPort(DlogPtr);
- X PenSize(3, 3);
- X GetDItem(DlogPtr, Ok, ItemType, Item, Box);
- X InsetRect(Box, - 4, - 4);
- X FrameRoundRect(Box, 16, 16);
- X ModalDialog(NIL, ItemHit);
- X CASE ItemHit OF
- X Ok:
- X BEGIN
- X GetDItem(DlogPtr, 4, ItemType, Item, Box);
- X GetIText(Item, NumStr);
- X StringToNum(NumStr, Num);
- X GetFileNum := Num;
- X END;
- X Cancel:
- X GetFileNum := 0;
- X END;
- X DisposDialog(DlogPtr);
- X END;
- X
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X{Specialized Procedures and Functions}
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X
- X {******************************************************************************}
- X {Used to add dialog items to an existing dialog. Written in C because it's a
- X heck lot easier}
- X {******************************************************************************}
- X
- X FUNCTION AddItems(theDialog: DialogPtr; ResID: Integer): Integer;
- X EXTERNAL;
- X
- X {******************************************************************************}
- X {Call the default item proc handler ofr the Job Dialog}
- X {******************************************************************************}
- X
- X PROCEDURE CallItemProc(theDialog: DialogPtr; ItemNum: Integer; TheProc: ProcPtr);
- X INLINE $205F, $4E90; {MOVE (SP)+, A0; JSR (A0)}
- X
- X {******************************************************************************}
- X {Draw the user bars in the Backround Dialog}
- X {******************************************************************************}
- X
- X PROCEDURE BRDlogDrawItem(TheDlog: DialogPtr; TheItem: Integer);
- X
- X VAR
- X ItemType : Integer;
- X Item : Handle;
- X Box : Rect;
- X Width : Integer;
- X TRect : Rect;
- X
- X BEGIN
- X GetDItem(BRDlogPtr, TheItem, ItemType, Item, Box);
- X TRect := Box;
- X InsetRect(TRect, - 1, - 1);
- X FrameRect(TRect); {Draw the frame}
- X IF UIPros[TheItem].Current = 0 THEN
- X EraseRect(Box) {That's our signal to erase the box}
- X ELSE IF UIPros[TheItem].Total <> 0 THEN {Avoid divide by zero}
- X BEGIN
- X Box.Right := Box.Left + Trunc((UIPros[TheItem].Current / UIPros[TheItem].Total) *
- X (Box.Right - Box.Left));
- X FillRect(Box, Gray);
- X MoveTo(Box.Right, Box.Top);
- X LineTo(Box.Right, Box.Bottom);
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Get and process events for the backround dialog, draw the PFPUser bar if we are
- X printing. Note that you can not use modal dialog because that keeps control until
- X an event occurs. We want to return even if nothing happens so we use modeless
- X dialogs}
- X {******************************************************************************}
- X
- X PROCEDURE PrintBackround;
- X
- X VAR
- X TheEvent : EventRecord;
- X TheDlog : DialogPtr;
- X ItemHit : Integer;
- X LeavePB : Boolean;
- X SavePort : GrafPtr;
- X TheErr : OSErr;
- X Dummy : LongInt;
- X
- X {****************************************************************************}
- X {Hilite the Resume button and the Pause button accordingly}
- X {****************************************************************************}
- X
- X PROCEDURE HiliteButtons(Res, Pus: Integer);
- X
- X VAR
- X ItemType : Integer;
- X Item : Handle;
- X Box : Rect;
- X
- X BEGIN
- X GetDItem(BRDlogPtr, Pause, ItemType, Item, Box);
- X SetDItem(BRDlogPtr, Pause, BtnCtrl + ItemDisable, Item, Box);
- X HiliteControl(ControlHandle(Item), Pus);
- X GetDItem(BRDlogPtr, Resume, ItemType, Item, Box);
- X SetDItem(BRDlogPtr, Resume, BtnCtrl, Item, Box);
- X HiliteControl(ControlHandle(Item), Res);
- X END;
- X
- X BEGIN
- X LeavePB := True; {automatically assume we are going to exit from
- X loop}
- X REPEAT
- X IF GetNextEvent(mDownMask + UpdateMask + ActivMask, TheEvent) & IsDialogEvent(TheEvent) &
- X DialogSelect(TheEvent, TheDlog, ItemHit) & (TheDlog = BRDlogPtr) THEN {An item was hit}
- X CASE ItemHit OF
- X Stop:
- X BEGIN
- X LeavePB := True; {Leave loop}
- X HiliteButtons(255, 0);
- X WITH CurJob DO
- X BEGIN
- X InJob := True;
- X PFNum := PrLoop; {Save current PF number}
- X PFPageNum := TheStRec.iCurPage; {Save current page number}
- X Document.Saved := False; {Document is dirty}
- X END;
- X PrSetError(iPrAbort); {Set the error}
- X END;
- X Pause:
- X BEGIN
- X LeavePB := False; {We are now in pause so do not leave
- X PrintBackround}
- X HiliteButtons(0, 255);
- X END;
- X Resume:
- X BEGIN
- X LeavePB := True; {We are not out of pause so leave PrintBackround}
- X HiliteButtons(255, 0);
- X END;
- X Cancel:
- X BEGIN
- X HiliteButtons(255, 0);
- X LeavePB := True; {leave Print Backround}
- X CurJob.InJob := False; {Turn job off}
- X PrSetError(iPrAbort); {Return cancelation}
- X END;
- X END;
- X UNTIL LeavePB;
- X
- X {& (OldPage <> TheStRec.iCurPage) is used to avoid unnecassary draws, which takes much time}
- X IF (TheStRec.iCurPage > 0) & (OldPage <> TheStRec.iCurPage) THEN
- X WITH TheStRec DO
- X BEGIN
- X UIPros[PFPUser].Total := iTotPages;
- X UIPros[PFPUser].Current := iCurPage - 1;
- X GetPort(SavePort);
- X SetPort(BRDlogPtr);
- X BRDlogDrawItem(BRDlogPtr, PFPUser);
- X SetPort(SavePort);
- X OldPage := iCurPage;
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Handle the items in MPJobDialog}
- X {******************************************************************************}
- X
- X PROCEDURE MPJobItemProc(theDialog: DialogPtr; ItemNum: Integer);
- X
- X VAR
- X MPItem : Integer;
- X Hand : Handle;
- X TheText : Str255;
- X
- X BEGIN
- X MPItem := ItemNum - FirstItem;
- X IF ItemNum = 1 THEN {Ok was hit so get and save the results}
- X WITH PrintFiles[PrJobPFNum] DO
- X BEGIN
- X Hand := GIH(theDialog, DrawBorder + FirstItem);
- X Border := Boolean(GetCtlValue(ControlHandle(Hand)));
- X
- X Hand := GIH(theDialog, Tab + FirstItem);
- X GetIText(Hand, TheText);
- X PFTab := StrToNum(TheText);
- X
- X Hand := GIH(theDialog, PFFont + FirstItem);
- X GetIText(Hand, TheText);
- X GetFNum(TheText, PFFontNum);
- X
- X Hand := GIH(theDialog, PFSize + FirstItem);
- X GetIText(Hand, TheText);
- X PFPtSize := StrToNum(TheText);
- X
- X Hand := GIH(theDialog, HFFont + FirstItem);
- X GetIText(Hand, TheText);
- X GetFNum(TheText, HFFontNum);
- X
- X Hand := GIH(theDialog, HFSize + FirstItem);
- X GetIText(Hand, TheText);
- X HFPtSize := StrToNum(TheText);
- X
- X CallItemProc(theDialog, ItemNum, PrDlgItemProc); {Now let the Print Manager do the
- X same}
- X END
- X ELSE IF MPItem = 1 THEN {It was our Draw Border item, so toggle value}
- X BEGIN
- X Hand := GIH(theDialog, DrawBorder + FirstItem);
- X SetCtlValue(ControlHandle(Hand), 1 - GetCtlValue(ControlHandle(Hand)));
- X END
- X ELSE
- X CallItemProc(theDialog, ItemNum, PrDlgItemProc); {Let the Print Manager handle it}
- X END;
- X
- X {******************************************************************************}
- X {Init our Job Dialog}
- X {******************************************************************************}
- X
- X FUNCTION MPJobDlgInit(TheHPrint: THPrint): TPPrDlg;
- X
- X VAR
- X PrDialog : TPPrDlg;
- X Item : Handle;
- X TheText : Str255;
- X FirstOffset : Integer;
- X
- X BEGIN
- X PrDialog := PrJobInit(TheHPrint); {Let the Print Mananer create the dialog}
- X FirstItem := AddItems(DialogPtr(PrDialog), JobItems); {Now add our items}
- X PrDlgItemProc := PrDialog^.pItemProc; {Save the Print Manager's item handler proc}
- X PrDialog^.pItemProc := @MPJobItemProc; {Give it ours}
- X
- X {Set up all the fields with our values}
- X WITH PrintFiles[PrJobPFNum] DO
- X BEGIN
- X Item := GIH(DialogPtr(PrDialog), DrawBorder + FirstItem);
- X SetCtlValue(ControlHandle(Item), ord(Border));
- X
- X Item := GIH(DialogPtr(PrDialog), Tab + FirstItem);
- X NumToString(PFTab, TheText);
- X SetIText(Item, TheText);
- X
- X Item := GIH(DialogPtr(PrDialog), PFFont + FirstItem);
- X GetFontName(PFFontNum, TheText);
- X SetIText(Item, TheText);
- X
- X Item := GIH(DialogPtr(PrDialog), PFSize + FirstItem);
- X NumToString(PFPtSize, TheText);
- X SetIText(Item, TheText);
- X
- X Item := GIH(DialogPtr(PrDialog), HFFont + FirstItem);
- X GetFontName(HFFontNum, TheText);
- X SetIText(Item, TheText);
- X
- X Item := GIH(DialogPtr(PrDialog), HFSize + FirstItem);
- X NumToString(HFPtSize, TheText);
- X SetIText(Item, TheText);
- X END;
- X MPJobDlgInit := PrDialog; {Return the Print Managers modified dialog}
- X END;
- X
- X {******************************************************************************}
- X {Look for the cancel button}
- X {******************************************************************************}
- X
- X FUNCTION MyDlg(Item: Integer; theDialog: DialogPtr): Integer;
- X
- X BEGIN
- X IF Item = 11 THEN {Our item was selected}
- X BEGIN
- X Canceled := True; {Tell DoSelect files cancel was hit}
- X MyDlg := getCancel; {Tell standard file to close dialog}
- X END
- X ELSE {Do nothing}
- X MyDlg := Item;
- X END;
- X
- X {******************************************************************************}
- X {Filter out files already selected, note that you return false to have that file
- X displayed}
- X {******************************************************************************}
- X
- X FUNCTION MyFilter(PBlock: ParmBlkPtr): Boolean;
- X
- X VAR
- X X : Integer;
- X
- X BEGIN
- X MyFilter := False; {Assume it is to be displayed}
- X FOR X := 1 TO NumPF DO
- X IF PrintFiles[X].PFName = PBlock^.ioNamePtr^ THEN {It was already selected}
- X MyFilter := True;
- X END;
- X
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X{Procedure to handle menu commands}
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X
- X {******************************************************************************}
- X {Select PrintFiles}
- X {******************************************************************************}
- X
- X PROCEDURE DoSelectSet;
- X
- X VAR
- X TopLeft : Point;
- X Reply : SFReply;
- X TheTypes : SFTypeList;
- X Dummy : Boolean;
- X OldNumNames : Integer; {Save the number of PrintFile's in case of
- X Cancel}
- X TheETABHdl : ETABHdl;
- X TheMPSRHdl : MPSRHdl;
- X
- X BEGIN
- X Canceled := False;
- X OldNumNames := NumPF; {Save the number of print files in case of
- X cancel}
- X
- X TopLeft.h := 90;
- X TopLeft.v := 80;
- X TheTypes[0] := 'TEXT';
- X TheTypes[1] := '????';
- X TheTypes[2] := '????';
- X TheTypes[3] := '????';
- X
- X SFPGetFile(TopLeft, '', @MyFilter, 1, TheTypes, @MyDlg, Reply, GPFDlgID, NIL);
- X WHILE Reply.Good AND (NumPF <= 50) DO
- X BEGIN
- X NumPF := NumPF + 1;
- X WITH PrintFiles[NumPF] DO
- X BEGIN
- X PFName := Reply.fName; {Save the name}
- X PFvRefNum := Reply.VRefNum; {Save the volume reference number}
- X IF NOT IOCheck(SetVol(NIL, PFvRefNum), 'DoSelectSet-SetVol') THEN
- X BEGIN
- X IF OpenResFile(PFName) <> -1 THEN
- X BEGIN
- X TheETABHdl := ETABHdl(GetResource('ETAB', 1004));
- X IF TheETABHdl <> NIL THEN
- X PFTab := TheETABHdl^^.ETABTab
- X ELSE
- X BEGIN
- X TheMPSRHdl := MPSRHdl(GetResource('MPSR', 1005));
- X IF TheMPSRHdl <> NIL THEN
- X PFTab := TheMPSRHdl^^.MPSRTab
- X ELSE
- X PFTab := 2;
- X END;
- X END;
- X END
- X ELSE
- X PFTab := 2;
- X {Init the Font and Size fields}
- X PFFontNum := Monaco;
- X PFPtSize := 9;
- X HFFontNum := Monaco;
- X HFPtSize := 9;
- X Border := False;
- X PrJobPFNum := NumPF; {Let our Job Dialog item handler now the
- X PrintFile we are on}
- X IF NOT PrDlgMain(PgSetUp, @MPJobDlgInit) THEN {We were canceld}
- X NumPF := NumPF - 1;
- X PFJobRec := PgSetUp^^.prJob; {Save the Job subrecord}
- X END;
- X SFPGetFile(TopLeft, '', @MyFilter, 1, TheTypes, @MyDlg, Reply, GPFDlgID, NIL);
- X END;
- X IF Canceled THEN
- X NumPF := OldNumNames {Restore original number of names}
- X ELSE IF NumPF >= 1 THEN {More then one file was indeed selected}
- X BEGIN
- X {If we are not in a job and we are adding new files then set the job}
- X {to print out the new files}
- X WITH CurJob DO
- X IF (NOT InJob) AND (OldNumNames >= 1) THEN
- X BEGIN
- X InJob := True;
- X PFNum := OldNumNames + 1;
- X PFPageNum := 1;
- X END;
- X
- X {Enable and disable items in the File and Edit menus}
- X Menus[FileMenu]^^.enableFlags := FMSetSelected;
- X IF FrontWindow = Write.WriteWindow THEN
- X Menus[EditMenu]^^.enableFlags := EMWindActFO
- X ELSE
- X Menus[EditMenu]^^.enableFlags := EMWindDctFO;
- X
- X IF OldNumNames = 0 THEN
- X Document.dName := 'Untitled';
- X Document.Saved := False;
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Put up Standard File's GetDialog and then call OpenFile to open selected file}
- X {******************************************************************************}
- X
- X PROCEDURE DoOpenSet;
- X
- X VAR
- X Reply : SFReply;
- X Loc : Point;
- X TheTypes : SFTypeList;
- X
- X BEGIN
- X Loc.h := 90;
- X Loc.v := 80;
- X TheTypes[0] := 'PRDC';
- X TheTypes[1] := '????';
- X TheTypes[2] := '????';
- X TheTypes[3] := '????';
- X SFGetFile(Loc, '', NIL, 1, TheTypes, NIL, Reply); {Put up the dialog}
- X IF Reply.Good THEN {Open the file}
- X OpenFile(Reply.fName, Reply.VRefNum);
- X END;
- X
- X {******************************************************************************}
- X {Ask the user to save the file and then close it}
- X {******************************************************************************}
- X
- X PROCEDURE DoCloseSet;
- X
- X VAR
- X SaveReply : Integer;
- X
- X BEGIN
- X SaveReply := AskForSave;
- X IF SaveReply <> MyCancel THEN
- X BEGIN
- X IF SaveReply = Yes THEN
- X DoSaveSet;
- X {Close the document}
- X IF (Document.FRefNum <> 0) & IOCheck(FSClose(Document.FRefNum),
- X 'DoCloseSet-FSClose') THEN
- X EXIT(DoCloseSet);
- X {Flush the volume}
- X IF IOCheck(FlushVol(NIL, Document.VRefNum), 'DoCloseSet-FlushVol') THEN
- X EXIT(DoCloseSet);
- X NumPF := 0;
- X Document.FRefNum := 0;
- X Document.Saved := True;
- X
- X {Modify menus}
- X Menus[FileMenu]^^.enableFlags := FMNoFileOpen;
- X IF FrontWindow = Write.WriteWindow THEN
- X Menus[EditMenu]^^.enableFlags := EMWindActNF
- X ELSE
- X Menus[EditMenu]^^.enableFlags := EMWindDctNF;
- X
- X {Set window title}
- X SetWTitle(Write.WriteWindow, 'Multi-Print');
- X END;
- X END;
- X
- X {******************************************************************************}
- X {If their is no document then put up Standard File's PutDialog and then
- X save the file}
- X {******************************************************************************}
- X
- X PROCEDURE DoSaveSet;
- X
- X VAR
- X Loc : Point;
- X Reply : SFReply;
- X NumBytes : LongInt;
- X TotBytes : LongInt;
- X
- X BEGIN
- X WITH Document DO
- X BEGIN
- X IF FRefNum = 0 THEN {We need to create a document}
- X BEGIN
- X Loc.h := 90;
- X Loc.v := 80;
- X SFPutFile(Loc, '', '', NIL, Reply);
- X IF Reply.Good THEN {Create a new document}
- X BEGIN
- X {Create the document}
- X IF IOCheck(Create(Reply.fName, Reply.VRefNum, 'PRNT', 'PRDC'),
- X 'DoSaveSet-Create') THEN
- X EXIT(DoSaveSet);
- X {Open it and save reference number in FRefNum}
- X IF IOCheck(FSOpen(Reply.fName, Reply.VRefNum, FRefNum), 'DoSaveSet-FSOpen') THEN
- X EXIT(DoSaveSet);
- X {Save the documents name}
- X dName := Reply.fName;
- X SetWTitle(Write.WriteWindow, dName);
- X END;
- X END;
- X {Set the file position the the begining}
- X IF IOCheck(SetFPos(FRefNum, FSFromStart, 0), 'DoSaveSet-SetFPos') THEN
- X EXIT(DoSaveSet);
- X {Save the number of PrintFiles}
- X NumBytes := 2;
- X IF IOCheck(FSWrite(FRefNum, NumBytes, @NumPF), 'DoSaveSet-FSWrite') THEN
- X EXIT(DoSaveSet);
- X TotBytes := NumBytes;
- X {Save the header}
- X NumBytes := SizeOf(Header);
- X IF IOCheck(FSWrite(FRefNum, NumBytes, @Header), 'DoSaveSet-FSWrite') THEN
- X EXIT(DoSaveSet);
- X TotBytes := TotBytes + NumBytes;
- X {Save the footer}
- X NumBytes := SizeOf(Footer);
- X IF IOCheck(FSWrite(FRefNum, NumBytes, @Footer), 'DoSaveSet-FSWrite') THEN
- X EXIT(DoSaveSet);
- X TotBytes := TotBytes + NumBytes;
- X {Save each PrintFiles record}
- X NumBytes := SizeOf(PrintFileRec) * NumPF;
- X IF IOCheck(FSWrite(FRefNum, NumBytes, @PrintFiles), 'DoSaveSet-FSWrite') THEN
- X EXIT(DoSaveSet);
- X TotBytes := TotBytes + NumBytes;
- X {Save job record}
- X NumBytes := SizeOf(JobRec);
- X IF IOCheck(FSWrite(FRefNum, NumBytes, @CurJob), 'DoSaveSet-FSWrite') THEN
- X EXIT(DoSaveSet);
- X TotBytes := TotBytes + NumBytes;
- X {Save page setup print record}
- X NumBytes := SizeOf(TPrint);
- X IF IOCheck(FSWrite(FRefNum, NumBytes, pointer(PgSetUp^)), 'DoSaveSet-FSWrite') THEN
- X EXIT(DoSaveSet);
- X TotBytes := TotBytes + NumBytes;
- X {Save document's name}
- X NumBytes := SizeOf(dName);
- X IF IOCheck(FSWrite(FRefNum, NumBytes, @dName), 'DoSaveSet-FSWrite') THEN
- X EXIT(DoSaveSet);
- X TotBytes := TotBytes + NumBytes;
- X {Set EOF to the end of the document}
- X IF IOCheck(SetEOF(FRefNum, TotBytes), 'DoSaveSet-SetEOF') THEN
- X EXIT(DoSaveSet);
- X
- X Saved := True; {Mark document as clean}
- X {Modify menus}
- X Menus[FileMenu]^^.enableFlags := FMFileIsOpen;
- X DisableItem(Menus[FileMenu], FMSaveSet);
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Display the page setup dialog}
- X {******************************************************************************}
- X
- X PROCEDURE DoPageSetup;
- X
- X VAR
- X Dummy : Boolean;
- X
- X BEGIN
- X Dummy := PrValidate(PgSetUp); {Validate the print record}
- X IF PrStlDialog(PgSetUp) THEN {Put up the style dialog}
- X BEGIN
- X Document.Saved := False; {Document is now dirty}
- X EnableItem(Menus[FileMenu], FMSaveSet); {Enable save}
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Print out each PrintFile}
- X {******************************************************************************}
- X
- X PROCEDURE DoPrint;
- X
- X LABEL 0001;
- X
- X CONST
- X Indent = 20;
- X
- X VAR
- X DlogPtr : DialogPtr; {Hold a pointer to our ContinuePrintJob dialog}
- X Done : Boolean; {True when nothing left to print}
- X Date : DateTimeRec; {Hold the date}
- X MyETABHdl : ETABHdl; {Hold the handle to Edit's format resource}
- X ItemHit : Integer; {Hold the item hit}
- X CurrentLine : Integer; {Hold current line number in page}
- X NumLines : Integer; {Hold total number of lines in page}
- X PFBaseLine : Integer; {Height of Print File text}
- X HFBaseLine : Integer; {Height of Header/Footer text}
- X NumSpacesInTab: Integer; {Number of spaces in the tab}
- X X : Integer; {General counter}
- X X2 : Integer; {General counter}
- X Index : Integer; {General counter}
- X Secs : LongInt; {Hold number of ticks}
- X TheLine : Str255; {Hold the current line text}
- X HeaderStr : Str255; {Hold the header text}
- X FooterStr : Str255; {Hold the footer text}
- X TimeStr : Str255; {Hold the time}
- X DateStr : Str255; {Hold the date}
- X SpaceStr : Str255; {Hold the spaces that make up a tab}
- X ThePrPort : TPPrPort; {The print port}
- X F : Text; {The file's text}
- X ItemType : Integer;
- X Item : Handle;
- X Box : Rect;
- X Dummy : Integer;
- X SavePort : GrafPtr;
- X PErr : OSErr;
- X FrameRect : Rect; {Holds the Print Managers graf port's portrect}
- X MPFontInfo : FontInfo; {Hold the font information}
- X LineStart : Integer; {Hold the pixel position from the top of the
- X screen to start printing the lines of the page}
- X HeaderIndent : Integer; {Pixel indent for header, held to constant for
- X each printfile so header will not move around
- X and page number increases}
- X FooterIndent : Integer; {Same^}
- X
- X {****************************************************************************}
- X {ReplaceWhat WithWhat in TheStr}
- X {****************************************************************************}
- X
- X FUNCTION ReplaceSubStr(TheStr, ReplaceWhat, WithWhat: Str255): Str255;
- X
- X VAR
- X Position : Integer;
- X
- X BEGIN
- X Position := Pos(ReplaceWhat, TheStr);
- X IF Position <> 0 THEN
- X BEGIN
- X Delete(TheStr, Position, Length(ReplaceWhat));
- X Insert(WithWhat, TheStr, Position);
- X END;
- X ReplaceSubStr := TheStr;
- X END;
- X
- X BEGIN
- X {Verify the user wants to continue with job. If so then leave the job}
- X {Alone, if the user does not want to continue or we are not in a job}
- X {then reset PF and PFPageNum to 1}
- X WITH CurJob DO
- X IF InJob THEN
- X BEGIN
- X DlogPtr := GetNewDialog(CPrintDlgID, NIL, pointer( - 1));
- X SetPort(DlogPtr);
- X PenSize(3, 3);
- X GetDItem(DlogPtr, Ok, ItemType, Item, Box);
- X InsetRect(Box, - 4, - 4);
- X FrameRoundRect(Box, 16, 16);
- X ModalDialog(NIL, ItemHit);
- X IF ItemHit <> 1 THEN
- X BEGIN
- X InJob := False;
- X PFPageNum := 1;
- X PFNum := 1;
- X END;
- X DisposDialog(DlogPtr);
- X END
- X ELSE
- X BEGIN
- X PFPageNum := 1;
- X PFNum := 1;
- X END;
- X
- X {Set up the PrintBackround dialog}
- X BRDlogPtr := GetNewDialog(PBRDlgID, NIL, pointer( - 1));
- X FOR X := TotUser TO PFPUser DO
- X BEGIN
- X {Insert our draw proc}
- X GetDItem(BRDlogPtr, X, ItemType, Item, Box);
- X SetDItem(BRDlogPtr, X, ItemType, Handle(@BRDlogDrawItem), Box);
- X {Reset UIPros}
- X UIPros[X].Total := 1;
- X UIPros[X].Current := 0;
- X END;
- X
- X {Dim Resume}
- X GetDItem(BRDlogPtr, Resume, ItemType, Item, Box);
- X SetDItem(BRDlogPtr, Resume, ItemType + ItemDisable, Item, Box);
- X HiliteControl(ControlHandle(Item), 255);
- X
- X {Insert our text}
- X ParamText(Document.dName, PrintFiles[CurJob.PFNum].PFName, '', '');
- X ShowWindow(BRDlogPtr);
- X SelectWindow(BRDlogPtr); {Bring up our window}
- X PrintBackround; {Handle deactive for WriteWindow}
- X PrintBackround; {Handle Active for BRDlogPtr}
- X PrintBackround; {Handle Update for BRDlogPtr}
- X
- X {One Time Initialization}
- X GetDateTime(Secs);
- X Secs2Date(Secs, Date);
- X DateStr := Concat(NumToStr(Date.Month), '/', NumToStr(Date.day), '/', NumToStr(Date.year -
- X 1900));
- X TimeStr := Concat(NumToStr(Date.hour), ':', NumToStr(Date.minute), ':',
- X NumToStr(Date.second));
- X UIPros[TotUser].Total := NumPF;
- X
- X {Go through each PrintFile}
- X FOR X := CurJob.PFNum TO NumPF DO
- X WITH PrintFiles[X] DO
- X BEGIN
- X IF PrValidate(PgSetUp) THEN;
- X PgSetUp^^.prJob := PFJobRec; {Give PgSetup our job subrecord}
- X PrLoop := X; {Save the number of the PrintFile we are on}
- X TheStRec.iCurPage := 0; {Tell PrintBackround we are not printing yet}
- X
- X {Get the length of the PrintFile}
- X IF IOCheck(FSOpen(PFName, PFvRefNum, Dummy), 'DoPrint-FSOpen') THEN
- X GOTO 0001;
- X IF IOCheck(GetEOF(Dummy, UIPros[SPFUser].Total), 'DoPrint-GetEOF') THEN
- X GOTO 0001;
- X IF IOCheck(FSClose(Dummy), 'DoPrint-FSClose') THEN
- X GOTO 0001;
- X
- X ParamText(Document.dName, PFName, '', '');
- X
- X {Reset the user items}
- X GetPort(SavePort);
- X SetPort(BRDlogPtr);
- X FOR X2 := SPFUser TO PFPUser DO
- X UIPros[X2].Current := 0;
- X FOR X2 := TotUser TO PFPUser DO
- X BEGIN
- X GetDItem(BRDlogPtr, X2, ItemType, Item, Box);
- X InvalRect(Box);
- X END;
- X SetPort(SavePort);
- X
- X PrintBackround;
- X
- X IF PFTab = 0 THEN
- X NumSpacesInTab := 2
- X ELSE
- X NumSpacesInTab := PFTab;
- X
- X {Generate the space string to handle tabs}
- X SpaceStr := '';
- X FOR X2 := 1 TO NumSpacesInTab DO
- X SpaceStr := Concat(SpaceStr, ' ');
- X
- X IF X = CurJob.PFNum THEN
- X BEGIN
- X PgSetUp^^.prJob.iFstPage := CurJob.PFPageNum;
- X PgSetUp^^.prJob.iLstPage := MAXINT;
- X END;
- X
- X ThePrPort := PrOpenDoc(PgSetUp, NIL, NIL);
- X IF IOCheck(PrError, 'DoPrint-PROpenDoc') THEN
- X GOTO 0001;
- X
- X Open(F, PFName);
- X Reset(F);
- X Pg := CurJob.PFPageNum;
- X Done := False;
- X REPEAT
- X PrOpenPage(ThePrPort, NIL); {Open a new page}
- X IF IOCheck(PrError, 'DoPrint-PrOpenPage') THEN
- X BEGIN
- X Close(F);
- X GOTO 0001;
- X END;
- X
- X {you MDS Edit user's might have experianced it's little
- X problem of printing only half the page, well I think found it's
- X problem. It was getting the size of the page from the gPort's portRect
- X before it called PrOpenPage. Judging from this next hack any guesses on
- X how I figured it out?}
- X IF Pg = CurJob.PFPageNum THEN
- X BEGIN
- X FrameRect := ThePrPort^.gPort.PortRect;
- X
- X TextFont(PFFontNum);
- X TextSize(PFPtSize);
- X TextFace([]);
- X GetFontInfo(MPFontInfo);
- X WITH MPFontInfo DO
- X PFBaseLine := Ascent + Descent + Leading;
- X
- X TextFont(HFFontNum);
- X TextSize(HFPtSize);
- X TextFace([Bold]);
- X WITH MPFontInfo DO
- X HFBaseLine := Ascent + Descent + Leading;
- X
- X WITH FrameRect DO
- X BEGIN
- X IF Header <> '' THEN
- X LineStart := Top + 6 + HFBaseLine
- X ELSE
- X LineStart := Top;
- X Left := Left + Indent - 4;
- X IF Footer <> '' THEN
- X BEGIN
- X Bottom := Bottom - HFBaseLine - 6;
- X NumLines := (Bottom - 3 - LineStart) DIV PFBaseLine;
- X END
- X ELSE
- X NumLines := (Bottom - LineStart) DIV PFBaseLine;
- X END;
- X {Get the indent here so that the header and footer do not
- X change position as the page number increases}
- X HeaderStr := Header;
- X HeaderStr := ReplaceSubStr(HeaderStr, '(NAME)', PFName);
- X HeaderStr := ReplaceSubStr(HeaderStr, '(DATE)', DateStr);
- X HeaderStr := ReplaceSubStr(HeaderStr, '(TIME)', TimeStr);
- X HeaderStr := ReplaceSubStr(HeaderStr, '(PAGE)', NumToStr(Pg));
- X HeaderStr := ReplaceSubStr(HeaderStr, '(SET)', Document.dName);
- X HeaderIndent := (FrameRect.Right - FrameRect.Left - StringWidth(HeaderStr)) DIV
- X 2 + FrameRect.Left;
- X
- X FooterStr := Footer;
- X FooterStr := ReplaceSubStr(FooterStr, '(NAME)', PFName);
- X FooterStr := ReplaceSubStr(FooterStr, '(DATE)', DateStr);
- X FooterStr := ReplaceSubStr(FooterStr, '(TIME)', TimeStr);
- X FooterStr := ReplaceSubStr(FooterStr, '(PAGE)', NumToStr(Pg));
- X FooterStr := ReplaceSubStr(FooterStr, '(SET)', Document.dName);
- X FooterIndent := (FrameRect.Right - FrameRect.Left - StringWidth(FooterStr)) DIV
- X 2 + FrameRect.Left;
- X END;
- X {Get and draw Header}
- X HeaderStr := Header;
- X HeaderStr := ReplaceSubStr(HeaderStr, '(NAME)', PFName);
- X HeaderStr := ReplaceSubStr(HeaderStr, '(DATE)', DateStr);
- X HeaderStr := ReplaceSubStr(HeaderStr, '(TIME)', TimeStr);
- X HeaderStr := ReplaceSubStr(HeaderStr, '(PAGE)', NumToStr(Pg));
- X HeaderStr := ReplaceSubStr(HeaderStr, '(SET)', Document.dName);
- X MoveTo(HeaderIndent, HFBaseLine + 3);
- X TextFace([Bold]);
- X TextFont(HFFontNum);
- X TextSize(HFPtSize);
- X DrawString(HeaderStr);
- X TextFace([]);
- X
- X IF Border THEN {Draw a border}
- X WITH FrameRect DO
- X BEGIN
- X FrameRoundRect(FrameRect, 20, 20);
- X IF Header <> '' THEN
- X BEGIN
- X MoveTo(Left, LineStart);
- X LineTo(Right, LineStart);
- X END;
- X END;
- X
- X TextFont(PFFontNum);
- X TextSize(PFPtSize);
- X {Draw lines of page}
- X FOR CurrentLine := 1 TO NumLines DO
- X BEGIN
- X readln(F, TheLine);
- X
- X {Add the number of bytes processed so far and display it}
- X UIPros[SPFUser].Current := UIPros[SPFUser].Current + Length(TheLine);
- X GetPort(SavePort);
- X SetPort(BRDlogPtr);
- X BRDlogDrawItem(BRDlogPtr, SPFUser);
- X SetPort(SavePort);
- X PrintBackround;
- X
- X IF PrError = iPrAbort THEN
- X BEGIN
- X Close(F);
- X GOTO 0001;
- X END;
- X
- X MoveTo(Indent, CurrentLine * (PFBaseLine) + LineStart);
- X FOR Index := 1 TO Length(TheLine) DO
- X IF TheLine[Index] = CHR(9) THEN
- X DrawString(SpaceStr)
- X ELSE
- X DrawChar(TheLine[Index]);
- X
- X IF EOF(F) THEN {We are done}
- X BEGIN
- X Done := True;
- X LEAVE;
- X END;
- X END;
- X
- X {Get and draw Footer}
- X FooterStr := Footer;
- X FooterStr := ReplaceSubStr(FooterStr, '(NAME)', PFName);
- X FooterStr := ReplaceSubStr(FooterStr, '(DATE)', DateStr);
- X FooterStr := ReplaceSubStr(FooterStr, '(TIME)', TimeStr);
- X FooterStr := ReplaceSubStr(FooterStr, '(PAGE)', NumToStr(Pg));
- X FooterStr := ReplaceSubStr(FooterStr, '(SET)', Document.dName);
- X MoveTo(FooterIndent, FrameRect.Bottom + HFBaseLine + 3);
- X TextFace([Bold]);
- X TextFont(HFFontNum);
- X TextSize(HFPtSize);
- X DrawString(FooterStr);
- X TextFace([]);
- X
- X Pg := Pg + 1;
- X
- X PrClosePage(ThePrPort); {Close this page}
- X IF IOCheck(PrError, 'DoPrint-PrClosePage') THEN
- X BEGIN
- X Close(F);
- X GOTO 0001;
- X END;
- X UNTIL Done;
- X
- X Close(F); {Close the file}
- X PrCloseDoc(ThePrPort); {Close the print document}
- X IF IOCheck(PrError, 'DoPrint-PrCloseDoc') THEN
- X GOTO 0001;
- X
- X {Display a solid bar}
- X UIPros[SPFUser].Current := UIPros[SPFUser].Total;
- X GetPort(SavePort);
- X SetPort(BRDlogPtr);
- X BRDlogDrawItem(BRDlogPtr, SPFUser);
- X SetPort(SavePort);
- X
- X {If we spooled then print it}
- X IF (PgSetUp^^.prJob.bjDocLoop = bSpoolLoop) AND (PrError = noErr) THEN
- X BEGIN
- X PgSetUp^^.prJob.pIdleProc := @PrintBackround;
- X
- X IF X = CurJob.PFNum THEN
- X BEGIN
- X PgSetUp^^.prJob.iFstPage := CurJob.PFPageNum;
- X PgSetUp^^.prJob.iLstPage := MAXINT;
- X END;
- X
- X OldPage := - 1;
- X PrPicFile(PgSetUp, NIL, NIL, NIL, TheStRec);
- X IF PrError = iPrAbort THEN
- X GOTO 0001;
- X END;
- X
- X {Display solid bar}
- X UIPros[TotUser].Current := X;
- X UIPros[PFPUser].Current := UIPros[PFPUser].Total;
- X GetPort(SavePort);
- X SetPort(BRDlogPtr);
- X BRDlogDrawItem(BRDlogPtr, PFPUser);
- X SetPort(SavePort);
- X
- X IF IOCheck(PrError, 'After printing') THEN
- X LEAVE;
- X END;
- X
- X 0001:
- X {Display solid bar}
- X UIPros[TotUser].Current := UIPros[TotUser].Total;
- X GetPort(SavePort);
- X SetPort(BRDlogPtr);
- X GetDItem(BRDlogPtr, TotUser, ItemType, Item, Box);
- X BRDlogDrawItem(BRDlogPtr, TotUser);
- X SetPort(SavePort);
- X FOR X := 1 TO 1000 DO;
- X DisposDialog(BRDlogPtr);
- X END;
- X
- X {******************************************************************************}
- X {Display all PrintFiles}
- X {******************************************************************************}
- X
- X PROCEDURE DoDisplay;
- X
- X VAR
- X X : Integer;
- X
- X BEGIN
- X EraseWindow;
- X FOR X := 1 TO NumPF DO
- X WriteLn(Concat(NumToStr(X), ': ', PrintFiles[X].PFName));
- X END;
- X
- X {******************************************************************************}
- X {Remove a PrintFile}
- X {******************************************************************************}
- X
- X PROCEDURE DoDeleteFile;
- X
- X VAR
- X Num : Integer;
- X X : Integer;
- X
- X BEGIN
- X Num := GetFileNum('Delete');
- X IF (Num > 0) AND (Num <= NumPF) THEN
- X BEGIN
- X IF Num < NumPF THEN
- X FOR X := Num TO NumPF - 1 DO
- X PrintFiles[X] := PrintFiles[X + 1];
- X NumPF := NumPF - 1;
- X Document.Saved := False;
- X EnableItem(Menus[FileMenu], FMSaveSet);
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Get the PrintFile to change and put up the Print Managers JobDialog}
- X {******************************************************************************}
- X
- X PROCEDURE DoChangeFile;
- X
- X VAR
- X Num : Integer;
- X Dummy : Boolean;
- X
- X BEGIN
- X Num := GetFileNum('Change');
- X IF ((Num > 0) AND (Num <= NumPF)) THEN
- X BEGIN
- X Dummy := PrValidate(PgSetUp);
- X PgSetUp^^.prJob := PrintFiles[Num].PFJobRec;
- X PrJobPFNum := Num;
- X IF PrDlgMain(PgSetUp, @MPJobDlgInit) THEN
- X BEGIN
- X Document.Saved := False;
- X EnableItem(Menus[FileMenu], FMSaveSet);
- X END;
- X END;
- X END;
- X
- X {******************************************************************************}
- X {Display the header dialog}
- X {******************************************************************************}
- X
- X PROCEDURE DoHeader;
- X
- X VAR
- X HeaderDlog : DialogPtr;
- X ItemHit : Integer;
- X ItemType : Integer;
- X Item : Handle;
- X Box : Rect;
- X
- X BEGIN
- X HeaderDlog := GetNewDialog(HFDlgID, NIL, pointer( - 1));
- X SetPort(HeaderDlog);
- X GetDItem(HeaderDlog, 3, ItemType, Item, Box);
- X SetIText(Item, Header);
- X PenSize(3, 3);
- X GetDItem(HeaderDlog, Ok, ItemType, Item, Box);
- X InsetRect(Box, - 4, - 4);
- X FrameRoundRect(Box, 16, 16);
- X ModalDialog(NIL, ItemHit);
- X IF ItemHit = 1 THEN
- X BEGIN
- X GetDItem(HeaderDlog, 3, ItemType, Item, Box);
- X GetIText(Item, Header);
- X Document.Saved := False; {Document is now dirty}
- X EnableItem(Menus[FileMenu], FMSaveSet); {Enable save}
- X END;
- X DisposDialog(HeaderDlog);
- X END;
- X
- X {******************************************************************************}
- X {Display the footer dialog}
- X {******************************************************************************}
- X
- X PROCEDURE DoFooter;
- X
- X VAR
- X FooterDlog : DialogPtr;
- X ItemHit : Integer;
- X ItemType : Integer;
- X Item : Handle;
- X Box : Rect;
- X
- X BEGIN
- X FooterDlog := GetNewDialog(HFDlgID, NIL, pointer( - 1));
- X SetPort(FooterDlog);
- X GetDItem(FooterDlog, 3, ItemType, Item, Box);
- X SetIText(Item, Footer);
- X PenSize(3, 3);
- X GetDItem(FooterDlog, Ok, ItemType, Item, Box);
- X InsetRect(Box, - 4, - 4);
- X FrameRoundRect(Box, 16, 16);
- X ModalDialog(NIL, ItemHit);
- X IF ItemHit = 1 THEN
- X BEGIN
- X GetDItem(FooterDlog, 3, ItemType, Item, Box);
- X GetIText(Item, Footer);
- X Document.Saved := False; {Document is now dirty}
- X EnableItem(Menus[FileMenu], FMSaveSet); {Enable save}
- X END;
- X DisposDialog(FooterDlog);
- X END;
- X
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X{Application specific procedures and Functions}
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X
- X {******************************************************************************}
- X {Choose the appropriate procedure to carry of menu item selection}
- X {******************************************************************************}
- X
- X PROCEDURE ProcessMenu(CodeWord: LongInt);
- X
- X VAR
- X MenuNum : Integer;
- X ItemNum : Integer;
- X DAName : Str255;
- X Dummy : Integer;
- X AboutDlog : DialogPtr;
- X SaveReply : Integer;
- X
- X BEGIN
- X MenuNum := HiWord(CodeWord);
- X ItemNum := LoWord(CodeWord);
- X CASE MenuNum OF
- X AppleMenu:
- X IF ItemNum = AMAbout THEN
- X BEGIN
- X AboutDlog := GetNewDialog(AboutDlgID, NIL, pointer( - 1));
- X ModalDialog(NIL, Dummy);
- X CloseDialog(AboutDlog);
- X END
- X ELSE
- X BEGIN
- X GetItem(Menus[AppleMenu], ItemNum, DAName);
- X Dummy := OpenDeskAcc(DAName);
- X END;
- X FileMenu:
- X CASE ItemNum OF
- X FMSelectSet:
- X DoSelectSet;
- X FMOpenSet:
- X DoOpenSet;
- X FMCloseSet:
- X DoCloseSet;
- X FMSaveSet:
- X DoSaveSet;
- X FMPageSetUp:
- X DoPageSetup;
- X FMPrint:
- X DoPrint;
- X FMQuit:
- X BEGIN
- X SaveReply := AskForSave;
- X IF SaveReply <> MyCancel THEN
- X BEGIN
- X IF SaveReply = Yes THEN
- X DoSaveSet;
- X IF (Document.FRefNum <> 0) & IOCheck(FSClose(Document.FRefNum),
- X 'Close-FSClose') THEN
- X WriteLn('Could not close document correctly.');
- X IF IOCheck(FlushVol(NIL, Document.VRefNum), 'Close-FlushVol') THEN
- X WriteLn('Could not flush volume.');
- X Finished := True;
- X END;
- X END;
- X END;
- X EditMenu:
- X CASE ItemNum OF
- X 1..6:
- X IF NOT SystemEdit(ItemNum - 1) THEN;
- X EMDisplaySet:
- X DoDisplay;
- X EMAddFile:
- X DoSelectSet;
- X EMDeleteFile:
- X DoDeleteFile;
- X EMChangeFile:
- X DoChangeFile;
- X EMHeader:
- X DoHeader;
- X EMFooter:
- X DoFooter;
- X END;
- X END;
- X HiliteMenu(0);
- X END;
- X
- X {******************************************************************************}
- X {Get and processes events}
- X {******************************************************************************}
- X
- X PROCEDURE MainEventLoop;
- X
- X TYPE
- X TrickType = PACKED RECORD
- X CASE Boolean OF
- X True:
- X (I : LongInt);
- X False:
- X (chr3, chr2, chr1, chr0: Char);
- X END;
- X
- X VAR
- X Event : EventRecord;
- X WindowLoc : Integer;
- X MouseLoc : Point;
- X TheWindow : WindowPtr;
- X TrickVar : TrickType;
- X CharCode : Char;
- X X : Integer;
- X SavePort : GrafPtr;
- X
- X BEGIN
- X REPEAT
- X SystemTask;
- X IF GetNextEvent(everyEvent, Event) THEN
- X CASE Event.what OF
- X mouseDown:
- X BEGIN
- X MouseLoc := Event.where;
- X WindowLoc := FindWindow(MouseLoc, TheWindow);
- X CASE WindowLoc OF
- X inMenuBar:
- X ProcessMenu(MenuSelect(MouseLoc));
- X inSysWindow:
- X SystemClick(Event, TheWindow);
- X inContent, inDrag:
- X IF Write.WriteWindow = TheWindow THEN
- X SelectWindow(TheWindow);
- X END;
- X END;
- X keyDown, AutoKey:
- X BEGIN
- X TrickVar.I := Event.Message;
- X CharCode := TrickVar.chr0;
- X IF BitAnd(Event.modifiers, CmdKey) = CmdKey THEN
- X ProcessMenu(MenuKey(CharCode));
- X END;
- X UpdateEvt:
- X IF WindowPtr(Event.Message) = Write.WriteWindow THEN
- X WITH Write DO
- X BEGIN
- X GetPort(SavePort);
- X SetPort(WriteWindow);
- X BeginUpdate(WriteWindow);
- X FOR X := 1 TO CurrLine - 1 DO
- X BEGIN
- X MoveTo(2, X * LineHeight);
- X DrawString(WindowCont[X]);
- X END;
- X EndUpdate(WriteWindow);
- X SetPort(SavePort);
- X END;
- X ActivateEvt: {Don't worry about this bit of monstrosity}
- X IF WindowPtr(Event.Message) = Write.WriteWindow THEN
- X IF Odd(Event.modifiers) THEN
- X IF NumPF = 0 THEN
- X Menus[EditMenu]^^.enableFlags := EMWindActNF
- X ELSE
- X Menus[EditMenu]^^.enableFlags := EMWindActFO
- X ELSE IF NumPF = 0 THEN
- X Menus[EditMenu]^^.enableFlags := EMWindDctNF
- X ELSE
- X Menus[EditMenu]^^.enableFlags := EMWindDctFO;
- X END;
- X UNTIL (Finished);
- X END;
- X
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X{Initialization specific Procedures and Functions}
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X
- X {******************************************************************************}
- X {Used internally to init some junk}
- X {******************************************************************************}
- X
- X PROCEDURE _DataInit;
- X EXTERNAL;
- X
- X {******************************************************************************}
- X {Create the WriteWindow and display our little message}
- X {******************************************************************************}
- X
- X PROCEDURE InitWriteWindow;
- X
- X VAR
- X Bounds : Rect;
- X Info : FontInfo;
- X SavePort : GrafPtr;
- X
- X BEGIN
- X WITH Write DO
- X BEGIN
- X GetPort(SavePort);
- X SetRect(Bounds, 7, 40, 503, 338);
- X WriteWindow := NewWindow(NIL, Bounds, 'Multi-Print', True, 0, pointer( - 1), False, 0);
- X SetPort(WriteWindow);
- X TextFont(Monaco);
- X TextSize(9);
- X GetFontInfo(Info);
- X LineHeight := Info.Ascent + Info.Descent + Info.Leading;
- X MaxLine := ((Bounds.Bottom - Bounds.Top) DIV LineHeight) - 1;
- X IF MaxLine > 50 THEN
- X MaxLine := 50;
- X END;
- X EraseWindow;
- X WriteLn('Print was written by Brent Pease to demonstrate several "Advanced"');
- X WriteLn('programming techniques. It was also written to experiment with');
- X WriteLn('these techniques and see how well they worked out.');
- X WriteLn('');
- X WriteLn('The source code is available and should have been distributed');
- X WriteLn('with this program. It demonstrates:');
- X WriteLn('1) How to print using the Print Manager.');
- X WriteLn('2) How to print a lot of files.');
- X WriteLn('3) How to use the Print Managers backround processing.');
- X WriteLn('4) How to custimize the Standard File Package.');
- X WriteLn('5) User items in dialogs.');
- X WriteLn('6) Add items to an existing dialog');
- X WriteLn('7) Add items to the Print Managers Job Dialog.');
- X WriteLn('8) What you see is what you get!');
- X WriteLn('');
- X WriteLn('Please send me your comments and suggestions.');
- X WriteLn('');
- X WriteLn('Delphi -> SOCCERKING');
- X WriteLn('Brent Pease');
- X WriteLn('20 Lansing St.');
- X WriteLn('Hinsdale, IL 60521');
- X WriteLn('');
- X WriteLn('This program is 100% public domain, please pass it on.');
- X SetPort(SavePort);
- X END;
- X
- X {******************************************************************************}
- X {init page set up print record}
- X {******************************************************************************}
- X
- X PROCEDURE InitPage;
- X
- X BEGIN
- X PgSetUp := THPrint(NewHandle(SizeOf(TPrint)));
- X PrintDefault(PgSetUp);
- X HLock(Handle(PgSetUp));
- X END;
- X
- X {******************************************************************************}
- X {Create the menus}
- X {******************************************************************************}
- X
- X PROCEDURE SetUpMenu;
- X
- X VAR
- X Index : Integer;
- X
- X BEGIN
- X Menus[AppleMenu] := GetMenu(AppleMenu);
- X AddResMenu(Menus[AppleMenu], 'DRVR');
- X InsertMenu(Menus[AppleMenu], 0);
- X FOR Index := FileMenu TO EditMenu DO
- X BEGIN
- X Menus[Index] := GetMenu(Index);
- X InsertMenu(Menus[Index], 0);
- X END;
- X DrawMenuBar;
- X END;
- X
- X {******************************************************************************}
- X {Init the ToolBox}
- X {******************************************************************************}
- X
- X PROCEDURE Init;
- X
- X BEGIN
- X UnLoadSeg(@_DataInit);
- X InitGraf(@thePort);
- X MoreMasters;
- X MoreMasters;
- X MoreMasters;
- X InitFonts;
- X InitWindows;
- X InitMenus;
- X InitCursor;
- X InitDialogs(NIL);
- X FlushEvents(everyEvent, 0);
- X
- X InitPage;
- X InitWriteWindow;
- X
- X Finished := False;
- X BRDlogPtr := NIL;
- X Document.Saved := True;
- X Footer := 'Page #(PAGE)';
- X Header := 'Set: (SET) File: (NAME) Date: (DATE) Time: (TIME)';
- X END;
- X
- X {******************************************************************************}
- X {Open the files selected from the finder}
- X {******************************************************************************}
- X
- X PROCEDURE LookAppFiles;
- X
- X VAR
- X X : Integer;
- X Mess : Integer;
- X NumDocs : Integer;
- X TheAppFile : AppFile;
- X
- X BEGIN
- X CountAppFiles(Mess, NumDocs);
- X IF Mess = AppPrint THEN
- X FOR X := 1 TO NumDocs DO
- X BEGIN
- X GetAppFiles(X, TheAppFile);
- X OpenFile(TheAppFile.fName, TheAppFile.VRefNum);
- X DoPrint;
- X END
- X ELSE IF (Mess = AppOpen) AND (NumDocs >= 1) THEN
- X BEGIN
- X GetAppFiles(1, TheAppFile);
- X OpenFile(TheAppFile.fName, TheAppFile.VRefNum);
- X END
- X ELSE
- X BEGIN
- X NumPF := 0;
- X Document.FRefNum := 0;
- X Menus[FileMenu]^^.enableFlags := FMNoFileOpen;
- X Menus[EditMenu]^^.enableFlags := EMWindActNF;
- X END;
- X END;
- X
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X{MAIN}
- X{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- X
- X BEGIN
- X Init;
- X SetUpMenu;
- X LookAppFiles;
- X PrOpen;
- X IF PrError = noErr THEN
- X BEGIN
- X MainEventLoop;
- X PrClose;
- X END
- X ELSE
- X BEGIN
- X SysBeep(10);
- X WriteLn('Sorry, Print Manager is un-openable.');
- X WriteLn('Hey, its not my fault!(hee, hee, hee)');
- X WriteLn('Click button.');
- X REPEAT
- X UNTIL Button;
- X END;
- X END.
- ________This_Is_The_END________
- if test `wc -l < MultiPrintv1.p` -ne 1872; then
- echo 'shar: MultiPrintv1.p was damaged during transit'
- echo ' (should have been 1872 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting MultiPrintv1.r'
- if test -f MultiPrintv1.r; then echo 'shar: will not overwrite MultiPrintv1.r'; else
- sed 's/^X//' << '________This_Is_The_END________' > MultiPrintv1.r
- X/* MultiPrint.r
- X written by Brent Pease
- X copyright (c) 1987
- X*/
- X
- Xinclude "MPW Programs:MultiPrint:MultiPrintv1" 'CODE';
- XTYPE 'PRNT' AS 'STR ';
- X
- XRESOURCE 'PRNT' (0)
- X {"MultiPrint v1.0 written by Brent Pease. Copyright \2511987"};
- X
- XRESOURCE 'ICN#' (128)
- X {
- X {
- X $"001F F800 0010 1400 00FF DE00 0080 A200"
- X $"0080 9200 07FC F200 040A 1200 0409 1200"
- X $"040F 1200 0401 1200 0401 1200 0401 1200"
- X $"0401 1200 0401 1200 0401 1E00 0401 1000"
- X $"0401 1000 0401 F000 0401 0000 0401 0000"
- X $"07FF 0000 0000 0000 FFFF FFF8 9000 004E"
- X $"9FFF FFCE 8000 000E 8000 0008 8000 0008"
- X $"8000 0008 8000 0008 8000 0008 FFFF FFF8";
- X $"001F F800 001F FC00 00FF FE00 00FF FE00"
- X $"00FF FE00 07FF FE00 07FF FE00 07FF FE00"
- X $"07FF FE00 07FF FE00 07FF FE00 07FF FE00"
- X $"07FF FE00 07FF FE00 07FF FE00 07FF F000"
- X $"07FF F000 07FF F000 07FF 0000 07FF 0000"
- X $"07FF 0000 0000 0000 FFFF FFF8 FFFF FFFE"
- X $"FFFF FFFE FFFF FFFE FFFF FFF8 FFFF FFF8"
- X $"FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
- X }
- X };
- X
- XRESOURCE 'ICN#' (129)
- X {
- X {
- X $"001F F800 0010 1400 00FF DE00 0080 A200"
- X $"00F6 9E00 07FC F200 040A 1E00 0409 D200"
- X $"05CF 1E00 0401 5200 05F9 1600 0401 D200"
- X $"05D9 1A00 0401 7200 05B1 1E00 0401 1000"
- X $"05F9 1000 0401 F000 05DD 0000 0401 0000"
- X $"07FF 0000 0000 0000 FFFF FFF8 9000 004E"
- X $"9FFF FFCE 8000 000E 8000 0008 8000 0008"
- X $"8000 0008 8000 0008 8000 0008 FFFF FFF8";
- X $"001F F800 001F FC00 00FF FE00 00FF FE00"
- X $"00FF FE00 07FF FE00 07FF FE00 07FF FE00"
- X $"07FF FE00 07FF FE00 07FF FE00 07FF FE00"
- X $"07FF FE00 07FF FE00 07FF FE00 07FF F000"
- X $"07FF F000 07FF F000 07FF 0000 07FF 0000"
- X $"07FF 0000 0000 0000 FFFF FFF8 FFFF FFFE"
- X $"FFFF FFFE FFFF FFFE FFFF FFF8 FFFF FFF8"
- X $"FFFF FFF8 FFFF FFF8 FFFF FFF8 FFFF FFF8"
- X }
- X };
- X
- XRESOURCE 'FREF' (128)
- X {
- X 'APPL', 0, ""
- X };
- X
- XRESOURCE 'FREF' (129)
- X {
- X 'PRDC', 1, ""
- X };
- X
- XRESOURCE 'BNDL' (128)
- X {
- X 'PRNT', 0,
- X {
- X 'ICN#',
- X {
- X 0, 128;
- X 1, 129
- X };
- X 'FREF',
- X {
- X 0, 128;
- X 1, 129
- X }
- X }
- X };
- X
- XRESOURCE 'DITL' (129)
- X {
- X {
- X {32, 56, 48, 112},
- X Button {enabled, "Ok"};
- X
- X {32, 216, 48, 272},
- X Button {enabled, "Cancel"};
- X
- X {8, 8, 24, 304},
- X StaticText {disabled, "Enter the number of the PrintFile to ^0:"};
- X
- X {8, 312, 24, 344},
- X EditText {disabled, ""}
- X }
- X };
- X
- XRESOURCE 'DITL' (-4001) {
- X {
- X {138, 256, 156, 336},
- X Button {enabled, "Add"};
- X
- X {0, 571, 80, 589},
- X Button {enabled, "Hidden"};
- X
- X {163, 256, 181, 336},
- X Button {enabled, "Done"};
- X
- X {39, 232, 59, 347},
- X UserItem {disabled};
- X
- X {68, 256, 86, 336},
- X Button {enabled, "Eject"};
- X
- X {93, 256, 111, 336},
- X Button {enabled, "Drive"};
- X
- X {39, 12, 185, 230},
- X UserItem {enabled};
- X
- X {39, 229, 185, 246},
- X UserItem {enabled};
- X
- X {124, 252, 125, 340},
- X UserItem {disabled};
- X
- X {0, 532, 101, 628},
- X StaticText {disabled, ""};
- X
- X {188, 256, 206, 336},
- X Button {enabled, "Cancel"}
- X }
- X };
- X
- XRESOURCE 'DITL' (128)
- X {
- X {
- X {56, 8, 72, 64},
- X Button {enabled, "Yes"};
- X
- X {80, 8, 96, 64},
- X Button {enabled, "No"};
- X
- X {80, 80, 96, 136},
- X Button {enabled, "Cancel"};
- X
- X {8, 16, 40, 48},
- X Icon {enabled, 2};
- X
- X {8, 80, 72, 312},
- X StaticText {enabled,"Save changes to:\n^0"}
- X }
- X };
- X
- XRESOURCE 'DITL' (130)
- X {
- X {
- X {40, 40, 56, 96},
- X Button {enabled, "Ok"};
- X
- X {40, 160, 56, 216},
- X Button {enabled, "Cancel"};
- X
- X {8, 16, 24, 240},
- X StaticText {disabled,"Continue with current print job?"}
- X }
- X };
- X
- XRESOURCE 'DITL' (131)
- X {
- X {
- X {56, 168, 72, 224},
- X Button {enabled, "Stop"};
- X
- X {80, 168, 96, 224},
- X Button {enabled, "Cancel"};
- X
- X {56, 88, 72, 144},
- X Button {enabled, "Pause"};
- X
- X {80, 88, 96, 144},
- X Button {enabled, "Resume"};
- X
- X {104, 128, 120, 192},
- X StaticText {disabled, "Total job"};
- X
- X {153, 86, 169, 245},
- X StaticText {disabled, "Saving Current PrintFile"};
- X
- X {200, 80, 216, 248},
- X StaticText {Disabled, "Printing Current PrintFile"};
- X
- X {8, 8, 24, 304},
- X StaticText {disabled, "Currently printing set: ^0"};
- X
- X {33, 10, 49, 306},
- X StaticText {disabled, "Currently Printing PrintFile: ^1"};
- X
- X {128, 8, 144, 304},
- X UserItem {disabled};
- X
- X {176, 8, 192, 304},
- X UserItem {disabled};
- X
- X {224, 8, 240, 304},
- X UserItem {Disabled}
- X }
- X };
- X
- XRESOURCE 'DITL' (132)
- X {
- X {
- X {142, 212, 165, 299}, Button {enabled, "Okay"};
- X {7, 82, 25, 283}, StaticText {disabled,
- X "The Developers At Large Group"};
- X {32, 152, 48, 216}, StaticText {disabled, "Present's"};
- X {56, 144, 72, 224}, StaticText {disabled, "Multi-Print"};
- X {96, 8, 128, 368}, StaticText {disabled,
- X "Written by Brent Pease. Copyright \251 1987"
- X " by The Developer's At Large Group. All "
- X "rights reserved."};
- X {112, 154, 132, 214}, Icon {enabled, 128}
- X }
- X };
- X
- XRESOURCE 'DITL' (133)
- X {
- X {
- X {8, 8, 24, 112},
- X CheckBox {enabled, "Draw Border"};
- X
- X {8, 216, 24, 248},
- X EditText {disabled, ""};
- X
- X {40, 120, 56, 264},
- X EditText {disabled, ""};
- X
- X {64, 120, 80, 176},
- X EditText {disabled, ""};
- X
- X {96, 160, 112, 304},
- X EditText {enabled, ""};
- X
- X {120, 160, 136, 216},
- X EditText {enabled, ""};
- X
- X {8, 176, 24, 208},
- X StaticText {enabled, "Tab:"};
- X
- X {40, 8, 56, 104},
- X StaticText {enabled, "PrintFile Font"};
- X
- X {64, 8, 80, 104},
- X StaticText {enabled, "PrintFile Size"};
- X
- X {96, 8, 112, 144},
- X StaticText {enabled, "Header/Footer Font"};
- X
- X {120, 8, 136, 144},
- X StaticText {enabled, "Header/Footer Size"}
- X }
- X };
- X
- XRESOURCE 'DITL' (134, preload)
- X {
- X {
- X {76, 160, 96, 220}, Button {enabled, "Okay"};
- X {77, 267, 97, 327}, Button {enabled, "Cancel"};
- X {12, 11, 28, 467}, EditText {disabled, ""};
- X {36, 7, 70, 469}, StaticText {disabled,
- X "The strings \"(NAME)\" \"(PAGE)\" \"(DATE)\" o"
- X "r \"(TIME)\" will be replaced at print tim"
- X "e with the coresponding entity."}
- X }
- X };
- X
- XRESOURCE 'DLOG' (-4001)
- X {
- X {54, 66, 279, 414},
- X dBoxProc,
- X invisible,
- X noGoAway,
- X 0x0,
- X -4001,
- X ""
- X };
- X
- XRESOURCE 'DLOG' (129)
- X {
- X {58, 74, 114, 424},
- X dBoxProc,
- X inVisible,
- X noGoAway,
- X 0x0,
- X 129,
- X ""
- X };
- X
- XRESOURCE 'DLOG' (128)
- X {
- X {104, 102, 204, 414},
- X dBoxProc,
- X inVisible,
- X goAway,
- X 0x0,
- X 128,
- X ""
- X };
- X
- XRESOURCE 'DLOG' (130)
- X {
- X {60, 136, 120, 384},
- X dBoxProc,
- X visible,
- X goAway,
- X 0x0,
- X 130,
- X ""
- X };
- X
- XRESOURCE 'DLOG' (131)
- X {
- X {58, 102, 302, 410},
- X dBoxProc,
- X invisible,
- X goAway,
- X 0x0,
- X 131,
- X ""
- X };
- X
- XRESOURCE 'DLOG' (132, preload)
- X {
- X {78, 78, 261, 436},
- X dBoxProc,
- X visible,
- X goAway,
- X 0x0,
- X 132,
- X ""
- X };
- X
- XRESOURCE 'DLOG' (134, preload)
- X {
- X {108, 14, 222, 496},
- X documentProc,
- X visible,
- X noGoAway,
- X 0x0,
- X 134,
- X "Header"
- X };
- X
- XRESOURCE 'MENU' (1, preload)
- X {
- X 1,
- X textMenuProc,
- X 0x7FFFFFFD,
- X enabled,
- X apple,
- X {
- X "About Print Demo...", noIcon, noKey, noMark, plain;
- X "-", noIcon, noKey, noMark, plain
- X }
- X };
- X
- XRESOURCE 'MENU' (2, preload)
- X {
- X 2,
- X textMenuProc,
- X 0B1111111111111111111111011011011,
- X enabled,
- X "File",
- X {
- X "Select Set", noIcon, "N", noMark , plain;
- X "Open Set", noIcon, "O", noMark, plain;
- X "-", noIcon, noKey, noMark, plain;
- X "Close Set",noIcon,"C",noMark,plain;
- X "Save Set",noIcon,"S",noMark,plain;
- X "-",noIcon,noKey,noMark,plain;
- X "Page Setup", noIcon, noKey, noMark, plain;
- X "Print", noIcon, "P", noMark, plain;
- X "-", noIcon, noKey, noMark, plain;
- X "Quit", noIcon, "Q", noMark, plain
- X }
- X };
- X
- XRESOURCE 'MENU' (3, preload)
- X {
- X 3,
- X textMenuProc,
- X 0B1111111111111111110111010111101,
- X enabled,
- X "Edit",
- X {
- X "Undo", noIcon, "Z", noMark, plain;
- X "-", noIcon, noKey, noMark, plain;
- X "Cut", noIcon, "X", noMark, plain;
- X "Copy", noIcon, "C", noMark, plain;
- X "Paste", noIcon, "V", noMark, plain;
- X "Clear", noIcon, noKey, noMark, plain;
- X "-", noIcon, noKey, noMark, plain;
- X "Display Set", noIcon, "D",noMark, plain;
- X "-", noIcon, noKey, noMark, plain;
- X "Add a PrintFile", noIcon, noKey, noMark, plain;
- X "Delete a PrintFile", noIcon, noKey, noMark, plain;
- X "Change a PrintFile", noIcon, noKey, noMark, plain;
- X "-", noIcon, noKey, noMark, plain;
- X "Header", noIcon, "H", noMark, plain;
- X "Footer", noIcon, "F", noMark, plain
- X }
- X };
- X
- X
- X
- ________This_Is_The_END________
- if test `wc -l < MultiPrintv1.r` -ne 417; then
- echo 'shar: MultiPrintv1.r was damaged during transit'
- echo ' (should have been 417 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting Multiprintv1.c'
- if test -f Multiprintv1.c; then echo 'shar: will not overwrite Multiprintv1.c'; else
- sed 's/^X//' << '________This_Is_The_END________' > Multiprintv1.c
- X/* MultiPrint.c Written by Brent Pease
- X add items to a existing DLOG */
- X#include <dialogs.h>
- X#include <types.h>
- X#include <resources.h>
- X#include <memory.h>
- X#include <controls.h>
- X
- Xpascal short AddItems(theDialog, resID)
- X DialogRecord *theDialog;
- X short resID;
- X
- X {
- X struct {
- X short dlgMaxIndex; /* number of items minus one */
- X struct DITLItem {
- X Handle itmHdnl;
- X Rect itmRect;
- X unsigned char itmType;
- X unsigned char itmData[];
- X } items[];
- X } **hDITL = GetResource('DITL',resID), **hItems = theDialog->items;
- X /* hDITL is a handle to the items to add on
- X hItems is a handle to the dialogs items */
- X
- X /* pItem holds a pointer to the current item we are working one */
- X register struct DITLItem *pItem = &(*hDITL)->items;
- X Rect maxRect, /* maxRect holds the size of the Dialogs window */
- X DummyRect; /* Dummy rect holds the rect of our Dummy dialog */
- X Point offset; /* offset every item in hDITL by this */
- X register short x;
- X DialogPtr DummyDialog;
- X /* PtrArth is used to override C's not so often convient Pointer Arthmitic */
- X register int PtrArth;
- X ControlHandle nControl, lControl;
- X
- X /* init some garbage */
- X maxRect = theDialog->window.port.portRect;
- X SetPt(&offset,0,maxRect.bottom); SetRect(&DummyRect,0,0,10,10);
- X maxRect.bottom -= 5; maxRect.right -= 5;
- X
- X /* offset every item in hDITL and add it to maxRect */
- X for(x=0;x<=(*hDITL)->dlgMaxIndex;x++) {
- X OffsetRect(&pItem->itmRect,offset.h,offset.v);
- X UnionRect(&pItem->itmRect,&maxRect,&maxRect);
- X PtrArth = pItem; /* I hate pointer arithmetic sometimes */
- X PtrArth += ((pItem->itmData[0] + 1) & 65534) + sizeof(struct DITLItem);
- X pItem = PtrArth; /* would'n it be nice if you could say ((int) pItem) += */
- X }
- X
- X /* find the last control for theDialog */
- X nControl = (lControl = theDialog->window.controlList);
- X while(nControl) {
- X lControl = nControl; nControl = (*nControl)->nextControl;
- X }
- X
- X /* Build the item list and control list then add it to hItems and theDialog */
- X DummyDialog = NewDialog(0,&DummyRect,'',false,0,-1,false,0,hDITL);
- X (*lControl)->nextControl = DummyDialog->window.controlList;
- X DummyDialog->window.controlList = 0; ((DialogPeek) DummyDialog)->items = 0;
- X DisposDialog(DummyDialog);
- X PtrAndHand(&(*hDITL)->items,hItems,GetHandleSize(hDITL)-2);
- X
- X /* Get the offset to our first items new position in theDialog */
- X x = (*hItems)->dlgMaxIndex+1;
- X (*hItems)->dlgMaxIndex += (*hDITL)->dlgMaxIndex+1;
- X ReleaseResource(hDITL);
- X
- X /* Give all the controls a new owner */
- X nControl = (*lControl)->nextControl;
- X while(nControl) {
- X (*nControl)->contrlOwner = theDialog; nControl = (*nControl)->nextControl;
- X }
- X
- X maxRect.bottom += 5; maxRect.right += 5;
- X SizeWindow(theDialog,maxRect.right,maxRect.bottom,true);
- X
- X return x;
- ________This_Is_The_END________
- if test `wc -l < Multiprintv1.c` -ne 78; then
- echo 'shar: Multiprintv1.c was damaged during transit'
- echo ' (should have been 78 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting Multiprintv1.mf'
- if test -f Multiprintv1.mf; then echo 'shar: will not overwrite Multiprintv1.mf'; else
- sed 's/^X//' << '________This_Is_The_END________' > Multiprintv1.mf
- XLibs = "{Libraries}Interface.o" [line continuation symbol]
- X "{PLibraries}PasLib.o" [line continuation symbol]
- X "{CLibraries}CRuntime.o" [line continuation symbol]
- X "{Plibraries}SANELib.o" [line continuation symbol]
- X "{CLibraries}CInterface.o"
- X
- XLinkOpts = -l -w
- X
- X"{CurProgPath}" [dependency symbol][dependency symbol] "{CurProgPath}".p.o "{CurProgPath}".c.o
- X LINK {LinkOpts} "{CurProgPath}.p.o" "{CurProgPath}".c.o {Libs} [line continuation symbol]
- X -o "{CurProgPath}" [redirect stderr symbol] "{CurProgPath}.l.err" [line continuation symbol]
- X > "{CurProgPath}.map" || (OPEN "{CurProgPath}.l.err"; Exit 99)
- X
- X"{CurProgPath}".p.o [dependency symbol] "{CurProgPath}".p
- X PASCAL -o "{PDir}" "{CurProgPath}.p" [redirect stderr symbol] "{CurProgPath}.p.err" [line continuation symbol]
- X || (OPEN "{CurProgPath}.p.err"; Exit 99)
- X
- X"{CurProgPath}".c.o [dependency symbol] "{CurProgPath}".c
- X C -w -o "{PDir}" "{CurProgPath}".c [redirect stderr symbol] "{CurProgPath}.c.err" [line continuation symbol]
- X || (OPEN "{CurProgPath}.c.err"; Exit 99)
- X
- X"{CurProgPath}" [dependency symbol][dependency symbol] "{CurProgPath}".r
- X REZ Types.r "{CurProgPath}.r" -o "{CurProgPath}.temp" [redirect stderr symbol] "{CurProgPath}.r.err" [line continuation symbol]
- X || (OPEN "{CurProgPath}.r.err"; Exit 99)
- X RENAME -y "{CurProgPath}.temp" "{CurProgPath}"
- ________This_Is_The_END________
- if test `wc -l < Multiprintv1.mf` -ne 25; then
- echo 'shar: Multiprintv1.mf was damaged during transit'
- echo ' (should have been 25 bytes)'
- fi
- fi ; : end of overwriting check
- exit 0
-