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

 
AAPL
$98.15
Apple Inc.
-0.23
MSFT
$43.58
Microsoft Corpora
-0.31
GOOG
$587.42
Google Inc.
+1.81

MacTech Search:
Community Search:

Software Updates via MacUpdate

Knock 1.1.7 - Unlock your Mac by knockin...
Knock is a faster, safer way to sign in. You keep your iPhone with you all the time. Now you can use it as a password. You never have to open the app -- just knock on your phone twice, even when it's... Read more
Mellel 3.3.6 - Powerful word processor w...
Mellel is the leading word processor for OS X and has been widely considered the industry standard since its inception. Mellel focuses on writers and scholars for technical writing and multilingual... Read more
LibreOffice 4.3.0.4 - Free Open Source o...
LibreOffice is an office suite (word processor, spreadsheet, presentations, drawing tool) compatible with other major office suites. The Document Foundation is coordinating development and... Read more
Freeway Pro 7.0 - Drag-and-drop Web desi...
Freeway Pro lets you build websites with speed and precision... without writing a line of code! With it's user-oriented drag-and-drop interface, Freeway Pro helps you piece together the website of... Read more
Drive Genius 3.2.4 - Powerful system uti...
Drive Genius is an OS X utility designed to provide unsurpassed storage management. Featuring an easy-to-use interface, Drive Genius is packed with powerful tools such as a drive optimizer, a... Read more
Vitamin-R 2.15 - Personal productivity t...
Vitamin-R creates the optimal conditions for your brain to work at its best by structuring your work into short bursts of distraction-free, highly focused activity alternating with opportunities for... Read more
Toast Titanium 12.0 - The ultimate media...
Toast Titanium goes way beyond the very basic burning in the Mac OS and iLife software, and sets the standard for burning CDs, DVDs, and now Blu-ray discs on the Mac. Create superior sounding audio... Read more
OS X Yosemite Wallpaper 1.0 - Desktop im...
OS X Yosemite Wallpaper is the gorgeous new background image for Apple's upcoming OS X 10.10 Yosemite. This wallpaper is available for all screen resolutions with a source file that measures 5,418... Read more
Acorn 4.4 - Bitmap image editor. (Demo)
Acorn is a new image editor built with one goal in mind - simplicity. Fast, easy, and fluid, Acorn provides the options you'll need without any overhead. Acorn feels right, and won't drain your bank... Read more
Bartender 1.2.20 - Organize your menu ba...
Bartender lets you organize your menu bar apps. Features: Lets you tidy your menu bar apps how you want. See your menu bar apps when you want. Hide the apps you need to run, but do not need to... Read more

Latest Forum Discussions

See All

Super Heavy Sword (Games)
Super Heavy Sword 0.0.1 Device: iOS Universal Category: Games Price: $.99, Version: 0.0.1 (iTunes) Description: Get Ready to Get HEAVY! Monster Robot Studios presents SUPER Heavy Sword! The sequel to the smash hit HEAVY sword which... | Read more »
Angels In The Sky (Games)
Angels In The Sky 1.00 Device: iOS Universal Category: Games Price: $6.99, Version: 1.00 (iTunes) Description: - This game is only for the iPhone 5s. please do not use the iPad, iPhone 5 or earlier devices.- Just touch or holding... | Read more »
80 Days (Games)
80 Days 1.0.2 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.2 (iTunes) Description: 1872, with a steampunk twist. Phileas Fogg has wagered he can circumnavigate the world in just eighty days. Choose your own route... | Read more »
Micromon (Games)
Micromon 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: 130+ Animated Monsters to Catch & Battle! No waiting, play at your own pace! Embark on an epic monster capture RPG like none... | Read more »
Empire Manager (Games)
Empire Manager 1.0 Device: iOS iPhone Category: Games Price: $3.99, Version: 1.0 (iTunes) Description: Become ruler of an empire. Manage your economy, develop technology, hire an army and conquer the world in this addictive turn-... | Read more »
Empire Manager HD (Games)
Empire Manager HD 1.0 Device: iOS Universal Category: Games Price: $7.99, Version: 1.0 (iTunes) Description: Become ruler of an empire. Manage your economy, develop technology, hire an army and conquer the world in this addictive... | Read more »
Star Admiral Review
Star Admiral Review By Rob Thomas on July 30th, 2014 Our Rating: :: ADMIRABLE ADMIRALSUniversal App - Designed for iPhone and iPad While this new digital CCG may feel a bit familiar, Star Admiral offers a sci-fi twist and galaxy’s... | Read more »
Zap! Pow! Become a Badass Wizard in Phan...
Zap! Pow! | Read more »
Urban Trial Freestyle Review
Urban Trial Freestyle Review By Blake Grundman on July 30th, 2014 Our Rating: :: RIDIN' DIRTYUniversal App - Designed for iPhone and iPad A rough ride that has trouble keeping its wheels on the track.   | Read more »
Take Note! Noteshelf Has Recieved a Big...
Take Note! Noteshelf Has Recieved a Big Update. Posted by Jessica Fisher on July 30th, 2014 [ permalink ] iPad Only App - Designed for the iPad | Read more »

Price Scanner via MacPrices.net

Save $50 on the 2.5GHz Mac mini, plus free sh...
B&H Photo has the 2.5GHz Mac mini on sale for $549.99 including free shipping. That’s $50 off MSRP, and B&H will also include a free copy of Parallels Desktop software. NY sales tax only. Read more
Save up to $140 on an iPad Air with Apple ref...
Apple is offering Certified Refurbished iPad Airs for up to $140 off MSRP. Apple’s one-year warranty is included with each model, and shipping is free. Stock tends to come and go with some of these... Read more
$250 price drop on leftover 15-inch Retina Ma...
B&H Photo has dropped prices on 2013 15″ Retina MacBook Pros by $250 off original MSRP. Shipping is free, and B&H charges NY sales tax only: - 15″ 2.3GHz Retina MacBook Pro: $2249, $250 off... Read more
More iPad Upgrade Musings – The ‘Book Mystiqu...
Much discussed recently, what with Apple reporting iPad sales shrinkage over two consecutive quarters, is that it had apparently been widely assumed that tablet users would follow a two-year hardware... Read more
13-inch 2.5GHz MacBook Pro on sale for $999,...
Best Buy has the 13″ 2.5GHz MacBook Pro available for $999.99 on their online store. Choose free shipping or free instant local store pickup (if available). Their price is $100 off MSRP. Price is... Read more
Save up to $300 on an iMac with Apple refurbi...
The Apple Store has Apple Certified Refurbished iMacs available for up to $300 off the cost of new models. Apple’s one-year warranty is standard, and shipping is free. These are the best prices on... Read more
WaterField Unveils 15″ Outback Solo & 13″...
Hard on the heels of Apple’s refreshed MacBook Pro Retina laptops announcement, WaterField Designs has unveiled a 15-inch version of the waxed-canvas and leather Outback Solo and a 13-inch version of... Read more
New Roxio Toast 12 Delivers Digital Media Pow...
Roxio Toast 12 is a hub for sharing digital media to virtually any platform or device. has introduced two new additions to its Roxio Toast product family – Roxio Toast 12 Titanium and Roxio Toast 12... Read more
The lowest prices on leftover Retina MacBook...
Best Buy has dropped prices on leftover 13″ and 15″ Retina MacBook Pros by up to $300 off original MSRP on their online store for a limited time. Choose free local store pickup (if available) or free... Read more
Apple Updates MacBook Pro with Retina Display...
Apple today updated its MacBook Pro with Retina display with faster processors and double the amount of memory in both entry-level configurations. MacBook Pro with Retina display features a Retina... Read more

Jobs Board

Sr Software Lead Engineer, *Apple* Online S...
Sr Software Lead Engineer, Apple Online Store Publishing Systems Keywords: Company: Apple Job Code: E3PCAK8MgYYkw Location (City or ZIP): Santa Clara Status: Full Read more
Sr Software Lead Engineer, *Apple* Online S...
Sr Software Lead Engineer, Apple Online Store Publishing Systems Keywords: Company: Apple Job Code: E3PCAK8MgYYkw Location (City or ZIP): Santa Clara Status: Full Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Sr. Product Leader, *Apple* Store Apps - Ap...
**Job Summary** Imagine what you could do here. At Apple , great ideas have a way of becoming great products, services, and customer experiences very quickly. Bring Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.