|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#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 |
| #define __NOLIBBASE__ |
| #define DO_FREELIST | ( | dob | ) |
| #define ICON_BASE_NAME iconlibbase |
| #define RENDER_IMAGE offsetof(struct DiskObject, do_Gadget.GadgetRender) |
| #define RENDER_SELECT offsetof(struct DiskObject, do_Gadget.SelectRender) |
| #define TOK_makecookie ((LIB_shapeslib << 7) + 2) |
| 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.
| BB_BOOL c_Close_icon | ( | void | ) |
FreeIconObject: frees the open icon (FreeDiskObject) and its tool type array.
| 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).
| tool | d0: the default tool |
| lens | a2: the argument stack (lens[-1] = the length of tool$) |
| 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).
| name | d0: the file name (without .info) |
| 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).
| n | d0: the number |
| 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.
| name | d0: the tool type's name |
| lens | a2: the argument stack (lens[-1] = the length of name) |
| 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.
| shapearg | d0: the shape's offset (shape# << 5) |
| shape | a0: the shape object (ia0|pd0) Returns nothing (nothing happens without an icon or image). |
| 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).
| shapearg | d0: the first shape's offset (shape# << 5) |
| shapearg2 | d1: the second shape's offset |
| shape | a0: the shape for the image (ia0|pd0) |
| shape2 | a1: the shape for the selected image (ia1|pd1) |
| 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.
| type | d0: the type |
| 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$)".
| name | d0: the tool type's name |
| 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 "(".
| name | d0: the tool type's name |
|
static |
finit: frees the open icon, closes icon.library.
|
static |
init: opens icon.library (any version).
Without it (iconlibbase 0) the commands do nothing and return 0.
| BB_BOOL c_Matchtoolvalue | ( | CONST_STRPTR | name, |
| CONST_STRPTR | value ) |
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).
| name | d0: the tool type's name |
| value | d1: the value |
| status | d2: BB_FALSE for the switched-off form "(tt$=value$)" |
| lens | a2: the argument stack (the lengths of name and value) |
| BB_BOOL c_NewTool2 | ( | const char * | name, |
| const char * | value, | ||
| const ULONG * | lens ) |
| 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).
| BB_BOOL c_Put_icon2 | ( | CONST_STRPTR | name | ) |
PutIconObject(filename$): as PutIconObject with the icon type unchanged.
| name | d0: the file name |
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
| name | d0: the tool type's name |
| value | d1: the value |
| status | d2: BB_FALSE for the switched-off form |
| lens | a2: the argument stack (the lengths of name and value) |
| BB_BOOL c_PutTool2 | ( | const char * | name, |
| const char * | value, | ||
| const ULONG * | lens ) |
| void c_selectrender | ( | UWORD | flags | ) |
IconRender render_flags: the flags of the icon's gadget.
| flags | d0: the gadget flags (a word) Returns nothing (nothing happens without an icon). |
| void c_seticonhit | ( | UWORD | w, |
| UWORD | h ) |
| 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).
| shape | a0: the shape object (ia0|pd0) Returns nothing (nothing happens without an icon). |
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.
| shape | a0: the shape for the image (ia0|pd0) |
| shape2 | a1: the shape for the selected image (ia1|pd1) Returns nothing (nothing happens without an icon). |
| void cleartooltypes | ( | void | ) |
| void Close_icon | ( | void | ) |
| void defaulttool | ( | void | ) |
|
static |
|
static |
|
static |
| void getstructure | ( | void | ) |
| void gettoolnumber | ( | void | ) |
| void gettooltype | ( | void | ) |
|
static |
|
static |
|
static |
| void icontoshape | ( | void | ) |
| void icontoshape2 | ( | void | ) |
|
static |
| void icontype | ( | void | ) |
| void istooltype | ( | void | ) |
| void istooltype2 | ( | void | ) |
| void Matchtoolvalue | ( | void | ) |
| void NewTool | ( | void | ) |
| void NewTool2 | ( | void | ) |
|
static |
| void Put_icon | ( | void | ) |
| void Put_icon2 | ( | void | ) |
| void PutTool | ( | void | ) |
| void PutTool2 | ( | void | ) |
| void ritooltypeslib_libfinit | ( | void | ) |
| void ritooltypeslib_libinit | ( | void | ) |
| void selectrender | ( | void | ) |
| void seticonhit | ( | void | ) |
| void shapetoicon | ( | void | ) |
| void shapetoicon2 | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |