IconStorage.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. {
  2. File: OSServices/IconStorage.h
  3. Contains: Services to load and share icon family data.
  4. Copyright: (c) 2000-2011 Apple Inc. All rights reserved.
  5. Bugs?: For bug reports, consult the following page on
  6. the World Wide Web:
  7. http://bugs.freepascal.org
  8. }
  9. {
  10. Modified for use with Free Pascal
  11. Version 308
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  15. {$mode macpas}
  16. {$modeswitch cblocks}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$calling mwpascal}
  21. unit IconStorage;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  24. {$setc GAP_INTERFACES_VERSION := $0308}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  40. {$setc __ppc64__ := 1}
  41. {$elsec}
  42. {$setc __ppc64__ := 0}
  43. {$endc}
  44. {$ifc not defined __i386__ and defined CPUI386}
  45. {$setc __i386__ := 1}
  46. {$elsec}
  47. {$setc __i386__ := 0}
  48. {$endc}
  49. {$ifc not defined __x86_64__ and defined CPUX86_64}
  50. {$setc __x86_64__ := 1}
  51. {$elsec}
  52. {$setc __x86_64__ := 0}
  53. {$endc}
  54. {$ifc not defined __arm__ and defined CPUARM}
  55. {$setc __arm__ := 1}
  56. {$elsec}
  57. {$setc __arm__ := 0}
  58. {$endc}
  59. {$ifc not defined __arm64__ and defined CPUAARCH64}
  60. {$setc __arm64__ := 1}
  61. {$elsec}
  62. {$setc __arm64__ := 0}
  63. {$endc}
  64. {$ifc defined cpu64}
  65. {$setc __LP64__ := 1}
  66. {$elsec}
  67. {$setc __LP64__ := 0}
  68. {$endc}
  69. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  70. {$error Conflicting definitions for __ppc__ and __i386__}
  71. {$endc}
  72. {$ifc defined __ppc__ and __ppc__}
  73. {$setc TARGET_CPU_PPC := TRUE}
  74. {$setc TARGET_CPU_PPC64 := FALSE}
  75. {$setc TARGET_CPU_X86 := FALSE}
  76. {$setc TARGET_CPU_X86_64 := FALSE}
  77. {$setc TARGET_CPU_ARM := FALSE}
  78. {$setc TARGET_CPU_ARM64 := FALSE}
  79. {$setc TARGET_OS_MAC := TRUE}
  80. {$setc TARGET_OS_IPHONE := FALSE}
  81. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  82. {$setc TARGET_OS_EMBEDDED := FALSE}
  83. {$elifc defined __ppc64__ and __ppc64__}
  84. {$setc TARGET_CPU_PPC := FALSE}
  85. {$setc TARGET_CPU_PPC64 := TRUE}
  86. {$setc TARGET_CPU_X86 := FALSE}
  87. {$setc TARGET_CPU_X86_64 := FALSE}
  88. {$setc TARGET_CPU_ARM := FALSE}
  89. {$setc TARGET_CPU_ARM64 := FALSE}
  90. {$setc TARGET_OS_MAC := TRUE}
  91. {$setc TARGET_OS_IPHONE := FALSE}
  92. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  93. {$setc TARGET_OS_EMBEDDED := FALSE}
  94. {$elifc defined __i386__ and __i386__}
  95. {$setc TARGET_CPU_PPC := FALSE}
  96. {$setc TARGET_CPU_PPC64 := FALSE}
  97. {$setc TARGET_CPU_X86 := TRUE}
  98. {$setc TARGET_CPU_X86_64 := FALSE}
  99. {$setc TARGET_CPU_ARM := FALSE}
  100. {$setc TARGET_CPU_ARM64 := FALSE}
  101. {$ifc defined iphonesim}
  102. {$setc TARGET_OS_MAC := FALSE}
  103. {$setc TARGET_OS_IPHONE := TRUE}
  104. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  105. {$elsec}
  106. {$setc TARGET_OS_MAC := TRUE}
  107. {$setc TARGET_OS_IPHONE := FALSE}
  108. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  109. {$endc}
  110. {$setc TARGET_OS_EMBEDDED := FALSE}
  111. {$elifc defined __x86_64__ and __x86_64__}
  112. {$setc TARGET_CPU_PPC := FALSE}
  113. {$setc TARGET_CPU_PPC64 := FALSE}
  114. {$setc TARGET_CPU_X86 := FALSE}
  115. {$setc TARGET_CPU_X86_64 := TRUE}
  116. {$setc TARGET_CPU_ARM := FALSE}
  117. {$setc TARGET_CPU_ARM64 := FALSE}
  118. {$ifc defined iphonesim}
  119. {$setc TARGET_OS_MAC := FALSE}
  120. {$setc TARGET_OS_IPHONE := TRUE}
  121. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  122. {$elsec}
  123. {$setc TARGET_OS_MAC := TRUE}
  124. {$setc TARGET_OS_IPHONE := FALSE}
  125. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  126. {$endc}
  127. {$setc TARGET_OS_EMBEDDED := FALSE}
  128. {$elifc defined __arm__ and __arm__}
  129. {$setc TARGET_CPU_PPC := FALSE}
  130. {$setc TARGET_CPU_PPC64 := FALSE}
  131. {$setc TARGET_CPU_X86 := FALSE}
  132. {$setc TARGET_CPU_X86_64 := FALSE}
  133. {$setc TARGET_CPU_ARM := TRUE}
  134. {$setc TARGET_CPU_ARM64 := FALSE}
  135. {$setc TARGET_OS_MAC := FALSE}
  136. {$setc TARGET_OS_IPHONE := TRUE}
  137. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  138. {$setc TARGET_OS_EMBEDDED := TRUE}
  139. {$elifc defined __arm64__ and __arm64__}
  140. {$setc TARGET_CPU_PPC := FALSE}
  141. {$setc TARGET_CPU_PPC64 := FALSE}
  142. {$setc TARGET_CPU_X86 := FALSE}
  143. {$setc TARGET_CPU_X86_64 := FALSE}
  144. {$setc TARGET_CPU_ARM := FALSE}
  145. {$setc TARGET_CPU_ARM64 := TRUE}
  146. {$ifc defined ios}
  147. {$setc TARGET_OS_MAC := FALSE}
  148. {$setc TARGET_OS_IPHONE := TRUE}
  149. {$setc TARGET_OS_EMBEDDED := TRUE}
  150. {$elsec}
  151. {$setc TARGET_OS_MAC := TRUE}
  152. {$setc TARGET_OS_IPHONE := FALSE}
  153. {$setc TARGET_OS_EMBEDDED := FALSE}
  154. {$endc}
  155. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  156. {$elsec}
  157. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  158. {$endc}
  159. {$ifc defined __LP64__ and __LP64__ }
  160. {$setc TARGET_CPU_64 := TRUE}
  161. {$elsec}
  162. {$setc TARGET_CPU_64 := FALSE}
  163. {$endc}
  164. {$ifc defined FPC_BIG_ENDIAN}
  165. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  166. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  167. {$elifc defined FPC_LITTLE_ENDIAN}
  168. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  169. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  170. {$elsec}
  171. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  172. {$endc}
  173. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  174. {$setc CALL_NOT_IN_CARBON := FALSE}
  175. {$setc OLDROUTINENAMES := FALSE}
  176. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  177. {$setc OPAQUE_UPP_TYPES := TRUE}
  178. {$setc OTCARBONAPPLICATION := TRUE}
  179. {$setc OTKERNEL := FALSE}
  180. {$setc PM_USE_SESSION_APIS := TRUE}
  181. {$setc TARGET_API_MAC_CARBON := TRUE}
  182. {$setc TARGET_API_MAC_OS8 := FALSE}
  183. {$setc TARGET_API_MAC_OSX := TRUE}
  184. {$setc TARGET_CARBON := TRUE}
  185. {$setc TARGET_CPU_68K := FALSE}
  186. {$setc TARGET_CPU_MIPS := FALSE}
  187. {$setc TARGET_CPU_SPARC := FALSE}
  188. {$setc TARGET_OS_UNIX := FALSE}
  189. {$setc TARGET_OS_WIN32 := FALSE}
  190. {$setc TARGET_RT_MAC_68881 := FALSE}
  191. {$setc TARGET_RT_MAC_CFM := FALSE}
  192. {$setc TARGET_RT_MAC_MACHO := TRUE}
  193. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  194. {$setc TYPE_BOOL := FALSE}
  195. {$setc TYPE_EXTENDED := FALSE}
  196. {$setc TYPE_LONGLONG := TRUE}
  197. uses MacTypes;
  198. {$endc} {not MACOSALLINCLUDE}
  199. {$ifc TARGET_OS_MAC}
  200. {$ALIGN MAC68K}
  201. { virtual ARGB icon types. Each type will be split into separate 24 bit RGB data and 8 bit mask for storage in icns container }
  202. { the ARGB bitmap must be non-premultiplied }
  203. const
  204. kIconServices16PixelDataARGB = FourCharCode('ic04'); { uses kSmall32BitIconIndex and kSmallDeepMaskIconIndex}
  205. kIconServices32PixelDataARGB = FourCharCode('ic05'); { uses kLarge32BitIconIndex and kLargeDeepMaskIconIndex}
  206. kIconServices48PixelDataARGB = FourCharCode('ic06'); { uses kHuge32BitIconIndex and kHugeDeepMaskIconIndex}
  207. kIconServices128PixelDataARGB = FourCharCode('ic07'); { uses kThumbnailDataIndex and kThumbnailMaskIndex}
  208. { The following icon types can only be used as an icon element }
  209. { inside a 'icns' icon family }
  210. const
  211. kIconServices256PixelDataARGB = FourCharCode('ic08'); { non-premultiplied 256x256 ARGB bitmap}
  212. kIconServices512PixelDataARGB = FourCharCode('ic09'); { non-premultiplied 512x512 ARGB bitmap}
  213. kIconServices1024PixelDataARGB = FourCharCode('ic10'); { non-premultiplied 1024x1024 ARGB bitmap}
  214. kThumbnail32BitData = FourCharCode('it32');
  215. kThumbnail8BitMask = FourCharCode('t8mk');
  216. const
  217. kHuge1BitMask = FourCharCode('ich#');
  218. kHuge4BitData = FourCharCode('ich4');
  219. kHuge8BitData = FourCharCode('ich8');
  220. kHuge32BitData = FourCharCode('ih32');
  221. kHuge8BitMask = FourCharCode('h8mk');
  222. { The following icon types can be used as a resource type }
  223. { or as an icon element type inside a 'icns' icon family }
  224. const
  225. kLarge1BitMask = FourCharCode('ICN#');
  226. kLarge4BitData = FourCharCode('icl4');
  227. kLarge8BitData = FourCharCode('icl8');
  228. kLarge32BitData = FourCharCode('il32');
  229. kLarge8BitMask = FourCharCode('l8mk');
  230. kSmall1BitMask = FourCharCode('ics#');
  231. kSmall4BitData = FourCharCode('ics4');
  232. kSmall8BitData = FourCharCode('ics8');
  233. kSmall32BitData = FourCharCode('is32');
  234. kSmall8BitMask = FourCharCode('s8mk');
  235. kMini1BitMask = FourCharCode('icm#');
  236. kMini4BitData = FourCharCode('icm4');
  237. kMini8BitData = FourCharCode('icm8');
  238. { Obsolete. Use names defined above. }
  239. const
  240. large1BitMask = kLarge1BitMask;
  241. large4BitData = kLarge4BitData;
  242. large8BitData = kLarge8BitData;
  243. small1BitMask = kSmall1BitMask;
  244. small4BitData = kSmall4BitData;
  245. small8BitData = kSmall8BitData;
  246. mini1BitMask = kMini1BitMask;
  247. mini4BitData = kMini4BitData;
  248. mini8BitData = kMini8BitData;
  249. {
  250. IconFamily 'icns' resources contain an entire IconFamily (all sizes and depths).
  251. For custom icons, icns IconFamily resources of the custom icon resource ID are fetched first before
  252. the classic custom icons (individual 'ics#, ICN#, etc) are fetched. If the fetch of the icns resource
  253. succeeds then the icns is looked at exclusively for the icon data.
  254. For custom icons, new icon features such as 32-bit deep icons are only fetched from the icns resource.
  255. This is to avoid incompatibilities with cut & paste of new style icons with an older version of the
  256. MacOS Finder.
  257. DriverGestalt is called with code kdgMediaIconSuite by IconServices after calling FSM to determine a
  258. driver icon for a particular device. The result of the kdgMediaIconSuite call to DriverGestalt should
  259. be a pointer an an IconFamily. In this manner driver vendors can provide rich, detailed drive icons
  260. instead of the 1-bit variety previously supported.
  261. The IconFamilyElement and IconFamilyResource data types (which also include the data types
  262. IconFamilyPtr and IconFamilyHandle) are always big-endian.
  263. }
  264. const
  265. kIconFamilyType = FourCharCode('icns');
  266. type
  267. IconFamilyElement = record
  268. elementType: OSType; { 'ICN#', 'icl8', etc...}
  269. elementSize: SInt32; { Size of this element}
  270. elementData : packed array [0..0] of UInt8;
  271. end;
  272. IconFamilyElementPtr = ^IconFamilyElement;
  273. type
  274. IconFamilyResource = record
  275. resourceType: OSType; { Always 'icns'}
  276. resourceSize: SInt32; { Total size of this resource}
  277. elements: array[0..0] of IconFamilyElement;
  278. end;
  279. IconFamilyResourcePtr = ^IconFamilyResource;
  280. type
  281. IconFamilyPtr = IconFamilyResourcePtr;
  282. IconFamilyPtrPtr = ^IconFamilyPtr;
  283. IconFamilyHandle = IconFamilyPtrPtr;
  284. { Icon Variants }
  285. { These can be used as an element of an 'icns' icon family }
  286. { or as a parameter to GetIconRefVariant }
  287. const
  288. kTileIconVariant = FourCharCode('tile');
  289. kRolloverIconVariant = FourCharCode('over');
  290. kDropIconVariant = FourCharCode('drop');
  291. kOpenIconVariant = FourCharCode('open');
  292. kOpenDropIconVariant = FourCharCode('odrp');
  293. {$endc} {TARGET_OS_MAC}
  294. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  295. end.
  296. {$endc} {not MACOSALLINCLUDE}