Skip to content

ritooltypeslib

This library reads and changes the icon (the .info file) of a file through the system’s icon.library: its tool types, its default tool, its type and its images. Without icon.library, every command does nothing and returns 0. All commands are Amiga mode only.

The library works on one icon at a time, not on numbered objects. GetIconObject loads the icon of a file, the other commands work on it, and PutIconObject writes it back, to the same file or another one; FreeIconObject drops it without writing. A second GetIconObject fails while an icon is loaded, also after a PutIconObject that could not write it.

Tool types are the lines of the form NAME=value or just NAME in the icon’s information window. A tool type in brackets, (NAME=value), is switched off: the system ignores it. Names are compared without regard to case, though they are usually written in capitals. An icon may have any number of tool types.

The commands ShapeToIcon and IconToShape exchange the icon’s images with the shape objects of Blitz Basic 2.

Reading a tool type and changing it:

If GetIconObject("myprog")
  NPrint "Window: ",FindToolValue("WINDOW")
  If FindToolType("DONOTWAIT") Then NPrint "DONOTWAIT is set"
  SetToolValue "WINDOW","CON:0/0/640/200"
  PutIconObject "myprog"
EndIf

The fixed bugs of the library are listed in Fixes in ritooltypeslib.

Based on the RI ToolTypes Lib guide by Reflective Images.

Library number 59.

Commands

ClearToolTypes

Removes all tool types of the loaded icon. Their memory is not freed until the icon is freed.

Statement. No help text.
No arguments.

FindToolNumber

The whole tool type at the position tooltype#, counted from 0, for example CLOCKX=157. An empty string if there is no tool type at that position or no icon is loaded.

Function, result $. Help text: (tooltype#)
Arguments: .l

FindToolType

Returns -1 if the loaded icon has the tool type tooltype$, and 0 if not or if no icon is loaded. With bracket_check, a switched-off (tooltype$) is also looked for, and found it returns 1.

Function, result .b. Help text: (tooltype$[,bracket_check])
2 forms:

  • $
  • $, .b

Any value of bracket_check switches the check on, also 0. It applies to that call only.

FindToolValue

The value of the tool type tooltype$, the part after the =. An empty string if the tool type is not found, has no value, or no icon is loaded.

Function, result $. Help text: (tooltype$)
Arguments: $

Use FindToolType to tell a tool type without a value from a missing one. A ) in the value is part of it; only for a name given with a ( in front, the ) that closes the switched-off tool type is left out.

FreeIconObject

Frees the loaded icon without writing it; all changes are lost. Returns -1, or 0 if no icon was loaded.

Statement or function, result .l. Help text: - free the disk object of a icon
No arguments.

GetIconObject

Loads the icon of the file filename$, given without .info, for the other commands of the library. Returns the address of the icon’s disk object, or 0 if it cannot be loaded or an icon is loaded already.

Statement or function, result .l. Help text: (filename$)
Arguments: $

The icon may have any number of tool types. Without memory for the library’s list of them, the result is 0.

From Kickstart 2.0 on, a file without an icon gets the system’s default icon for its kind. On Kickstart 1.x, which has no default icons, such a file gives 0.

IconDefTool

Sets the default tool of the loaded icon, the program that a project icon is opened with. Returns -1, or 0 if tool$ is empty, there is no memory or no icon is loaded.

Statement or function, result .l. Help text: tool$
Arguments: $

IconRender

Sets the render flags of the loaded icon, which tell Workbench how to show the icon when it is selected.

Statement. Help text: render_flags
Arguments: .l

The value is the flags word of the icon’s gadget. Its two lowest bits choose the highlight: 0 inverts the image, 1 draws a box around it, 2 shows the selected image and 3 does nothing; 4 is added when the icon has an image. So 4 is the usual value, and 6 an icon that changes to its selected image.

IconToShape

Copies the image of the loaded icon into a shape, and its selected image into a second shape. A shape that is in use is freed first. Nothing happens if no icon is loaded; if the icon has no such image, the shape is only freed.

Statement. Help text: shape[,shape]
2 forms:

  • .l
  • .l, .l

MatchToolValue

Returns -1 if the tool type tooltype$ has the value value$, and 0 if not, if the tool type is not found or no icon is loaded. A tool type can have several values separated by |, as in LANGUAGE=ENGLISH|FRENCH; each of them matches.

Function, result .l. Help text: (tooltype$,value$)
Arguments: $, $

NewToolType

Adds the tool type tooltype$=value$, or tooltype$ alone if value$ is empty, after the last one. With status 0 it is switched off, (tooltype$=value$). Returns -1, or 0 if there is no memory or no icon is loaded.

Statement or function, result .l. Help text: (tooltype$,value$[,status])
2 forms:

  • $, $
  • $, $, .l

The command does not check whether the tool type exists already. An empty name makes the tool type =value$.

PutIconObject

Writes the loaded icon as the icon of the file filename$ and drops it. Returns -1, or 0 if no icon is loaded or the icon cannot be written. With icontype, the icon’s type is set first (the values of SetIconType); 0 keeps it.

Statement or function, result .l. Help text: (filename$[,icontype])
2 forms:

  • $
  • $, .l

After PutIconObject, load the icon again to work on it. When the icon cannot be written, it stays loaded: write it again or drop it with FreeIconObject.

SetIconHit

Sets the size of the loaded icon’s hit box, the area that reacts to the mouse, in pixels.

Statement. Help text: width,height
Arguments: .w, .w

SetIconType

Sets the type of the loaded icon, 1 disk, 2 drawer, 3 tool, 4 project or 5 trashcan. Returns -1, or 0 for another value or without a loaded icon.

Statement or function, result .l. Help text: object_type
Arguments: .l

SetToolValue

Replaces the tool type tooltype$ by tooltype$=value$, or by tooltype$ alone if value$ is empty. Returns -1, or 0 if the tool type is not found, there is no memory, or no icon is loaded.

Statement or function, result .l. Help text: (tooltype$,value$[,status])
2 forms:

  • $, $
  • $, $, .l

With status 0, the new tool type is switched off: (tooltype$=value$). A switched-off tool type is found and replaced like the others. The memory of the old string is not freed until the icon is freed, so change tool types sparingly.

Only a tool type of the whole name is replaced: FL does not replace FLAG. An empty name makes the tool type =value$.

ShapeToIcon

Makes a shape the image of the loaded icon, and a second shape its selected image. The hit box becomes the size of the first shape, one pixel higher.

Statement. Help text: shape[,shape]
2 forms:

  • .l
  • .l, .l

The shape’s graphics are not copied: the icon uses the shape’s memory, so keep the shapes until the icon is written. The images show all bitplanes of their shapes.

With two shapes, the render flags of the icon become 6: the selected image is shown when the icon is selected (see IconRender).