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
$102.50
Apple Inc.
+0.25
MSFT
$45.43
Microsoft Corpora
+0.55
GOOG
$571.60
Google Inc.
+2.40

MacTech Search:
Community Search:

Software Updates via MacUpdate

VueScan 9.4.41 - Scanner software with a...
VueScan is a scanning program that works with most high-quality flatbed and film scanners to produce scans that have excellent color fidelity and color balance. VueScan is easy to use, and has... Read more
Cloud 3.0.0 - File sharing from your men...
Cloud is simple file sharing for the Mac. Drag a file from your Mac to the CloudApp icon in the menubar and we take care of the rest. A link to the file will automatically be copied to your clipboard... Read more
LibreOffice 4.3.1.2 - 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
SlingPlayer Plugin 3.3.20.505 - Browser...
SlingPlayer is the screen interface software that works hand-in-hand with the hardware inside the Slingbox to make your TV viewing experience just like that at home. It features an array of... Read more
Get Lyrical 3.8 - Auto-magically adds ly...
Get Lyrical auto-magically add lyrics to songs in iTunes. You can choose either a selection of tracks, or the current track. Or turn on "Active Tagging" to get lyrics for songs as you play them.... Read more
Viber 4.2.2 - Send messages and make cal...
Viber lets you send free messages and make free calls to other Viber users, on any device and network, in any country! Viber syncs your contacts, messages and call history with your mobile device,... Read more
Cocktail 7.6 - General maintenance and o...
Cocktail is a general purpose utility for OS X that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
LaunchBar 6.1 - Powerful file/URL/email...
LaunchBar is an award-winning productivity utility that offers an amazingly intuitive and efficient way to search and access any kind of information stored on your computer or on the Web. It provides... Read more
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
BBEdit 10.5.12 - Powerful text and HTML...
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

Latest Forum Discussions

See All

Rhonna Designs Magic (Photography)
Rhonna Designs Magic 1.0 Device: iOS Universal Category: Photography Price: $1.99, Version: 1.0 (iTunes) Description: Want to sprinkle *magic* on your photos? With RD Magic, you can add colors, filters, light leaks, bokeh, edges,... | Read more »
This Week at 148Apps: August 25-29, 2014
Shiny Happy App Reviews   | Read more »
Qube Kingdom – Tips, Tricks, Strategies,...
Qube Kingdom is a tower defense game from DeNA. You rally your troops – magicians, archers, knights, barbarians, and others – and fight against an evil menace looking to dominate your kingdom of tiny squares. Planning a war isn’t easy, so here are a... | Read more »
Qube Kingdom Review
Qube Kingdom Review By Nadia Oxford on August 29th, 2014 Our Rating: :: KIND OF A SQUARE KINGDOMUniversal App - Designed for iPhone and iPad Qube Kingdom has cute visuals, but it’s a pretty basic tower defense game at heart.   | Read more »
Fire in the Hole Review
Fire in the Hole Review By Rob Thomas on August 29th, 2014 Our Rating: :: WALK THE PLANKUniversal App - Designed for iPhone and iPad Seafoam’s Fire in the Hole looks like a bright, 8-bit throwback, but there’s not enough booty to... | Read more »
Alien Creeps TD is Now Available Worldwi...
Alien Creeps TD is Now Available Worldwide Posted by Ellis Spice on August 29th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Dodo Master Review
Dodo Master Review By Jordan Minor on August 29th, 2014 Our Rating: :: NEST EGGiPad Only App - Designed for the iPad Dodo Master is tough but fair, and that’s what makes it a joy to play.   | Read more »
Motorsport Manager Review
Motorsport Manager Review By Lee Hamlet on August 29th, 2014 Our Rating: :: MARVELOUS MANAGEMENTUniversal App - Designed for iPhone and iPad Despite its depth and sense of tactical freedom, Motorsport Manager is one of the most... | Read more »
Motorsport Manager – Beginner Tips, Tric...
The world of Motorsport management can be an unforgiving and merciless one, so to help with some of the stress that comes with running a successful race team, here are a few hints and tips to leave your opponents in the dust. | Read more »
CalPal Update Brings the App to 2.0, Add...
CalPal Update Brings the App to 2.0, Adds Lots of New Stuff Posted by Ellis Spice on August 29th, 2014 [ permalink ] | Read more »

Price Scanner via MacPrices.net

The Rise of Phablets
Carlisle & Gallagher Consulting Group, a businesses and technology consulting firm focused solely on the financial services industry, has released an infographic depicting the convergence of... Read more
Eddy – Cloud Music Player for iPhone/iPad Fre...
Ukraine based CapableBits announces the release of Eddy, its tiny, but smart and powerful cloud music player for iPhone and iPad that allows users to stream or download music directly from cloud... Read more
A&D Medical Launches Its WellnessConnecte...
For consumers and the healthcare providers and loved ones who care for them, A&D Medical, a leader in connected health and biometric measurement devices and services, has launched its... Read more
Anand Lal Shimpi Retires From AnandTech
Anand Lal Shimpi, whose AnandTech Website is famous for its meticulously detailed and thoroughgoing reviews and analysis, is packing it in. Lal Shimpi, who founded the tech site at age 14 in 1997,... Read more
2.5GHz Mac mini, Apple refurbished, in stock...
The Apple Store has Apple Certified Refurbished 2.5GHz Mac minis available for $509, $90 off MSRP. Apple’s one-year warranty is included, and shipping is free. Read more
13-inch 2.5GHz MacBook Pro on sale for $999,...
B&H Photo has the 13″ 2.5GHz MacBook Pro on sale for $999.99 including free shipping plus NY sales tax only. Their price is $100 off MSRP. Read more
Labor Day Weekend MacBook Pro sale; 15-inch m...
B&H Photo has the new 2014 15″ Retina MacBook Pros on sale for up to $125 off MSRP. Shipping is free, and B&H charges NY sales tax only. They’ll also include free copies of Parallels Desktop... Read more
Labor Day Weekend iPad mini sale; $50 to $100...
Best Buy has the iPad mini with Retina Display (WiFi models) on sale for $50 off MSRP on their online store for Labor Day Weekend. Choose free shipping or free local store pick up. Price is for... Read more
13-inch 1.4GHz MacBook Air on sale for $899,...
Adorama has the new 2014 13″ 1.4GHz/128GB MacBook Air on sale for $899.99 including free shipping plus NY & NJ tax only. Their price is $100 off MSRP. Read more
It’s Official: Apple Issues Invitations To Se...
Apple has issued one of its characteristically cryptic press invitations for a special event to be held at the Flint Center for the Performing Arts in hometown Cupertino on Sept. 9, 2014 at 10:00 am... 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...
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
Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.