TweetFollow Us on Twitter

PREC Resource
Volume Number:5
Issue Number:8
Column Tag:Pascal Procedures

Related Info: Resource Manager Print Manager List Manager

A Look At The PREC Resource

By Dave Kelly, MacTutor Editorial Board

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

As we all know the Apple ImageWriter printer has taken a back seat over the past several years to the LaserWriter. Most of us prefer Laser quality printing to that of the ImageWriter. However, another reality is the extra cost of the LaserWriter.

A quick look back in history reminds us that there are some previsions in the ImageWriter drivers which allow applications to “own” their own page sizes. This facility is brought to use by way of the PREC resource. In particular, the driver itself uses PREC resource ID=3 for the page size definitions as a default. If an application contains a PREC resource with ID=4 these size definitions take precedence. This may be old news to most of us, but it doesn’t seem to be well documented anywhere. The only place I found information about this was in some old notes from April, 1985. The Macintosh Technical notes don’t give any indication about this subject.

A sample RMaker source defining a PREC 4 resource that encodes the default configuration of the Page Setup Dialog is:

Type PREC = GNRL
*Paper size info -- localizable, customizable.
 ,4
 .I
*Number of paper-size buttons used (max is 6):
5
*6 paper sizes in 120ths (decimal!):
*1st number is vertical, 2nd is horizontal.
*First button: 8.5 X 11"  ‘US letter’ paper
1320
1020
*Second button: 8.25 X 11.66" ‘A4 letter’
1400
990
*Third button:  8.5 X 14"  ‘US legal’ paper
1680
1020
*4th button:8.25 X 12" ‘international fanfold’
1440
990
*Fifth button: 14 X 11"  ‘computer paper’
1320
1680
*Sixth button: - not visible
0
0
 .P
*Titles for six buttons.
US Letter
A4 Letter
US Legal
International Fanfold
Computer Paper
?

*The blank line just above this one is necessary!

One easy way of creating this type of resource is with RMaker. It may not be very convenient for non-programmers to create the resource without help. The Pascal application included here allows editing and creation of the PREC 4 resource. Handling the resource is not too difficult although there are a couple of things you need to know to manipulate the structure.

1. The type PREC is reserved for use by the Macintosh print driver. It should not be used in any other way than described here and not with any other resource ID other than 4. The PREC 3 resource in the printer driver itself could be modified although is not recommended.

2. Exactly six buttons must be defined in the PREC 4 resource even if you are not using all the buttons. One character titles should be used for unused buttons.

3. All PREC 4 numbers are in decimal.

4. The first item in the PREC resource is the number of buttons to be displayed, a word-size integer. Whatever number is used here will be used by the printer driver to determine the number of items in the Page Setup dialog. If you use a number greater than six you are in big trouble.

5. The dimensions follow next as an array of six pairs of integers. Each pair of numbers corresponds to the paper sizes with the first integer in each pair as the height and the second integer as the width. These numbers are given in 120ths of an inch.

6. The remainder of the data is presented as an array of variable length Pascal strings. To get to each string, these strings need to be handled as a byte or char array. The first byte is the length of the first string which is followed by the first string, followed by the length of the second string, and so forth.

I credit my assistant, Prototyper for the shell of this program with the necessary additions added for loading, saving and manipulating the PREC 4 resource. The List Manager is used to display and select the 6 possible buttons.

With all this said and done, it is good to note that Apple has announced that with System 7.0, spooling will be supported for all printers, not just the LaserWriter. Personally, I use the AppleTalk ImageWriter driver with 2 Macs wishing that the background printing was supported with the current system.

unit globals;

interface
 var
 MyWindow: WindowPtr;     {Window pointer}
 TitleFieldhndl: TEHandle;  {Text Edit field handle}
 WidthFieldhndl: TEHandle;  {Text Edit field handle}
 HeightFieldhndl: TEHandle;   {Text Edit field handle}
 reply: SFReply;
 type
 realprec = record
 numberofbuttons: signedbyte;
 Size: array[1..6] of point;
 title: packed array[0..255] of char;
 end;
 realprec4ptr = ^realprec;
 realprec4hndl = ^realprec4ptr;
 prec = record
 numberofbuttons: integer;
 Size: array[1..6] of point;
 Title: array[1..6] of str255;
 end;
 prec4ptr = ^prec;
 prec4hndl = ^prec4ptr;
 var
 therealprec4: realprec;
 therealprec4hndl: realprec4hndl;
 prec4: prec;
 theprec4hndl: prec4hndl;
implementation
end.

unit  InitTheMenus;
{File name:  InitTheMenus.p}
{Function: Pull in menu lists from a resource file.}
{   This procedure is called once at program start.}
{   AppleMenu is the handle to the Apple menu, it is also}
{   used in the procedure that handles menu events.}
{History: 6/10/89 Original by Prototyper.   }

interface
 procedure Init_My_Menus;     {Initialize the menus}
 var
 AppleMenu:MenuHandle;    {Menu handle}
 M_File:MenuHandle;  {Menu handle}
 M_Edit:MenuHandle;  {Menu handle}
implementation
 procedure Init_My_Menus;     {Initialize the menus}
 const
 Menu1 = 1001;   {Menu resource ID}
 Menu2 = 1002;   {Menu resource ID}
 Menu3 = 1003;   {Menu resource ID}
 begin    {Start of Init_My_Menus}
 ClearMenuBar;   {Clear any old menu bars}
 AppleMenu := GetMenu(Menu1);{Get the menu}
 InsertMenu (AppleMenu,0);    {Insert this menur}
 AddResMenu(AppleMenu,’DRVR’);{Add in DAs}
 M_File := GetMenu(Menu2);    {Get the menu}
 InsertMenu (M_File,0);   {Insert this menu}
 M_Edit := GetMenu(Menu3);    {Get the menu}
 InsertMenu (M_Edit,0);   {Insert this menu}
 DrawMenuBar;    {Draw the menu bar}
end;    {End of procedure Init_My_Menus}
end.    {End of this unit}

unit About;
{File name:  About.p  }
{Function: Handle a dialog}
{History: 6/10/89 Original by Prototyper.   }

interface
 procedure D_About;
implementation
 const  {These are item numbers for controls in the Dialog}
 I_OK = 1;
 I_x = 2;
 I_Icon6 = 3;
 var
 ExitDialog: boolean;     {Flag used to exit the Dialog}
 DoubleClick: boolean;    {Flag a double click on list}
 MyPt: Point;    {Current list selection point}
 MyErr: OSErr;   {OS error returned}

{===========================================================}
 function MyFilter (theDialog: DialogPtr; var theEvent: EventRecord; 
var itemHit: integer): boolean;
 var
 tempRect: Rect;
 begin
 MyFilter := FALSE;
 if (theEvent.what = MouseDown) then{Only do on a mouse click}
 begin
 MyPt := theEvent.where;{Get the point where the mouse was clicked}
 GlobalToLocal(MyPt);     {Convert global to local}
 end;
 end;

{===========================================================}
 procedure D_About;
 var
 GetSelection: DialogPtr;{Pointer to this dialog}
 tempRect: Rect;     {Temporary rectangle}
 DType: Integer;     {Type of dialog item}
 Index: Integer;     {For looping}
 DItem: Handle;  {Handle to the dialog item}
 CItem, CTempItem: controlhandle;{Control handle}
 sTemp: Str255;  {Get text entered, temp holding}
 itemHit: Integer;   {Get selection}
 temp: Integer;  {Get selection, temp holding}
 dataBounds: Rect;   {Rect to setup the list}
 cSize: Point;   {Pointer to a cell in a list}
 Icon_Handle: Handle; {Temp handle to read an Icon into}
 NewMouse: Point; {Mouse loc during tracking Icon}
 InIcon: boolean;    {Flag to say pressed in an Icon}
 ThisEditText: TEHandle; {Handle to get Dialogs TE rec}
 TheDialogPtr: DialogPeek;{Ptr to Dialogs definition record, contains 
the TE record}
 {This is an update routine for non-controls in the dialog}
 {This is executed after the dialog is uncovered by an alert}
 procedure Refresh_Dialog;{Refresh dialogs non-controls}
 var
 rTempRect: Rect;  {Temp rectangle used for drawing}
 begin
 SetPort(GetSelection);   {Point to our dialog window}
 GetDItem(GetSelection, I_OK, DType, DItem, tempRect);{Get the item handle}
 PenSize(3, 3); {Change pen to draw default outline}
 InsetRect(tempRect, -4, -4);
 FrameRoundRect(tempRect, 16, 16); {Draw the outline}
 PenSize(1, 1); {Restore pen size to the default value}
 end;
 begin    {Start of dialog handler}
 GetSelection := GetNewDialog(2, nil, Pointer(-1));
 {Bring in the dialog resource}
 ShowWindow(GetSelection);{Open a dialog box}
 SelectWindow(GetSelection);{Lets see it}
 SetPort(GetSelection);   {Prepare to add conditional text}
 TheDialogPtr := DialogPeek(GetSelection);
 ThisEditText := TheDialogPtr^.textH;{Get to the TE record}
 HLock(Handle(ThisEditText));{Lock it for safety}
 ThisEditText^^.txSize := 12;{TE Point size}
 TextSize(12);   {Window Point size}
 ThisEditText^^.txFont := systemFont;{TE Font ID}
 TextFont(systemFont);    {Window Font ID}
 ThisEditText^^.txFont := 0;{TE Font ID}
 ThisEditText^^.fontAscent := 12;{Font ascent}
 ThisEditText^^.lineHeight := 12 + 3 + 1;{Font ascent + descent + leading}
 HUnLock(Handle(ThisEditText));{UnLock handle when done}
 {Setup initial conditions}
 Refresh_Dialog; 
 ExitDialog := FALSE;{Do not exit dialog handle loop yet}
 repeat   {Start of dialog handle loop}
 ModalDialog(nil, itemHit);{Wait until an item is hit}
 GetDItem(GetSelection, itemHit, DType, DItem, tempRect);{Get item information}
 CItem := Pointer(DItem);{Get the control handle}
 {Handle it real time}
 if (ItemHit = I_OK) then
 begin
 {?? Code to handle this button goes here}
 ExitDialog := TRUE;
 Refresh_Dialog;
 end;     {End for this item selected}
 if (ItemHit = I_Icon6) then{Handle the Icon}
 begin
 Icon_Handle := GetIcon(10032);
 if (Icon_Handle <> nil) then
 begin  {Get ready to plot the hilighted icon}
 EraseRect(tempRect);{Erase the original icon}
 PlotIcon(tempRect, Icon_Handle);
 end;     {End of drawing hilighted icon}
 InIcon := TRUE;{Flag as mouse in the Icon}
 repeat   {Start of mouse tracking routine}
 GetMouse(NewMouse);{Get latest mouse position}
 if (PtInRect(NewMouse, tempRect)) then
 begin    {...yes, over the Icon}
 if not (InIcon) then
 begin{...yes, so it is unhilighted}
 Icon_Handle := GetIcon(10032);
 if (Icon_Handle <> nil) then
 begin{...yes, have hilighted Icon}
 EraseRect(tempRect);
 PlotIcon(tempRect, Icon_Handle);{Draw the hilighted icon}
 end;{End of Draw the hilighted icon}
 InIcon := TRUE;
 end;{}
 end    {}
 else if InIcon then{Then draw unhilighted Icon}
 begin    {Start drawing unhilighted Icon}
 Icon_Handle := GetIcon(32);
 if (Icon_Handle <> nil) then
 begin{...yes, have hilighted Icon}
 EraseRect(tempRect);{Erase hilited icon}
 PlotIcon(tempRect, Icon_Handle);{Draw the standard icon}
 end;{End of Draw the icon}
 InIcon := FALSE;
 end;     {}
 until not (StillDown);
 if (PtInRect(NewMouse, tempRect)) then
 begin    {...yes, released in the Icon}
 Refresh_Dialog;
 end;     {End of released in the Icon}
 Icon_Handle := GetIcon(32);
 if (Icon_Handle <> nil) then
 begin    {...yes, have hilighted Icon}
 EraseRect(tempRect);{Erase the hilighted icon}
 PlotIcon(tempRect, Icon_Handle);
 end;     {End of Draw the icon}
 end;     {End for this item selected}
 until ExitDialog; {Handle dialog items until exit}
 {Get results after dialog}
 DisposDialog(GetSelection);{Flush dialog out of memory}
 end;     {End of procedure}
end.    {End of unit}

unit TEConvert;
{General utilities for conversion between TextEdit and strings}
   { see Macintosh Technical note #18 }
interface
{    uses}
{    MemTypes, QuickDraw, OSIntf, ToolIntf;}
 procedure TERecToStr (hTE: TEHandle; var str: Str255);
{TERecToStr converts the TextEdit record hTE to string str.}
{If necessary, the text will be truncated to 255 characters.}
 procedure StrToTERec (str: Str255; hTE: TEHandle);
{StrToTERec converts the string str to TextEdit record hTE. }
implementation
 procedure TERecToStr (hTE: TEHandle; var str: Str255);
 begin
 GetIText(hTE^^.hText, str);
 end;
 procedure StrToTERec (str: Str255; hTE: TEHandle);
 begin
 TESetText(POINTER(ORD4(@str) + 1), ORD4(length(str)), hTE);
 end;
end.

unit Options;
{File name: Options.p}
{Function: Handle a Window}
{History: 6/10/89 Original by Prototyper.   }
interface
 uses
 globals, FixMath, TEConvert;
 procedure preparewidth (i: integer);
 procedure prepareheight (i: integer);
 procedure SetFields;
 procedure SetDefaultPREC;
 {Initialize us so all our routines can be activated}
 procedure Init_Options;
 {Record status of all edit fields & buttons and update list}
 procedure Recordstatus;
 {Close our window}
 procedure Close_Options (whichWindow: WindowPtr; var theInput: TEHandle);
 {Open our window and draw everything}
 procedure Open_Options (var theInput: TEHandle);
 {Update our window, someone uncovered a part of us}
 procedure Update_Options (whichWindow: WindowPtr);
 {Handle action to our window, like controls}
 procedure Do_Options (myEvent: EventRecord; var theInput: TEHandle);
implementation
 const
 TitleFieldid = 23;  {Edit text ID}
 WidthFieldid = 24;  {Edit text ID}
 HeightFieldid = 25;      {Edit text ID}
 var
 tempRect, temp2Rect: Rect;   {Temporary rectangle}
 Index: Integer;     {For looping}
 CtrlHandle: ControlHandle; {Control handle}
 sTemp, sTemp1: Str255; {Get text entered, temp holding}
 List_I_Titles: ListHandle;   {List Manager list handle}
 Rect_I_Titles: Rect;     {List Manager list rectangle}
 dataBounds: Rect;   {For use by lists}
 cSize: Point;   {For use by lists}
 theRow: integer;    {Used for adding rows to lists}
 num: extended;
 fixednum: Fixed;
 theCell: Cell;

{=================================}
 procedure SetTeWidth (i: integer);
 begin
 num := PREC4.size[i].h / 120;
 fixednum := X2Fix(num);
 NumToString(HiWord(Fixednum), sTemp);
 num := (num - Hiword(Fixednum)) * 100;
 fixednum := X2Fix(num);
 NumToString(HiWord(Fixednum), sTemp1);
 sTemp := concat(sTemp, ‘.’, sTemp1);
 TESetText(Pointer(Ord4(@sTemp) + 1), length(sTemp), WidthFieldhndl);{Place 
default text in the TE area}
 SetRect(TempRect, 220, 82, 270, 102);{left,top,right,bottom of WidthField 
Rectangle}
 TEUpdate(TempRect, WidthFieldhndl);
 end;

{=================================}
 procedure SetTeHeight (i: integer);
 begin
 num := PREC4.size[i].v / 120;
 fixednum := X2Fix(num);
 NumToString(HiWord(Fixednum), sTemp);
 num := (num - Hiword(Fixednum)) * 100;
 fixednum := X2Fix(num);
 NumToString(HiWord(Fixednum), sTemp1);
 sTemp := concat(sTemp, ‘.’, sTemp1);
 TESetText(Pointer(Ord4(@sTemp) + 1), length(sTemp), HeightFieldhndl);{Place 
default text in the TE area}
 SetRect(TempRect, 326, 82, 376, 102);{left,top,right,bottom of HeightField 
Rectangle}
 TEUpdate(TempRect, HeightFieldhndl);
 end;

{=================================}
 procedure SetFields;
 var
 i, datalen: integer;
 begin
 for i := 6 downto 1 do
 begin
 dataLen := length(PREC4.Title[i]);
 cSize.v := i - 1;
 LSetCell(Pointer(ord(@PREC4.Title[i]) + 1), dataLen, cSize, List_I_Titles);
 {Set string in row }
 LSetSelect(false, cSize, List_I_Titles);
 end;
 SetTeWidth(1);
 SetTeHeight(1);
 TESetText(Pointer(Ord4(@PREC4.Title[1]) + 1), length(PREC4.Title[1]), 
TitleFieldhndl);
 {default text in the TE area}
 SetRect(TempRect, 220, 40, 380, 62);
 TEUpdate(TempRect, TitleFieldhndl);
 LSetSelect(true, cSize, List_I_Titles);
 end;

{=================================}
 procedure SetDefaultPREC;
 begin
 with prec4 do
 begin
 numberofbuttons := 5;
 Size[1].v := 1320;{ 11.0"}
 Size[1].h := 1020;{ 8.50"}
 Size[2].v := 1400;{ 11.66" }
 Size[2].h := 990; { 8.25"}
 Size[3].v := 1680;{ 14.0"}
 Size[3].h := 1020;{ 8.50"}
 Size[4].v := 1440;{ 14.0"}
 Size[4].h := 990; { 8.50"}
 Size[5].v := 1320;{ 14.0"}
 Size[5].h := 1680;{ 8.50"}
 Size[6].v := 0; { undefined}
 Size[6].h := 0; { undefined}
 Title[1] := ‘US Letter’;
 Title[2] := ‘A4 Letter’;
 Title[3] := ‘US Legal’;
 Title[4] := ‘International Fanfold’;
 Title[5] := ‘Computer Paper’;
 Title[6] := ‘?’;
 end;
 setFields;
 SetWTitle(MyWindow, ‘Page Option Defaults’);
 end;

{=================================}
 {Initialize us so all our routines can be activated}
 procedure Init_Options;
 begin    {Start of Window initialize routine}
 MyWindow := nil; 
 {Make sure other routines know we are not valid yet}
 end;     {End of procedure}

{=================================}
{Record status of all edit fields & buttons and update list}
 procedure Recordstatus;
 var
 i, datalen: integer;
 tempnumber: real;
 function strtox (s: str255): extended;
 var
 number: longint;
 total, multiplier: real;
 decimalposition, i: integer;
 begin
 total := 0;
 decimalposition := pos(‘.’, s);
 multiplier := 1;
 for i := (decimalposition - 1) downto 1 do
 begin
 stringtonum(s[i], number);
 total := total + (number * multiplier);
 multiplier := multiplier * 10;
 end;
 multiplier := 0.1;
 for i := (decimalposition + 1) to length(s) do
 begin
 stringtonum(s[i], number);
 total := total + (number * multiplier);
 multiplier := multiplier / 10;
 end;
 if decimalposition = 0 then
 begin
 multiplier := 1;
 total := 0;
 for i := length(s) downto 1 do
 begin
 stringtonum(s[i], number);
 total := total + (number * multiplier);
 multiplier := multiplier * 10;
 end;
 end;
 strtox := total;
 end;
 begin
 Csize.h := 0;
 TERecToStr(TitleFieldhndl, sTemp);
 PREC4.Title[cSize.v + 1] := sTemp;
 dataLen := length(sTemp);
 LSetCell(Pointer(ord(@sTemp) + 1), dataLen, cSize, List_I_Titles);
 {Set string in row }
 TERecToStr(WidthFieldhndl, sTemp);
 i := 120;
 tempnumber := strtox(sTemp) * i;
 PREC4.size[cSize.v + 1].h := trunc(tempnumber);
 TERecToStr(HeightFieldhndl, sTemp1);
 tempnumber := strtox(sTemp1) * i;
 PREC4.size[cSize.v + 1].v := trunc(tempnumber);
 end;

{=================================}
 {Close our window}
 procedure Close_Options;
 begin    {Start of Window close routine}
 if (MyWindow <> nil) and ((MyWindow = whichWindow) or (ord4(whichWindow) 
= -1)) then
 begin
 if (theInput = TitleFieldhndl) then
 theInput := nil;  {Clear the handle used}
 if (theInput = WidthFieldhndl) then
 theInput := nil;  {Clear the handle used}
 if (theInput = HeightFieldhndl) then
 theInput := nil;  {Clear the handle used}
 DisposeWindow(MyWindow);{Clear window and controls}
 MyWindow := nil;
 end;     {End for if (MyWindow<>nil)}
 end;     {End of procedure}

{=================================}
 {Update our window, someone uncovered a part of us}
 procedure UpDate_Options;
 var
 SavePort: WindowPtr;   {Place to save the last port}
 sTemp: Str255;    {Temporary string}
 begin    {Start of Window update routine}
 Recordstatus;
 if (MyWindow <> nil) and (MyWindow = whichWindow) then{Handle an open 
when already opened}
 begin
 GetPort(SavePort);  {Save the current port}
 SetPort(MyWindow);  {Set the port to my window}
 TextFont(systemFont);    {Set the font to draw in}
 {Draw a string of text,  }
 SetRect(tempRect, 273, 85, 318, 102);
 sTemp := ‘“ X’;
 TextBox(Pointer(ord(@sTemp) + 1), length(sTemp), tempRect, teJustLeft);
 TextFont(applFont); {Set default application font}

 TextFont(systemFont);    {Set the font to draw in}
 {Draw a string of text,  }
 SetRect(tempRect, 378, 85, 423, 102);
 sTemp := ‘“‘;
 TextBox(Pointer(ord(@sTemp) + 1), length(sTemp), tempRect, teJustLeft);
 TextFont(applFont);
 {Update a TE box, US Letter }
 SetRect(TempRect, 220, 40, 380, 65);{left,top,right,bottom}
 FrameRect(TempRect);     {Frame this TE area}
 InsetRect(TempRect, 3, 3);{Surround the TE area}
 if (TitleFieldhndl <> nil) then
 begin    {Update the TE area}
 TEUpdate(TempRect, TitleFieldhndl);
 {Update the TE area}
 TextFont(applFont);
 {Set the default application font}
 end;     {End of the TE area}
 {Update a TE box, Width }
 SetRect(TempRect, 220, 82, 270, 102);
 FrameRect(TempRect);     {Frame this TE area}
 InsetRect(TempRect, 3, 3);{Surround the TE area}
 if (WidthFieldhndl <> nil) then{
 begin    {Update the TE area}
 TEUpdate(TempRect, WidthFieldhndl);
 {Update the TE area}
 TextFont(applFont);
 {Set the default application font}
 end;     {End of the TE area}
 {Update a TE box, Height }
 SetRect(TempRect, 326, 82, 376, 102);
 FrameRect(TempRect);     {Frame this TE area}
 InsetRect(TempRect, 3, 3);{Surround the TE area}
 if (HeightFieldhndl <> nil) then
 begin    {Update the TE area}
 TEUpdate(TempRect, HeightFieldhndl);
 {Update the TE area}
 TextFont(systemFont);
 {Set the default application font}
 end;     {End of the TE area}
 {Update a List, Titles }
 SetRect(TempRect, 21, 21, 204, 117);
 TempRect.Right := TempRect.Right - 15;
 {Go inside the scroll bar}
 InsetRect(TempRect, -1, -1);{Surround the List area}
 FrameRect(TempRect);     {Frame this List area}
 if (List_I_Titles <> nil) then
 LUpdate(MyWindow^.visRgn, List_I_Titles);
 DrawControls(MyWindow);{Draw all the controls}
 SetPort(SavePort);  {Restore the old port}
 end;     {End for if (MyWindow<>nil)}
 end;     {End of procedure}

{=================================}
 {Open our window and draw everything}
 procedure Open_Options;
 var
 Index: Integer;     {For looping}
 dataBounds: Rect;   {For making lists}
 cSize: Point;   {For making lists}
{This is a routine used to add strings to an existing list}
 procedure Add_List_String (theString: Str255; theList: ListHandle);
 var
 theRow: integer;  {The Row that we are adding}
 begin
 if (theList <> nil) then
 begin
 cSize.h := 0;   {Point to the correct column}
 theRow := LAddRow(1, 200, theList);
 cSize.v := theRow;  {Point to the row just added}
 sTemp := theString;      {Get the string to add}
 LSetCell(Pointer(ord(@sTemp) + 1), length(sTemp), cSize, theList);{Place 
string in row just created}
 LDraw(cSize, theList);   {Draw the new string}
 end;
 end;
 begin    {Start of Window open routine}
 if (MyWindow = nil) then
 begin
 MyWindow := GetNewWindow(1, nil, Pointer(-1));
 SetPort(MyWindow);  {Prepare to write into window}
 {Open a TE box, Width }
 SetRect(TempRect, 220, 82, 270, 102);
 FrameRect(TempRect);     {Frame this TE area}
 InsetRect(TempRect, 3, 3);{Restore the original size}
 WidthFieldhndl := TENew(TempRect, TempRect);
 if (theInput <> nil) then
 TEDeactivate(theInput);{Yes, so turn it off}
 theInput := WidthFieldhndl;     {Activate the TE area}
 HLock(Handle(WidthFieldhndl));
 WidthFieldhndl^^.txFont := systemFont;
 WidthFieldhndl^^.fontAscent := 12;{Font ascent}
 WidthFieldhndl^^.lineHeight := 12 + 3 + 1;
 HUnLock(Handle(WidthFieldhndl));
 sTemp := ‘8.50’;
 TESetText(Pointer(Ord4(@sTemp) + 1), length(sTemp), WidthFieldhndl);{Place 
default text in the TE area}
 TEActivate(WidthFieldhndl);
 TEUpdate(TempRect, WidthFieldhndl);
 TextFont(applFont);
 {Open a TE box, Height }
 SetRect(TempRect, 326, 82, 376, 102);
 FrameRect(TempRect);     {Frame this TE area}
 InsetRect(TempRect, 3, 3);{Restore the original size}
 HeightFieldhndl := TENew(TempRect, TempRect);
 if (theInput <> nil) then
 TEDeactivate(theInput);{Yes, so turn it off}
 theInput := HeightFieldhndl; {Activate the TE area}
 HLock(Handle(HeightFieldhndl));
 HeightFieldhndl^^.txFont := systemFont;
 HeightFieldhndl^^.fontAscent := 12;{Font ascent}
 HeightFieldhndl^^.lineHeight := 12 + 3 + 1;
 HUnLock(Handle(HeightFieldhndl));
 sTemp := ’11.0';
 TESetText(Pointer(Ord4(@sTemp) + 1), length(sTemp), HeightFieldhndl);{Place 
default text in the TE area}
 TEActivate(HeightFieldhndl);{Make the TE area active}
 TEUpdate(TempRect, HeightFieldhndl);
 TextFont(applFont);
 {Open a TE box, Title }
 SetRect(TempRect, 220, 40, 380, 62);
 FrameRect(TempRect);     {Frame this TE area}
 InsetRect(TempRect, 3, 3);{Restore the original size}
 TitleFieldhndl := TENew(TempRect, TempRect);
 if (theInput <> nil) then
 TEDeactivate(theInput);{Yes, so turn it off}
 theInput := TitleFieldhndl;     {Activate the TE area}
 HLock(Handle(TitleFieldhndl));
 TitleFieldhndl^^.txFont := systemFont;
 TitleFieldhndl^^.fontAscent := 12;{Font ascent}
 TitleFieldhndl^^.lineHeight := 12 + 3 + 1;
 HUnLock(Handle(TitleFieldhndl));
 sTemp := ‘US Letter’;
 TESetText(Pointer(Ord4(@sTemp) + 1), length(sTemp), TitleFieldhndl);{Place 
default text in the TE area}
 TEActivate(TitleFieldhndl);{Make the TE area active}
 TEUpdate(TempRect, TitleFieldhndl);
 TextFont(applFont); 
 {Make a List, Titles }
 SetRect(TempRect, 21, 21, 204, 117);{left,top,right,bottom}
 Rect_I_Titles := tempRect;{Save the list position}
 TempRect.Right := TempRect.Right - 15;{Go inside the scroll bar area}
 InsetRect(TempRect, -1, -1);{Surround the List area}
 FrameRect(TempRect);     {Frame this List area}
 InsetRect(TempRect, 1, 1);{Restore to the List area}
 SetRect(dataBounds, 0, 0, 1, 0);{Make the empty list}
 cSize.h := TempRect.Right - TempRect.Left;
 {Get the width of the list}
 cSize.v := 16; {Set the HEIGHT of each list element}
 List_I_Titles := LNew(TempRect, dataBounds, cSize, 0, MyWindow, TRUE, 
FALSE, FALSE, TRUE);{Create the list}
 List_I_Titles^^.selFlags := lOnlyOne + lNoNilHilite;{Set for only one 
active item at a time}
 LdoDraw(TRUE, List_I_Titles);{Draw list}
 cSize.h := 0; {Point to correct col, starts at zero}
 Add_List_String(‘US Letter’, List_I_Titles);
 Add_List_String(‘A4 Letter’, List_I_Titles);
 Add_List_String(‘US Legal’, List_I_Titles);
 Add_List_String(‘International Fanfold’, List_I_Titles);
 Add_List_String(‘Computer Paper’, List_I_Titles);
 Add_List_String(‘?’, List_I_Titles);
 cSize.h := 0;     {All elements are in column 0}
 cSize.v := 0;     {Select the first list element}
 LSetSelect(TRUE, cSize, List_I_Titles);
 ShowWindow(MyWindow);    {Show the window now}
 SelectWindow(MyWindow);{Bring our window to the front}
 SetDefaultPrec;
 end    {End for if (MyWindow<>nil)}
 else
 SelectWindow(MyWindow);{Already open, so show it}
 end;     {End of procedure}

{=================================}
 {Handle action to our window, like controls}
 procedure Do_Options;
 var
 RefCon: longint;  {RefCon for controls}
 code: integer; {Location of event in window or controls}
 theValue: integer;       {Current value of a control}
 whichWindow: WindowPtr;
 myPt: Point;    {Point where event happened}
 theControl: ControlHandle;   {Handle for a control}
 MyErr: OSErr;     {OS error returned}
 DoubleClick: boolean;    {Used by lists}
 datalen: integer;
 begin    {Start of Window handler}
 Recordstatus;
 if (MyWindow <> nil) then
 begin
 code := FindWindow(myEvent.where, whichWindow);
 if (myEvent.what = MouseDown) and (MyWindow = whichWindow) then{}
 begin 
 myPt := myEvent.where;{Get mouse position}
 with MyWindow^.portBits.bounds do
 begin
 myPt.h := myPt.h + left;
 myPt.v := myPt.v + top;
 end;
 SetRect(tempRect, 220, 40, 380, 62);
 if PtInRect(myPt, tempRect) then
 begin
 if (theInput <> nil) then
 TEDeactivate(theInput);
 theInput := TitleFieldhndl;
 TEActivate(theInput);{Turn it on}
 TEClick(myPt, FALSE, TitleFieldhndl);
 end;
 SetRect(tempRect, 220, 82, 270, 102);
 if PtInRect(myPt, tempRect) then
 begin
 if (theInput <> nil) then
 TEDeactivate(theInput);
 theInput := WidthFieldhndl;
 TEActivate(theInput);{Turn it on}
 TEClick(myPt, FALSE, WidthFieldhndl);
 end;
 SetRect(tempRect, 326, 82, 376, 102);
 if PtInRect(myPt, tempRect) then
 begin
 if (theInput <> nil) then
 TEDeactivate(theInput);
 theInput := HeightFieldhndl;
 TEActivate(theInput);{Turn it on}
 TEClick(myPt, FALSE, HeightFieldhndl);
 end;
 if PtInRect(myPt, Rect_I_Titles) then
 begin
 DoubleClick := LClick(myPt, myEvent.modifiers, List_I_Titles);
 if DoubleClick then
 begin
 end;
 begin
 cSize := LLastClick(List_I_Titles);
 datalen := 100;
 LGetCell(Pointer(ord(@sTemp) + 1), dataLen, cSize, List_I_Titles);{Get 
string in row }
 if not (LGetSelect(false, cSize, List_I_Titles)) then
 begin
 theCell.v := 0;
 theCell.h := 0;
 if LGetSelect(true, theCell, List_I_Titles) then
 begin
 cSize := theCell;
 datalen := 100;
 LGetCell(Pointer(ord(@sTemp) + 1), dataLen, cSize, List_I_Titles);
 {Get string in row }
 end;
 end;
 TESetText(Pointer(Ord4(@PREC4.Title[cSize.v + 1]) + 1), dataLen, TitleFieldhndl);
 SetRect(TempRect, 220, 40, 380, 62);
 TEUpdate(TempRect, TitleFieldhndl);
 SetTeWidth(cSize.v + 1);
 SetTeHeight(cSize.v + 1);
 end;
 end;
 end;

 if (MyWindow = whichWindow) and (code = inContent) then{for our window}
 begin
 code := FindControl(myPt, whichWindow, theControl);{Get type of control}
 if (code <> 0) then{Check type of control}
 code := TrackControl(theControl, myPt, nil);{Track the control}
 end;     {End for if (MyWindow=whichWindow)}
 end;     {End for if (MyWindow<>nil)}
 end;     {End of procedure}

{=================================}
end.    {End of unit}

unit HandleTheMenus;
{File name :  HandleTheMenus.Pp  }
{Function: Handle all menu selections.}
{  This procedure is called when a menu item is selected.}
{  There is one CASE statement for all Lists.  There is}
{  another CASE for all the commands in each List.}
{History: 6/10/89 Original by Prototyper.   }
{ Created for MacTutor   }
{ ©1989 CopyRight MacTutor  All Rights Reserved   }
interface
 uses
 Globals, About, Options, InitTheMenus;
 procedure Handle_My_Menu (var doneFlag: boolean; theMenu, theItem: integer; 
var theInput: TEHandle);
implementation
 procedure Handle_My_Menu;
 const
 L_Apple = 1001; {Menu list}
 C_About_Page_Sizes = 1;
 L_File = 1002;  {Menu list}
 C_Open = 1;
 C_Save_As = 2;
 C_Set_Page_Setup_Default = 4;
 C_Quit = 6;
 L_Edit = 1003;  {Menu list}
 C_Undo = 1;
 C_Cut = 3;
 C_Copy = 4;
 C_Paste = 5;
 var
 DNA, Err: integer;  {For opening DAs}
 BoolHolder: boolean;     {For SystemEdit result}
 DAName: Str255;     {For getting DA name}
 SavePort: GrafPtr; {Save current port when opening DAs}
 where: point;   {location of SF dialogs}
 prompt, origname, astring: str255;
 typeList: SFTypeList;
 numtypes, count, oldcount: integer;
 Total_length, RefNum, i, j, k: integer;
 PRECHndl, SaveHndl, hndl: handle;
 begin    {Start of procedure}
 case theMenu of {Do selected menu list}
 L_Apple: 
 begin
 case theItem of
 C_About_Page_Sizes: 
 begin
 D_About;{Call a dialog}
 end;
 otherwise{Handle the DAs}
 begin{Start of Otherwise}
 GetPort(SavePort);{Save the current port}
 GetItem(AppleMenu, theItem, DAName);
 {Get the name of the DA selected}
 DNA := OpenDeskAcc(DAName);
 SetPort(SavePort);{Restore to saved port}
 end;{End of Otherwise}
 end;     {End of item case}
 end;     {End for this list}
 L_File: 
 begin
 case theItem of
 C_Open: 
 begin
 {Call the SFGetFile OS routine}
 where.h := 80;
 where.v := 80;
 prompt := ‘’;
 numTypes := -1;
 SFGetFile(where, prompt, nil, numTypes, typeList, nil, reply);
 if reply.good = true then
 begin
 RefNum := OpenRFPerm(reply.fName, reply.VRefNum, 3);
 if (RefNum = -1) or (ResError <> NoErr) then
 SetDefaultPrec
 else
 begin
 Count := CountResources(‘PREC’);
 if Count = 0 then
 SetdefaultPrec
 else
 begin
 UseResFile(RefNum);
 PRECHndl := Get1Resource(‘PREC’, 4);
 if (PRECHndl = nil) or (ResError <> NoErr) then
 SetdefaultPrec
 else
 begin
 HNoPurge(PRECHndl);
 therealprec4hndl := realprec4hndl(PRECHndl);
 for k := 1 to 6 do
 begin
 PREC4.Size[k].h := therealprec4hndl^^.Size[k].h;
 PREC4.Size[k].v := therealprec4hndl^^.Size[k].v;
 end;
 count := -1;
 for k := 1 to 6 do
 begin
 count := count + 1;
 j := ord(therealprec4hndl^^.title[count]) - 1;
 count := count + 1;
 oldcount := count;
 PREC4.Title[k] := ‘’;
 for count := oldcount to oldcount + j do
 begin
 PREC4.Title[k] := concat(PREC4.Title[k], therealprec4hndl^^.title[count]);
 end;
 if PREC4.Title[k] = ‘’ then
 PREC4.Title[k] := ‘?’;
 count := oldcount + j;
 end;
 SetWTitle(MyWindow, reply.fName);
 end;
 CloseResFile(RefNum);
 HPurge(PRECHndl);
 DisposHandle(PRECHndl);
 SetFields;
 end;
 end;
 end;
 end;
 C_Save_As: 
 begin
 {Call the SFPutFile OS routine}
 where.h := 80;
 where.v := 80;
 origname := reply.fName;
 prompt := ‘Save PREC4 resource to file:’;
 SFPutFile(where, prompt, origName, nil, reply);
 if reply.good then
 begin
 Total_length := 32;  {first half of PREC resource}
 for i := 1 to 6 do
 Total_length := Total_length + length(PREC4.Title[i]);
 SaveHndl := NewHandle(Total_length);  {Create new PREC resource}
 if SaveHndl <> nil then
 begin
 HNoPurge(SaveHndl);
 therealprec4Hndl := realprec4hndl(SaveHndl);
 therealprec4hndl^^.numberofbuttons := 0;
 for i := 1 to 6 do
 if (length(PREC4.Title[i]) <> 0) or (PREC4.Title[i] = ‘?’) then
 therealprec4hndl^^.numberofbuttons := therealprec4hndl^^.numberofbuttons 
+ 1;
 for k := 1 to 6 do
 begin
 therealprec4hndl^^.Size[k].h := PREC4.Size[k].h;
 therealprec4hndl^^.Size[k].v := PREC4.Size[k].v;
 end;
 if length(PREC4.Title[1]) <> 0 then
 astring := PREC4.Title[1]
 else
 astring := concat(chr(1), ‘?’);
 for j := 2 to 6 do
 begin
 if length(PREC4.Title[j]) <> 0 then
 astring := concat(astring, chr(length(PREC4.Title[j])), PREC4.Title[j])
 else
 astring := concat(astring, chr(1), ‘?’);
 end;
 therealprec4hndl^^.Title[0] := chr(length(PREC4.Title[1]));
 for i := 1 to length(astring) do
 begin
 therealprec4hndl^^.Title[i] := astring[i];
 end;
 err := SetVol(nil, reply.VRefNum);
 err := Create(reply.fname, reply.vRefNum, ‘PROF’, ‘TEXT’);
 CreateResFile(reply.fname);
 if ResError = dupFNErr then
 begin
 RefNum := OpenRfPerm(reply.fname, reply.VRefNum, 3);
 hndl := Get1Resource(‘PREC’, 4);
 if Hndl <> nil then
 begin
 RmveResource(Hndl);
 ChangedResource(Hndl);
 UpdateResFile(RefNum);
 DisposHandle(Hndl);
 end;
 end;
 begin
 RefNum := OpenRfPerm(reply.fname, reply.VRefNum, 3);
 end;
 addresource(SaveHndl, ‘PREC’, 4, ‘’);
 writeresource(saveHndl);
 closeresfile(RefNum);
 HPurge(SaveHndl);
 DisposHandle(SaveHndl);
 SetWTitle(MyWindow, reply.fName);
 end;
 end;
 end;
 C_Set_Page_Setup_Default: 
 begin
 SetDefaultPREC;
 end;
 C_Quit: 
 begin
 doneFlag := TRUE;
 end;
 otherwise
 begin{Start of the Otherwise}
 end;{End of Otherwise}
 end;     {End of item case}
 end;     {End for this list}
 L_Edit: 
 begin
 BoolHolder := SystemEdit(theItem - 1);
 if not (BoolHolder) then
 begin    {Handle by using a Case statment}
 case theItem of
 C_Undo: 
 begin
 end;
 C_Cut: 
 begin
 end;
 C_Copy: 
 begin
 end;
 C_Paste: 
 begin
 end;
 otherwise{Send to a DA}
 begin{Start of the Otherwise}
 end;{End of Otherwise}
 end;     {End of not BoolHolder}
 end;     {End of item case}
 end;     {End for this list}
 otherwise
 begin    {Start of the Otherwise}
 end;     {End of Otherwise}
 end;     {End for the Lists}
 HiliteMenu(0);  {Turn menu selection off}
 end;     {End of procedure Handle_My_Menu}
end.    {End of unit}

{The Project should have the following files in it:     }
{µRunTime.lib     LSP This is for main Pascal runtime library}
{     Interface.lib      LSP This is the Mac trap interfaces}
{     InitTheMenus.p      This initializes the Menus.}
{     About       Modal Dialog}
{     Options       Window}
{    HandleTheMenus         Handle the menu selections.}
{Set  RUN OPTIONS to use the  resource file PREC4.RSRC  }
{ RMaker file to use is PREC4.R  }
{   PREC4.p      Main program  }
program PREC4;
{Program name:  PREC4.p  }
{Function:  This is the main module for this program.  }
{History: 6/10/89 Original by Prototyper.   }
{ Created for MacTutor   }
{ ©1989 CopyRight MacTutor  All Rights Reserved   }

 uses
 globals, About, Options, InitTheMenus, HandleTheMenus;
 var    {Main variables}
 myEvent: EventRecord;    {Event record for all events}
 doneFlag: boolean;  {Exit program flag}
 code: integer;  {Determine event type}
 whichWindow: WindowPtr;    {See which window for event}
 tempRect, OldRect: Rect;     {Rect for dragging}
 mResult: longint;
 theMenu, theItem: integer;{Menu list and item selected}
 chCode: integer;    {Key code}
 ch: char;  {Key pressed in Ascii}
 theInput: TEHandle;      {Used in text edit selections}
 myPt: Point;    {Temp Point, used in Zoom}
begin   {Start of main body}
 MoreMasters;   {This reserves space for more handles}
 InitGraf(@thePort); {Quickdraw Init}
 InitFonts;      {Font manager init}
 InitWindows;    {Window manager init}
 InitMenus;      {Menu manager init}
 TEInit;  {Text edit init}
 InitDialogs(nil);   {Dialog manager}
 FlushEvents(everyEvent, 0);{Clear out all events}
 InitCursor;     {Make an arrow cursor}
 doneFlag := FALSE;  {Do not exit program yet}
 Init_My_Menus;  {Initialize menu bar}
 theInput := nil;  {Init to no text edit selection active}
 Init_Options;   {Initialize the window routines}
 Open_Options(theInput);  {Open window routines}
 D_About; {Open the modal dialog routines at program start}
 reply.fname := ‘’;
 repeat   {Start of main event loop}
 if (theInput <> nil) then{See if a TE is active}
 TEIdle(theInput);
 SystemTask;     {For support of desk accessories}
 if GetNextEvent(everyEvent, myEvent) then
 begin    {Start handling the event}
 code := FindWindow(myEvent.where, whichWindow);
 case myEvent.what of{Decide type of event}
 MouseDown: {Mouse button pressed}
 begin    {Handle the pressed button}
 if (code = inMenuBar) then
 begin{Get the menu selection and handle it}
 mResult := MenuSelect(myEvent.Where);
 theMenu := HiWord(mResult);
 theItem := LoWord(mResult);
 Handle_My_Menu(doneFlag, theMenu, theItem, theInput);{Handle the menu}
 end;{End of inMenuBar}
 if (code = InDrag) then
 begin{Do dragging the window}
 tempRect := screenbits.bounds;
 SetRect(tempRect, tempRect.Left + 10, tempRect.Top + 25, tempRect.Right 
- 10, tempRect.Bottom - 10);
 DragWindow(whichWindow, myEvent.where, tempRect);{Drag the window}
 end;{End of InDrag}
 if ((code = inGrow) and (whichWindow <> nil)) then{In a grow area of 
the window}
 begin{Handle the growing}
 SetPort(whichWindow);
 myPt := myEvent.where;{Get mouse position}
 GlobalToLocal(myPt);{Make it relative}
 OldRect := WhichWindow^.portRect;
 with screenbits.bounds do{screens size}
 SetRect(tempRect, 15, 15, (right - left), (bottom - top) - 20);{l,t,r,b}
 mResult := GrowWindow(whichWindow, myEvent.where, tempRect);{Grow it}
 SizeWindow(whichWindow, LoWord(mResult), HiWord(mResult), TRUE);{Resize 
to result}
 SetPort(whichWindow);
 SetRect(tempRect, 0, myPt.v - 15, myPt.h + 15, myPt.v + 15); {Position 
for horz scrollbar area}
 EraseRect(tempRect);{Erase old area}
 InvalRect(tempRect);{Flag us to update it}
 SetRect(tempRect, myPt.h - 15, 0, myPt.h + 15, myPt.v + 15);  {Position 
for vert scrollbar area}
 EraseRect(tempRect);{Erase old area}
 InvalRect(tempRect);{Flag us to update it}
 DrawGrowIcon(whichWindow);
 end;{End of doing the growing}
 if (code = inZoomIn) or (code = inZoomOut) then{Handle Zooming windows}
 begin{}
 if (WhichWindow <> nil) then
 begin{}
 SetPort(whichWindow);
 myPt := myEvent.where;
 GlobalToLocal(myPt);{Make it relative}
 OldRect := whichWindow^.portRect;
 if TrackBox(whichWindow, myPt, code) then{Zoom it}
 begin{}
 ZoomWindow(WhichWindow, code, TRUE);{Resize to result}
 SetRect(tempRect, 0, 0, 32000, 32000);
 EraseRect(tempRect);
 InvalRect(tempRect);
 end;
 end;
 end;
 if (code = inGoAway) then
 begin{Handle the goaway button}
 if TrackGoAway(whichWindow, myEvent.where) then{See if mouse released 
in GoAway box}
 begin{Handle the GoAway}
 case (GetWRefCon(whichWindow)) of
 1: 
 begin
 Close_Options(whichWindow, theInput);{Close this window}
 doneFlag := TRUE;
 end;
 otherwise{Handle others dialogs}
 begin{Others}
 end;{End of the otherwise}
 end;{End of the case}
 end;{End of TrackGoAway}
 end;{End of InGoAway}
 if (code = inContent) then
 begin{Handle the hit inside a window}
 if (whichWindow <> FrontWindow) then
 SelectWindow(whichWindow)
 else
 begin{Handle the button in the content}
 SetPort(whichWindow);
 case (GetWRefCon(whichWindow)) of
 1: 
 Do_Options(myEvent, theInput);{Handle this window}
 otherwise{Handle others dialogs}
 begin{Others}
 end;{End of the otherwise}
 end;{End of the case}
 end;{End of else}
 end;{End of inContent}
 if (code = inSysWindow) then
 SystemClick(myEvent, whichWindow);
 end;     {End of MouseDown}
 KeyDown, AutoKey:{Handle key inputs}
 begin    {Get the key and handle it}
 with myevent do{Check for menu command keys}
 begin{}
 chCode := BitAnd(message, CharCodeMask);{Get character}
 ch := CHR(chCode);{Change to ASCII}
 if (Odd(modifiers div CmdKey)) then
 begin{}
 mResult := MenuKey(ch);
 theMenu := HiWord(mResult);
 theItem := LoWord(mResult);
 if (theMenu <> 0) then
 Handle_My_Menu(doneFlag, theMenu, theItem, theInput);{Do the menu selection}
 if ((ch = ‘x’) or (ch = ‘X’)) and (theInput <> nil) then{}
 TECut(theInput);
 if ((ch = ‘c’) or (ch = ‘C’)) and (theInput <> nil) then{}
 TECopy(theInput);
 if ((ch = ‘v’) or (ch = ‘V’)) and (theInput <> nil) then{}
 TEPaste(theInput);
 end{}
 else if (theInput <> nil) then{}
 begin
 if ch = chr(9) then
 begin
 TEDeactivate(theInput);
 if theInput = TitleFieldhndl then
 theInput := WidthFieldhndl
 else if theInput = WidthFieldhndl then
 theInput := HeightFieldhndl
 else if theInput = HeightFieldhndl then
 theInput := TitleFieldhndl;
 TEActivate(theInput);{Turn it on}
 recordstatus;
 end
 else
 TEKey(ch, theInput);{}
 end;
 end;{}
 end;     {End for KeyDown,AutoKey}
 UpDateEvt: {Update event for a window}
 begin    {Handle the update}
 whichWindow := WindowPtr(myEvent.message);
 BeginUpdate(whichWindow);
 case (GetWRefCon(whichWindow)) of
 1: 
 Update_Options(whichWindow);
 otherwise       {Handle others dialogs}
 begin    {Others}
 end;     {End of the otherwise}
 end;     {End of the case}
 EndUpdate(whichWindow);
 end;     {End of UpDateEvt}
 DiskEvt:   {Disk inserted event}
 begin    {Handle a disk event}
 if (HiWord(myevent.message) <> noErr) then
 begin{due to unformatted diskette inserted}
 myEvent.where.h := ((screenbits.bounds.Right - screenbits.bounds.Left) 
div 2) - (304 div 2);{Center horz}
 myEvent.where.v := ((screenbits.bounds.Bottom - screenbits.bounds.Top) 
div 3) - (104 div 2);{Top 3ed vertically}
 InitCursor;{Make sure has arrow cursor}
 chCode := DIBadMount(myEvent.where, myevent.message);{Let the OS handle 
the diskette}
 end;
 end;   {End of DiskEvt}
 app1Evt:
 begin    {Start handling our events}
 if (HiWord(myEvent.message) = 1) and (LoWord(myEvent.Message) = 1) then
 Open_Options(theInput);{Open the window}
 if (HiWord(myEvent.message) = 2) and (LoWord(myEvent.Message) = 1) then
 Close_Options(WindowPtr(ord4(-1)), theInput);{Close the window}
 end;     {End handling our events}
 ActivateEvt:    {Window activated event}
 begin    {Handle the activation}
 whichWindow := WindowPtr(myevent.message);
 if odd(myEvent.modifiers) then
 begin{Handle the activate}
 SelectWindow(whichWindow);
 end;{End of Activate}
 end;     {End of ActivateEvt}
 otherwise 
 end;     {End of case}
 end;     {end of GetNextEvent}
 until doneFlag; {End of the event loop}
end.    {End of the program}

*********************************************************
*
* RMaker resource file sources.
* File: PREC4.R
* History: 6/10/89 Original by Prototyper.   
* This file contains the sources for all the resources except for Pictures. 

*
*********************************************************

PREC4.RSRC
APPL????

*
Type WIND

 ,1     ;;Resource ID
Page Setup Options   ;;Window title
45  20  185  454     ;;Top Left Bottom Right
InVisible  GoAway    ;;Visible GoAway 
16      ;;ProcID, Window def ID
1       ;;Refcon, reference value

Type DLOG
*
 ,2     ;;Resource ID
About   ;;Dialog title
51  54  182  355     ;;Top Left Bottom Right
Visible NoGoAway     ;;Visible GoAway 
1       ;;ProcID, dialog def ID
2       ;;Refcon, reference value
2       ;;ID of item list

Type DITL
*

 ,2     ;;Resource ID
3       ;;Number of controls in list

Button  Enabled  ;;Push button
99  109  120  189    ;;Top Left Bottom Right
OK      ;;message

StaticText  ;;Static text
30  80  90  280  ;;Top Left Bottom Right
ImageWriter Page Size Editor\0D©1989 MacTutor\0DBy Dave Kelly;;message

Icon  Enabled    ;;Icon
40  32  72  64   ;;Top Left Bottom Right
31      ;;ID for the resource to use, Icon6

Type ICON = GNRL 


* This Icon is Icon6
 ,32    ;;ICON Resource ID
.H
 00000000 001C0000 003E0000 007F8000
 00FFE000 01FFF800 03FFFC00 07FBFC00
 07FEF800 03FFB000 017FF800 021FF400
 02E79200 02D11700 02001200 02001700
 02809200 02FF9000 0277176C 01002254
 00804254 007F8000 00408000 007F8000
 01806000 06001800 08618400 130C3200
 10000200 1FFFFE00 00000000 00000000
.I

 ,10032   ;;ICON highlighted Resource ID
.H
 00000000 00010000 00038000 0006C000
 000D6000 001BB000 0037D800 006FEC00
 00DFF600 01BFFB00 037FFD80 06FFFEC0
 0DFFFF60 1BFFFFB0 37FFFFD8 6FFFFFEC
 F7FFFFDE 73FFFF9C 31FFFF18 18FFFE30
 0C7FFC60 063FF8C0 031FF180 018FE300
 00C7C600 00638C00 00311800 00183000
 000C6000 0006C000 00038000 00010000
.I

Type MENU
*

 ,1001    ;;Resource ID
\14     ;;APPLE menu title
About Page Sizes...  ;;item title
(-      ;;

 ,1002    ;;Resource ID
File    ;;menu title
Open /O   ;;item title
Save As /S  ;;item title
(-      ;;
Set Page Setup Default    ;;item title
(-      ;;
Quit/Q  ;;item title

 ,1003    ;;Resource ID
Edit    ;;menu title
(Undo/Z ;;item title
(-      ;;
Cut/X   ;;item title
Copy/C  ;;item title
Paste/V ;;item title

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Recruit two powerful-sounding students t...
I am a fan of anime, and I hear about a lot that comes through, but one that escaped my attention until now is A Certain Scientific Railgun T, and that name is very enticing. If it's new to you too, then players of Blue Archive can get a hands-on... | Read more »
Top Hat Studios unveils a new gameplay t...
There are a lot of big games coming that you might be excited about, but one of those I am most interested in is Athenian Rhapsody because it looks delightfully silly. The developers behind this project, the rather fancy-sounding Top Hat Studios,... | Read more »
Bound through time on the hunt for sneak...
Have you ever sat down and wondered what would happen if Dr Who and Sherlock Holmes went on an adventure? Well, besides probably being the best mash-up of English fiction, you'd get the Hidden Through Time series, and now Rogueside has announced... | Read more »
The secrets of Penacony might soon come...
Version 2.2 of Honkai: Star Rail is on the horizon and brings the culmination of the Penacony adventure after quite the escalation in the latest story quests. To help you through this new expansion is the introduction of two powerful new... | Read more »
The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »

Price Scanner via MacPrices.net

May 2024 Apple Education discounts on MacBook...
If you’re a student, teacher, or staff member at any educational institution, you can use your .edu email address when ordering at Apple Education to take up to $300 off the purchase of a new MacBook... Read more
Clearance 16-inch M2 Pro MacBook Pros in stoc...
Apple has clearance 16″ M2 Pro MacBook Pros available in their Certified Refurbished store starting at $2049 and ranging up to $450 off original MSRP. Each model features a new outer case, shipping... Read more
Save $300 at Apple on 14-inch M3 MacBook Pros...
Apple has 14″ M3 MacBook Pros with 16GB of RAM, Certified Refurbished, available for $270-$300 off MSRP. Each model features a new outer case, shipping is free, and an Apple 1-year warranty is... Read more
Apple continues to offer 14-inch M3 MacBook P...
Apple has 14″ M3 MacBook Pros, Certified Refurbished, available starting at only $1359 and ranging up to $270 off MSRP. Each model features a new outer case, shipping is free, and an Apple 1-year... Read more
Apple AirPods Pro with USB-C return to all-ti...
Amazon has Apple’s AirPods Pro with USB-C in stock and on sale for $179.99 including free shipping. Their price is $70 (28%) off MSRP, and it’s currently the lowest price available for new AirPods... Read more
Apple Magic Keyboards for iPads are on sale f...
Amazon has Apple Magic Keyboards for iPads on sale today for up to $70 off MSRP, shipping included: – Magic Keyboard for 10th-generation Apple iPad: $199, save $50 – Magic Keyboard for 11″ iPad Pro/... Read more
Apple’s 13-inch M2 MacBook Airs return to rec...
Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices currently... Read more
Best Buy is clearing out iPad Airs for up to...
In advance of next week’s probably release of new and updated iPad Airs, Best Buy has 10.9″ M1 WiFi iPad Airs on record-low sale prices for up to $200 off Apple’s MSRP, starting at $399. Sale prices... Read more
Every version of Apple Pencil is on sale toda...
Best Buy has all Apple Pencils on sale today for $79, ranging up to 39% off MSRP for some models. Sale prices for online orders only, in-store prices may vary. Order online and choose free shipping... Read more
Sunday Sale: Apple Studio Display with Standa...
Amazon has the standard-glass Apple Studio Display on sale for $300 off MSRP for a limited time. Shipping is free: – Studio Display (Standard glass): $1299.97 $300 off MSRP For the latest prices and... Read more

Jobs Board

Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
*Apple* App Developer - Datrose (United Stat...
…year experiencein programming and have computer knowledge with SWIFT. Job Responsibilites: Apple App Developer is expected to support essential tasks for the RxASL Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.