Name
GetIconProperties -- retrieve properties from an icon (V4.5)
Synopsis
t = GetIconProperties(id)
type, tooltypes, deftool$ = GetIconProperties(file$)
Function
This function can be used to get the properties of an icon. This is mostly useful for Amiga icons because they contain metadata besides the image data, e.g. icon type, tooltypes, default tool, and so on.

There are two ways of using this function: You can either pass the identifier of an icon in the first parameter or the filename of an icon file. Passing a filename to GetIconProperties() is only supported on AmigaOS and compatibles, passing an icon identifier is supported on all platforms however.

If you choose to pass the identifier of an icon in the first parameter, GetIconProperties() will return a table that has the following fields initialized:

Type:
This tag will be set to the Amiga icon type of the icon. This will be one of the following constants:

#AMIGAICON_DISK:
An icon of a drive (e.g. RAM, HD, CD-ROM, etc.)

#AMIGAICON_DRAWER:
An icon of a drawer.

#AMIGAICON_TOOL:
An icon of a program

#AMIGAICON_PROJECT:
An icon of a project. A project is a data file that can be opened by an other program. The program that should be used to open the project will be passed in DefaultTool, e.g. SYS:Utilities/MultiView.

#AMIGAICON_GARBAGE:
A trashcan icon.

##AMIGAICON_DEVICE:
A device icon.

#AMIGAICON_KICKSTART:
A Kickstart icon.

(V9.0)

IconX:
The icon's x position relative to the top-left corner of the drawer it is stored in. (V9.0)

IconY:
The icon's y position relative to the top-left corner of the drawer it is stored in. (V9.0)

DrawerX:
In case Type is set to a container type like #AMIGAICON_DRAWER, this tag will be set to the x position of the new window that will be opened when double-clicking the icon. (V9.0)

DrawerY:
In case Type is set to a container type like #AMIGAICON_DRAWER, this tag will be set to the y position of the new window that will be opened when double-clicking the icon. (V9.0)

DrawerWidth:
In case Type is set to a container type like #AMIGAICON_DRAWER, this tag will be set to the width of the new window that will be opened when double-clicking the icon. (V9.0)

DrawerHeight:
In case Type is set to a container type like #AMIGAICON_DRAWER, this tag will be set to the height of the new window that will be opened when double-clicking the icon. (V9.0)

ViewAll:
In case Type is set to a container type like #AMIGAICON_DRAWER, this tag will be set to True if all files of the drawer should be shown instead of just the ones that have an icon. (V9.0)

StackSize:
In case Type is set to #AMIGAICON_TOOL or #AMIGAICON_PROJECT, the desired stack size for the program to be launched. (V9.0)

DefaultTool:
In case Type is set to #AMIGAICON_PROJECT, this will be set to a string containing name (and optionally path) of the program to open the file with. (V9.0)

ToolTypes:
If there are tooltypes in the icon, they will be returned in this tag. The ToolTypes tag will contain a table that contains a list of subtables, one subtable per tooltype entry. Each subtable will contain the following tags:

Key:
This tag contains the name of the tooltype.

Value:
This tag contains the tooltype's value.

Enabled:
This tag is a boolean that indicates whether or not the tooltype is enabled.

Alternatively, you can also get the tooltypes by using the RawToolTypes tag (see below).

(V9.0)

RawToolTypes:
If you don't want to use the ToolTypes tag for some reason, you can also use RawToolTypes to get them. In contrast to ToolTypes, the RawToolTypes tag doesn't divide tooltypes into their individual constituents (key, value, enabled flag). Instead, the RawToolTypes tag will just return the tooltypes as they are stored in the icon, i.e. without any additional processing. This makes it possible to get custom data stored in tooltypes as well. RawToolTypes will be set to a table that contains the tooltypes as strings. (V9.0)

Images:
This tag will be set to a table containing information about the individual images within the icon. The table will contain a subtable for each image in the icon. Each subtable will have the following fields:

Width:
Image width in pixels.

Height:
Image height in pixels.

Standard:
True if the image is the standard image, False otherwise.

Frames:
Number of image frames. This can be either 1 or 2. If it is 1, there is only a normal image, if it is 2, there is a selected state image as well.

(V9.0)

To set the properties of an icon, use the SetIconProperties() command.

Inputs
id
syntax 1: identifier of an icon to examine
file$
syntax 2: the icon to examine
Results
t
syntax 1: table containing icon properties
type
syntax 2: type of the icon; will be one of the constants from above
tooltypes
syntax 2: a table containing a list of all tooltypes; each list entry will have the fields Key, Value, and Enabled initialized
deftool$
syntax 2: the default tool set for this icon; only set for icons of type #AMIGAICON_PROJECT
Example
t = GetIconProperties(1)
For k = 0 To ListItems(t.ToolTypes) - 1
   DebugPrint("Item:", k, "Key:", t.ToolTypes[k].key,
       "Value:", t.ToolTypes[k].value,
       "Enabled:", t.ToolTypes[k].enabled)
Next
The code above gets the properties of icon 1 and then prints all information stored in its tooltypes.


type, tt, deftool$ = GetIconProperties("MyIcon.info")
For k = 0 To ListItems(tt) - 1
   DebugPrint("Item:", k, "Key:", tt[k].key, "Value:", tt[k].value,
              "Enabled:", tt[k].enabled)
Next
The code above gets the properties of the icon "MyIcon.info" and then prints all information stored in its tooltypes.

Show TOC