home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1993-09-24 | 10.8 KB | 254 lines | [ TEXT/PJMM]
unit pp_filter_defs; interface const {--misc. constants--} kDontDisableItem = 16384; {add this constant to avoid InstallDITLItem to disable a user item} {--file types and creators--} kPreprocessorAddinFileType = 'PScP'; kFilterAddinFileType = 'PScF'; {--preprocessor addins constants--} kPPParamVersion = $0001; {version 1 of PP API} kPPAddinResType = 'PScP'; {resource type for preprocessor addin} kPPAddinResID = 128; {resource ID for preprocessor addin code} kPPAddinInfoResType = 'PSpi'; {resource type for preprocessor info} kPPAddinInfoResID = 128; {resource ID for preprocessor info} kPPAddinInfoStringResType = 'STR '; {resource type for preprocessor info string} kPPAddinInfoStringResID = 128; {resource ID for preprocessor info string} kPPUnusedTypes = ' '; {type that is unused by the preprocessor} kPPMatchAnyType = '****'; {type code that preprocessor can use to match any file} {--selector codes for filter addin--} kPPAddinLoad = 1; {open preprocessor first time [application launch]} kPPAddinPreprocessFile = 2; {preprocess file} kPPAddinCleanup = 3; {cleanup before closing preprocessor [application exit]} {--filter addins constants--} kFilterParamVersion = $0001; {version 1 of filter API} kFilterAddinResType = 'PScF'; {resource type for filter addin} kFilterAddinResID = 128; {resource ID for filter addin code} kFilterAddinInfoResType = 'PSfi'; {resource type for filter info} kFilterAddinInfoResID = 128; {resource ID for filter info} kCallbackBlockVersion = $0001; {first version of callback block} {--selector codes for filter addin--} kFilterAddinLoad = 1; {open filter first time [application launch]} kFilterAddinDefaultSettings = 2; {fill in settings with default values} kFilterAddinSettingsDialog = 3; {show dialog [instance-specific]} kFilterAddinPrepareForFiltering = 4; {init filter before filtering [instance-specific]} kFilterAddinFilterFile = 5; {filter file [instance-specific]} kFilterAddinFilteringFinished = 6; {cleanup after filtering [instance-specific]} kFilterAddinCleanup = 7; {cleanup before closing filter [application exit]} {--variant parts of tFileInfo record--} kFileInfoVariant = 3; type tStr10 = string[10]; tStr15 = string[15]; tStr20 = string[20]; tStr31 = string[31]; tStr63 = string[63]; tStr63Ptr = ^tStr63; tStr100 = string[100]; {--block with callback routines for external filter code--} tMyCallbackBlock = record cbVersion: integer; {version for the callback block} cbCenterWindow: procPtr; {(theWindow, sameScreenAsWin: windowPtr; showIt: boolean)} cbMyDisposeDialog: procPtr; {(theDialog:dialogPtr)} cbInstallDITLItem: procPtr; {(dP: dialogPtr; itemNo: integer; proc: procPtr; expandItemRect: boolean)} cbFrameButtonRect: procPtr; {(theD: dialogPtr; itemNo: integer)} cbInstallPopupUserItem: procPtr; {(theD: dialogPtr; item: integer; theMenu: menuHandle; selectedItem: integer)} cbPopupItemSelected: procPtr; {(theD: dialogPtr; item: integer): integer} cbReleaseDialogItemData: procPtr; {(theD: dialogPtr)} cbHandlePopupMenu: procPtr; {(theD: dialogPtr; item: integer)} cbMyModalDialogFilter: procPtr; {(theD: dialogPtr; var e: eventRecord; var itemHit: integer): boolean} cbSetDialogItemData: procPtr; {(theD: dialogPtr; item: integer; data1, data2: longint)} end; tMyCallbackBlockPtr = ^tMyCallbackBlock; {Define array used to store additional data for an item in a dialog box; used so we can extract the procPtr for the} {callback routine of e.g. an user item update procedure without using globals in our code resource and without nesting} {the routine which isn’t possbile due to Pascal’s handling of the @ operator} tDialogItemDataRecord = record itemData1, itemData2: longint; end; tDialogItemDataArray = array[1..1] of tDialogItemDataRecord; tDialogItemDataPtr = ^tDialogItemDataArray; {--scan preprocessors--} tInterestingTypesArray = array[1..8] of OSType; {'****' for any file; ' ' for unused} tInterestingTypesPtr = ^tInterestingTypesArray; tPPAddinType = record longName: tStr63; {full name of preprocessor} uniqueType: OSType; {four chars that uniquely identify this preprocessor} paramVersion: integer; {what version of the API is this preprocessor compatible with?} filler1: integer; refCon: longint; {field owned by the preprocessor} resForkRefNum: integer; {refnumber for resource fork of this addin} enabledFlag: boolean; {is this filter enabled?} filler2: boolean; preprocessorIconSuiteID: integer; {resource id of icon suite} preprocessorEntryProc: procPtr; {entrypoint for preprocessor code} interestingFileTypes: tInterestingTypesArray; {what filetypes are this filter interested in?} end; tPPAddinPtr = ^tPPAddinType; {--filter addins--} tFilterAddinType = record longName: tStr63; {full name of filter} shortName: tStr15; {short name of addin as listed in Edit File Filters dialog box} uniqueType: OSType; {four chars that uniquely identify this filter} paramVersion: integer; {what version of the API is this filter compatible with?} filler1: integer; refCon: longint; {field owned by the addin [shared among all instances]} resForkRefNum: integer; {refnumber for resource fork of this addin} filterIconSuiteID: integer; {resource ID for filter icon suite} filterIconSuite: handle; {handle to icon suite} filterEntryProc: procPtr; {entrypoint for filter code} hasSettingsDialog: boolean; {flag if this filter has any settings dialog box} filler2: boolean; end; tFilterAddinPtr = ^tFilterAddinType; {--directory entry for a file or folder--} tDelimiterType = (fileDelimiter, scanDelimiter); {different types of delimiting lines} tIconType = (iconApplication, iconArchiveApplication, iconDocument, iconArchiveDocument, iconFolder, iconArchiveFolder, noIcon); tTextStrType = tStr100; {type of string for text string rows} tFileInfo = record case fileInfoVariant : integer of kFileInfoVariant: ( fileName: tStr31; dirID: longint; vRefNum: integer; {this field is used as an index in the volume alias array as soon as the scanning is completed} iconType: tIconType; {what kind of icon should we use and is this file really an existing file (not inside an archive)?} isAlias: boolean; {is this an alias?} fileFlags: integer; {attribute flags from file info; 0 for folders} indentLevel: integer; {how many levels should we indent this filename?} fileSize: longint; crDate, mdDate: longint; fileType, fileCreator: OSType; fileVersion: numVersion; {version info} crDateStr, mdDateStr: tStr20; {dates converted to strings} selected: boolean; {is this row highlighted?} indexInFolder: integer; {indicates the number of rows one must step back to come to parent folder; used for creating pathnames quickly through backtracing} internalFlag: boolean; {used e.g. when copying records after filtering} ) end; tFileInfoPtr = ^tFileInfo; {--record used when preprocessing an archive that contain multiple files--} tArchiveScanRecord = record fileIndex: integer; {index of the file that should be returned from the archive; pp increases this value} refCon: longint; {owned by the preprocessor while an archive is scanned} end; tArchiveScanPtr = ^tArchiveScanRecord; procedure extractDialogItemData (theD: dialogPtr; item: integer; var data1, data2: longint); procedure cbCenterWindow (theWindow, sameScreenAsWin: windowPtr; showIt: boolean; theAddr: procPtr); inline $205f, $4e90; procedure cbMyDisposeDialog (theDialog: dialogPtr; theAddr: procPtr); inline $205f, $4e90; procedure cbInstallDITLItem (dP: dialogPtr; itemNo: integer; proc: procPtr; expandItemRect: boolean; theAddr: procPtr); inline $205f, $4e90; procedure cbFrameButtonRect (theD: dialogPtr; itemNo: integer); procedure cbInstallPopupUserItem (theD: dialogPtr; item: integer; theMenu: menuHandle; selectedItem: integer; theAddr: procPtr); inline $205f, $4e90; function cbPopupItemSelected (theD: dialogPtr; item: integer; theAddr: procPtr): integer; inline $205f, $4e90; procedure cbReleaseDialogItemData (theD: dialogPtr; theAddr: procPtr); inline $205f, $4e90; procedure cbHandlePopupMenu (theD: dialogPtr; item: integer; theAddr: procPtr); inline $205f, $4e90; function cbMyModalDialogFilter (theD: dialogPtr; var e: eventRecord; var itemHit: integer): boolean; procedure cbSetDialogItemData (theD: dialogPtr; item: integer; data1, data2: longint; theAddr: procPtr); inline $205f, $4e90; implementation {==========================================================================================} { C A L L B A C K S E C T I O N } {==========================================================================================} {extractDialogItemData returns info for a specific item in a dialog; it is a hack to circumvent the problem that a userItem} {can’t have any additional parameters except for dialog pointer and item number} procedure extractDialogItemData (theD: dialogPtr; item: integer; var data1, data2: longint); var myDialogItemDataPtr: tDialogItemDataPtr; begin {--get pointer to array of items for this dialog--} myDialogItemDataPtr := tDialogItemDataPtr(getWRefCon(theD)); {--make sure we have a valid pointer before dereferencing--} if myDialogItemDataPtr <> nil then with myDialogItemDataPtr^[item] do begin {--myDialogItemDataPtr<>nil--} {--return data from array--} data1 := itemData1; data2 := itemData2; end {--myDialogItemDataPtr<>nil; with myDialogItemDataPtr^[item]--} else begin {--myDialogItemDataPtr=nil--} data1 := 0; data2 := 0; end; {--myDialogItemDataPtr=nil--} end; procedure cbFrameButtonRectInline (theD: dialogPtr; itemNo: integer; theAddr: procPtr); inline $205f, $4e90; procedure cbFrameButtonRect (theD: dialogPtr; itemNo: integer); var data1, data2: longint; begin {--extract callback address from this item’s external data array--} extractDialogItemData(theD, itemNo, data1, data2); {--now call the callback routine--} cbFrameButtonRectInline(theD, itemNo, procPtr(data1)); end; function cbMyModalDialogFilterInline (theD: dialogPtr; var e: eventRecord; var itemHit: integer; theAddr: procPtr): boolean; inline $205f, $4e90; function cbMyModalDialogFilter (theD: dialogPtr; var e: eventRecord; var itemHit: integer): boolean; var data1, data2: longint; begin {--extract callback address from dialog’s external data array; this address should be at the first item’s position--} extractDialogItemData(theD, 1, data1, data2); {--now call the callback routine--} cbMyModalDialogFilter := cbMyModalDialogFilterInline(theD, e, itemHit, procPtr(data1)); end; {==========================================================================================} end.