TweetFollow Us on Twitter

cdev Debugging
Volume Number:6
Issue Number:2
Column Tag:Pascal Procedures

Related Info: Control Panel Dialog Manager

CDEV Debugging

By J. Peter Hoddie, Palo Alto, CA

A cdev Shell

This article describes a shell program created to simplify the process of writing, testing, and debugging Control Panel devices. The shell is written in MPW Pascal (actually it was developed in TML Pascal II, but the two are compatible) and so is appropriate for use with cdev’s written in the MPW environment. The cdev shell has been tested with Apple’s SADE debugger. This article does not describe how to write a cdev. For the details on writing a cdev, including a working example, see Inside Macintosh Volume 5.

Without a cdev shell, the process of testing a cdev is less then simple. You must compile and link the cdev, place it in the system folder, and select the Control Panel. Under these circumstances you cannot use a source level debugger, only MacsBug. Using the cdev shell, you simply link your cdev with the shell code and run it as a normal application which gives you access to a source level debugger. The cdev shell has several features designed specifically for testing. The shell itself does not appear graphically identical to the Control Panel, however as far as the cdev itself is concerned there is no difference.

The cdev shell was designed not only to allow the use of a source level debugger, but also to provide a collection of features for easily testing the many messages to which a cdev is expected to respond. Further, because as you are developing a cdev you may not have written code to handle each messages, a dialog presented from the “Message Masks...” menu item allows you to filter out any combination of cdev messages. Your message mask settings are stored as a resource type ‘msks’ so that you don’t have to reset them each time you use the shell.

An option to force the cdev to update its entire window to test your drawing code is available as the “Force Update” menu item.

A small window named “Other Window” appears above and to the right of the Control Panel window. This window allows you to test the activate and deactivate messages by making the “Other Window” the active window. By covering areas of your cdev’s panel with the “Other Window” you can further test the screen updating capabilities of your cdev.

All of the options on the standard Edit menu are passed to the cdev as the corresponding cdev messages.

When you start up the cdev shell, the test cdev is not selected. Either click on its icon or select Open from the file menu. To close the cdev, select Close from the file menu or click on the stop sign icon. This allows you to test the open and close cdev messages multiple times without having to relaunch the cdev shell. By not immediately selecting the test cdev in the shell, you have the opportunity to set break points, modify the message masks, and perform any other required actions.

Tech Note #215 - “New” cdev Messages - describes a cdev message, cursorDev, that is not documented in Inside Macintosh. It states that if a ‘CURS’ -4064 (cursor) resource is present in the cdev file, that the cdev will receive a cursorDev message (number 14) whenever the cursor is inside the cdev’s window. This allows the cdev to have its own cursor as appropriate. The shell fully supports this new message.

The shell also checks that certain required resources are present. If a required resource is missing, an error message is generated and the shell aborts. The cdev resources that the shell must have to run are ‘DITL’, ‘mach’, ‘nrct’, and ‘ICN#’ all with ID -4064. The only required resources that the shell does not check for are the ‘cdev’ code, ‘BNDL’ and ‘FREF’ resources.

The shell does other error checking as appropriate. For example, the macDev message is only allowed to return one of two values. If any other value is returned, the shell issues a warning alert.

The shell will only send the cdev the macDev message if the values of the hard and soft masks in the ‘mach’ -4064 resource are set as documented in Inside Macintosh. Otherwise the shell compares these to HwCfgFlags and ROM85 in low memory as described in Inside Macintosh. While Inside Macintosh claims that HwCfgFlags is a low memory global, its location is never given. I had to fish it out of one the “private” MPW Assembler equates files.

This article does not include a sample cdev to use with the shell. It is currently set up to work with the Sample provide in Inside Macintosh Volume 5. The only call the cdev shell makes to code outside itself is to the entry point of the cdev unit that is being tested. The name of the unit that the cdev shell expects to find is “cdev” and the name of the main cdev routine (really its entry point) is “Sample” - exactly as the sample unit in Inside Macintosh.

There is one minor bug in the Sample cdev from Inside Macintosh. In the function EnoughRoomToRun the call to GetResource should be replaced with a call to RGetResource or the cdev will not run.

The shell is not a great example of how to write a Macintosh application. It clearly demonstrates what Tech Note #203 - Don’t Abuse the Managers - tries to drive home: the Dialog Manager is not a user interface! Unfortunately, since the Control Panel relies on the Dialog Manager, there was no choice for the cdev shell. Also, the shell was originally written in THINK C, and then translated to Pascal when I found out that a cdev shell was shipping with THINK C Version 4. Anyone who is interested in the C version may contact me directly for a copy. Converting the code presented in this article to run under THINK Pascal should be an easy task.

File: cdevShell.make

# Commands to build cdev Shell using MPW Pascal
#
# put the name of your cdev files in place of cdev.p, 
# cdev.p.o, and cdev.r below
#
    Pascal cdev.p -sym on
    Pascal cdevShell.p -sym on
    Link -w -t ‘APPL’ -c ‘????’ -sym on 
 cdev.p.o 
   cdevShell.p.o 
 “{Libraries}”Runtime.o 
 “{Libraries}”Interface.o 
 “{PLibraries}”PasLib.o 
 “{PLibraries}”SANELib.o
 -o cdevShell
    Rez -append -o cdevShell cdev.r
    Rez -append -o cdevShell cdevShell.r
File: cdevShell.p

PROGRAM cdevShell;

USES  MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
 cdev;

CONST
 cursorDev = 14;
 HwCfgFlgs = $0B22;
 ROM85 = $028E;

TYPE
 IntPtr = ^integer;
 IntHandle = ^IntPtr;
 RectPtr = ^rect;
 EventPtr = ^EventRecord;

PROCEDURE doMenu(l: longInt); FORWARD;
PROCEDURE updateDial;FORWARD;
PROCEDURE drawIcon(ih: Handle; selected: Boolean;
 r: Rect);FORWARD;
PROCEDURE startupCdev;  FORWARD;
PROCEDURE shutDownCdev; FORWARD;
PROCEDURE cdevInitDev;  FORWARD;
PROCEDURE cdevHitDev(item: integer; e: EventPtr);
 FORWARD;
PROCEDURE cdevUpdateDev;  FORWARD;
PROCEDURE cdevNulDev(e: EventPtr); FORWARD;
PROCEDURE cdevCloseDev; FORWARD;
PROCEDURE cdevEdit(c: integer);  FORWARD;
PROCEDURE cdevKeyEvtDev(e: EventPtr);FORWARD;
PROCEDURE cdevActivate(e: EventPtr); FORWARD;
PROCEDURE cdevMacDev;FORWARD;
PROCEDURE cdevCursorDev;  FORWARD;
PROCEDURE fatalError(s : Str255);  FORWARD;
PROCEDURE warningError(s : Str255);FORWARD;
PROCEDURE doMsgDialog;  FORWARD;
FUNCTION callCdev( msgCode : integer; item : integer;
 e : EventPtr; st : longInt) :longInt; FORWARD;
PROCEDURE doNRCTs; FORWARD;
PROCEDURE getNRCTrgn;FORWARD;
PROCEDURE HiliteDefault(d: DialogPtr); FORWARD;

VAR
 cdevDial:DialogPtr;
 dP:    DialogPeek;
 cdevItems: integer;
 userItems: integer;
 teWas: integer;
 cdevStorage:  longInt;

 nrctRgn: RgnHandle;
 greyRgn: RgnHandle;
 userArea:Rect;

 stopRect,
 startRect: Rect;
 myStopIcon,
 myStartIcon:  Handle;

 cursorIsArrow:  Boolean;
 cdevMsgOff:array[0 .. 16] of Boolean;
 selected:Boolean;
 running: Boolean;

 env:   SysEnvRec;
 entryVref: integer;
 otherWindow:  WindowPtr;
 error: integer;

 i,j:   integer;
 temp, cdevDITL: Handle;
 e:EventRecord;
 rH:    RgnHandle;
 whichWindow:  WindowPtr;
 key:   char;
 p:Point;
 s:Str255;
 hasCursor: Boolean;
 teH:   TEHandle;
 trashB:Boolean;

PROCEDURE doMenu(l: longInt);
VARmenu, choice, i:integer;
 daName:Str255;
 d:DialogPtr;
BEGIN
 menu := HiWord(l);
 choice := LoWord(l);
 
 case menu of
 1:BEGIN
 if choice = 1 then BEGIN
 d := GetNewDialog(132, nil, WindowPtr(-1));
 HiliteDefault(d);
 repeat
 ModalDialog(nil, i)
 until i = 1;
 DisposDialog(d);
 END;
 if choice > 1 then BEGIN
 GetItem(GetMHandle(1), choice, daName);
 error := OpenDeskAcc(daName);
 END;
 END;
 2:case choice of
 1: startupCdev;
 2: shutDownCdev;
 4: running := false;
 END;
 3:if FrontWindow = cdevDial then
 cdevEdit(choice)
 else
 trashB := SystemEdit(choice - 1);
 4:case choice of
 1: doMsgDialog;
 2: 
 InvalRect(GrafPtr(cdevDial)^.portRect);
 END; { of case }
 END; { of case }
 HiliteMenu(0);
END;

PROCEDURE updateDial;
VAR
 r:Rect;
 patHand: PatHandle;
 i:integer;
 h:Handle;
BEGIN
 SetPort(cdevDial);
 TextSize(9);
 
 PenSize(2,2);
 
 patHand := GetPattern(-16000);
 PenPat(patHand^^);
 PaintRgn(nrctRgn);
 PenPat(black);

 doNRCTs;
 r := cdevDial^.portRect;
 InsetRect(r, -2, -2);
 r.top := r.top + 1;
 FrameRect(r);

 GetDItem(cdevDial, 2, i, h, r);
 r.top := r.top - 2;
 r.bottom := r.bottom -1;
 r.left := r.left - 2;
 r.right := r.right + 1;
 FrameRect(r);

 GetDItem(cdevDial, 1, i, h, r);
 r.top := r.top - 2;
 r.bottom := r.bottom + 2;
 r.left := r.left - 2;
 r.right := r.right + 2;
 FrameRect(r);

 PenSize(1,1);

 drawIcon(myStopIcon, not selected, stopRect);
 drawIcon(myStartIcon, selected, startRect);
END;

PROCEDURE drawIcon(ih: Handle; selected: Boolean; r: Rect);
VAR
 iconBitMap:BitMap;
 fromR: Rect;
BEGIN
 SetRect(fromR, 0, 0, 32, 32);
 iconBitMap.rowBytes := 4;
 iconBitMap.bounds := fromR;
 HLock(iH);
 if (selected) then BEGIN
 iconBitMap.baseAddr := Ptr(ORD4(iH^) + longInt(128));
 CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r,
 srcCopy, nil);

 iconBitMap.baseAddr := ih^;
 CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r,
 srcXor, nil);
 END
 else BEGIN
 iconBitMap.baseAddr := ih^;
 CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r,
 srcCopy, nil);
 END;
 HUnlock(iH);
END;

PROCEDURE startupCdev;
VAR
 temp:  Handle;
 i,j,totalItems: integer;
 hardMask, softMask: integer;
 p:Ptr;
 c:ControlHandle;
 tempD: DialogPtr;
 r:Rect;
BEGIN
 selected := true;
 
 getNRCTrgn;
 
 temp := GetResource(‘mach’, -4064);
 if temp = nil then
 fatalError(‘mach -4064 resource not found’);
 softMask := IntHandle(temp)^^;
 hardMask := IntPtr(2+ORD4(temp^))^;
 if (softMask = 0) and (hardMask = $ffff) then BEGIN
 cdevMacDev;
 if cdevStorage = 0 then
 fatalError(‘cdev refuses to run on this machine’);
 if cdevStorage <> 1 then
 fatalError(‘Invalid result returned from macDev call’);
 END
 else BEGIN
 if integer(BitAnd(softMask, IntPtr(ROM85)^))
 <> Intptr(ROM85)^ then
 fatalError(‘cdev failed SoftMask test’);
 if integer(BitAnd(hardMask, IntPtr(HwCfgFlgs)^))
 <> hardMask then
 fatalError(‘cdev failed HardMask test’);
 END;
 ReleaseResource(temp);

 IntHandle(dP^.items)^^ := cdevItems + userItems;
 dP^.editField := teWas;
 if teWas <> -1 then
 TEActivate( dP^.textH);
 SetPort(cdevDial);
 TextSize(9);
 for i:= cdevItems + 1 to cdevItems + userItems do
 ShowDItem(cdevDial,i);

 doNRCTs;
 
 DisableItem(GetMHandle(2),1);
 EnableItem(GetMHandle(2), 2);

 cdevInitDev;

 InvalRect(GrafPtr(cdevDial)^.portRect);
END;

PROCEDURE shutDownCdev;
VARi: integer;
BEGIN
 cdevCloseDev;

 SetCursor(arrow);
 cursorIsArrow := true;

 if cdevStorage <> 0 then
 warningError(‘Close call did not return zero’);

 for i := cdevItems + 1 to cdevItems + userItems do
 HideDItem(cdevDial, i);
 
 IntHandle(dP^.items)^^ := cdevItems;
 dP^.editField := -1;
 if teWas <> -1 then
 TEDeactivate(dP^.textH);

 selected := false;

 getNRCTrgn;

 EnableItem(GetMHandle(2), 1);
 DisableItem(GetMHandle(2), 2);

 InvalRect(GrafPtr(cdevDial)^.portRect);
END;

PROCEDURE cdevInitDev;
BEGIN
 cdevStorage := callCdev(initDev, 0, nil, cdevUnset);
END;

PROCEDURE cdevHitDev(item: integer; e: EventPtr);
BEGIN
 cdevStorage := callCdev(hitDev, item, e, cdevStorage);
END;

PROCEDURE cdevUpdateDev;
BEGIN
 cdevStorage := callCdev(updateDev, 0, nil, cdevStorage);
END;

PROCEDURE cdevNulDev(e: EventPtr);
BEGIN
 cdevStorage := callCdev(nulDev, 0, e, cdevStorage);
END;

PROCEDURE cdevCloseDev;
BEGIN
 cdevStorage := callCdev(closeDev, 0, nil, cdevStorage);
END;

PROCEDURE cdevEdit(c: integer);
BEGIN
 case c of
 1:i := undoDev;
 3:   i := cutDev;
 4:i := copyDev;
 5:i := pasteDev;
 6:i := clearDev;
 END;
 cdevStorage := callCdev(i, 0, nil, cdevStorage);
END;

PROCEDURE cdevKeyEvtDev(e: EventPtr);
BEGIN
 cdevStorage := callCdev(keyEvtDev, 0, e, cdevStorage);
END;

PROCEDURE cdevActivate(e: EventPtr);
VARi:   integer;
BEGIN
 if BitAnd(e^.modifiers, activeFlag) <> 0 then
 i := activDev
 else
 i := deactivDev;
 cdevStorage := callCdev(i, 0, e, cdevStorage);
END;

PROCEDURE cdevMacDev;
BEGIN
 cdevStorage := callCdev(macDev, 0, nil, cdevStorage);
END;

PROCEDURE cdevCursorDev;
BEGIN
 cdevStorage := callCdev(cursorDev, 0, nil, cdevStorage);
END;

FUNCTION callCdev( msgCode : integer; item : integer; 
 e : EventPtr; st : longInt) :longInt;
 var  rValue:  longInt;
 error :integer;
BEGIN
 if (not selected) or (cdevMsgOff[msgCode]) 
 then BEGIN
 callCdev := st;
 exit(callCdev);
 END;

 SetPort(cdevDial);
 TextSize(9);
 error := SetVol(nil, env.sysVRefNum);
 rValue := Sample(msgCode, item, cdevItems, 0, e^,
 st, cdevDial);
 error := SetVol(nil, entryVref);

 if (msgCode <> macDev) and 
 (msgCode <> closeDev) then
 case rValue of
 cdevGenErr:fatalError(‘General cdev error’);
 cdevMemErr: fatalError(‘cdev insufficient memory error’);
 cdevResErr: fatalError
 (‘cdev could not locate needed resource’);
 END; { of case }
 callCdev := rValue;
END;

PROCEDURE fatalError(s : Str255);
BEGIN
 ParamText(s, ‘’, ‘’, ‘’);
 error := Alert(130, nil);
 ExitToShell;
END;

PROCEDURE warningError(s : Str255);
BEGIN
 ParamText(s, ‘’, ‘’, ‘’);
 error := Alert(131, nil);
END;

PROCEDURE doMsgDialog;
VARd:   DialogPtr;
 i,kind:integer;
 r:Rect;
 h:Handle;
BEGIN
 d := GetNewDialog(128, nil, WindowPtr(-1));
 HiliteDefault(d);

 for i:= initDev + 3 to cursorDev + 3 do BEGIN
 GetDItem(d, i, kind, h, r);
 kind := integer(cdevMsgOff[i-3]);
 if kind <> 0 then
 kind := 1;
 SetCtlValue(ControlHandle(h), kind);
 END;
 
 repeat
 ModalDialog(nil, i);
 if i > 2 then BEGIN
 GetDItem(d, i, kind, h, r);
 SetCtlValue(ControlHandle(h),
 ABS(GetCtlValue(ControlHandle(h)) - 1));
 END
 until i <= 2;

 if i = 1 then BEGIN
 for i:= initDev + 3 to cursorDev + 3 do BEGIN
 GetDItem(d, i, kind, h, r);
 cdevMsgOff[i-3] :=
 Boolean(GetCtlValue(ControlHandle(h)));
 END;
 h := GetResource(‘msks’, 128);
 if h <> nil then BEGIN
 BlockMove(Ptr(@cdevMsgOff), h^, 16);
 ChangedResource(h);
 WriteResource(h);
 END;
 END;

 DisposDialog(d);
END;

PROCEDURE doNRCTs;
VARh:   Handle;
 r:RectPtr;
 i:integer;
BEGIN
 if not selected then
 exit(doNRCTs);

 h := GetResource(‘nrct’, -4064);
 r := RectPtr(2 + ORD4(h^));
 for i:= 1 to IntHandle(h)^^ do BEGIN
 EraseRect(r^);
 FrameRect(r^);
 r := RectPtr(ORD4(r) + sizeof(Rect));
 END; { of loop }
 ReleaseResource(h);
END;

PROCEDURE getNRCTrgn;
VAR
 h:Handle;
 r:RectPtr;
 rct: Rect;
 i:integer;
 rRgn:  RgnHandle;
BEGIN
 if not selected then
 BEGIN
 SetRect(rct, 86, -1, 322, 255);
 nrctRgn := NewRgn;
 RectRgn(nrctRgn, rct);
 exit(getNRCTrgn);
 END;

 h := GetResource(‘nrct’, -4064);
 if h = nil then
 fatalError(‘nrct -4064 resource is missing’);
 nrctRgn := NewRgn;
 HLock(h);
 r := RectPtr(2+ORD4(h^));
 for i:= 1 to IntHandle(h)^^ do BEGIN
 rRgn := NewRgn;
 RectRgn(rRgn, r^);
 r := RectPtr(ORD4(r) + sizeof(Rect));
 UnionRgn(nrctRgn, rRgn, nrctRgn);
 DisposeRgn(rRgn);
 END; { of loop }
 HUnlock(h);
 ReleaseResource(h);

 SetRect(rct, 86, -1, 322, 255);
 rRgn := NewRgn;
 RectRgn(rRgn, rct);
 DiffRgn(rRgn, nrctRgn, nrctRgn);
 DisposeRgn(rRgn);
END;

PROCEDURE mvWindow(w: WindowPtr; p: Point);
VARtrashR:Rect;
BEGIN
 trashR := screenBits.bounds;
 InsetRect(trashR, 6, 6);
 DragWindow(w, p, trashR);
END;

PROCEDURE HiliteDefault(d: DialogPtr);
VARi:   integer;
 box:   Rect;
 h:Handle;
BEGIN
 SetPort(d);
 GetDItem(d, 1, i, h, box);
 PenSize(3,3);
 InsetRect(box, -4, -4);
 FrameRoundRect(box, 16, 16);
END;

PROCEDURE Initialize;
BEGIN
 InitGraf(@thePort);
 InitFonts;
 InitWindows;
 TEInit;
 InitDialogs(nil);
 InitCursor;
 cursorIsArrow := true;
 MaxApplZone;
 
 SetMenuBar( GetNewMBar(256) );
 AddResMenu( GetMHandle(1), ‘DRVR’);
 DrawMenuBar;
 DisableItem(GetMHandle(2),2);
 
 error := SysEnvirons(0, env);
 error := GetVol(@s, entryVref);

 getNRCTrgn;
 
 temp := GetResource(‘msks’, 128);
 if temp <> nil then
 BlockMove(temp^, Ptr(@cdevMsgOff), 16);

 hasCursor := ( GetResource(‘CURS’, -4064) <> nil );

 SetRect(userArea, 87, 0, 322, 255);
 SetRect(stopRect, 25, 15, 25+32, 15+32);
 SetRect(startRect, 25, 85, 25+32, 85+32);

 myStartIcon := GetResource(‘ICN#’, -4064);
 if (myStartIcon = nil) then
 fatalError(‘Unable to find cdev ICN# -4064 resource’);
 myStopIcon := GetResource(‘ICN#’, 128);

 selected := false;

 cdevDITL := GetResource(‘DITL’, -16000);
 HNoPurge(cdevDITL);
 temp := GetResource(‘DITL’, -4064);
 if temp = nil then
 fatalError(‘Unable to find cdev DITL -4064 resource’);
 cdevItems := 1 + IntHandle(cdevDITL)^^;
 
 userItems := IntHandle(temp)^^;
 IntHandle(cdevDITL)^^ := cdevItems + userItems;
 i := GetHandleSize( cdevDITL );
 j := GetHandleSize( temp );
 SetHandleSize(cdevDITL, i+j-2);
 BlockMove(Ptr(2 + ORD4(temp^)), 
 Ptr(i + ORD4(cdevDITL^)), j-2);
 
 SetDAFont(1);
 cdevDial := GetNewDialog(-16000, nil, WindowPtr(-1));
 SetDAFont(0);
 dP := DialogPeek(cdevDial);
 SetPort(cdevDial);
 TextSize(9);
 ShowWindow(cdevDial);
 for i:= cdevItems + 1 to cdevItems+userItems do
 HideDItem(cdevDial, i);

 IntHandle(dP^.items)^^ := cdevItems;
 teWas := dP^.editField;
 dP^.editField := -1;
 if teWas >= 0 then BEGIN
 teH := dp^.textH;
 teH^^.txSize := 9;
 END;

 otherWindow := GetNewWindow(128, nil, WindowPtr(0));
END; { of Initialize}

PROCEDURE DoNullEvent;
BEGIN
 cdevNulDev(@e);
 SetPort(cdevDial);
 GetMouse(p);
 if (FrontWindow = cdevDial) and 
 PtInRect(p, userArea) then BEGIN
 if hasCursor then 
 cdevCursorDev
 else 
 if cursorIsArrow then
 SetCursor(GetCursor(crossCursor)^^);
 cursorIsArrow := false;
 END
 else
 if not cursorIsArrow then BEGIN
 SetCursor(arrow);
 cursorIsArrow := true
 END
END; { of doNullEvent }

PROCEDURE DoMouseDown;
BEGIN
 i := FindWindow(e.where, whichWindow);
 case i of
 inMenuBar: doMenu( MenuSelect(e.where) );
 inDrag:BEGIN
 mvWindow(whichWindow, e.where);
 e.what := nullEvent;
 END;
 inGoAway:if TrackGoAway(whichWindow, e.where)                 
 then running := false;
 inSysWindow: SystemClick(e, whichWindow);
 inContent: BEGIN
 if FrontWindow <> whichWindow
 then BEGIN
 SelectWindow(whichWindow);
 e.what := nullEvent
 END
 else if (FrontWindow = cdevDial)
 then BEGIN
 p := e.where;
 GlobalToLocal(p);
 if (not selected) and    PtInRect(p, startRect) then
 startUpCdev;
 if selected and
 PtInRect(p, stopRect) then
 shutDownCdev;
 END; { of if frontWindow}
 END; { of inContent}
 END; { end of case }
END;


BEGIN
 Initialize;

 running := true;
 while running do BEGIN
 SystemTask;
 
 if dp^.editField >= 0 then
 TEIdle( dp^.textH);
 
 if GetNextEvent(everyEvent, e) then BEGIN

 if (e.what = keyDown) or (e.what = autoKey) 
 then BEGIN
 key := char(BitAnd(e.message,charCodeMask));
 if BitAnd(e.modifiers, cmdKey) <> 0 then                      BEGIN
 doMenu(MenuKey(key));
 e.what := nullEvent;
 END;
 END;
 
 if e.what = mouseDown then
 DoMouseDown;

 if (e.what = updateEvt) and
 (e.message=longInt(otherWindow))
 then BEGIN
 BeginUpdate(otherWindow);
 EndUpdate(otherWindow);
 END;
 if IsDialogEvent(e) then BEGIN
 if (e.what = updateEvt) and
 (e.message = longInt(cdevDial))
 then BEGIN
 rH :=
 WindowPeek(cdevDial)^.updateRgn;
 error := HandToHand(Handle(rH));
 BeginUpdate(cdevDial);
 updateDial;
 cdevUpdateDev;
 EndUpdate(cdevDial);
 WindowPeek(cdevDial)^.updateRgn
 := rH;
 END;
 if (e.what = keyDown) or
 (e.what = autoKey) then
 cdevKeyEvtDev(@e);
 if e.what = activateEvt then
 cdevActivate(@e);
 
 SetPort(cdevDial);
 TextSize(9);
 if DialogSelect(e, cdevDial, i) then
 BEGIN
 if e.what = mouseDown then BEGIN
 if i =1 then
 error := 
 Alert(-16000, nil);
 if i > cdevItems then
 cdevHitDev(i, @e);
 END;
 END; { of DialogSelect if }
 END; { of DialogEvent if }
 END; { end of GNE if }
 if e.what = nullEvent then
 doNullEvent;

 END;

 cdevCloseDev;
 DisposDialog(cdevDial);
 DisposeWindow(otherWindow);
END.
File: cdevShell.r

#include “SysTypes.r”
#include “Types.r”

resource ‘PAT ‘ (-16000, purgeable) {
 $”40 00 04 00 40 00 04"
};

resource ‘ICN#’ (128, “Other”) {
 { /* array: 2 elements */
 /* [1] */
 $”00 00 00 00 00 7F FF 80 00 80 00 40 01 00 00 20"
 $”02 00 00 10 04 3C 00 08 08 24 00 04 08 20 00 02"
 $”08 3D F0 02 08 04 40 02 08 24 40 02 08 3C 5E 02"
 $”08 00 52 02 08 00 52 02 08 00 12 02 08 00 12 F2"
 $”08 00 1E 92 08 00 00 92 08 00 00 F2 08 00 00 82"
 $”08 00 00 82 04 00 00 82 02 00 00 02 01 00 00 04"
 $”00 80 00 08 00 40 00 10 00 20 00 20 00 1F FF C0",
 /* [2] */
 $”00 00 00 00 00 7F FF 80 00 FF FF C0 01 FF FF E0"
 $”03 FF FF F0 07 FF FF F8 0F FF FF FC 0F FF FF FE”
 $”0F FF FF FE 0F FF FF FE 0F FF FF FE 0F FF FF FE”
 $”0F FF FF FE 0F FF FF FE 0F FF FF FE 0F FF FF FE”
 $”0F FF FF FE 0F FF FF FE 0F FF FF FE 0F FF FF FE”
 $”0F FF FF FE 07 FF FF FE 03 FF FF FE 01 FF FF FC”
 $”00 FF FF F8 00 7F FF F0 00 3F FF E0 00 1F FF C0"
 }
};

resource ‘DLOG’ (-16000, purgeable) {
 {58, 117, 311, 437},
 documentProc,
 invisible,
 goAway,
 0x0,
 -16000,
 “Control Panel”
};

resource ‘DLOG’ (128, “Msg Masks”) {
 {50, 60, 286, 450},
 dBoxProc,
 visible,
 goAway,
 0x0,
 128,
 “”
};

resource ‘DLOG’ (132, “About...”) {
 {62, 104, 172, 398},
 dBoxProc,
 visible,
 noGoAway,
 0x0,
 132,
 “”
};

resource ‘DITL’ (-15999, purgeable) {
 { {65, 85, 85, 155},
 Button {
 enabled,
 “OK”
 },
 {8, 60, 56, 235},
 StaticText {
 disabled,
 “”
 },
 {61, 81, 89, 159},
 UserItem {
 disabled
 },
 {10, 20, 42, 52},
 Icon {
 enabled,
 0
 }
 }
};

resource ‘DITL’ (-16000, purgeable) {
 { {241, 1, 253, 87},
 StaticText {
 enabled,
 “3.3.1”
 },
 {1, 1, 242, 88},
 UserItem {
 enabled
 }
 }
};

resource ‘DITL’ (-15998, purgeable) {
 { {5, 7, 100, 227},
 StaticText {
 disabled,
 “Contributions by:\n   Steve Horowitz--the “
 “main man\n   scott douglass\n   Kristee Kr”
 “eitman\n   Amy Goldsmith”
 },
 {113, 155, 134, 224},
 Button {
 enabled,
 “Continue”
 }
 }
};

resource ‘DITL’ (130) {
 { {139, 189, 159, 249},
 Button {
 enabled,
 “OK”
 },
 {29, 30, 124, 251},
 StaticText {
 disabled,
 “Fatal Error: ^0”
 }
 }
};

resource ‘DITL’ (128) {
 { {202, 300, 222, 360},
 Button {
 enabled,
 “OK”
 },
 {201, 212, 221, 272},
 Button {
 enabled,
 “Cancel”
 },
 {40, 24, 62, 102},
 CheckBox {
 enabled,
 “initDev”
 },
 {70, 24, 84, 110},
 CheckBox {
 enabled,
 “hitDev”
 },
 {100, 24, 115, 104},
 CheckBox {
 enabled,
 “closeDev”
 },
 {130, 24, 146, 106},
 CheckBox {
 enabled,
 “nulDev”
 },
 {160, 24, 176, 112},
 CheckBox {
 enabled,
 “updateDev”
 },
 {40, 160, 61, 251},
 CheckBox {
 enabled,
 “activDev”
 },
 {70, 160, 92, 276},
 CheckBox {
 enabled,
 “deActiveDev”
 },
 {100, 160, 116, 253},
 CheckBox {
 enabled,
 “keyEvtDev”
 },
 {130, 160, 148, 261},
 CheckBox {
 enabled,
 “macDev”
 },
 {160, 160, 180, 268},
 CheckBox {
 enabled,
 “undoDev”
 },
 {40, 282, 69, 368},
 CheckBox {
 enabled,
 “cutDev”
 },
 {70, 282, 100, 367},
 CheckBox {
 enabled,
 “copyDev”
 },
 {100, 282, 127, 369},
 CheckBox {
 enabled,
 “pasteDev”
 },
 {130, 282, 154, 374},
 CheckBox {
 enabled,
 “clearDev”
 },
 {160, 282, 184, 365},
 CheckBox {
 enabled,
 “cursorDev”
 },
 {8, 8, 33, 278},
 StaticText {
 disabled,
 “Mark Boxes to Disable cdev Messages:”
 }
 }
};

resource ‘DITL’ (131) {
 { {106, 168, 126, 228},
 Button {
 enabled,
 “OK”
 },
 {7, 14, 98, 228},
 StaticText {
 disabled,
 “Warning: ^0”
 }
 }
};

resource ‘DITL’ (132) {
 { {80, 217, 100, 277},
 Button {
 enabled,
 “OK”
 },
 {12, 51, 32, 238},
 StaticText {
 disabled,
 “cdev Shell for Pascal”
 },
 {48, 52, 68, 235},
 StaticText {
 disabled,
 “© 1989 by J. Peter Hoddie”
 }
 }
};

resource ‘CNTL’ (-4048, purgeable) {
 {26, 122, 43, 170},
 0,
 visible,
 1,
 0,
 radioButProcUseWFont,
 0,
 “Show”
};

resource ‘MENU’ (128, “Apple Menu”) {
 1,
 textMenuProc,
 0x7FFFFFFD,
 enabled,
 apple,
 { “About it...”, noIcon, noKey, noMark, plain,
 “-”, noIcon, noKey, noMark, plain
 }
};

resource ‘MENU’ (129, “Files”) {
 2,
 textMenuProc,
 0x7FFFFFFB,
 enabled,
 “File”,
 { “Open”, noIcon, “O”, noMark, plain,
 “Close”, noIcon, “W”, noMark, plain,
 “-”, noIcon, noKey, noMark, plain,
 “Quit”, noIcon, “Q”, noMark, plain
 }
};

resource ‘MENU’ (130, “Edit”, preload) {
 3,
 textMenuProc,
 0x7FFFFFFD,
 enabled,
 “Edit”,
 { “Undo”, noIcon, “Z”, noMark, plain,
 “-”, noIcon, noKey, noMark, plain,
 “Cut”, noIcon, “X”, noMark, plain,
 “Copy”, noIcon, “C”, noMark, plain,
 “Paste”, noIcon, “V”, noMark, plain,
 “Clear”, noIcon, noKey, noMark, plain
 }
};

resource ‘MENU’ (131, “Options”) {
 4,
 textMenuProc,
 allEnabled,
 enabled,
 “Options”,
 { “Msg Masks...”, noIcon, noKey, noMark, plain,
 “Force Update”, noIcon, noKey, noMark, plain
 }
};

resource ‘MBAR’ (256) {
 { 128,
 129,
 130,
 131
 }
};

resource ‘ALRT’ (-16000, purgeable) {
 {48, 128, 188, 368},
 -15998,
 {
 OK, visible, silent,
 OK, visible, silent,
 OK, visible, silent,
 OK, visible, silent
 }
};

resource ‘ALRT’ (130, “Fatal Error”) {
 {56, 126, 238, 410},
 130,
 { OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1
 }
};

resource ‘ALRT’ (131, “Warning Error”) {
 {54, 134, 192, 378},
 131,
 { OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1
 }
};

data ‘msks’ (128) {
 $”00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
 };

resource ‘WIND’ (128, “Other Window”) {
 {38, 388, 80, 510},
 documentProc,
 visible,
 noGoAway,
 0x0,
 “OtherWindow”
};

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Combo Quest (Games)
Combo Quest 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: Combo Quest is an epic, time tap role-playing adventure. In this unique masterpiece, you are a knight on a heroic quest to retrieve... | Read more »
Hero Emblems (Games)
Hero Emblems 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: ** 25% OFF for a limited time to celebrate the release ** ** Note for iPhone 6 user: If it doesn't run fullscreen on your device... | Read more »
Puzzle Blitz (Games)
Puzzle Blitz 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Puzzle Blitz is a frantic puzzle solving race against the clock! Solve as many puzzles as you can, before time runs out! You have... | Read more »
Sky Patrol (Games)
Sky Patrol 1.0.1 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.1 (iTunes) Description: 'Strategic Twist On The Classic Shooter Genre' - Indie Game Mag... | Read more »
The Princess Bride - The Official Game...
The Princess Bride - The Official Game 1.1 Device: iOS Universal Category: Games Price: $3.99, Version: 1.1 (iTunes) Description: An epic game based on the beloved classic movie? Inconceivable! Play the world of The Princess Bride... | Read more »
Frozen Synapse (Games)
Frozen Synapse 1.0 Device: iOS iPhone Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: Frozen Synapse is a multi-award-winning tactical game. (Full cross-play with desktop and tablet versions) 9/10 Edge 9/10 Eurogamer... | Read more »
Space Marshals (Games)
Space Marshals 1.0.1 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.1 (iTunes) Description: ### IMPORTANT ### Please note that iPhone 4 is not supported. Space Marshals is a Sci-fi Wild West adventure taking place... | Read more »
Battle Slimes (Games)
Battle Slimes 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: BATTLE SLIMES is a fun local multiplayer game. Control speedy & bouncy slime blobs as you compete with friends and family.... | Read more »
Spectrum - 3D Avenue (Games)
Spectrum - 3D Avenue 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: "Spectrum is a pretty cool take on twitchy/reaction-based gameplay with enough complexity and style to stand out from the... | Read more »
Drop Wizard (Games)
Drop Wizard 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Bring back the joy of arcade games! Drop Wizard is an action arcade game where you play as Teo, a wizard on a quest to save his... | Read more »

Price Scanner via MacPrices.net

Apple’s M4 Mac minis on sale for record-low p...
B&H Photo has M4 and M4 Pro Mac minis in stock and on sale right now for up to $150 off Apple’s MSRP, each including free 1-2 day shipping to most US addresses. Prices start at only $469: – M4... Read more
Deal Alert! Mac Studio with M4 Max CPU on sal...
B&H Photo has the standard-configuration Mac Studio model with Apple’s M4 Max CPU in stock today and on sale for $300 off MSRP, now $1699 (10-Core CPU and 32GB RAM/512GB SSD). B&H also... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.