home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-01-01 | 11.5 KB | 324 lines | [TEXT/MPS ] |
- {
- COPYRIGHT (C) 1984-1989 Apple Computer,Inc.
- All rights reserved
-
- Resource editor interface unit for instances of editors and pickers. This should be
- USE'd by any pascal implementation of a resource editor or picker. The
- companion file ResDisp.a.o should be linked with the pascal to build
- the file for inclusion in ResEdit.
-
- Pickers are given a resource type and should display all of that type in
- the current resfile in a suitable format. If the picker is given an open call
- AND there's a compatible editor, it should give birth to the Editor. The editor
- is given a handle to the resource object and it should open up an edit
- window for the user.
-
- Note that anybody can open pickers and editors so, for instance, a dialog item list
- editor might open an icon Picker for the user to choose an appropriate icon.
- The user could also, while in the icon picker, open the icon editor to create
- a new icon if desired. }
-
-
- UNIT ResEd;
-
-
- INTERFACE
-
- Uses Memtypes, QuickDraw, OSIntf, ToolIntf;
-
-
- CONST
-
- { Standard menus exported by ResEdit }
-
- fileMenu = 2;
-
- newItem = 1;
- openItem = 2;
- openAsItem = 3;
- opnOther = 3;
- openGeneralItem = 4;
- opnGnrl = 4;
- closeItem = 6;
- saveItem = 7;
- revertItem = 8;
- getInfoItem = 9;
- preferencesItem = 10;
- transferItem = 12;
- quitItem = 13;
-
- { Masks for AbleMenu - normally not used directly. }
- newMask = $2;
- openMask = $4;
- openAsMask = $8;
- openGnrlMask = $10;
- closeMask = $40;
- saveMask = $80;
- revertMask = $100;
- getInfoMask = $200;
- preferencesMask = $400;
- transferMask = $1000;
- quitMask = $2000;
- disabledMask = $FFFFC001;
-
- { Mask combinations to be used in calls to AbleMenu. }
- fileQuit = disabledMask + preferencesMask + transferMask + quitMask;
- fileClose = fileQuit + closeMask + saveMask;
- fileAll = fileClose + newMask + openMask + openAsMask + openGnrlMask + revertMask + getInfoMask;
- fileNoRevert = fileAll - revertMask;
- fileNoInfo = fileAll - getInfoMask;
- fileNoNew = fileAll - newMask;
- fileNoOpen = fileClose + newMask + revertMask + getInfoMask;
- fileNoNewOrOpen = fileNoOpen - newMask;
- fileTop = fileClose + revertMask + getInfoMask;
- fileOpQuOnly = fileQuit + openMask + openAsMask + openGnrlMask;
- fileROMStuff = fileQuit + openMask + openAsMask + openGnrlMask + closeMask + getInfoMask;
- fileDiskStuff = fileQuit + newMask + openMask + closeMask + getInfoMask;
-
- editMenu = 3;
-
- undoItem = 1;
- cutItem = 3;
- copyItem = 4;
- pasteItem = 5;
- clearItem = 6;
- dupItem = 8;
-
- { Masks for AbleMenu - normally not used directly. }
- undoMask = $2;
- cutMask = $8;
- editCopyMask = $10;
- pasteMask = $20;
- clearMask = $40;
- duplicateMask = $100;
- editDisabledMask= $FFFFFE01;
-
- { Mask combinations to be used in calls to AbleMenu. }
- editNone = editDisabledMask;
- editClear = editNone + clearMask;
- editCopy = editNone + editCopyMask;
- editPaste = editNone + pasteMask;
- editUndoPasteOnly = editPaste + undoMask;
- editDup = editClear + duplicateMask;
- editNoDup = editNone + cutMask + editCopyMask + pasteMask + clearMask; { No dup or undo }
- editNoUndo = editNoDup + duplicateMask;
- editUndNoDup= editNoDup + undoMask;
- editAll = editNoUndo + undoMask;
- editAcc = editUndNoDup;
-
- editorNameChr = CHR(0); { First char of the name for editors }
-
- { Standard strings available by calling GetStr. }
- editStrings = 130; { Resource ID of STR# resource containing the strings. }
- undoChangeStr = 1;
- redoChangeStr = 2;
- undoCutStr = 3;
- redoCutStr = 4;
- undoCopyStr = 5;
- redoCopyStr = 6;
- undoClearStr = 7;
- redoClearStr = 8;
- undoTypingStr = 9;
- redoTypingStr = 10;
- undoPasteStr = 11;
- redoPasteStr = 12;
- undoStr = 13;
-
- miscStrings = 129; { Resource ID of STR# resource containing the strings. }
- fromStr = 1; { String for window titles. }
- fullWindowStr = 38; { String for the resizeWind menu item }
- ownerWindowWindowStr= 39;
- newItemStr = 40; { Enter new item number }
- selectItemStr = 41; { Open which item? }
- clipBoardErrorStr = 42; { Error accessing the Clipboard. }
- sndErrorStr = 43; { Error playing a sound. }
- openAsDotStr = 44; { Open As ... }
- openAsDITMStr = 45; { Open As Dialog Item }
-
- arrowCursor = -1; { Used in the call to SetTheCursor to set the arrow cursor. }
-
- minPickStdWidth = 150;
- minPickStdRows = 4;
-
- okChoice = 1;
-
- revertResourceAlert = 1387; { Used by all editors to when revert is selected. }
- TYPE
- STR64 = STRING[64];
-
- AlertType = (displayTheAlert, displayStopAlert, displayNoteAlert, displayCautionAlert);
-
- { Map entry definition for new resource manager calls. }
- ResMapEntry = RECORD
- RID: INTEGER;
- RNameOff: INTEGER;
- RLocn: LongInt;
- RHndl: Handle;
- END;{ ResMapEntry }
-
- { This structure is used by the GetQuickDrawVars procedure. }
- pQuickDrawVars = ^QuickDrawVars;
- QuickDrawVArs = RECORD
- randSeed: LONGINT;
- screenBits: BitMap;
- arrow: Cursor;
- dkGray: Pattern;
- ltGray: Pattern;
- gray: Pattern;
- black: Pattern;
- white: Pattern;
- thePort: GrafPtr;
- END; { QuickDrawVars }
-
-
- { Each driver has its own object handle. This has to start with a handle
- to its parent's object followed by the name distinguishing the father
- This name will be part of the son's window title. The next field should
- be the window of the obj (may be used by son to get back to the father
- (through the refcon in the windowRec). The next field is the rebuild flag
- used to indicate that a windows data (e.g. a pickers list) needs to be
- recalculated at the next opportunity. The rest of the handle can be of
- any format. The name for pickers should be the name of the file or disk.
- For editors, the name should be the complete name (not the windows title)
- preceded by an editorNameChr character (see const above). An example of a
- complete name would be "ALRT ID = -1234 from AFile". This name is used to
- uniquely identify a window.
-
- See the manual for detailed documentation of this interface file. }
-
- ParentPtr = ^ParentRec;
- ParentHandle = ^ParentPtr;
-
- ParentRec = RECORD
- father: ParentHandle;
- name: str64;
- wind: WindowPeek;
- rebuild: BOOLEAN; { Flag set by son to indicate that world }
- { has changed so father should rebuild list }
- END;
-
- { Standard picker record }
-
- PickPtr = ^PickRec; { Any type is OK here }
- PickHandle = ^PickPtr;
-
- PickRec = RECORD
- father: ParentHandle; { Back ptr to dad }
- fName: STR64;
- wind: WindowPtr; { Directory window }
- rebuild: BOOLEAN;
- pickID: INTEGER; { ID of this picker }
- rType: ResType; { Type for picker }
- rNum: INTEGER; { Resfile number }
- rSize: LONGINT; { Size of a null resource }
- nInsts: INTEGER; { Number of instances }
- instances: ListHandle; { List of instances }
- drawProc: Ptr; { List draw proc }
- scroll: ControlHandle; { Scroll bar }
- END;
-
-
-
- { These routines are used to start pickers and editors. }
-
- PROCEDURE GiveEBirth (resHandle: Handle; pick: PickHandle);
- PROCEDURE GiveSubEBirth (resHandle: Handle; pick: PickHandle);
- PROCEDURE GiveThisEBirth (resHandle: Handle; pick: PickHandle; openThisType:ResType);
-
- { These routines are used to feed events and menu calls to the appropriate picker or editor. }
- PROCEDURE CallInfoUpdate (oldID, newID: INTEGER; refcon: LONGINT; id: INTEGER );
- PROCEDURE PassMenu (menu, item: INTEGER; father: ParentHandle);
-
-
- { Window Utilities }
-
- FUNCTION AlreadyOpen (VAR windowTitle, windowName: STR255; father: ParentHandle): BOOLEAN;
- FUNCTION CWindSetup (width, height: INTEGER; t, s: STR255): WindowPtr;
- FUNCTION EditorWindSetup (color: BOOLEAN; width, height: INTEGER;
- VAR windowTitle, windowName: STR255; addFrom: BOOLEAN;
- father: ParentHandle): WindowPtr;
- PROCEDURE GetWindowTitle (VAR windowTitle, windowName: STR255; addFrom: BOOLEAN; father: ParentHandle);
- PROCEDURE SetETitle (h: Handle; VAR str: STR255);
- FUNCTION WindAlloc: WindowPtr;
- PROCEDURE WindReturn (w: WindowPtr);
- FUNCTION WindList (w: WindowPtr; nAcross: INTEGER; cSize: Point; drawProc:INTEGER): ListHandle;
- PROCEDURE WindOrigin (w: WindowPtr);
- FUNCTION WindSetup (width, height: INTEGER; t, s: STR255): WindowPtr;
-
- { Extended Resource Manager }
-
- FUNCTION CurrentRes: INTEGER;
- FUNCTION Get1Index (t: ResType; index: INTEGER): Handle;
- FUNCTION Get1Res (t: ResType; id: INTEGER): Handle;
- FUNCTION NeedToRevert (myWindow: WindowPtr; theRes: Handle): BOOLEAN;
- PROCEDURE RemoveResource (theRes: Handle);
- FUNCTION RevertThisResource (theObj: ParentHandle; res: Handle): BOOLEAN;
- FUNCTION SysResFile: INTEGER;
-
- { Miscellaneous utilities }
-
- PROCEDURE Abort;
- PROCEDURE AbleMenu (menu: INTEGER; enable: LONGINT);
- FUNCTION AddNewRes (hNew: Handle; t: ResType; idNew: INTEGER; s: str255): BOOLEAN;
- PROCEDURE BubbleUp (h: Handle);
- FUNCTION BuildType (t: ResType; l: ListHandle): INTEGER;
- FUNCTION CheckError (err, msgID: INTEGER): BOOLEAN;
- FUNCTION CloseNoSave: BOOLEAN;
- PROCEDURE ConcatStr (VAR str1: STR255; str2: STR255);
- FUNCTION DefaultListCellSize:INTEGER;
- FUNCTION DisplayAlert (which: AlertType; id: INTEGER): INTEGER;
- PROCEDURE FixHand (s: LONGINT; h: Handle);
- PROCEDURE FlashDialogItem (dp: DialogPtr; item: integer);
- PROCEDURE FrameDialogItem (dp: DialogPtr; item: integer);
- FUNCTION GetQuickDrawVars: pQuickDrawVars;
- PROCEDURE GetStr (num, list: INTEGER; VAR str: STR255);
- PROCEDURE GrowMyWindow (minWidth, minHeight: INTEGER; windPtr: WindowPtr; lh: ListHandle);
- FUNCTION HandleCheck (h: Handle; msgID: INTEGER): BOOLEAN;
- PROCEDURE MetaKeys (VAR cmd, shift, opt: BOOLEAN);
- FUNCTION NewRes (s: LONGINT; t: ResType; l: ListHandle; VAR n: INTEGER): Handle;
- PROCEDURE PickEvent (VAR evt: EventRecord; pick: PickHandle);
- PROCEDURE PickInfoUp (oldID, newID: INTEGER; pick: PickHandle);
- PROCEDURE PickMenu (menu, item: INTEGER; pick: PickHandle);
- FUNCTION PickStdRows: INTEGER;
- FUNCTION PickStdWidth: INTEGER;
- FUNCTION ResEdID: INTEGER;
- PROCEDURE SendRebuildToPickerAndFile (theType: ResType; parent: ParentHandle) ;
- PROCEDURE SetResChanged (h: Handle);
- PROCEDURE SetTheCursor (whichCursor: INTEGER);
- PROCEDURE ShowInfo (h:Handle; father: ParentHandle);
- PROCEDURE TypeToString (t: ResType; VAR s: Str255);
- PROCEDURE UseAppRes;
- Inline { move.w CurApRefNum,-(sp) } $3f38, $0900,
- { _UseResFile } $a998;
- FUNCTION WasAborted: BOOLEAN;
-
-
- { Routines that are used internally withing ResEdit and may be useful in other
- circumstances. }
-
- PROCEDURE CallEBirth (resHandle: Handle; parent: ParentHandle; id: INTEGER );
- PROCEDURE CallEvent( VAR evt: EventRecord; refcon: LONGINT; id: INTEGER );
- PROCEDURE CallMenu (menu, item: INTEGER; refcon: LONGINT; id: INTEGER);
- PROCEDURE CallPBirth (theType: ResType; parent: ParentHandle; id: INTEGER );
- FUNCTION CopyRes (VAR h: Handle; makeID: BOOLEAN; resNew: INTEGER): Handle;
- PROCEDURE DoKeyScan (var evt: EventRecord; offset: integer; lh: ListHandle);
- PROCEDURE DoListEvt (e: EventRecord; l: ListHandle);
- FUNCTION DupPick (h: Handle; c: cell; pick: PickHandle): Handle;
- FUNCTION GetType (templatesOnly: BOOLEAN; VAR s: STR255): BOOLEAN;
- PROCEDURE KillCache;
- PROCEDURE MyCalcMask (srcPtr,dstPtr: Ptr; srcRow,dstRow,height,words: INTEGER);
- FUNCTION ResEditRes: INTEGER;
- Inline { move.w CurApRefNum,(sp) } $3eB8, $0900;
- PROCEDURE ScrapCopy ( VAR h: Handle );
- PROCEDURE ScrapEmpty;
- PROCEDURE ScrapPaste(pasteAll: BOOLEAN; typeToPaste: ResType; resFile: INTEGER);
-
- { Obsolete routines that are left in for compatability. }
-
- FUNCTION RevertResource (h: Handle): BOOLEAN;
-
- END.
-
-
-
-