BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
ritooltypeslib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"
#include "blitzexec.h"
#include <proto/icon.h>
#include <workbench/workbench.h>
#include <intuition/intuition.h>
#include <stddef.h>

Data Structures

struct  diskobjfree

Macros

#define __NOLIBBASE__
#define ICON_BASE_NAME   iconlibbase
#define TOK_makecookie   ((LIB_shapeslib << 7) + 2)
#define DO_FREELIST(dob)
#define RENDER_IMAGE   offsetof(struct DiskObject, do_Gadget.GadgetRender)
#define RENDER_SELECT   offsetof(struct DiskObject, do_Gadget.SelectRender)

Functions

void ritooltypeslib_libinit (void)
void ritooltypeslib_libfinit (void)
void getstructure (void)
void gettooltype (void)
void PutTool2 (void)
void PutTool (void)
void Put_icon2 (void)
void Put_icon (void)
void Close_icon (void)
void Matchtoolvalue (void)
void NewTool2 (void)
void NewTool (void)
void gettoolnumber (void)
void cleartooltypes (void)
void seticonhit (void)
void shapetoicon (void)
void shapetoicon2 (void)
void icontype (void)
void selectrender (void)
void defaulttool (void)
void istooltype (void)
void istooltype2 (void)
void icontoshape (void)
void icontoshape2 (void)
static ULONG globalloc (ULONG size, ULONG flags)
static void globfree (ULONG mem, ULONG size)
static void c_libinit (void)
 init: opens icon.library (any version).
static STRPTR * newtooltypes (ULONG n)
static void freetooltypes (void)
BB_BOOL c_Close_icon (void)
 FreeIconObject: frees the open icon (FreeDiskObject) and its tool type array.
static void c_libfinit (void)
 finit: frees the open icon, closes icon.library.
ULONG c_getstructure (CONST_STRPTR name)
 GetIconObject(filename$): opens the icon of a file.
void c_cleartooltypes (void)
 ClearToolTypes: removes all tool types of the open icon.
ULONG c_gettoolnumber (ULONG n)
 FindToolNumber(tooltype#): the tool type of that number (0 = the first).
static ULONG findtooltype (CONST_STRPTR name, BOOL bracket)
ULONG c_istooltype (CONST_STRPTR name)
 FindToolType(tooltype$): whether the icon has the tool type.
ULONG c_istooltype2 (CONST_STRPTR name)
 FindToolType(tooltype$,bracket_check): as FindToolType(tt$), with the bracket check.
ULONG c_gettooltype (CONST_STRPTR name, const ULONG *lens)
 FindToolValue(tooltype$): the value of a tool type.
BB_BOOL c_Matchtoolvalue (CONST_STRPTR name, CONST_STRPTR value)
 MatchToolValue(tooltype$,value$): whether the tool type has the value.
BB_BOOL c_Put_icon (CONST_STRPTR name, ULONG type)
 PutIconObject(filename$,icontype): writes the open icon and closes it.
BB_BOOL c_Put_icon2 (CONST_STRPTR name)
 PutIconObject(filename$): as PutIconObject with the icon type unchanged.
static int stringcompare (const UBYTE *name, const UBYTE *entry)
static BB_BOOL gotit (STRPTR *entry)
static void toolargs (const char *name, const char *value, BB_BOOL status, const ULONG *lens)
BB_BOOL c_PutTool (const char *name, const char *value, BB_BOOL status, const ULONG *lens)
 SetToolValue(tooltype$,value$,status): replaces a tool type.
BB_BOOL c_PutTool2 (const char *name, const char *value, const ULONG *lens)
 SetToolValue(tooltype$,value$): as SetToolValue with status -1.
BB_BOOL c_NewTool (const char *name, const char *value, BB_BOOL status, const ULONG *lens)
 NewToolType(tooltype$,value$,status): appends a tool type.
BB_BOOL c_NewTool2 (const char *name, const char *value, const ULONG *lens)
 NewToolType(tooltype$,value$): as NewToolType with status -1.
void c_seticonhit (UWORD w, UWORD h)
 SetIconHit width,height: the size of the icon's gadget (the hit box).
void c_shapetoicon (const struct bb_shape *shape)
 ShapeToIcon shape: the icon's image from a shape.
void c_shapetoicon2 (const struct bb_shape *shape, const struct bb_shape *shape2)
 ShapeToIcon shape,shape: the icon's image and selected image from two shapes.
ULONG c_icontype (ULONG type)
 SetIconType object_type: the icon's type (do_Type, 1-5).
void c_selectrender (UWORD flags)
 IconRender render_flags: the flags of the icon's gadget.
BB_BOOL c_defaulttool (const char *tool, const ULONG *lens)
 IconDefTool tool$: the icon's default tool.
static void freeashape (struct bb_shape *s)
static void icontoshape_jump (ULONG shapearg, struct bb_shape *shape, UWORD render, UBYTE **cookiestr)
void c_icontoshape (ULONG shapearg, struct bb_shape *shape)
 IconToShape shape: the icon's image (GadgetRender) as a shape.
void c_icontoshape2 (ULONG shapearg, ULONG shapearg2, struct bb_shape *shape, struct bb_shape *shape2)
 IconToShape shape,shape: the image and the selected image as two shapes.

Variables

static struct Library * iconlibbase
static struct DiskObject * diskobject
static STRPTR * tooltype
static ULONG ttcap
static ULONG toolbuffersize
static BB_BOOL status_tool
static STRPTR * array_address
static const char * tooltype_address
static const char * string_address
static UWORD shapenumber
static struct Image SelectRender

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ DO_FREELIST

#define DO_FREELIST ( dob)
Value:
(&((struct diskobjfree *)(dob))->freelist)
Definition ritooltypeslib.c:281

◆ ICON_BASE_NAME

#define ICON_BASE_NAME   iconlibbase

◆ RENDER_IMAGE

#define RENDER_IMAGE   offsetof(struct DiskObject, do_Gadget.GadgetRender)

◆ RENDER_SELECT

#define RENDER_SELECT   offsetof(struct DiskObject, do_Gadget.SelectRender)

◆ TOK_makecookie

#define TOK_makecookie   ((LIB_shapeslib << 7) + 2)

Function Documentation

◆ c_cleartooltypes()

void c_cleartooltypes ( void )

ClearToolTypes: removes all tool types of the open icon.

Clears the entries of the array up to the first empty one; nothing without an icon.

◆ c_Close_icon()

BB_BOOL c_Close_icon ( void )

FreeIconObject: frees the open icon (FreeDiskObject) and its tool type array.

Returns
d0: BB_TRUE if an icon was open, BB_FALSE otherwise or without icon.library

◆ c_defaulttool()

BB_BOOL c_defaulttool ( const char * tool,
const ULONG * lens )

IconDefTool tool$: the icon's default tool.

A copy of tool$ (AllocMem, on the icon's FreeList) becomes do_DefaultTool. a3 is rewound by the length + 1 and stays there: no defect, it gives back the space of the string argument, which the compiler does not take back after a library function with a numeric result (#846, closed; without it "ab"+Str$(IconDefTool("tool"))+"cd" gives "abtool" instead of "ab-1cd"). A failing AddFreeList frees the block (fixed #840: the original freed address 0).

Parameters
toold0: the default tool
lensa2: the argument stack (lens[-1] = the length of tool$)
Returns
d0: BB_TRUE done, BB_FALSE for an empty string, no memory or no icon

◆ c_getstructure()

ULONG c_getstructure ( CONST_STRPTR name)

GetIconObject(filename$): opens the icon of a file.

GetDiskObjectNew from icon.library V36 on, GetDiskObject below (fixed, #1149: the original called GetDiskObjectNew there too, behind the jump table of Workbench 1.x's icon.library V34, a crash); GetDiskObjectNew gives a default icon for a file without one, GetDiskObject 0. The icon's tool types are copied into the library's array (allocated for their count and the terminator), which becomes the icon's do_ToolTypes. Fixed (#855): the original's array had 100 entries and the copy no limit. BUG(orig) (#845), wontfix: an icon without tool types is read from address 0 (not observable, the long at 0 is 0).

Parameters
named0: the file name (without .info)
Returns
d0: the DiskObject, 0 if an icon is open already, there is none, no memory for the array or no icon.library

◆ c_gettoolnumber()

ULONG c_gettoolnumber ( ULONG n)

FindToolNumber(tooltype#): the tool type of that number (0 = the first).

Copied to a3 without a terminating 0 (string results need none: no defect, #257).

Parameters
nd0: the number
Returns
d0: the length of the string, 0 if there is no such entry or no icon

◆ c_gettooltype()

ULONG c_gettooltype ( CONST_STRPTR name,
const ULONG * lens )

FindToolValue(tooltype$): the value of a tool type.

The value after "=" (icon.library FindToolType), written over the argument at a3 (a3 - length - 1), without a 0; for a name beginning with "(" (a switched-off entry "(name=value)") without its last ")". Fixed (#844): the original stopped at every ")", also inside the value.

Parameters
named0: the tool type's name
lensa2: the argument stack (lens[-1] = the length of name)
Returns
d0: the length of the value, 0 if not found or no icon

◆ c_icontoshape()

void c_icontoshape ( ULONG shapearg,
struct bb_shape * shape )

IconToShape shape: the icon's image (GadgetRender) as a shape.

A shape in use is freed first; the data is allocated with memlib globalloc (CHIP) and copied from the Image, the cookie made with shapeslib's MakeCookie. BUG(orig): the shape is filled before the data is allocated (#848, not a bug in practice). MakeCookie gets the caller's a3 unless the shape was in use; not a defect in compiled programs, the ALibJsr stub sets a3 = Shape(d0) (#849). The copy takes the words of the allocation (fixed #847: the original took one word per row more for a width that is a multiple of 16). DIFF: a3 kept.

Parameters
shapeargd0: the shape's offset (shape# << 5)
shapea0: the shape object (ia0|pd0) Returns nothing (nothing happens without an icon or image).

◆ c_icontoshape2()

void c_icontoshape2 ( ULONG shapearg,
ULONG shapearg2,
struct bb_shape * shape,
struct bb_shape * shape2 )

IconToShape shape,shape: the image and the selected image as two shapes.

As IconToShape shape for each; MakeCookie for the second shape gets a3 still on the first: not a defect in compiled programs, the ALibJsr stub sets a3 = Shape(d0) (#849).

Parameters
shapeargd0: the first shape's offset (shape# << 5)
shapearg2d1: the second shape's offset
shapea0: the shape for the image (ia0|pd0)
shape2a1: the shape for the selected image (ia1|pd1)

◆ c_icontype()

ULONG c_icontype ( ULONG type)

SetIconType object_type: the icon's type (do_Type, 1-5).

Fixed (#852): without an icon the original returned the argument.

Parameters
typed0: the type
Returns
d0: -1 done, 0 for a type outside 1-5 or without an icon

◆ c_istooltype()

ULONG c_istooltype ( CONST_STRPTR name)

FindToolType(tooltype$): whether the icon has the tool type.

icon.library FindToolType, without the bracket search. Fixed (#843): the original kept the bracket check in a flag that FindToolType tt$,1 set and only the end of the bracket search cleared, so after such a call that returned earlier this form also searched "(tt$)".

Parameters
named0: the tool type's name
Returns
d0: -1 found, 0 not found or no icon

◆ c_istooltype2()

ULONG c_istooltype2 ( CONST_STRPTR name)

FindToolType(tooltype$,bracket_check): as FindToolType(tt$), with the bracket check.

Also looks for the switched-off form "(tt$)" (for any bracket_check value, as in the original), unless tt$ begins with "(".

Parameters
named0: the tool type's name
Returns
d0: -1 found, 1 found as "(tt$)" (no defect: it tells the two apart), 0 not found or no icon

◆ c_libfinit()

void c_libfinit ( void )
static

finit: frees the open icon, closes icon.library.

◆ c_libinit()

void c_libinit ( void )
static

init: opens icon.library (any version).

Without it (iconlibbase 0) the commands do nothing and return 0.

◆ c_Matchtoolvalue()

BB_BOOL c_Matchtoolvalue ( CONST_STRPTR name,
CONST_STRPTR value )

MatchToolValue(tooltype$,value$): whether the tool type has the value.

icon.library FindToolType, then MatchToolValue.

Parameters
named0: the tool type's name
valued1: the value
Returns
d0: BB_TRUE if it matches, BB_FALSE otherwise or no icon

◆ c_NewTool()

BB_BOOL c_NewTool ( const char * name,
const char * value,
BB_BOOL status,
const ULONG * lens )

NewToolType(tooltype$,value$,status): appends a tool type.

A new entry at the end, built as by SetToolValue. A full array is replaced by one of twice the size (fixed #855: the original's array had 100 entries and NewToolType no limit).

Parameters
named0: the tool type's name
valued1: the value
statusd2: BB_FALSE for the switched-off form "(tt$=value$)"
lensa2: the argument stack (the lengths of name and value)
Returns
d0: BB_TRUE done, BB_FALSE no memory (nothing changed) or no icon

◆ c_NewTool2()

BB_BOOL c_NewTool2 ( const char * name,
const char * value,
const ULONG * lens )

NewToolType(tooltype$,value$): as NewToolType with status -1.

Parameters
named0: the tool type's name
valued1: the value
lensa2: the argument stack
Returns
d0: BB_TRUE done, BB_FALSE otherwise

◆ c_Put_icon()

BB_BOOL c_Put_icon ( CONST_STRPTR name,
ULONG type )

PutIconObject(filename$,icontype): writes the open icon and closes it.

A non-zero icontype (its low byte) becomes do_Type; PutDiskObject. If that fails, the icon stays open (it can be written again or freed with FreeIconObject) and the result is 0 (fixed #851, the user's decision of 2026-11-17: the original returned -1 and closed it). A written icon is freed as by FreeIconObject (fixed #850: the original forgot it without FreeDiskObject).

Parameters
named0: the file name
typed1: the icon type (0: unchanged)
Returns
d0: BB_TRUE written, BB_FALSE writing failed or no icon

◆ c_Put_icon2()

BB_BOOL c_Put_icon2 ( CONST_STRPTR name)

PutIconObject(filename$): as PutIconObject with the icon type unchanged.

Parameters
named0: the file name
Returns
d0: BB_TRUE written, BB_FALSE writing failed or no icon

◆ c_PutTool()

BB_BOOL c_PutTool ( const char * name,
const char * value,
BB_BOOL status,
const ULONG * lens )

SetToolValue(tooltype$,value$,status): replaces a tool type.

The first entry of tt$ (tt$ case insensitive for a-z, then the end, "=" or ")"; its own "(" skipped: "OFF" also replaces "(OFF)=1", no defect) becomes "tt$=value$" (no "=" for an empty value), "(tt$=value$)" with status 0; the string is allocated (length of both

  • 8) and hung on the icon's FreeList. Fixed (#853): the original took the first entry that only began with tt$ ("FL" replaced "FLAG"). An empty name gives "=value$" (fixed #841). A failing AddFreeList frees the block (fixed #840: the original freed address 0).
    Parameters
    named0: the tool type's name
    valued1: the value
    statusd2: BB_FALSE for the switched-off form
    lensa2: the argument stack (the lengths of name and value)
    Returns
    d0: BB_TRUE done, BB_FALSE no such entry, no memory or no icon

◆ c_PutTool2()

BB_BOOL c_PutTool2 ( const char * name,
const char * value,
const ULONG * lens )

SetToolValue(tooltype$,value$): as SetToolValue with status -1.

Parameters
named0: the tool type's name
valued1: the value
lensa2: the argument stack
Returns
d0: BB_TRUE done, BB_FALSE otherwise

◆ c_selectrender()

void c_selectrender ( UWORD flags)

IconRender render_flags: the flags of the icon's gadget.

Parameters
flagsd0: the gadget flags (a word) Returns nothing (nothing happens without an icon).

◆ c_seticonhit()

void c_seticonhit ( UWORD w,
UWORD h )

SetIconHit width,height: the size of the icon's gadget (the hit box).

Parameters
wd0: the width
hd1: the height Returns nothing (nothing happens without an icon).

◆ c_shapetoicon()

void c_shapetoicon ( const struct bb_shape * shape)

ShapeToIcon shape: the icon's image from a shape.

The gadget gets the shape's width and height + 1, its GadgetRender Image the shape's width, height, depth and data, and picks the shape's planes (PlanePick (1 << depth) - 1, PlaneOnOff 0; fixed #1083: the original kept the icon's PlanePick and PlaneOnOff).

Parameters
shapea0: the shape object (ia0|pd0) Returns nothing (nothing happens without an icon).

◆ c_shapetoicon2()

void c_shapetoicon2 ( const struct bb_shape * shape,
const struct bb_shape * shape2 )

ShapeToIcon shape,shape: the icon's image and selected image from two shapes.

The second shape goes into the library's own Image (SelectRender), then as ShapeToIcon shape. That Image picks the shape's planes (PlanePick (1 << depth) - 1, PlaneOnOff 0; fixed #854: the original left both 0). The gadget flags become 6 (GADGHIMAGE), all others dropped: documented (RIToolTypesLib.guide, IconRender), no defect. DIFF: a3 unchanged.

Parameters
shapea0: the shape for the image (ia0|pd0)
shape2a1: the shape for the selected image (ia1|pd1) Returns nothing (nothing happens without an icon).

◆ cleartooltypes()

void cleartooltypes ( void )

◆ Close_icon()

void Close_icon ( void )

◆ defaulttool()

void defaulttool ( void )

◆ findtooltype()

ULONG findtooltype ( CONST_STRPTR name,
BOOL bracket )
static

◆ freeashape()

void freeashape ( struct bb_shape * s)
static

◆ freetooltypes()

void freetooltypes ( void )
static

◆ getstructure()

void getstructure ( void )

◆ gettoolnumber()

void gettoolnumber ( void )

◆ gettooltype()

void gettooltype ( void )

◆ globalloc()

ULONG globalloc ( ULONG size,
ULONG flags )
static

◆ globfree()

void globfree ( ULONG mem,
ULONG size )
static

◆ gotit()

BB_BOOL gotit ( STRPTR * entry)
static

◆ icontoshape()

void icontoshape ( void )

◆ icontoshape2()

void icontoshape2 ( void )

◆ icontoshape_jump()

void icontoshape_jump ( ULONG shapearg,
struct bb_shape * shape,
UWORD render,
UBYTE ** cookiestr )
static

◆ icontype()

void icontype ( void )

◆ istooltype()

void istooltype ( void )

◆ istooltype2()

void istooltype2 ( void )

◆ Matchtoolvalue()

void Matchtoolvalue ( void )

◆ NewTool()

void NewTool ( void )

◆ NewTool2()

void NewTool2 ( void )

◆ newtooltypes()

STRPTR * newtooltypes ( ULONG n)
static

◆ Put_icon()

void Put_icon ( void )

◆ Put_icon2()

void Put_icon2 ( void )

◆ PutTool()

void PutTool ( void )

◆ PutTool2()

void PutTool2 ( void )

◆ ritooltypeslib_libfinit()

void ritooltypeslib_libfinit ( void )

◆ ritooltypeslib_libinit()

void ritooltypeslib_libinit ( void )

◆ selectrender()

void selectrender ( void )

◆ seticonhit()

void seticonhit ( void )

◆ shapetoicon()

void shapetoicon ( void )

◆ shapetoicon2()

void shapetoicon2 ( void )

◆ stringcompare()

int stringcompare ( const UBYTE * name,
const UBYTE * entry )
static

◆ toolargs()

void toolargs ( const char * name,
const char * value,
BB_BOOL status,
const ULONG * lens )
static

Variable Documentation

◆ array_address

STRPTR* array_address
static

◆ diskobject

struct DiskObject* diskobject
static

◆ iconlibbase

struct Library* iconlibbase
static

◆ SelectRender

struct Image SelectRender
static

◆ shapenumber

UWORD shapenumber
static

◆ status_tool

BB_BOOL status_tool
static

◆ string_address

const char* string_address
static

◆ toolbuffersize

ULONG toolbuffersize
static

◆ tooltype

STRPTR* tooltype
static

◆ tooltype_address

const char* tooltype_address
static

◆ ttcap

ULONG ttcap
static