icon.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. History:
  14. Added overlay functions for Pchar->Strings, functions
  15. and procedures.
  16. 14 Jul 2000.
  17. Removed amigaoverlays, use smartlink instead.
  18. 05 Nov 2002.
  19. Added the defines use_amiga_smartlink and
  20. use_auto_openlib. Implemented autoopening of
  21. the library.
  22. 14 Jan 2003.
  23. Update for AmigaOS 3.9.
  24. A lof of new const and a record.
  25. Functions added.
  26. FUNCTION DupDiskObjectA
  27. FUNCTION IconControlA
  28. PROCEDURE DrawIconStateA
  29. FUNCTION GetIconRectangleA
  30. FUNCTION NewDiskObject
  31. FUNCTION GetIconTagList
  32. FUNCTION PutIconTagList
  33. FUNCTION LayoutIconA
  34. PROCEDURE ChangeToSelectedIconColor
  35. plus overlay for
  36. FUNCTION GetIconTagList;
  37. FUNCTION PutIconTagList
  38. Changed start code for unit.
  39. 02 Feb 2003.
  40. Changed cardinal > longword.
  41. 09 Feb 2003.
  42. [email protected]
  43. }
  44. {$I useamigasmartlink.inc}
  45. {$ifdef use_amiga_smartlink}
  46. {$smartlink on}
  47. {$endif use_amiga_smartlink}
  48. unit icon;
  49. INTERFACE
  50. uses exec, workbench,utility,amigados,graphics,intuition,datatypes;
  51. const
  52. ICONA_Dummy = TAG_USER + $9000;
  53. { }
  54. { Error reporting (LONG ) }
  55. ICONA_ErrorCode = ICONA_Dummy + 1;
  56. { Points to the tag item that caused the error (struct TagItem ). }
  57. ICONA_ErrorTagItem = ICONA_Dummy + 75;
  58. { }
  59. { Global options for IconControlA() }
  60. { Screen to use for remapping Workbench icons to (struct Screen ) }
  61. ICONCTRLA_SetGlobalScreen = ICONA_Dummy + 2;
  62. ICONCTRLA_GetGlobalScreen = ICONA_Dummy + 3;
  63. { Icon color remapping precision; defaults to PRECISION_ICON (LONG) }
  64. ICONCTRLA_SetGlobalPrecision = ICONA_Dummy + 4;
  65. ICONCTRLA_GetGlobalPrecision = ICONA_Dummy + 5;
  66. { Icon frame size dimensions (struct Rectangle ) }
  67. ICONCTRLA_SetGlobalEmbossRect = ICONA_Dummy + 6;
  68. ICONCTRLA_GetGlobalEmbossRect = ICONA_Dummy + 7;
  69. { Render image without frame (BOOL) }
  70. ICONCTRLA_SetGlobalFrameless = ICONA_Dummy + 8;
  71. ICONCTRLA_GetGlobalFrameless = ICONA_Dummy + 9;
  72. { Enable NewIcons support (BOOL) }
  73. ICONCTRLA_SetGlobalNewIconsSupport = ICONA_Dummy + 10;
  74. ICONCTRLA_GetGlobalNewIconsSupport = ICONA_Dummy + 11;
  75. { Enable color icon support (BOOL) }
  76. ICONCTRLA_SetGlobalColorIconSupport = ICONA_Dummy + 77;
  77. ICONCTRLA_GetGlobalColorIconSupport = ICONA_Dummy + 78;
  78. { Set/Get the hook to be called when identifying a file (struct Hook ) }
  79. ICONCTRLA_SetGlobalIdentifyHook = ICONA_Dummy + 12;
  80. ICONCTRLA_GetGlobalIdentifyHook = ICONA_Dummy + 13;
  81. { Set/get the maximum length of a file/drawer name supported
  82. by icon.library (LONG).
  83. }
  84. ICONCTRLA_SetGlobalMaxNameLength = ICONA_Dummy + 67;
  85. ICONCTRLA_GetGlobalMaxNameLength = ICONA_Dummy + 68;
  86. {**************************************************************************}
  87. { Per icon local options for IconControlA() }
  88. { Get the icon rendering masks (PLANEPTR) }
  89. ICONCTRLA_GetImageMask1 = ICONA_Dummy + 14;
  90. ICONCTRLA_GetImageMask2 = ICONA_Dummy + 15;
  91. { Transparent image color; set to -1 if opaque }
  92. ICONCTRLA_SetTransparentColor1 = ICONA_Dummy + 16;
  93. ICONCTRLA_GetTransparentColor1 = ICONA_Dummy + 17;
  94. ICONCTRLA_SetTransparentColor2 = ICONA_Dummy + 18;
  95. ICONCTRLA_GetTransparentColor2 = ICONA_Dummy + 19;
  96. { Image color palette (struct ColorRegister ) }
  97. ICONCTRLA_SetPalette1 = ICONA_Dummy + 20;
  98. ICONCTRLA_GetPalette1 = ICONA_Dummy + 21;
  99. ICONCTRLA_SetPalette2 = ICONA_Dummy + 22;
  100. ICONCTRLA_GetPalette2 = ICONA_Dummy + 23;
  101. { Size of image color palette (LONG) }
  102. ICONCTRLA_SetPaletteSize1 = ICONA_Dummy + 24;
  103. ICONCTRLA_GetPaletteSize1 = ICONA_Dummy + 25;
  104. ICONCTRLA_SetPaletteSize2 = ICONA_Dummy + 26;
  105. ICONCTRLA_GetPaletteSize2 = ICONA_Dummy + 27;
  106. { Image data; one by per pixel (UBYTE ) }
  107. ICONCTRLA_SetImageData1 = ICONA_Dummy + 28;
  108. ICONCTRLA_GetImageData1 = ICONA_Dummy + 29;
  109. ICONCTRLA_SetImageData2 = ICONA_Dummy + 30;
  110. ICONCTRLA_GetImageData2 = ICONA_Dummy + 31;
  111. { Render image without frame (BOOL) }
  112. ICONCTRLA_SetFrameless = ICONA_Dummy + 32;
  113. ICONCTRLA_GetFrameless = ICONA_Dummy + 33;
  114. { Enable NewIcons support (BOOL) }
  115. ICONCTRLA_SetNewIconsSupport = ICONA_Dummy + 34;
  116. ICONCTRLA_GetNewIconsSupport = ICONA_Dummy + 35;
  117. { Icon aspect ratio (UBYTE ) }
  118. ICONCTRLA_SetAspectRatio = ICONA_Dummy + 36;
  119. ICONCTRLA_GetAspectRatio = ICONA_Dummy + 37;
  120. { Icon dimensions; valid only for palette mapped icon images (LONG) }
  121. ICONCTRLA_SetWidth = ICONA_Dummy + 38;
  122. ICONCTRLA_GetWidth = ICONA_Dummy + 39;
  123. ICONCTRLA_SetHeight = ICONA_Dummy + 40;
  124. ICONCTRLA_GetHeight = ICONA_Dummy + 41;
  125. { Check whether the icon is palette mapped (LONG ). }
  126. ICONCTRLA_IsPaletteMapped = ICONA_Dummy + 42;
  127. { Get the screen the icon is attached to (struct Screen ). }
  128. ICONCTRLA_GetScreen = ICONA_Dummy + 43;
  129. { Check whether the icon has a real select image (LONG ). }
  130. ICONCTRLA_HasRealImage2 = ICONA_Dummy + 44;
  131. { Check whether the icon is of the NewIcon type (LONG ). }
  132. ICONCTRLA_IsNewIcon = ICONA_Dummy + 79;
  133. { Check whether this icon was allocated by icon.library
  134. or if consists solely of a statically allocated
  135. struct DiskObject. (LONG ).
  136. }
  137. ICONCTRLA_IsNativeIcon = ICONA_Dummy + 80;
  138. {**************************************************************************}
  139. { Icon aspect ratio is not known. }
  140. ICON_ASPECT_RATIO_UNKNOWN = 0;
  141. { Tags for use with GetIconTagList() }
  142. { Default icon type to retrieve (LONG) }
  143. ICONGETA_GetDefaultType = ICONA_Dummy+45;
  144. { Retrieve default icon for the given name (STRPTR) }
  145. ICONGETA_GetDefaultName = ICONA_Dummy + 46;
  146. { Return a default icon if the requested icon
  147. file cannot be found (BOOL).
  148. }
  149. ICONGETA_FailIfUnavailable = ICONA_Dummy + 47;
  150. { If possible, retrieve a palette mapped icon (BOOL). }
  151. ICONGETA_GetPaletteMappedIcon = ICONA_Dummy + 48;
  152. { Set if the icon returned is a default icon (BOOL ). }
  153. ICONGETA_IsDefaultIcon = ICONA_Dummy + 49;
  154. { Remap the icon to the default screen, if possible (BOOL). }
  155. ICONGETA_RemapIcon = ICONA_Dummy + 50;
  156. { Generate icon image masks (BOOL). }
  157. ICONGETA_GenerateImageMasks = ICONA_Dummy + 51;
  158. { Label text to be assigned to the icon (STRPTR). }
  159. ICONGETA_Label = ICONA_Dummy + 52;
  160. { Screen to remap the icon to (struct Screen ). }
  161. ICONGETA_Screen = ICONA_Dummy + 69;
  162. {**************************************************************************}
  163. { Tags for use with PutIconTagList() }
  164. { Notify Workbench of the icon being written (BOOL) }
  165. ICONPUTA_NotifyWorkbench = ICONA_Dummy + 53;
  166. { Store icon as the default for this type (LONG) }
  167. ICONPUTA_PutDefaultType = ICONA_Dummy + 54;
  168. { Store icon as a default for the given name (STRPTR) }
  169. ICONPUTA_PutDefaultName = ICONA_Dummy + 55;
  170. { When storing a palette mapped icon, don't save the
  171. the original planar icon image with the file. Replace
  172. it with a tiny replacement image.
  173. }
  174. ICONPUTA_DropPlanarIconImage = ICONA_Dummy + 56;
  175. { Don't write the chunky icon image data to disk. }
  176. ICONPUTA_DropChunkyIconImage = ICONA_Dummy + 57;
  177. { Don't write the NewIcons tool types to disk. }
  178. ICONPUTA_DropNewIconToolTypes = ICONA_Dummy + 58;
  179. { If this tag is enabled, the writer will examine the
  180. icon image data to find out whether it can compress
  181. it more efficiently. This may take extra time and
  182. is not generally recommended.
  183. }
  184. ICONPUTA_OptimizeImageSpace = ICONA_Dummy + 59;
  185. { Don't write the entire icon file back to disk,
  186. only change the do->do_CurrentX/do->do_CurrentY
  187. members.
  188. }
  189. ICONPUTA_OnlyUpdatePosition = ICONA_Dummy + 72;
  190. { Before writing a palette mapped icon back to disk,
  191. icon.library will make sure that the original
  192. planar image data is stored in the file. If you
  193. don't want that to happen, set this option to
  194. FALSE. This will allow you to change the planar icon
  195. image data written back to disk.
  196. }
  197. ICONPUTA_PreserveOldIconImages = ICONA_Dummy + 84;
  198. {**************************************************************************}
  199. { For use with the file identification hook. }
  200. type
  201. PIconIdentifyMsg = ^tIconIdentifyMsg;
  202. tIconIdentifyMsg = record
  203. { Libraries that are already opened for your use. }
  204. iim_SysBase : PLibrary;
  205. iim_DOSBase : PLibrary;
  206. iim_UtilityBase : PLibrary;
  207. iim_IconBase : PLibrary;
  208. { File context information. }
  209. iim_FileLock : BPTR; { Lock on the object to return an icon for. }
  210. iim_ParentLock : BPTR; { Lock on the object's parent directory, if available. }
  211. iim_FIB : PFileInfoBlock; { Already initialized for you. }
  212. iim_FileHandle : BPTR; { If non-NULL, pointer to the file to examine,
  213. * positioned right at the first byte, ready
  214. * for you to use.
  215. }
  216. iim_Tags : PTagItem; { Tags passed to GetIconTagList(). }
  217. end;
  218. {**************************************************************************}
  219. { Tags for use with DupDiskObjectA() }
  220. const
  221. { Duplicate do_DrawerData }
  222. ICONDUPA_DuplicateDrawerData = ICONA_Dummy + 60;
  223. { Duplicate the Image structures. }
  224. ICONDUPA_DuplicateImages = ICONA_Dummy + 61;
  225. { Duplicate the image data (Image->ImageData) itself. }
  226. ICONDUPA_DuplicateImageData = ICONA_Dummy + 62;
  227. { Duplicate the default tool. }
  228. ICONDUPA_DuplicateDefaultTool = ICONA_Dummy + 63;
  229. { Duplicate the tool types list. }
  230. ICONDUPA_DuplicateToolTypes = ICONA_Dummy + 64;
  231. { Duplicate the tool window. }
  232. ICONDUPA_DuplicateToolWindow = ICONA_Dummy + 65;
  233. { If the icon to be duplicated is in fact a palette mapped
  234. icon which has never been set up to be displayed on the
  235. screen, turn the duplicate into that palette mapped icon.
  236. }
  237. ICONDUPA_ActivateImageData = ICONA_Dummy + 82;
  238. {**************************************************************************}
  239. { Tags for use with DrawIconStateA() and GetIconRectangleA(). }
  240. { Drawing information to use (struct DrawInfo ). }
  241. ICONDRAWA_DrawInfo = ICONA_Dummy + 66;
  242. { Draw the icon without the surrounding frame (BOOL). }
  243. ICONDRAWA_Frameless = ICONA_Dummy + 70;
  244. { Erase the background before drawing a frameless icon (BOOL). }
  245. ICONDRAWA_EraseBackground = ICONA_Dummy + 71;
  246. { Draw the icon without the surrounding border and frame (BOOL). }
  247. ICONDRAWA_Borderless = ICONA_Dummy + 83;
  248. { The icon to be drawn refers to a linked object (BOOL). }
  249. ICONDRAWA_IsLink = ICONA_Dummy + 89;
  250. {**************************************************************************}
  251. { Reserved tags; don't use! }
  252. ICONA_Reserved1 = ICONA_Dummy + 73;
  253. ICONA_Reserved2 = ICONA_Dummy + 74;
  254. ICONA_Reserved3 = ICONA_Dummy + 76;
  255. ICONA_Reserved4 = ICONA_Dummy + 81;
  256. ICONA_Reserved5 = ICONA_Dummy + 85;
  257. ICONA_Reserved6 = ICONA_Dummy + 86;
  258. ICONA_Reserved7 = ICONA_Dummy + 87;
  259. ICONA_Reserved8 = ICONA_Dummy + 88;
  260. { }
  261. ICONA_LAST_TAG = ICONA_Dummy + 89;
  262. {**************************************************************************}
  263. Const
  264. ICONNAME : PChar = 'icon.library';
  265. VAR IconBase : pLibrary;
  266. FUNCTION AddFreeList(freelist : pFreeList;const mem : POINTER; size : ULONG) : BOOLEAN;
  267. FUNCTION BumpRevision(newname : pCHAR;const oldname : pCHAR) : pCHAR;
  268. FUNCTION DeleteDiskObject(const name : pCHAR) : BOOLEAN;
  269. FUNCTION FindToolType(const toolTypeArray : POINTER;const typeName : pCHAR) : pCHAR;
  270. PROCEDURE FreeDiskObject(diskobj : pDiskObject);
  271. PROCEDURE FreeFreeList(freelist : pFreeList);
  272. FUNCTION GetDefDiskObject(typ : LONGINT) : pDiskObject;
  273. FUNCTION GetDiskObject(const name : pCHAR) : pDiskObject;
  274. FUNCTION GetDiskObjectNew(const name : pCHAR) : pDiskObject;
  275. FUNCTION MatchToolValue(const typeString : pCHAR;const value : pCHAR) : BOOLEAN;
  276. FUNCTION PutDefDiskObject(const diskObject : pDiskObject) : BOOLEAN;
  277. FUNCTION PutDiskObject(const name : pCHAR;const diskobj : pDiskObject) : BOOLEAN;
  278. { version 44 }
  279. FUNCTION DupDiskObjectA(CONST diskObject : pDiskObject; CONST tags : pTagItem) : pDiskObject;
  280. FUNCTION IconControlA(icon : pDiskObject; CONST tags : pTagItem) : longword;
  281. PROCEDURE DrawIconStateA(rp : pRastPort; CONST icon : pDiskObject; CONST label_ : pCHAR; leftOffset : LONGINT; topOffset : LONGINT; state : longword; CONST tags : pTagItem);
  282. FUNCTION GetIconRectangleA(rp : pRastPort; CONST icon : pDiskObject; CONST label_ : pCHAR; rect : pRectangle; CONST tags : pTagItem) : BOOLEAN;
  283. FUNCTION NewDiskObject(type_ : LONGINT) : pDiskObject;
  284. FUNCTION GetIconTagList(CONST name : pCHAR; CONST tags : pTagItem) : pDiskObject;
  285. FUNCTION PutIconTagList(CONST name : pCHAR; CONST icon : pDiskObject; CONST tags : pTagItem) : BOOLEAN;
  286. FUNCTION LayoutIconA(icon : pDiskObject; screen : pScreen; tags : pTagItem) : BOOLEAN;
  287. PROCEDURE ChangeToSelectedIconColor(cr : pColorRegister);
  288. { overlay }
  289. FUNCTION BumpRevision(newname : string;const oldname : pCHAR) : pCHAR;
  290. FUNCTION BumpRevision(newname : pCHar;const oldname : string) : pCHAR;
  291. FUNCTION BumpRevision(newname : string;const oldname : string) : pCHAR;
  292. FUNCTION DeleteDiskObject(const name : string) : BOOLEAN;
  293. FUNCTION FindToolType(const toolTypeArray : POINTER;const typeName : string) : pCHAR;
  294. FUNCTION GetDiskObject(const name : string) : pDiskObject;
  295. FUNCTION GetDiskObjectNew(const name : string) : pDiskObject;
  296. FUNCTION MatchToolValue(const typeString :string;const value : pCHAR) : BOOLEAN;
  297. FUNCTION MatchToolValue(const typeString : pCHAR;const value : string) : BOOLEAN;
  298. FUNCTION MatchToolValue(const typeString : string;const value : string) : BOOLEAN;
  299. FUNCTION PutDiskObject(const name : string;const diskobj : pDiskObject) : BOOLEAN;
  300. { version 44 overlay}
  301. FUNCTION GetIconTagList(CONST name : string; CONST tags : pTagItem) : pDiskObject;
  302. FUNCTION PutIconTagList(CONST name : string; CONST icon : pDiskObject; CONST tags : pTagItem) : BOOLEAN;
  303. {macros}
  304. function PACK_ICON_ASPECT_RATIO(num,den : longint) : longint;
  305. {Here we read how to compile this unit}
  306. {You can remove this include and use a define instead}
  307. {$I useautoopenlib.inc}
  308. {$ifdef use_init_openlib}
  309. procedure InitICONLibrary;
  310. {$endif use_init_openlib}
  311. {This is a variable that knows how the unit is compiled}
  312. var
  313. ICONIsCompiledHow : longint;
  314. IMPLEMENTATION
  315. uses
  316. {$ifndef dont_use_openlib}
  317. msgbox,
  318. {$endif dont_use_openlib}
  319. pastoc;
  320. function PACK_ICON_ASPECT_RATIO(num,den : longint) : longint;
  321. begin
  322. PACK_ICON_ASPECT_RATIO:=(num shl 4) or den;
  323. end;
  324. FUNCTION AddFreeList(freelist : pFreeList;const mem : POINTER; size : ULONG) : BOOLEAN;
  325. BEGIN
  326. ASM
  327. MOVE.L A6,-(A7)
  328. MOVEA.L freelist,A0
  329. MOVEA.L mem,A1
  330. MOVEA.L size,A2
  331. MOVEA.L IconBase,A6
  332. JSR -072(A6)
  333. MOVEA.L (A7)+,A6
  334. TST.W D0
  335. BEQ.B @end
  336. MOVEQ #1,D0
  337. @end: MOVE.B D0,@RESULT
  338. END;
  339. END;
  340. FUNCTION BumpRevision(newname : pCHAR;const oldname : pCHAR) : pCHAR;
  341. BEGIN
  342. ASM
  343. MOVE.L A6,-(A7)
  344. MOVEA.L newname,A0
  345. MOVEA.L oldname,A1
  346. MOVEA.L IconBase,A6
  347. JSR -108(A6)
  348. MOVEA.L (A7)+,A6
  349. MOVE.L D0,@RESULT
  350. END;
  351. END;
  352. FUNCTION DeleteDiskObject(const name : pCHAR) : BOOLEAN;
  353. BEGIN
  354. ASM
  355. MOVE.L A6,-(A7)
  356. MOVEA.L name,A0
  357. MOVEA.L IconBase,A6
  358. JSR -138(A6)
  359. MOVEA.L (A7)+,A6
  360. TST.W D0
  361. BEQ.B @end
  362. MOVEQ #1,D0
  363. @end: MOVE.B D0,@RESULT
  364. END;
  365. END;
  366. FUNCTION FindToolType(const toolTypeArray : POINTER;const typeName : pCHAR) : pCHAR;
  367. BEGIN
  368. ASM
  369. MOVE.L A6,-(A7)
  370. MOVEA.L toolTypeArray,A0
  371. MOVEA.L typeName,A1
  372. MOVEA.L IconBase,A6
  373. JSR -096(A6)
  374. MOVEA.L (A7)+,A6
  375. MOVE.L D0,@RESULT
  376. END;
  377. END;
  378. PROCEDURE FreeDiskObject(diskobj : pDiskObject);
  379. BEGIN
  380. ASM
  381. MOVE.L A6,-(A7)
  382. MOVEA.L diskobj,A0
  383. MOVEA.L IconBase,A6
  384. JSR -090(A6)
  385. MOVEA.L (A7)+,A6
  386. END;
  387. END;
  388. PROCEDURE FreeFreeList(freelist : pFreeList);
  389. BEGIN
  390. ASM
  391. MOVE.L A6,-(A7)
  392. MOVEA.L freelist,A0
  393. MOVEA.L IconBase,A6
  394. JSR -054(A6)
  395. MOVEA.L (A7)+,A6
  396. END;
  397. END;
  398. FUNCTION GetDefDiskObject(typ : LONGINT) : pDiskObject;
  399. BEGIN
  400. ASM
  401. MOVE.L A6,-(A7)
  402. MOVE.L typ,D0
  403. MOVEA.L IconBase,A6
  404. JSR -120(A6)
  405. MOVEA.L (A7)+,A6
  406. MOVE.L D0,@RESULT
  407. END;
  408. END;
  409. FUNCTION GetDiskObject(const name : pCHAR) : pDiskObject;
  410. BEGIN
  411. ASM
  412. MOVE.L A6,-(A7)
  413. MOVEA.L name,A0
  414. MOVEA.L IconBase,A6
  415. JSR -078(A6)
  416. MOVEA.L (A7)+,A6
  417. MOVE.L D0,@RESULT
  418. END;
  419. END;
  420. FUNCTION GetDiskObjectNew(const name : pCHAR) : pDiskObject;
  421. BEGIN
  422. ASM
  423. MOVE.L A6,-(A7)
  424. MOVEA.L name,A0
  425. MOVEA.L IconBase,A6
  426. JSR -132(A6)
  427. MOVEA.L (A7)+,A6
  428. MOVE.L D0,@RESULT
  429. END;
  430. END;
  431. FUNCTION MatchToolValue(const typeString : pCHAR;const value : pCHAR) : BOOLEAN;
  432. BEGIN
  433. ASM
  434. MOVE.L A6,-(A7)
  435. MOVEA.L typeString,A0
  436. MOVEA.L value,A1
  437. MOVEA.L IconBase,A6
  438. JSR -102(A6)
  439. MOVEA.L (A7)+,A6
  440. TST.W D0
  441. BEQ.B @end
  442. MOVEQ #1,D0
  443. @end: MOVE.B D0,@RESULT
  444. END;
  445. END;
  446. FUNCTION PutDefDiskObject(const diskObject : pDiskObject) : BOOLEAN;
  447. BEGIN
  448. ASM
  449. MOVE.L A6,-(A7)
  450. MOVEA.L diskObject,A0
  451. MOVEA.L IconBase,A6
  452. JSR -126(A6)
  453. MOVEA.L (A7)+,A6
  454. TST.W D0
  455. BEQ.B @end
  456. MOVEQ #1,D0
  457. @end: MOVE.B D0,@RESULT
  458. END;
  459. END;
  460. FUNCTION PutDiskObject(const name : pCHAR;const diskobj : pDiskObject) : BOOLEAN;
  461. BEGIN
  462. ASM
  463. MOVE.L A6,-(A7)
  464. MOVEA.L name,A0
  465. MOVEA.L diskobj,A1
  466. MOVEA.L IconBase,A6
  467. JSR -084(A6)
  468. MOVEA.L (A7)+,A6
  469. TST.W D0
  470. BEQ.B @end
  471. MOVEQ #1,D0
  472. @end: MOVE.B D0,@RESULT
  473. END;
  474. END;
  475. FUNCTION DupDiskObjectA(CONST diskObject : pDiskObject; CONST tags : pTagItem) : pDiskObject;
  476. BEGIN
  477. ASM
  478. MOVE.L A6,-(A7)
  479. MOVEA.L diskObject,A0
  480. MOVEA.L tags,A1
  481. MOVEA.L IconBase,A6
  482. JSR -150(A6)
  483. MOVEA.L (A7)+,A6
  484. MOVE.L D0,@RESULT
  485. END;
  486. END;
  487. FUNCTION IconControlA(icon : pDiskObject; CONST tags : pTagItem) : longword;
  488. BEGIN
  489. ASM
  490. MOVE.L A6,-(A7)
  491. MOVEA.L icon,A0
  492. MOVEA.L tags,A1
  493. MOVEA.L IconBase,A6
  494. JSR -156(A6)
  495. MOVEA.L (A7)+,A6
  496. MOVE.L D0,@RESULT
  497. END;
  498. END;
  499. PROCEDURE DrawIconStateA(rp : pRastPort; CONST icon : pDiskObject; CONST label_ : pCHAR; leftOffset : LONGINT; topOffset : LONGINT; state : longword; CONST tags : pTagItem);
  500. BEGIN
  501. ASM
  502. MOVE.L A6,-(A7)
  503. MOVEA.L rp,A0
  504. MOVEA.L icon,A1
  505. MOVEA.L label_,A2
  506. MOVE.L leftOffset,D0
  507. MOVE.L topOffset,D1
  508. MOVE.L state,D2
  509. MOVEA.L tags,A3
  510. MOVEA.L IconBase,A6
  511. JSR -162(A6)
  512. MOVEA.L (A7)+,A6
  513. END;
  514. END;
  515. FUNCTION GetIconRectangleA(rp : pRastPort; CONST icon : pDiskObject; CONST label_ : pCHAR; rect : pRectangle; CONST tags : pTagItem) : BOOLEAN;
  516. BEGIN
  517. ASM
  518. MOVE.L A6,-(A7)
  519. MOVEA.L rp,A0
  520. MOVEA.L icon,A1
  521. MOVEA.L label_,A2
  522. MOVEA.L rect,A3
  523. MOVEA.L tags,A4
  524. MOVEA.L IconBase,A6
  525. JSR -168(A6)
  526. MOVEA.L (A7)+,A6
  527. TST.W D0
  528. BEQ.B @end
  529. MOVEQ #1,D0
  530. @end: MOVE.B D0,@RESULT
  531. END;
  532. END;
  533. FUNCTION NewDiskObject(type_ : LONGINT) : pDiskObject;
  534. BEGIN
  535. ASM
  536. MOVE.L A6,-(A7)
  537. MOVE.L type_,D0
  538. MOVEA.L IconBase,A6
  539. JSR -174(A6)
  540. MOVEA.L (A7)+,A6
  541. MOVE.L D0,@RESULT
  542. END;
  543. END;
  544. FUNCTION GetIconTagList(CONST name : pCHAR; CONST tags : pTagItem) : pDiskObject;
  545. BEGIN
  546. ASM
  547. MOVE.L A6,-(A7)
  548. MOVEA.L name,A0
  549. MOVEA.L tags,A1
  550. MOVEA.L IconBase,A6
  551. JSR -180(A6)
  552. MOVEA.L (A7)+,A6
  553. MOVE.L D0,@RESULT
  554. END;
  555. END;
  556. FUNCTION PutIconTagList(CONST name : pCHAR; CONST icon : pDiskObject; CONST tags : pTagItem) : BOOLEAN;
  557. BEGIN
  558. ASM
  559. MOVE.L A6,-(A7)
  560. MOVEA.L name,A0
  561. MOVEA.L icon,A1
  562. MOVEA.L tags,A2
  563. MOVEA.L IconBase,A6
  564. JSR -186(A6)
  565. MOVEA.L (A7)+,A6
  566. TST.W D0
  567. BEQ.B @end
  568. MOVEQ #1,D0
  569. @end: MOVE.B D0,@RESULT
  570. END;
  571. END;
  572. FUNCTION LayoutIconA(icon : pDiskObject; screen : pScreen; tags : pTagItem) : BOOLEAN;
  573. BEGIN
  574. ASM
  575. MOVE.L A6,-(A7)
  576. MOVEA.L icon,A0
  577. MOVEA.L screen,A1
  578. MOVEA.L tags,A2
  579. MOVEA.L IconBase,A6
  580. JSR -192(A6)
  581. MOVEA.L (A7)+,A6
  582. TST.W D0
  583. BEQ.B @end
  584. MOVEQ #1,D0
  585. @end: MOVE.B D0,@RESULT
  586. END;
  587. END;
  588. PROCEDURE ChangeToSelectedIconColor(cr : pColorRegister);
  589. BEGIN
  590. ASM
  591. MOVE.L A6,-(A7)
  592. MOVEA.L cr,A0
  593. MOVEA.L IconBase,A6
  594. JSR -198(A6)
  595. MOVEA.L (A7)+,A6
  596. END;
  597. END;
  598. FUNCTION BumpRevision(newname : string;const oldname : pCHAR) : pCHAR;
  599. begin
  600. BumpRevision := BumpRevision(pas2c(newname),oldname);
  601. end;
  602. FUNCTION BumpRevision(newname : pCHar;const oldname : string) : pCHAR;
  603. begin
  604. BumpRevision := BumpRevision(newname,pas2c(oldname));
  605. end;
  606. FUNCTION BumpRevision(newname : string;const oldname : string) : pCHAR;
  607. begin
  608. BumpRevision := BumpRevision(pas2c(newname),pas2c(oldname));
  609. end;
  610. FUNCTION DeleteDiskObject(const name : string) : BOOLEAN;
  611. begin
  612. DeleteDiskObject := DeleteDiskObject(pas2c(name));
  613. end;
  614. FUNCTION FindToolType(const toolTypeArray : POINTER;const typeName : string) : pCHAR;
  615. begin
  616. FindToolType := FindToolType(toolTypeArray,pas2c(typeName));
  617. end;
  618. FUNCTION GetDiskObject(const name : string) : pDiskObject;
  619. begin
  620. GetDiskObject := GetDiskObject(pas2c(name));
  621. end;
  622. FUNCTION GetDiskObjectNew(const name : string) : pDiskObject;
  623. begin
  624. GetDiskObjectNew := GetDiskObjectNew(pas2c(name));
  625. end;
  626. FUNCTION MatchToolValue(const typeString : string;const value : pCHAR) : BOOLEAN;
  627. begin
  628. MatchToolValue := MatchToolValue(pas2c(typeString),value);
  629. end;
  630. FUNCTION MatchToolValue(const typeString : pCHAR;const value : string) : BOOLEAN;
  631. begin
  632. MatchToolValue := MatchToolValue(typeString,pas2c(value));
  633. end;
  634. FUNCTION MatchToolValue(const typeString : string;const value : string) : BOOLEAN;
  635. begin
  636. MatchToolValue := MatchToolValue(pas2c(typeString),pas2c(value));
  637. end;
  638. FUNCTION PutDiskObject(const name : string;const diskobj : pDiskObject) : BOOLEAN;
  639. begin
  640. PutDiskObject := PutDiskObject(pas2c(name),diskobj);
  641. end;
  642. FUNCTION GetIconTagList(CONST name : string; CONST tags : pTagItem) : pDiskObject;
  643. begin
  644. GetIconTagList := GetIconTagList(pas2c(name),tags);
  645. end;
  646. FUNCTION PutIconTagList(CONST name : string; CONST icon : pDiskObject; CONST tags : pTagItem) : BOOLEAN;
  647. begin
  648. PutIconTagList := PutIconTagList(pas2c(name),icon,tags);
  649. end;
  650. const
  651. { Change VERSION and LIBVERSION to proper values }
  652. VERSION : string[2] = '0';
  653. LIBVERSION : longword = 0;
  654. {$ifdef use_init_openlib}
  655. {$Info Compiling initopening of icon.library}
  656. {$Info don't forget to use InitICONLibrary in the beginning of your program}
  657. var
  658. icon_exit : Pointer;
  659. procedure CloseiconLibrary;
  660. begin
  661. ExitProc := icon_exit;
  662. if IconBase <> nil then begin
  663. CloseLibrary(IconBase);
  664. IconBase := nil;
  665. end;
  666. end;
  667. procedure InitICONLibrary;
  668. begin
  669. IconBase := nil;
  670. IconBase := OpenLibrary(ICONNAME,LIBVERSION);
  671. if IconBase <> nil then begin
  672. icon_exit := ExitProc;
  673. ExitProc := @CloseiconLibrary;
  674. end else begin
  675. MessageBox('FPC Pascal Error',
  676. 'Can''t open icon.library version ' + VERSION + #10 +
  677. 'Deallocating resources and closing down',
  678. 'Oops');
  679. halt(20);
  680. end;
  681. end;
  682. begin
  683. ICONIsCompiledHow := 2;
  684. {$endif use_init_openlib}
  685. {$ifdef use_auto_openlib}
  686. {$Info Compiling autoopening of icon.library}
  687. var
  688. icon_exit : Pointer;
  689. procedure CloseiconLibrary;
  690. begin
  691. ExitProc := icon_exit;
  692. if IconBase <> nil then begin
  693. CloseLibrary(IconBase);
  694. IconBase := nil;
  695. end;
  696. end;
  697. begin
  698. IconBase := nil;
  699. IconBase := OpenLibrary(ICONNAME,LIBVERSION);
  700. if IconBase <> nil then begin
  701. icon_exit := ExitProc;
  702. ExitProc := @CloseiconLibrary;
  703. ICONIsCompiledHow := 1;
  704. end else begin
  705. MessageBox('FPC Pascal Error',
  706. 'Can''t open icon.library version ' + VERSION + #10 +
  707. 'Deallocating resources and closing down',
  708. 'Oops');
  709. halt(20);
  710. end;
  711. {$endif use_auto_openlib}
  712. {$ifdef dont_use_openlib}
  713. begin
  714. ICONIsCompiledHow := 3;
  715. {$Warning No autoopening of icon.library compiled}
  716. {$Warning Make sure you open icon.library yourself}
  717. {$endif dont_use_openlib}
  718. END. (* UNIT ICON *)