PageRenderTime 55ms CodeModel.GetById 15ms app.highlight 36ms RepoModel.GetById 1ms app.codeStats 0ms

/packages/univint/src/Finder.pas

https://github.com/slibre/freepascal
Pascal | 494 lines | 186 code | 39 blank | 269 comment | 0 complexity | 135db52588564885e15408058705261c MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
  1{
  2     File:       CarbonCore/Finder.h
  3 
  4     Contains:   Finder flags and container types.
  5                 The contents of this header file are deprecated.
  6 
  7     Copyright:   1990-2011 by Apple Inc. All rights reserved.
  8}
  9{    Pascal Translation Updated:  Jonas Maebe, <jonas@freepascal.org>, October 2009 }
 10{    Pascal Translation Updated:  Jonas Maebe, <jonas@freepascal.org>, September 2012 }
 11{
 12    Modified for use with Free Pascal
 13    Version 308
 14    Please report any bugs to <gpc@microbizz.nl>
 15}
 16
 17{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 18{$mode macpas}
 19{$packenum 1}
 20{$macro on}
 21{$inline on}
 22{$calling mwpascal}
 23
 24unit Finder;
 25interface
 26{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
 27{$setc GAP_INTERFACES_VERSION := $0308}
 28
 29{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
 30    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
 31{$endc}
 32
 33{$ifc defined CPUPOWERPC and defined CPUI386}
 34	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
 35{$endc}
 36{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
 37	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
 38{$endc}
 39
 40{$ifc not defined __ppc__ and defined CPUPOWERPC32}
 41	{$setc __ppc__ := 1}
 42{$elsec}
 43	{$setc __ppc__ := 0}
 44{$endc}
 45{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
 46	{$setc __ppc64__ := 1}
 47{$elsec}
 48	{$setc __ppc64__ := 0}
 49{$endc}
 50{$ifc not defined __i386__ and defined CPUI386}
 51	{$setc __i386__ := 1}
 52{$elsec}
 53	{$setc __i386__ := 0}
 54{$endc}
 55{$ifc not defined __x86_64__ and defined CPUX86_64}
 56	{$setc __x86_64__ := 1}
 57{$elsec}
 58	{$setc __x86_64__ := 0}
 59{$endc}
 60{$ifc not defined __arm__ and defined CPUARM}
 61	{$setc __arm__ := 1}
 62{$elsec}
 63	{$setc __arm__ := 0}
 64{$endc}
 65
 66{$ifc defined cpu64}
 67  {$setc __LP64__ := 1}
 68{$elsec}
 69  {$setc __LP64__ := 0}
 70{$endc}
 71
 72
 73{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
 74	{$error Conflicting definitions for __ppc__ and __i386__}
 75{$endc}
 76
 77{$ifc defined __ppc__ and __ppc__}
 78	{$setc TARGET_CPU_PPC := TRUE}
 79	{$setc TARGET_CPU_PPC64 := FALSE}
 80	{$setc TARGET_CPU_X86 := FALSE}
 81	{$setc TARGET_CPU_X86_64 := FALSE}
 82	{$setc TARGET_CPU_ARM := FALSE}
 83	{$setc TARGET_OS_MAC := TRUE}
 84	{$setc TARGET_OS_IPHONE := FALSE}
 85	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
 86	{$setc TARGET_OS_EMBEDDED := FALSE}
 87{$elifc defined __ppc64__ and __ppc64__}
 88	{$setc TARGET_CPU_PPC := FALSE}
 89	{$setc TARGET_CPU_PPC64 := TRUE}
 90	{$setc TARGET_CPU_X86 := FALSE}
 91	{$setc TARGET_CPU_X86_64 := FALSE}
 92	{$setc TARGET_CPU_ARM := FALSE}
 93	{$setc TARGET_OS_MAC := TRUE}
 94	{$setc TARGET_OS_IPHONE := FALSE}
 95	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
 96	{$setc TARGET_OS_EMBEDDED := FALSE}
 97{$elifc defined __i386__ and __i386__}
 98	{$setc TARGET_CPU_PPC := FALSE}
 99	{$setc TARGET_CPU_PPC64 := FALSE}
100	{$setc TARGET_CPU_X86 := TRUE}
101	{$setc TARGET_CPU_X86_64 := FALSE}
102	{$setc TARGET_CPU_ARM := FALSE}
103{$ifc defined(iphonesim)}
104 	{$setc TARGET_OS_MAC := FALSE}
105	{$setc TARGET_OS_IPHONE := TRUE}
106	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
107{$elsec}
108	{$setc TARGET_OS_MAC := TRUE}
109	{$setc TARGET_OS_IPHONE := FALSE}
110	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
111{$endc}
112	{$setc TARGET_OS_EMBEDDED := FALSE}
113{$elifc defined __x86_64__ and __x86_64__}
114	{$setc TARGET_CPU_PPC := FALSE}
115	{$setc TARGET_CPU_PPC64 := FALSE}
116	{$setc TARGET_CPU_X86 := FALSE}
117	{$setc TARGET_CPU_X86_64 := TRUE}
118	{$setc TARGET_CPU_ARM := FALSE}
119	{$setc TARGET_OS_MAC := TRUE}
120	{$setc TARGET_OS_IPHONE := FALSE}
121	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
122	{$setc TARGET_OS_EMBEDDED := FALSE}
123{$elifc defined __arm__ and __arm__}
124	{$setc TARGET_CPU_PPC := FALSE}
125	{$setc TARGET_CPU_PPC64 := FALSE}
126	{$setc TARGET_CPU_X86 := FALSE}
127	{$setc TARGET_CPU_X86_64 := FALSE}
128	{$setc TARGET_CPU_ARM := TRUE}
129	{ will require compiler define when/if other Apple devices with ARM cpus ship }
130	{$setc TARGET_OS_MAC := FALSE}
131	{$setc TARGET_OS_IPHONE := TRUE}
132	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
133	{$setc TARGET_OS_EMBEDDED := TRUE}
134{$elsec}
135	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
136{$endc}
137
138{$ifc defined __LP64__ and __LP64__ }
139  {$setc TARGET_CPU_64 := TRUE}
140{$elsec}
141  {$setc TARGET_CPU_64 := FALSE}
142{$endc}
143
144{$ifc defined FPC_BIG_ENDIAN}
145	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
146	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
147{$elifc defined FPC_LITTLE_ENDIAN}
148	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
149	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
150{$elsec}
151	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
152{$endc}
153{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
154{$setc CALL_NOT_IN_CARBON := FALSE}
155{$setc OLDROUTINENAMES := FALSE}
156{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
157{$setc OPAQUE_UPP_TYPES := TRUE}
158{$setc OTCARBONAPPLICATION := TRUE}
159{$setc OTKERNEL := FALSE}
160{$setc PM_USE_SESSION_APIS := TRUE}
161{$setc TARGET_API_MAC_CARBON := TRUE}
162{$setc TARGET_API_MAC_OS8 := FALSE}
163{$setc TARGET_API_MAC_OSX := TRUE}
164{$setc TARGET_CARBON := TRUE}
165{$setc TARGET_CPU_68K := FALSE}
166{$setc TARGET_CPU_MIPS := FALSE}
167{$setc TARGET_CPU_SPARC := FALSE}
168{$setc TARGET_OS_UNIX := FALSE}
169{$setc TARGET_OS_WIN32 := FALSE}
170{$setc TARGET_RT_MAC_68881 := FALSE}
171{$setc TARGET_RT_MAC_CFM := FALSE}
172{$setc TARGET_RT_MAC_MACHO := TRUE}
173{$setc TYPED_FUNCTION_POINTERS := TRUE}
174{$setc TYPE_BOOL := FALSE}
175{$setc TYPE_EXTENDED := FALSE}
176{$setc TYPE_LONGLONG := TRUE}
177uses MacTypes;
178{$endc} {not MACOSALLINCLUDE}
179
180
181{$ifc TARGET_OS_MAC}
182
183{$ALIGN MAC68K}
184
185{ Creator and type of clipping files }
186const
187	kClippingCreator = FourCharCode('drag');
188	kClippingPictureType = FourCharCode('clpp');
189	kClippingTextType = FourCharCode('clpt');
190	kClippingSoundType = FourCharCode('clps');
191	kClippingUnknownType = FourCharCode('clpu');
192
193
194{ Creator and type of Internet Location files }
195const
196	kInternetLocationCreator = FourCharCode('drag');
197	kInternetLocationHTTP = FourCharCode('ilht');
198	kInternetLocationFTP = FourCharCode('ilft');
199	kInternetLocationFile = FourCharCode('ilfi');
200	kInternetLocationMail = FourCharCode('ilma');
201	kInternetLocationNNTP = FourCharCode('ilnw');
202	kInternetLocationAFP = FourCharCode('ilaf');
203	kInternetLocationAppleTalk = FourCharCode('ilat');
204	kInternetLocationNSL = FourCharCode('ilns');
205	kInternetLocationGeneric = FourCharCode('ilge');
206
207
208const
209	kCustomIconResource = -16455; { Custom icon family resource ID }
210
211{ In order to specify any of the information described in the }
212{ CustomBadgeResource data structure you must clear the kExtendedFlagsAreInvalid }
213{ and set kExtendedFlagHasCustomBadge of the FXInfo.fdXFlags or DXInfo.frXFlags field, }
214{ and add a resource of type kCustomBadgeResourceType and ID kCustomBadgeResourceID to }
215{ the file or to the "Icon/n" file for a folder }
216const
217	kCustomBadgeResourceType = FourCharCode('badg');
218	kCustomBadgeResourceID = kCustomIconResource;
219	kCustomBadgeResourceVersion = 0;
220
221type
222	CustomBadgeResource = record
223		version: SInt16;                { This is version kCustomBadgeResourceVersion}
224		customBadgeResourceID: SInt16;  { If not 0, the ID of a resource to use on top}
225                                              { of the icon for this file or folder}
226		customBadgeType: OSType;        { If not 0, the type and creator of an icon}
227		customBadgeCreator: OSType;     { to use on top of the icon}
228		windowBadgeType: OSType;        { If not 0, the type and creator of an icon}
229		windowBadgeCreator: OSType;     { to display in the header of the window for this }
230                                              { file or folder}
231		overrideType: OSType;           { If not 0, the type and creator of an icon to}
232		overrideCreator: OSType;        { use INSTEAD of the icon for this file or folder}
233	end;
234	CustomBadgeResourcePtr = ^CustomBadgeResource;
235type
236	CustomBadgeResourceHandle = ^CustomBadgeResourcePtr;
237{ You can specify routing information for a file by including a 'rout' 0 
238    resource in it and setting the kExtendedFlagHasRoutingInfo bit in the extended 
239    Finder flags. 
240    The 'rout' resource is an array of RoutingResourceEntry. Each entry is considered
241    in turn. The first matching entry is used.
242    If the creator and fileType match the file being dropped and targetFolder match
243    the folder ID of the folder being dropped onto, then the file is rerouted 
244    into the specified destination folder.
245    The only target folder currently supported is the system folder, 
246    kSystemFolderType = 'macs'.
247}
248const
249	kRoutingResourceType = FourCharCode('rout');
250	kRoutingResourceID = 0;
251
252type
253	RoutingResourceEntryPtr = ^RoutingResourceEntry;
254	RoutingResourceEntry = record
255		creator: OSType;                { Use '****' or 0 to match any creator }
256		fileType: OSType;               { Use '****' or 0 to match any file type }
257		targetFolder: OSType;           { Folder ID of the folder this file was dropped onto }
258		destinationFolder: OSType;      { Folder that the source will be routed to }
259		reservedField: OSType;          { Set to 0 }
260	end;
261type
262	RoutingResourcePtr = RoutingResourceEntryPtr;
263	RoutingResourceHandle = ^RoutingResourcePtr;
264
265{ Types for special container aliases }
266const
267	kContainerFolderAliasType = FourCharCode('fdrp'); { type for folder aliases }
268	kContainerTrashAliasType = FourCharCode('trsh'); { type for trash folder aliases }
269	kContainerHardDiskAliasType = FourCharCode('hdsk'); { type for hard disk aliases }
270	kContainerFloppyAliasType = FourCharCode('flpy'); { type for floppy aliases }
271	kContainerServerAliasType = FourCharCode('srvr'); { type for server aliases }
272	kApplicationAliasType = FourCharCode('adrp'); { type for application aliases }
273	kContainerAliasType = FourCharCode('drop'); { type for all other containers }
274	kDesktopPrinterAliasType = FourCharCode('dtpa'); { type for Desktop Printer alias }
275	kContainerCDROMAliasType = FourCharCode('cddr'); { type for CD-ROM alias }
276	kApplicationCPAliasType = FourCharCode('acdp'); { type for application control panel alias }
277	kApplicationDAAliasType = FourCharCode('addp'); { type for application DA alias }
278	kPackageAliasType = FourCharCode('fpka'); { type for plain package alias }
279	kAppPackageAliasType = FourCharCode('fapa'); { type for application package alias }
280
281{ Types for Special folder aliases }
282const
283	kSystemFolderAliasType = FourCharCode('fasy');
284	kAppleMenuFolderAliasType = FourCharCode('faam');
285	kStartupFolderAliasType = FourCharCode('fast');
286	kPrintMonitorDocsFolderAliasType = FourCharCode('fapn');
287	kPreferencesFolderAliasType = FourCharCode('fapf');
288	kControlPanelFolderAliasType = FourCharCode('fact');
289	kExtensionFolderAliasType = FourCharCode('faex');
290
291{ Types for AppleShare folder aliases }
292const
293	kExportedFolderAliasType = FourCharCode('faet');
294	kDropFolderAliasType = FourCharCode('fadr');
295	kSharedFolderAliasType = FourCharCode('fash');
296	kMountedFolderAliasType = FourCharCode('famn');
297
298{ Finder flags (finderFlags, fdFlags and frFlags) }
299{ Any flag reserved or not specified should be set to 0. }
300{ If a flag applies to a file, but not to a folder, make sure to check }
301{ that the item is not a folder by checking ((ParamBlockRec.ioFlAttrib & ioDirMask) == 0) }
302const
303	kIsOnDesk = $0001; { Files and folders (System 6) }
304	kColor = $000E; { Files and folders }
305                                        { bit 0x0020 was kRequireSwitchLaunch, but is now reserved for future use}
306	kIsShared = $0040; { Files only (Applications only) }
307                                        { If clear, the application needs to write to }
308                                        { its resource fork, and therefore cannot be }
309                                        { shared on a server }
310	kHasNoINITs = $0080; { Files only (Extensions/Control Panels only) }
311                                        { This file contains no INIT resource }
312	kHasBeenInited = $0100; { Files only }
313                                        { Clear if the file contains desktop database }
314                                        { resources ('BNDL', 'FREF', 'open', 'kind'...) }
315                                        { that have not been added yet. Set only by the Finder }
316                                        { Reserved for folders - make sure this bit is cleared for folders }
317                                        { bit 0x0200 was the letter bit for AOCE, but is now reserved for future use }
318	kHasCustomIcon = $0400; { Files and folders }
319	kIsStationery = $0800; { Files only }
320	kNameLocked = $1000; { Files and folders }
321	kHasBundle = $2000; { Files and folders }
322                                        { Indicates that a file has a BNDL resource }
323                                        { Indicates that a folder is displayed as a package }
324	kIsInvisible = $4000; { Files and folders }
325	kIsAlias = $8000; { Files only }
326
327{ Obsolete. Use names defined above. }
328const
329	fOnDesk = kIsOnDesk;
330	fHasBundle = kHasBundle;
331	fInvisible = kIsInvisible;
332
333{ Obsolete }
334const
335	fTrash = -3;
336	fDesktop = -2;
337	fDisk = 0;
338
339{$ifc OLDROUTINENAMES}
340const
341	kIsStationary = kIsStationery;
342
343{$endc} {OLDROUTINENAMES}
344
345{ Extended flags (extendedFinderFlags, fdXFlags and frXFlags) }
346{ Any flag not specified should be set to 0. }
347const
348	kExtendedFlagsAreInvalid = $8000; { If set the other extended flags are ignored }
349	kExtendedFlagHasCustomBadge = $0100; { Set if the file or folder has a badge resource }
350	kExtendedFlagObjectIsBusy = $0080; { Set if the object is marked as busy/incomplete }
351	kExtendedFlagHasRoutingInfo = $0004; { Set if the file contains routing info resource }
352
353
354{ Use a filetype in this range to indicate that a file is temporarily busy }
355{ (while it is being downloaded or installed, for example).  This prevents }
356{ Finder 8.5 and later from trying to change the item's attributes before it }
357{ is fully created. -- If you provide a series of 'BNDL' icons for your creator }
358{ and some of these filetypes, you can achieve limited icon animation while }
359{ the file creation progresses. }
360const
361	kFirstMagicBusyFiletype = FourCharCode('bzy ');
362	kLastMagicBusyFiletype = FourCharCode('bzy?');
363
364{ Use this date as a file's or folder's creation date to indicate that it is }
365{ temporarily busy (while it is being downloaded or installed, for example). }
366{ This prevents Finder from trying to change the item's attributes before it }
367{ is fully created (Finder 8.5 and 8.6 check file creation dates; later Finders }
368{ may check folder creation dates as well). }
369const
370	kMagicBusyCreationDate = $4F3AFDB0;
371
372
373{------------------------------------------------------------------------}
374{
375   The following data structures are binary compatible with FInfo, DInfo,
376   FXInfo and DXInfo but represent the Mac OS 8 semantic of the fields.
377   Use these data structures preferably to FInfo, etc...
378}
379{------------------------------------------------------------------------}
380
381type
382	FileInfoPtr = ^FileInfo;
383	FileInfo = record
384		fileType: OSType;               { The type of the file }
385		fileCreator: OSType;            { The file's creator }
386		finderFlags: UInt16;            { ex: kHasBundle, kIsInvisible... }
387		location: Point;               { File's location in the folder }
388                                              { If set to (0, 0), the Finder will place the item automatically }
389		reservedField: UInt16;          { (set to 0) }
390	end;
391type
392	FolderInfoPtr = ^FolderInfo;
393	FolderInfo = record
394		windowBounds: Rect;           { The position and dimension of the folder's window }
395		finderFlags: UInt16;            { ex. kIsInvisible, kNameLocked, etc.}
396		location: Point;               { Folder's location in the parent folder }
397                                              { If set to (0, 0), the Finder will place the item automatically }
398		reservedField: UInt16;          { (set to 0) }
399	end;
400type
401	ExtendedFileInfoPtr = ^ExtendedFileInfo;
402	ExtendedFileInfo = record
403		reserved1: array [0..3] of SInt16;           { Reserved (set to 0) }
404		extendedFinderFlags: UInt16;    { Extended flags (custom badge, routing info...) }
405		reserved2: SInt16;              { Reserved (set to 0). Comment ID if high-bit is clear }
406		putAwayFolderID: SInt32;        { Put away folder ID }
407	end;
408type
409	ExtendedFolderInfoPtr = ^ExtendedFolderInfo;
410	ExtendedFolderInfo = record
411		scrollPosition: Point;         { Scroll position (for icon views) }
412		reserved1: SInt32;              { Reserved (set to 0) }
413		extendedFinderFlags: UInt16;    { Extended flags (custom badge, routing info...) }
414		reserved2: SInt16;              { Reserved (set to 0). Comment ID if high-bit is clear }
415		putAwayFolderID: SInt32;        { Put away folder ID }
416	end;
417{------------------------------------------------------------------------}
418{
419   The following data structures are here for compatibility.
420   Use the new data structures replacing them if possible (i.e. FileInfo 
421   instead of FInfo, etc...)
422}
423{------------------------------------------------------------------------}
424{ File info }
425{
426     IMPORTANT:
427     In MacOS 8, the fdFldr field has become reserved for the Finder.
428}
429type
430	FInfoPtr = ^FInfo;
431	FInfo = record
432		fdType: OSType;                 { The type of the file }
433		fdCreator: OSType;              { The file's creator }
434		fdFlags: UInt16;                { Flags ex. kHasBundle, kIsInvisible, etc. }
435		fdLocation: Point;             { File's location in folder. }
436                                              { If set to (0, 0), the Finder will place the item automatically }
437		fdFldr: SInt16;                 { Reserved (set to 0) }
438	end;
439{ Extended file info }
440{
441     IMPORTANT:
442     In MacOS 8, the fdIconID and fdComment fields were changed
443     to become reserved fields for the Finder.
444     The fdScript has become an extended flag.
445}
446type
447	FXInfoPtr = ^FXInfo;
448	FXInfo = record
449		fdIconID: SInt16;              { Reserved (set to 0) }
450		fdReserved: array [0..2] of SInt16;          { Reserved (set to 0) }
451		fdScript: SInt8;               { Extended flags. Script code if high-bit is set }
452		fdXFlags: SInt8;               { Extended flags }
453		fdComment: SInt16;              { Reserved (set to 0). Comment ID if high-bit is clear }
454		fdPutAway: SInt32;              { Put away folder ID }
455	end;
456{ Folder info }
457{
458     IMPORTANT:
459     In MacOS 8, the frView field was changed to become reserved 
460     field for the Finder.
461}
462type
463	DInfoPtr = ^DInfo;
464	DInfo = record
465		frRect: Rect;                 { Folder's window bounds }
466		frFlags: UInt16;                { Flags ex. kIsInvisible, kNameLocked, etc.}
467		frLocation: Point;             { Folder's location in parent folder }
468                                              { If set to (0, 0), the Finder will place the item automatically }
469		frView: SInt16;                 { Reserved (set to 0) }
470	end;
471{ Extended folder info }
472{
473     IMPORTANT:
474     In MacOS 8, the frOpenChain and frComment fields were changed
475     to become reserved fields for the Finder.
476     The frScript has become an extended flag.
477}
478type
479	DXInfoPtr = ^DXInfo;
480	DXInfo = record
481		frScroll: Point;               { Scroll position }
482		frOpenChain: SInt32;            { Reserved (set to 0) }
483		frScript: SInt8;               { Extended flags. Script code if high-bit is set }
484		frXFlags: SInt8;               { Extended flags }
485		frComment: SInt16;              { Reserved (set to 0). Comment ID if high-bit is clear }
486		frPutAway: SInt32;              { Put away folder ID }
487	end;
488{ ControlPanelDefProcPtr and cdev constants have all been moved to Processes.i}
489
490{$endc} {TARGET_OS_MAC}
491{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
492
493end.
494{$endc} {not MACOSALLINCLUDE}