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

QuickBooks 2015 16.1.7.1524 R8 - Financi...
Save 20% on QuickBooks Pro for Mac today through this special discount link QuickBooks 2015 helps you manage your business easily and efficiently. Organize your finances all in one place, track... Read more
Sierra Cache Cleaner 11.0.1 - Clear cach...
Sierra Cache Cleaner is an award-winning general purpose tool for macOS X. SCC makes system maintenance simple with an easy point-and-click interface to many macOS X functions. Novice and expert... Read more
Default Folder X 5.0.7 - Enhances Open a...
Default Folder X attaches a toolbar to the right side of the Open and Save dialogs in any OS X-native application. The toolbar gives you fast access to various folders and commands. You just click on... Read more
Safari Technology Preview 10.1 - The new...
Safari Technology Preview contains the most recent additions and improvements to WebKit and the latest advances in Safari web technologies. And once installed, you will receive notifications of... Read more
Tweetbot 2.4.4 - Popular Twitter client.
Tweetbot is a full-featured OS X Twitter client with a lot of personality. Whether it's the meticulously-crafted interface, sounds and animation, or features like multiple timelines and column views... Read more
Google Earth 7.1.7.2602 - View and contr...
Google Earth gives you a wealth of imagery and geographic information. Explore destinations like Maui and Paris, or browse content from Wikipedia, National Geographic, and more. Google Earth combines... Read more
Things 2.8.8 - Elegant personal task man...
Things is a task management solution that helps to organize your tasks in an elegant and intuitive way. Things combines powerful features with simplicity through the use of tags and its intelligent... Read more
Firefox 49.0.1 - Fast, safe Web browser.
Firefox offers a fast, safe Web browsing experience. Browse quickly, securely, and effortlessly. With its industry-leading features, Firefox is the choice of Web development professionals and casual... Read more
Airfoil 5.1.2 - Send audio from any app...
Airfoil allows you to send any audio to AirPort Express units, Apple TVs, and even other Macs and PCs, all in sync! It's your audio - everywhere. With Airfoil you can take audio from any... Read more
ClamXav 2.10 - Virus checker based on Cl...
ClamXav is a popular virus checker for OS X. I have been working on ClamXav for more than 10 years now, and over those years, I have invested a huge amount of my own time and energy into bringing... Read more

Cybird’s latest release - BFB Champions...
Launched in the UK in early September, BFB Champions’ newest update is loaded with great new features, and looks set to outshine the original version by taking it out of soft launch and giving it a new lease of life. | Read more »
3 apps to boost your focus
As someone who works from home, my workspace is a minefield of distraction. Cats, tasty snacks, the wind blowing past my window, that cleaning that I suddenly can’t put off any longer. If I let distraction takes its course, I find that soon half... | Read more »
4 games like Burly Men at Sea to inspire...
Burly Men at Sea is out today and it looks a treat. It tells the tale of three Scandinavian fishermen who leave the humdrum of their daily lives to go exploring. It’s a beautiful folksy story that unfurls as you interact with the environment... | Read more »
3 reasons you need to play Kingdom: New...
Developed by a tag team of indie developers - Thomas "Noio" van den Berg and Marco "Licorice" Bancale - Kingdom is a vibrant medieval fantasy adventure that casts players as a king or queen who must expand their empire by exploring the vasts lands... | Read more »
JoyCity have launched a brand new King o...
Great news for all of you Game of Dice fans out there - JoyCity have just released a brand new limited edition pack with a really cool twist. The premise of Game of Dice is fairly straightforward, asking you to roll dice to navigate your way around... | Read more »
Burly Men at Sea (Games)
Burly Men at Sea 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: Burly Men at Sea is a folktale about a trio of large, bearded fishermen who step away from the ordinary to seek adventure. | Read more »
3 tips for catching the gnarliest waves...
Like a wave breaking on the shore, Tidal Rider swept its way onto the App Store charts this week settling firmly in the top 10. It’s a one-touch high score-chaser in which you pull surfing stunts while dodging seagulls and collecting coins. The... | Read more »
The beginner's guide to destroying...
Age of Heroes: Conquest is 5th Planet Games’ all new turn-based multiplayer RPG, full of fantasy exploration, guild building, and treasure hunting. It’s pretty user-friendly as far as these games go, but when you really get down to it, you’ll find... | Read more »
Infinite Tanks (Games)
Infinite Tanks 1.0.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.0 (iTunes) Description: | Read more »
Agatha Christie - The ABC Murders (FULL)...
Agatha Christie - The ABC Murders (FULL) 1.0 Device: iOS Universal Category: Games Price: $6.99, Version: 1.0 (iTunes) Description: Agatha Christie: The ABC Murders Your weapon is your knowledge. Your wits will be put to the ultimate... | Read more »

Price Scanner via MacPrices.net

Apple refurbished 2015 13-inch MacBook Airs a...
Apple has Certified Refurbished 2015 13″ MacBook Airs available starting at $759. An Apple one-year warranty is included with each MacBook, and shipping is free: - 2015 13″ 1.6GHz/4GB/128GB MacBook... Read more
MacBook Airs on sale for up to $100 off MSRP
B&H Photo has 13″ and 11″ MacBook Airs on sale for up to $100 off MSRP. Shipping is free, and B&H charges NY sales tax only: - 11″ 1.6GHz/128GB MacBook Air: $799 $100 MSRP - 11″ 1.6GHz/256GB... Read more
Apple refurbished 12-inch 128GB iPad Pros ava...
Apple has Certified Refurbished 12″ Apple iPad Pros available for up to $160 off the cost of new iPads. An Apple one-year warranty is included with each model, and shipping is free: - 32GB 12″ iPad... Read more
Phone2Action Unveils New Voter Turnout Techno...
Phone2Action, a leading digital advocacy platform, today launched its Tech to Vote Civic Action Center digital advocacy and communications platform on National Voter Registration Day September 27.... Read more
Apple & Deloitte Team Up to Help Business...
Apple and international professional services firm Deloitte have announced a partnership to help companies quickly and easily transform their workflow dynamics by maximizing the power, ease-of-use,... Read more
Chop Commute – See Traffic and Drive Times on...
Shrewsbury, Massachusetts based Indie developer, InchWest has released Chop Commute 1.61, a Mac app that takes the guesswork out of daily commute by showing real-time traffic and drive times right on... Read more
12-inch 32GB WiFi iPad Pros on sale for $50 o...
B&H Photo has 12″ 32GB WiFi Apple iPad Pros on sale for $50 off MSRP, each including free shipping. B&H charges sales tax in NY only: - 12″ Space Gray 32GB WiFi iPad Pro: $749 $50 off MSRP -... Read more
Recent price drops on refurbished iPad minis...
Apple recently dropped prices on several Certified Refurbished iPad mini 4s and 2s as well as iPad Air 2s. An Apple one-year warranty is included with each model, and shipping is free: - 16GB iPad... Read more
Apple refurbished Mac minis available startin...
Apple has Certified Refurbished Mac minis available starting at $419. Apple’s one-year warranty is included with each mini, and shipping is free: - 1.4GHz Mac mini: $419 $80 off MSRP - 2.6GHz Mac... Read more
13-inch 2.5GHz MacBook Pro available for $928...
Overstock has the 13″ 2.5GHz MacBook Pro available for $927.99 including free shipping. Their price is $171 off MSRP. Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
Restaurant Manager (Neighborhood Captain) - A...
…in every aspect of daily operation. WHY YOU'LL LIKE IT: You'll be the Big Apple . You'll solve problems. You'll get to show your ability to handle the stress and Read more
*Apple* Wireless Lead - T-ROC - The Retail O...
…wealth of knowledge in wireless sales and activations to the Beautiful and NEW APPLE Experience store within MACYS.. THIS role, APPLE Wireless Lead, isbrandnewas Read more
Lead *Apple* Advocate - T-ROC - The Retail...
…Company, is proud of its unprecedented relationship with our partner and client, APPLE ,in bringing amazing" APPLE ADVOCATES"to "non" Apple store locations. Read more
*Apple* Advocate - T-ROC - The Retail Outsou...
…Company, is proud of its unprecedented relationship with our partner and client, APPLE ,in bringing amazing" APPLE ADVOCATES"to "non" Apple store locations. Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.