1 {
2     This file is part of the Free Pascal run time library.
3     Copyright (c) 2014 by Free Pascal development team
4 
5     icon.library functions
6 
7     See the file COPYING.FPC, included in this distribution,
8     for details about the copyright.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 
14  **********************************************************************}
15 
16 unit icon;
17 
18 interface
19 
20 uses
21   exec, workbench, utility, amigados, agraphics, intuition;
22 
23 const
24   ICONNAME: PChar = 'icon.library';
25 
26   ICONA_Dummy                   = TAG_USER + $9000; // Start of icon.library tags
27   ICONA_ErrorCode               = ICONA_Dummy + 1;  // (PLongInt) Errorcode
28   ICONA_ErrorTagItem            = ICONA_Dummy + 75; // (^PTagItem) Points to the tag item that caused the error .
29 
30 // Global options for IconControlA()
31 
32   ICONCTRLA_SetGlobalScreen     = ICONA_Dummy + 2;  // (PScreen) Screen to use for remapping Workbench icons to
33   ICONCTRLA_GetGlobalScreen     = ICONA_Dummy + 3;
34   ICONCTRLA_SetGlobalPrecision  = ICONA_Dummy + 4;  // (LongInt) Icon color remapping precision; defaults to PRECISION_ICON
35   ICONCTRLA_GetGlobalPrecision  = ICONA_Dummy + 5;
36   ICONCTRLA_SetGlobalEmbossRect = ICONA_Dummy + 6;  // (PRectangle) Icon frame size dimensions
37   ICONCTRLA_GetGlobalEmbossRect = ICONA_Dummy + 7;
38   ICONCTRLA_SetGlobalFrameless  = ICONA_Dummy + 8;  // (LongBool) Render image without frame
39   ICONCTRLA_GetGlobalFrameless  = ICONA_Dummy + 9;
40   ICONCTRLA_SetGlobalNewIconsSupport  = ICONA_Dummy + 10; // (LongBool) Enable NewIcons support
41   ICONCTRLA_GetGlobalNewIconsSupport  = ICONA_Dummy + 11;
42   ICONCTRLA_SetGlobalColorIconSupport = ICONA_Dummy + 77; // (LongBool) Enable color icon support
43   ICONCTRLA_GetGlobalColorIconSupport = ICONA_Dummy + 78;
44   ICONCTRLA_SetGlobalIdentifyHook     = ICONA_Dummy + 12; // (PHook) Set/Get the hook to be called when identifying a file
45   ICONCTRLA_GetGlobalIdentifyHook     = ICONA_Dummy + 13;
46   ICONCTRLA_SetGlobalMaxNameLength    = ICONA_Dummy + 67; // (LongInt) Set/get the maximum length of a file/drawer name supported by icon.library
47   ICONCTRLA_GetGlobalMaxNameLength    = ICONA_Dummy + 68;
48   ICONCTRLA_SetGlobalLeftOutMarking   = ICONA_Dummy + 96; // (LongBool) Enable marking of left-out icons (V51)
49   ICONCTRLA_GetGlobalLeftOutMarking   = ICONA_Dummy + 97;
50   ICONCTRLA_SetGlobalSelectEffect     = ICONA_Dummy +113; // (LongWord) Set/get the required visual effect for selected icons (V51)
51   ICONCTRLA_GetGlobalSelectEffect     = ICONA_Dummy +114;
52 // Values for ICONCTRLA_Set/GetGlobalSelectEffect
53   SEL_DARKEN    = $00000000; // Darken the icon, by the amount specified in the lowest byte (000000XX)
54   SEL_BRIGHTEN  = $01000000; // Brighten the icon, by the amount specified in the lowest byte (000000XX)
55   SEL_IMPOSE    = $02000000; // Impose a color over the icon image, specified in the lower bytes (00RRGGBB)
56   SEL_NEGATIVE  = $03000000; // Invert the colors of the icon, as specified in the lowest byte (000000XX)
57   SEL_ROTATERGB = $04000000; // Rotate RGB, as specified in the lowest byte (000000XX): 0 = left, 1 = right
58 
59 // Tags for use with GetIconTagList()
60   ICONGETA_GetDefaultType       = ICONA_Dummy + 45; // Default icon type to retrieve (LongInt)
61   ICONGETA_GetDefaultName       = ICONA_Dummy + 46; // Retrieve default icon for the given name (PChar)
62   ICONGETA_FailIfUnavailable    = ICONA_Dummy + 47; // Return a default icon if the requested icon file cannot be found (BOOL).
63   ICONGETA_GetPaletteMappedIcon = ICONA_Dummy + 48; // If possible, retrieve a palette mapped icon (BOOL).
64   ICONGETA_IsDefaultIcon        = ICONA_Dummy + 49; // Set if the icon returned is a default icon (PLongBool).
65   ICONGETA_RemapIcon            = ICONA_Dummy + 50; // Remap the icon to the default screen, if possible (BOOL).
66   ICONGETA_GenerateImageMasks   = ICONA_Dummy + 51; // Generate icon image masks (BOOL).
67   ICONGETA_Label                = ICONA_Dummy + 52; // Label text to be assigned to the icon (PChar).
68   ICONGETA_Screen               = ICONA_Dummy + 69; // Screen to remap the icon to (PScreen).
69   ICONGETA_UseFriendBitMap      = ICONA_Dummy + 90; // Allocate a bitmap for the icon images instead of the traditional planar icon images (LongBool). (V50)
70   ICONGETA_FileFormat           = ICONA_Dummy + 112; // Returns the format of the file the icon is loaded from. If the file is in native Amiga format, the returned name will be "Amiga" (^STRPTR). (V51)
71   ICONGETA_Width                = ICONA_Dummy + 117; // Request a specific size for the icon to be loaded.
72   ICONGETA_Height               = ICONA_Dummy + 118; //
73   ICONGETA_ForceScaling         = ICONA_Dummy + 120; // Tell icon.library to perform a manual bitmap rescaling of the loaded icon if it doesn't already have the size which was requested with ICONGETA_Width and ICONGETA_Height.
74   ICONGETA_IdentifyBuffer       = ICONA_Dummy + 122; // Request the type of the actual file whose icon is being loaded by GetIconTagList()
75   ICONGETA_IdentifyOnly         = ICONA_Dummy + 123; //
76   ICONGETA_SizeBounds           = ICONA_Dummy + 124; // Specify the size limits for the icon to be loaded.
77   ICONGETA_AllowUpscaling       = ICONA_Dummy + 126; // This means the icon image may be made larger even if no upscaling was explicitly requested.
78 
79 // Per icon local options for IconControlA()  }
80   ICONCTRLA_GetImageMask1        = ICONA_Dummy + 14; // (TPlanePtr) Get the icon rendering masks
81   ICONCTRLA_GetImageMask2        = ICONA_Dummy + 15;
82   ICONCTRLA_SetTransparentColor1 = ICONA_Dummy + 16; // Transparent image color; set to -1 if opaque
83   ICONCTRLA_GetTransparentColor1 = ICONA_Dummy + 17;
84   ICONCTRLA_SetTransparentColor2 = ICONA_Dummy + 18;
85   ICONCTRLA_GetTransparentColor2 = ICONA_Dummy + 19;
86   ICONCTRLA_SetPalette1 = ICONA_Dummy + 20; // (PColorRegister) Image color palette
87   ICONCTRLA_GetPalette1 = ICONA_Dummy + 21;
88   ICONCTRLA_SetPalette2 = ICONA_Dummy + 22;
89   ICONCTRLA_GetPalette2 = ICONA_Dummy + 23;
90   ICONCTRLA_SetPaletteSize1 = ICONA_Dummy + 24; // (LongInt) Size of image color palette
91   ICONCTRLA_GetPaletteSize1 = ICONA_Dummy + 25;
92   ICONCTRLA_SetPaletteSize2 = ICONA_Dummy + 26;
93   ICONCTRLA_GetPaletteSize2 = ICONA_Dummy + 27;
94   ICONCTRLA_SetImageData1   = ICONA_Dummy + 28; // (PByte) Image data; one by per pixel
95   ICONCTRLA_GetImageData1   = ICONA_Dummy + 29;
96   ICONCTRLA_SetImageData2   = ICONA_Dummy + 30;
97   ICONCTRLA_GetImageData2   = ICONA_Dummy + 31;
98   ICONCTRLA_SetFrameless       = ICONA_Dummy + 32; // (LongBool) Render image without frame
99   ICONCTRLA_GetFrameless       = ICONA_Dummy + 33;
100   ICONCTRLA_SetNewIconsSupport = ICONA_Dummy + 34; // (LongBool) Enable NewIcons support
101   ICONCTRLA_GetNewIconsSupport = ICONA_Dummy + 35;
102   ICONCTRLA_SetAspectRatio     = ICONA_Dummy + 36; // (PByte) Icon aspect ratio
103   ICONCTRLA_GetAspectRatio     = ICONA_Dummy + 37;
104   ICONCTRLA_SetWidth  = ICONA_Dummy + 38; // (LongInt) Icon dimensions; valid only for palette mapped icon images
105   ICONCTRLA_GetWidth  = ICONA_Dummy + 39;
106   ICONCTRLA_SetHeight = ICONA_Dummy + 40;
107   ICONCTRLA_GetHeight = ICONA_Dummy + 41;
108   ICONCTRLA_IsPaletteMapped = ICONA_Dummy + 42; // (PLongInt) Check whether the icon is palette mapped
109   ICONCTRLA_GetScreen       = ICONA_Dummy + 43; // (^PScreen) Get the screen the icon is attached to
110   ICONCTRLA_HasRealImage2   = ICONA_Dummy + 44; // (PLongInt) Check whether the icon has a real select image
111   ICONCTRLA_IsNewIcon       = ICONA_Dummy + 79; // (PLongInt) Check whether the icon is of the NewIcon type
112   ICONCTRLA_IsNativeIcon    = ICONA_Dummy + 80; // (PLongInt) Check whether this icon was allocated by icon.library or if consists solely of a statically allocated TDiskObject.
113   ICONCTRLA_UseFriendBitMap = ICONGETA_UseFriendBitMap; // (LongBool) Alias for ICONGETA_UseFriendBitMap. (V50)
114   ICONCTRLA_GetBitMap1 = ICONA_Dummy + 91; // (PBitMap) Get the bitmaps of the icon. Can be nil, only valid after an icon has been layouted. (V50)
115   ICONCTRLA_GetBitMap2 = ICONA_Dummy + 92;
116   ICONCTRLA_SetImageDataFormat = ICONA_Dummy + 103; // (LongWord) Format of icon image data (supersedes ICONCTRLA_IsPaletteMapped). The possible values are listed below. (V51)
117   ICONCTRLA_GetImageDataFormat = ICONA_Dummy + 104;
118   ICONCTRLA_SetIconModuleData  = ICONA_Dummy + 105; // (APTR) The module-specific data for an icon. Only for private use by icon loader/saver modules. (V51)
119   ICONCTRLA_GetIconModuleData  = ICONA_Dummy + 106;
120   ICONCTRLA_GetIconFileFormat  = ICONA_Dummy + 111; // (^STRPTR) Get the format of the file an icon was loaded from. (V51)
121   ICONCTRLA_AddScaledSize      = ICONA_Dummy + 115; // (LongWord) Generate a scaled version of the icon's imagery. (V51)
122   ICONCTRLA_RemScaledSize      = ICONA_Dummy + 116; // (LongWord) Remove a particular scaled version of the icon's imagery, and free all memory associated with it.
123 
124 
125 // Icon Aspect Handling
126   ICON_ASPECT_RATIO_UNKNOWN = 0; // Icon aspect ratio is not known.
127 
128 // Tags for use with PutIconTagList()
129 
130   ICONPUTA_NotifyWorkbench       = ICONA_Dummy + 53; // Notify Workbench of the icon being written (BOOL)
131   ICONPUTA_PutDefaultType        = ICONA_Dummy + 54; // Store icon as the default for this type (LongInt)
132   ICONPUTA_PutDefaultName        = ICONA_Dummy + 55; // Store icon as a default for the given name (PChar)
133   ICONPUTA_DropPlanarIconImage   = ICONA_Dummy + 56; // When storing a palette mapped icon, don't save the the original planar icon image with the file. Replace it with a tiny replacement image.
134   ICONPUTA_DropChunkyIconImage   = ICONA_Dummy + 57; // Don't write the chunky icon image data to disk.
135   ICONPUTA_DropNewIconToolTypes  = ICONA_Dummy + 58; // Don't write the NewIcons tool types to disk.
136   ICONPUTA_OptimizeImageSpace    = ICONA_Dummy + 59; // If this tag is enabled, the writer will examine the icon image data to find out whether it can compress it more efficiently. This may take extra time and is not generally recommended.
137   ICONPUTA_OnlyUpdatePosition    = ICONA_Dummy + 72; // Don't write the entire icon file back to disk, only change the do^.do_CurrentX/do^.do_CurrentY members.
138   ICONPUTA_PreserveOldIconImages = ICONA_Dummy + 84; // Before writing a palette mapped icon back to disk, icon.library will make sure that the original
139                                                      // planar image data is stored in the file. If you don't want that to happen, set this option to
140                                                      // FALSE. This will allow you to change the planar icon image data written back to disk.
141   ICONPUTA_FileFormat            = ICONA_Dummy + 107; // Tell icon.library what file format the icon should be saved in, by passing the name of a file format which is supported by some external icon saver module.
142   ICONPUTA_NoFallback            = ICONA_Dummy + 108; // Tell icon.library to fail if the icon cannot be saved in the requested file format, rather than falling back to saving it in native Amiga format.
143 
144 // For use with the file identification hook.
145 type
146   PIconIdentifyMsg = ^TIconIdentifyMsg;
147   TIconIdentifyMsg = record
148     // Libraries that are already opened for your use.
149     iim_SysBase : PLibrary;
150     iim_DOSBase : PLibrary;
151     iim_UtilityBase : PLibrary;
152     iim_IconBase : PLibrary;
153     // File context information.
154     iim_FileLock : BPTR;     // Lock on the object to return an icon for.
155     iim_ParentLock : BPTR;   // Lock on the object's parent directory, if available.
156     iim_FIB : PFileInfoBlock;// Already initialized for you.
157     iim_FileHandle : BPTR;   // If non-nil, pointer to the file to examine, positioned right at the first byte, ready for you to use.
158     iim_Tags : PTagItem;     // Tags passed to GetIconTagList().
159     iim_IExec: PInterface;
160     iim_IDOS: PInterface;
161     iim_IUtility: PInterface;
162     iim_IIcon: PInterface;
163   end;
164 
165 // Tags for use with DupDiskObjectA()
166 const
167   ICONDUPA_DuplicateDrawerData  = ICONA_Dummy + 60; // Duplicate do_DrawerData
168   ICONDUPA_DuplicateImages      = ICONA_Dummy + 61; // Duplicate the Image structures.
169   ICONDUPA_DuplicateImageData   = ICONA_Dummy + 62; // Duplicate the image data (Image->ImageData) itself.
170   ICONDUPA_DuplicateDefaultTool = ICONA_Dummy + 63; // Duplicate the default tool.
171   ICONDUPA_DuplicateToolTypes   = ICONA_Dummy + 64; // Duplicate the tool types list.
172   ICONDUPA_DuplicateToolWindow  = ICONA_Dummy + 65; // Duplicate the tool window.
173   ICONDUPA_ActivateImageData    = ICONA_Dummy + 82; // If the icon to be duplicated is in fact a palette mapped icon which has never been
174                                                     // set up to be displayed on the   screen, turn the duplicate into that palette mapped icon.
175   ICONDUPA_UseFriendBitMap      = ICONGETA_UseFriendBitMap; // Alias for ICONGETA_UseFriendBitMap (BOOL). (V50)
176   ICONDUPA_DuplicateScaledSizes = ICONA_Dummy + 119; // Duplicate any scaled versions of the icon's imagery (BOOL). (V51)
177   ICONDUPA_Width                = ICONGETA_Width;    // Request a specific size for the icon to be duplicated.
178   ICONDUPA_Height               = ICONGETA_Height;
179   ICONDUPA_ForceScaling         = ICONGETA_ForceScaling; // Tell icon.library to perform a manual bitmap rescaling of the duplicate icon
180   ICONDUPA_SizeBounds           = ICONGETA_SizeBounds; // Specify the size limits for the icon to be duplicated.
181   ICONDUPA_AllowUpscaling       = ICONGETA_AllowUpscaling; // Tell icon.library to enforce the minimum size specified with ICONDUPA_SizeBounds
182 
183 // Tags for use with DrawIconStateA() and GetIconRectangleA().
184   ICONDRAWA_DrawInfo        = ICONA_Dummy + 66; // Drawing information to use (PDrawInfo).
185   ICONDRAWA_Frameless       = ICONA_Dummy + 70; // Draw the icon without the surrounding frame (BOOL).
186   ICONDRAWA_EraseBackground = ICONA_Dummy + 71; // Erase the background before drawing a frameless icon (BOOL).
187   ICONDRAWA_Borderless      = ICONA_Dummy + 83; // Draw the icon without the surrounding border and frame (BOOL).
188   ICONDRAWA_IsLink               = ICONA_Dummy + 89;  // The icon to be drawn refers to a linked object (BOOL). */
189   ICONDRAWA_LabelShadow          = ICONA_Dummy + 93;  // Draw the icon label with shadow (BOOL). (V50) */
190   ICONDRAWA_LabelOutline         = ICONA_Dummy + 94;  // Draw the icon label with outline (BOOL). (V50) */
191   ICONDRAWA_Properties           = ICONA_Dummy + 95;  // Special properties of the icon to be drawn (ULONG). (V51) */
192   ICONDRAWA_DrawIcon             = ICONA_Dummy + 98;  // Draw the actual icon image. Defaults to TRUE (BOOL). (V51) */
193   ICONDRAWA_EraseLabelBackground = ICONA_Dummy + 101; // Erase the background before drawing an icon label (BOOL). (V51) */
194   ICONDRAWA_Transparency         = ICONA_Dummy + 102; // Override the transparency value which is used for drawing the icon image in range from 0 to 255 (opaque) (LONG). (V51)
195   ICONDRAWA_Width                = ICONGETA_Width;  // Specify a size for the icon to be drawn.
196   ICONDRAWA_Height               = ICONGETA_Height;
197   ICONDRAWA_SizeBounds           = ICONGETA_SizeBounds; // Specify the size limits for the icon to be drawn.
198   ICONDRAWA_AllowUpscaling       = ICONGETA_AllowUpscaling; // Tell icon.library to enforce the minimum size specified with ICONDRAWA_SizeBounds
199   ICONDRAWA_Borders              = ICONA_Dummy + 125; // Specify the size of the (possibly invisible) borders around the icon to be drawn
200 // Property flags for ICONDRAWA_Properties
201   ICON_DRAGGED   = $00000001; // Icon is being dragged
202   ICON_DROPPABLE = $00000002; // Icon is over a drop area
203   ICON_LEFTOUT   = $00000004; // Icon has been "left out"
204   ICON_POINTED   = $00000008; // Icon is under mouse pointer
205 // Reserved tags; don't use!
206   ICONA_Reserved1   = ICONA_Dummy + 73;
207   ICONA_Reserved2   = ICONA_Dummy + 74;
208   ICONA_Reserved3   = ICONA_Dummy + 76;
209   ICONA_Reserved4   = ICONA_Dummy + 81;
210   ICONA_Reserved5   = ICONA_Dummy + 85;
211   ICONA_Reserved6   = ICONA_Dummy + 86;
212   ICONA_Reserved7   = ICONA_Dummy + 87;
213   ICONA_Reserved8   = ICONA_Dummy + 88;
214   ICONA_Reserved9   = ICONA_Dummy + 99;
215   ICONA_Reserved10  = ICONA_Dummy + 100;
216   ICONA_Reserved11  = ICONA_Dummy + 109;
217   ICONA_Reserved12  = ICONA_Dummy + 110;
218   ICONA_Reserved13  = ICONA_Dummy + 121;
219 
220   ICONA_LAST_TAG    = ICONA_Dummy + 126;
221 
222 var
223   IconBase: PLibrary;
224   IIcon: PInterface;
225 
226 function IcontObtain(): LongWord; syscall IIcon 60;
227 function IconRelease(): LongWord; syscall IIcon 64;
228 procedure IconExpunge(); syscall IIcon 68;
229 function IconClone(): PInterface; syscall IIcon 72;
230 // 76-88 private
231 procedure FreeFreeList(FreeList: PFreeList); syscall IIcon 92;
232 // 92-96 private
233 function AddFreeList(FreeList: PFreeList; const Mem: APTR; Size: LongWord): LongBool; syscall IIcon 104;
234 function GetDiskObject(const Name: STRPTR): PDiskObject; syscall IIcon 108;
235 function PutDiskObject(const Name: STRPTR; const Icon: PDiskObject): LongBool; syscall IIcon 112;
236 procedure FreeDiskObject(DiskObj: PDiskObject); syscall IIcon 116;
237 function FindToolType(const ToolTypeArray: PPChar; const TypeName: STRPTR): STRPTR; syscall IIcon 120;
238 function MatchToolValue(const TypeString: STRPTR; const Value: STRPTR): BOOL; syscall IIcon 124;
239 function BumpRevision(NewName: PChar; const OldName: PChar): PChar; syscall IIcon 128;
240 function FreeAlloc(FreeList: PFreeList; Len, Type_: LongWord): APTR; syscall IIcon 132;
241 function GetDefDiskObject(Typ: LongInt): PDiskObject; syscall IIcon 136;
242 function PutDefDiskObject(const Icon: PDiskObject): LongBool; syscall IIcon 140;
243 function GetDiskObjectNew(const Name: STRPTR): PDiskObject; syscall IIcon 144;
244 function DeleteDiskObject(const Name: STRPTR): LongBool; syscall IIcon 148;
245 function FreeFree(FreeList: PFreeList; Address: APTR): LongBool; syscall IIcon 152;
246 function DupDiskObjectA(const DiskObject: PDiskObject; const Tags: PTagItem): PDiskObject; syscall IIcon 156;
247 // 160 DupDiskObject
248 function IconControlA(Icon: PDiskObject; const Tags: PTagItem): LongWord; syscall IIcon 164;
249 // 168 IconControl
250 procedure DrawIconStateA(Rp: PRastPort; const Icon: PDiskObject; const Label_: STRPTR; LeftOffset, TopOffset: LongInt; State: LongWord; const Tags: PTagItem); syscall IIcon 172;
251 // 176 DrawIconState
252 function GetIconRectangleA(Rp: PRastPort; const Icon: PDiskObject; const Label_: STRPTR; Rect: PRectangle; const Tags: PTagItem): LongBool; syscall IIcon 180;
253 // 184 GetIconRectangle
254 function NewDiskObject(Type_: LongWord): PDiskObject; syscall IIcon 188;
255 function GetIconTagList(const Name: STRPTR; const Tags: PTagItem): PDiskObject; syscall IIcon 192;
256 // 196 GetIconTags
257 function PutIconTagList(const Name: STRPTR; const Icon: PDiskObject; const Tags: PTagItem): LongBool; syscall IIcon 200;
258 // 204 PutIconTags
259 function LayoutIconA(Icon: PDiskObject; Screen: PScreen; Tags: PTagItem): LongBool; syscall IIcon 208;
260 // 212 LayoutIcon
261 procedure ChangeToSelectedIconColor(Cr: Pointer); syscall IIcon 216; //TODO: PColorRegister
262 function BumpRevisionLength(NewName: STRPTR; const OldName: STRPTR; MaxLength: LongWord): STRPTR; syscall IIcon 220;
263 
264 {macros}
265 function PACK_ICON_ASPECT_RATIO(Num, Den: LongInt): LongInt;
266 procedure UNPACK_ICON_ASPECT_RATIO(Aspect: LongInt; var Num, Den: LongInt);
267 
268 type
269   TToolTypeArray= array of AnsiString;
270 
271 function GetToolTypes(Filename: AnsiString): TToolTypeArray;
272 
273 
274 implementation
275 
276 function GetToolTypes(Filename: AnsiString): TToolTypeArray;
277 var
278   DObj: PDiskObject;
279   Tooltype: PPChar;
280   Idx: Integer;
281 begin
282   SetLength(GetToolTypes, 0);
283   DObj := GetDiskObject(PChar(FileName));
284   if not Assigned(Dobj) then
285     Exit;
286   Tooltype := DObj^.do_Tooltypes;
287   while Assigned(ToolType^) do
288   begin
289     Idx := Length(GetToolTypes);
290     SetLength(GetToolTypes, Idx + 1);
291     GetToolTypes[Idx] := ToolType^;
292     Inc(ToolType);
293   end;
294   FreeDiskObject(DObj);
295 end;
296 
297 function PACK_ICON_ASPECT_RATIO(Num, Den: LongInt): LongInt; inline;
298 begin
299   PACK_ICON_ASPECT_RATIO := (Num shl 4) or Den;
300 end;
301 
302 procedure UNPACK_ICON_ASPECT_RATIO(Aspect: LongInt; var Num, Den: LongInt); inline;
303 begin
304   Num := (Aspect shr 4) and $F;
305   Den := Aspect and $15;
306 end;
307 
308 initialization
309   IconBase := OpenLibrary(ICONNAME, 40);
310   if Assigned(IconBase) then
311     IIcon := GetInterface(IconBase, 'main', 1, nil);
312 finalization
313   if Assigned(IIcon) then
314     DropInterface(IIcon);
315   if Assigned(IconBase) then
316   CloseLibrary(IconBase);
317 end.
318 
319 
320 
321 
322