using-toolbox-imagefilegadget
Skill4 starsChanged 7 months agoMITView on GitHub
Use when writing, reviewing, or debugging RISC OS Toolbox applications that use the ImageFileGadget object or its methods, including ImageFileGadget_SetValue, SetTransform, SetQuality, SetColourMap, SetScroll, GetBounds, and ImageFileGadget_MouseClick events.
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Use this skill when application code uses the Toolbox ImageFileGadget object to display image files in a Toolbox Window.
- Very specific: line 27
Call ImageFileGadget_SetValue with the filetype, data pointer, and data length.
- Very specific: line 92
If code needs the actual ImageFileRender register contract or transform block formats, read the riscos-output ImageFileRender reference.
- Very specific: line 131
Use *ImageFileRenderers to confirm that a renderer is registered for the filetype being supplied to ImageFileGadget_SetValue.
- Distinctive: line 134
If the image is blank, check:
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Toolbox ImageFileGadget
Use this skill when application code uses the Toolbox ImageFileGadget object to
display image files in a Toolbox Window. ImageFileGadget is a client of
ImageFileRender: the application supplies image file bytes and metadata, and
the gadget performs redraws by calling ImageFileRender_Render.
For direct image rendering or for implementing new filetype renderers, use the
riscos-output skill and read its references/imagefilerender.md reference.
New image file format support is registered with ImageFileRender, not with
ImageFileGadget. Once a renderer is registered for a filetype, ImageFileGadget
can render that filetype through its normal SetValue method.
Application Workflow
- Include the ImageFileGadget Toolbox headers and use a Toolbox resource which contains an ImageFileGadget component.
- Load the image file into memory and determine its RISC OS filetype, normally
from
(load_address >> 8) & &FFF. - Call
ImageFileGadget_SetValuewith the filetype, data pointer, and data length. - Optionally call
ImageFileGadget_SetIndex,SetQuality,SetColourMap,SetTransform, orSetScrollto configure how the image is displayed. - Register a Toolbox handler for
ImageFileGadget_MouseClickif the application needs image-coordinate mouse interaction.
Applications do not need to register the gadget type with the Toolbox Window object. That is internal module setup done by ImageFileGadget itself.
Template and Flags
The ImageFileGadget template extends a normal Toolbox GadgetHeader:
typedef struct {
GadgetHeader hdr;
int event;
unsigned int unused;
unsigned int background;
} ImageFileGadget;Useful gadget flags:
| Flag | Meaning |
ImageFileGadget_NoBorder | Disable the gadget border |
ImageFileGadget_ColourMapWhole | Apply colour mapping to the whole gadget area |
Public Methods
| Method | Purpose |
ImageFileGadget_SetValue(flags, window, component, filetype, data, length) | Set the image bytes and filetype |
ImageFileGadget_GetValue(flags, window, component, &filetype, &data, &length) | Read the current filetype, data pointer, and length |
ImageFileGadget_SetColour / GetColour | Set or read the background colour |
ImageFileGadget_SetState / GetState | Set or read gadget state bits |
ImageFileGadget_SetIndex / GetIndex | Select or read the image sequence number |
ImageFileGadget_SetQuality / GetQuality | Select or read the ImageFileRender quality level |
ImageFileGadget_SetColourMap | Supply a colour map descriptor |
ImageFileGadget_SetTransform | Set the ImageFileRender transform type and transform data |
ImageFileGadget_SetScroll / GetScroll | Set or read the scroll position |
ImageFileGadget_GetBounds | Read bounds for the current image and transform |
ImageFileGadget_DesktopColours is used with colour methods when the colour is
a desktop colour. ImageFileGadget_ImageCoords is used with scroll methods
when scroll positions are in image coordinates.
Transform and Display
ImageFileGadget_SetTransform uses the same transform types and data blocks as
ImageFileRender:
| Transform type | Data |
TRANSFORMTYPE_SIZE | 16-byte to-fit block: width, height, border, angle |
TRANSFORMTYPE_SCALE | Standard 16-byte scale block: xmult, ymult, xdiv, ydiv |
TRANSFORMTYPE_TRANSFORM | Six-word standard transform matrix |
The gadget computes display size with ImageFileRender_BBox, then redraws
inside Wimp redraw rectangles using ImageFileRender_Render. It normally uses
FLAG_IGNORE_DOCUMENT_OFFSET, optional FLAG_COLOURMAP, and
quality << FLAG_QUALITY_SHIFT.
If code needs the actual ImageFileRender register contract or transform block
formats, read the riscos-output ImageFileRender reference.
Mouse Events
Mouse events are raised as ImageFileGadget_MouseClick. The event block is:
typedef struct {
ToolboxEventHeader hdr;
unsigned int flags;
int smousex;
int smousey;
int imousex;
int imousey;
} ImageFileGadgetMouseClickEvent;smousex and smousey are screen coordinates within the gadget. imousex and
imousey are image coordinates computed by inverting the ImageFileRender
transform.
Mouse event flags:
| Flag | Meaning |
ImageFileGadget_MouseClick_Flags_DoubleClick | Double-click |
ImageFileGadget_MouseClick_Flags_AdjustClick | Adjust button was used |
ImageFileGadget_MouseClick_Flags_StartDrag | Drag start |
ImageFileGadget_MouseClick_Flags_MenuClick | Menu button was used |
ImageFileGadget_MouseClick_Flags_XInImage | X coordinate is inside image bounds |
ImageFileGadget_MouseClick_Flags_XLow | X coordinate is below image bounds |
ImageFileGadget_MouseClick_Flags_XHigh | X coordinate is above image bounds |
ImageFileGadget_MouseClick_Flags_YInImage | Y coordinate is inside image bounds |
ImageFileGadget_MouseClick_Flags_YLow | Y coordinate is below image bounds |
ImageFileGadget_MouseClick_Flags_YHigh | Y coordinate is above image bounds |
Debugging
Use *ImageFileRenderers to confirm that a renderer is registered for the
filetype being supplied to ImageFileGadget_SetValue.
If the image is blank, check:
- The file data pointer remains valid for as long as the gadget needs it.
- The filetype matches the image data.
- A renderer exists for that filetype.
- The transform data matches the selected transform type.
- The quality value is in the ImageFileRender range 0-15.
- Scroll values are using the expected coordinate system.
In this repository47 other files it gives its agents.
- allocating-resourcesSkill
- ci-testingSkill
- creating-pull-requestsSkill
- designing-modulesSkill
- porting-to-riscos-cSkill
- reading-assemblySkill
- riscos-commandsSkill
- riscos-desktop-fileractionSkill
- riscos-filer-likeSkill
- riscos-filesystemSkill
- riscos-graphics-convertersSkill
- riscos-network-dcistatisticsSkill
- riscos-network-resolverSkill
- riscos-outputSkill
- riscos-reSkill
- riscos-styleSkill
- riscos-throwbackSkill
- riscos-urls-fetchingSkill
- riscos-urls-launchingSkill
- riscos-wimp-appSkill
- riscos-wimpSkill
- riscos-wimp-templatesSkill
- updating-robe-skillsSkill
- using-bbcbasicSkill
- using-cmhgSkill
- using-ghSkill
- using-gitSkill
- using-libasmSkill
- using-libgcontextSkill
- using-liboslibSkill
- using-libriscoslibSkill
- using-libtoolboxSkill
- using-makefilesSkill
- using-perlSkill
- using-stronghelpSkill
- using-tooltesterSkill
- writing-assemblySkill
- writing-assembly-testsSkill
- writing-cmodulesSkill
- writing-cplusplusSkill
- writing-cSkill
- writing-fortranSkill
- writing-oslib-defsSkill
- writing-pascalSkill
- writing-prminxmlSkill
- writing-pymodulesSkill
- writing-pyromaniac-integration-testsSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

