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
$112.14
Apple Inc.
+2.73
MSFT
$47.25
Microsoft Corpora
+1.51
GOOG
$507.67
Google Inc.
+2.78

MacTech Search:
Community Search:

Software Updates via MacUpdate

BBEdit 11.0.2 - Powerful text and HTML e...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more
ExpanDrive 4.2.1 - Access cloud storage...
ExpanDrive builds cloud storage in every application, acts just like a USB drive plugged into your Mac. With ExpanDrive, you can securely access any remote file server directly from the Finder or... Read more
Adobe After Effects CC 2014 13.2 - Creat...
After Effects CC 2014 is available as part of Adobe Creative Cloud for as little as $19.99/month (or $9.99/month if you're a previous After Effects customer). After Effects CS6 is still available... Read more
Command-C 1.1.7 - Clipboard sharing tool...
Command-C is a revolutionary app which makes easy to share your clipboard between iOS and OS X using your local WiFi network, even if the app is not currently opened. Copy anything (text, pictures,... Read more
Tidy Up 4.0.2 - Find duplicate files and...
Tidy Up is a complete duplicate finder and disk-tidiness utility. With Tidy Up you can search for duplicate files and packages by the owner application, content, type, creator, extension, time... Read more
Typinator 6.3 - Speedy and reliable text...
Typinator turbo-charges your typing productivity. Type a little. Typinator does the rest. We've all faced projects that require repetitive typing tasks. With Typinator, you can store commonly used... Read more
GraphicConverter 9.5 - Graphics editor w...
GraphicConverter is an all-purpose image-editing program that can import 200 different graphic-based formats, edit the image, and export it to any of 80 available file formats. The high-end editing... Read more
Toast Titanium 12.0.1 - The ultimate med...
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
QuickBooks 2015 16.0.2.1422 R3 - Financi...
Save 20% on QuickBooks Pro for Mac today through this special discount link QuickBooks Pro 2013 helps you manage your business easily and efficiently. Organize your finances all in one place, track... Read more
Remotix 3.0.6 - Access all your computer...
Remotix is a fast and powerful application to easily access multiple Macs (and PCs) from your own Mac. Features: Complete Apple Screen Sharing support - including Mac OS X login, clipboard... Read more

Latest Forum Discussions

See All

Game of the Year 2014 – 148Apps Staff Pi...
The end of 2014 is almost here, which can only mean one thing. Okay it can mean a lot of things, but in this specific context it means Game of the Year lists! Which is why the 148Apps staff have all picked their favorites from the past year. And why... | Read more »
Dragon Quest III Review
Dragon Quest III Review By Jennifer Allen on December 18th, 2014 Our Rating: :: DATED BUT NOT WITHOUT MERITUniversal App - Designed for iPhone and iPad A walk down memory lane isn’t foolproof for Dragon Quest III, but it has its... | Read more »
8 KEMCO JRPGs Are Just $0.99 in Celebrat...
8 KEMCO JRPGs Are Just $0.99 in Celebration of the Holidays Posted by Jessica Fisher on December 18th, 2014 [ permalink ] KEMCO has announc | Read more »
Brothers in Arms 3: Sons of War Review
Brothers in Arms 3: Sons of War Review By Jennifer Allen on December 18th, 2014 Our Rating: :: FUN BUT PUSHYUniversal App - Designed for iPhone and iPad Brothers in Arms 3: Sons of War could be great fun, but its plethora of... | Read more »
The Snow is Falling on the French Countr...
The Snow is Falling on the French Countryside of Carcassonne’s Newest Update Posted by Jessica Fisher on December 18th, 2014 [ permalink ] < | Read more »
Creatures Such As We Review
Creatures Such As We Review By Jennifer Allen on December 18th, 2014 Our Rating: :: INTERESTING DISCUSSIONSUniversal App - Designed for iPhone and iPad Taking a more sedate approach to interactive fiction, Creatures Such As We... | Read more »
Stair: Slide the Blocks to Ascend (Game...
Stair: Slide the Blocks to Ascend 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Slide the blocks to ascend! Stair: Slide the Blocks to Ascend | Read more »
Give It Up! (Games)
Give It Up! 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: GIVE IT UP is a rather hard game where you have to assist this cheerful, singing Blob in jumping through 9 different tracks.So far... | Read more »
The Drive : Devil's Run (Games)
The Drive : Devil's Run 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: ON THE ROAD AGAIN! The Drive - Devil’s Run is classic point to point style racing game that pays homage to the classics... | Read more »
Procreate Pocket (Entertainment)
Procreate Pocket 1.01 Device: iOS iPhone Category: Entertainment Price: $2.99, Version: 1.01 (iTunes) Description: Create - anytime, anywhere. Made by the developers of the award-winning Procreate® for iPad®, Procreate Pocket™ allows... | Read more »

Price Scanner via MacPrices.net

iOS and Android OS Targeted by Man-in-the-Mid...
Cloud services security provider Akamai Technologies, Inc. has released, through the company’s Prolexic Security Engineering & Research Team (PLXsert), a new cybersecurity threat advisory. The... Read more
KMI MIDI K-Board Great Gift for Amateur &...
The K-Board is a MIDI Nano keyboard for music creation for iPad, Android, And computers; the easiest way to make music with iPads & Android tablets, and Mac, Windows, or Linux computers. Ultra-... Read more
Amazon offers 15-inch 2.2GHz Retina MacBook P...
 Amazon.com has the 15″ 2.2GHz Retina MacBook Pro on sale for $1699 including free shipping. Their price is $300 off MSRP. Stock is limited, so act now if you’re interested. Read more
Holiday sales continue: MacBook Pros for up t...
 B&H Photo has new MacBook Pros on sale for up to $300 off MSRP as part of their Holiday pricing. Shipping is free, and B&H charges NY sales tax only: - 15″ 2.2GHz Retina MacBook Pro: $1699... Read more
Google Search App For iOS Gets A Major Makeov...
Google has given iOS users an early Christmas present with a substantial update of it’s not-very-often-upgraded Google Search app. Google Search has been my go-to tool for Web searches since it was... Read more
ShopKeep Apple Pay And Chip Card Reader Avail...
ShopKeep, a cloud-based technology provider to more than 10,000 small business owners to manage retail shops and restaurants with iPads, has released its new Apple Pay and chip card reader. This... Read more
Holiday sale! 27-inch 5K iMac for $2299, save...
 B&H Photo has the 27″ 3.5GHz 5K iMac in stock today and on sale for $2299 including free shipping plus NY sales tax only. Their price is $200 off MSRP, and it’s the lowest price available for... Read more
Holiday Sale! 3.7GHz Quad Core Mac Pro availa...
 B&H Photo has the 3.7GHz Quad Core Mac Pro on sale for $2599 including free shipping plus NY sales tax only. Their price is $400 off MSRP, and it’s the lowest price for this model from any... Read more
iPhone 6 Number 3 Canadian Google Search Of 2...
CTVNews.ca reports that Apple’s iPhone 6 was the third highest-trending Google Canada search topic of 2014, exceeded only by Robin Williams largely after his death by suicide in August, and the FIFA... Read more
New iPad mini 3 Counter-Top & Wall Mount...
newMacgadgets has announced new secure all-acrylic displays for the iPad mini 3 (also works fine with the mini 2, last year’s iPad mini With Retina Display, and the original iPad mini). The new iPad... 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
*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
*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
*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
Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.