gadgetslib
Gadgets are collected in a gadget list, a Blitz object numbered from 0.
TextGadget, StringGadget, PropGadget and ShapeGadget add a
gadget with a number of its own, its Id, to a list, and Window ..., GadgetList# opens a window with all of them. The Id comes back from
GadgetHit when the gadget is used, so the gadgets of a list should
have different Ids. A gadget placed relative to
the right or bottom edge of the window takes a negative x or y.
The look of the gadgets made from now on is set beforehand: GadgetPens
and GadgetJam for their texts, Borders and BorderPens for their
borders. A text gadget whose text has parts separated by | cycles
through them when it is clicked (unless it is a toggle gadget or in a
button group); GadgetStatus and SetGadgetStatus read and set the
part shown. Gadgets made with the button group flag after ButtonGroup
form a group of which one is selected at a time, and ButtonId tells
which.
Commands that change a gadget, such as SetString, Toggle or
SetHProp, do not redraw it; Redraw does. With runtime error
checking, an Id that the list does not have is the error “Can’t Find
Gadget”; without it, the
search for an Id does not stop at the end of the list
(#166). Freeing a
list frees all memory of its gadgets, also the text buffers of string
gadgets.
Based on the gadgetslib guide by Acid Software.
Library number 140. It manages GadgetList objects, by default at most 5 (the compiler options set the maximum).
Commands
ActivateString
Activates a string gadget of the window, so that typing goes into it.
Statement. Help text: Window#,Id
Arguments: .w, .w
BorderPens
The colours of the borders of the gadgets made from now on, the light and the shadow side.
Statement. Help text: Highlight Colour,Shadow Colour
Arguments: .w, .w
Borders
Whether the gadgets made from now on get borders (On or Off), or the space between a gadget’s text and its border.
Statement. Help text: [On|Off]|[Width,Height]
2 forms:
.w.w, .w
ButtonGroup
The button group of the gadgets made from now on whose flags ask for one; it must be greater than 0.
Statement. Help text: Group
Arguments: .w
ButtonId
The Id of the selected gadget of a button group, or -1 if none is selected.
Function, result .w. Help text: (GadgetList#,ButtonGroup)
Arguments: .w, .w
ClearString
Empties a string gadget.
Statement. Help text: GadgetList#,Id
Arguments: .w, .w
Disable
Makes a gadget unusable; Intuition shows it ghosted.
Statement. Help text: (GadgetList#,Id)
Arguments: .w, .w
Enable
Makes a gadget usable again.
Statement. Help text: (GadgetList#,Id)
Arguments: .w, .w
GadgetBorder
Draws a border in the style of the gadgets into the used window.
Statement. Help text: X,Y,Width,Height
Arguments: .w, .w, .w, .w
GadgetJam
The drawing mode of the texts of the gadgets made from now on.
Statement. Help text: Jammode
Arguments: .w
GadgetList
The object that holds a list of gadgets made with the commands of this library, as the introduction describes.
Object name. Help text: List of Gadgets
GadgetPens
The colours of the texts of the gadgets made from now on, the foreground and optionally the background.
Statement. Help text: Foreground Colour[,Background Colour]
2 forms:
.w.w, .w
GadgetStatus
For a text gadget that is not a toggle gadget, the number of the part it shows, from 1; for toggle gadgets and gadgets without a text, -1 if it is selected, else 0.
Function, result .w. Help text: (GadgetList#,Id)
Arguments: .w, .w
HPropBody
The horizontal size of the knob of a proportional gadget.
Function, result .q. Help text: (GadgetList#,Id)
Arguments: .w, .w
HPropPot
The horizontal position of the knob of a proportional gadget.
Function, result .q. Help text: (GadgetList#,Id)
Arguments: .w, .w
PropGadget
Adds a proportional gadget, a slider or scroller, with the given size; flags select horizontal, vertical or both directions. Its pot is where the knob is and its body how large it is, both from 0 to 1. A slider for the values 0 to 15 has a body of 1/16.
Statement. Help text: GadgetList#,X,Y,Flags,Id,Width,Height
Arguments: .w, .w, .w, .l, .w, .w, .w
Redraw
Draws a gadget of the window again, after its state was changed.
Statement. Help text: Window#,Id
Arguments: .w, .w
ResetString
Moves the cursor of a string gadget to the start; the contents stay.
Statement. Help text: GadgetList#,Id
Arguments: .w, .w
SelectMode
Chooses how the gadgets made from now on are highlighted while they are selected - 1 with a box around them, 0 by inverting their colours. A shape gadget with a second shape shows that shape instead.
Statement. Help text: 1=Box, 0=Inverse
Arguments: .w
SetGadgetStatus
Makes a cycling text gadget show part Value, from 1; toggle gadgets and a Value of 0 are ignored.
Statement. Help text: (GadgetList#,Id,Value)
Arguments: .w, .w, .w
SetHProp
Sets the horizontal position (Pot) and size of the knob (Body) of a proportional gadget, as quick values from 0 to 1.
Statement. Help text: GadgetList#,Id,Pot,Body
Arguments: .w, .w, .q, .q
SetString
Sets the contents of a string gadget.
Statement. Help text: GadgetList#,Id,String$
Arguments: .w, .w, $
With runtime error checking, a string of Maxlen characters or more
is the error “String to long for Gadget”.
SetTextGadget
Replaces the text of a gadget; the new text is padded with spaces and cut to the length of the old one.
Statement. Help text: GadgetList#,Id,Text$
Arguments: .w, .w, $
SetVProp
Sets the vertical position and size of the knob of a proportional gadget, as SetHProp.
Statement. Help text: GadgetList#,Id,Pot,Body
Arguments: .w, .w, .q, .q
ShapeGadget
Adds a gadget that shows a shape, optionally with a second shape for the selected state.
Statement. Help text: GadgetList#,X,Y,Flags,Id,Shape#[,Shape#]
2 forms:
.w, .w, .w, .l, .w, .w.w, .w, .w, .l, .w, .w, .w
StringGadget
Adds a string gadget, a field for typing text, as high as the font, with a buffer of Maxlen bytes (room for Maxlen-1 characters) and the given width in pixels; a longer text scrolls inside the gadget. StringText$ reads what was typed.
Statement. Help text: GadgetList#,X,Y,Flags,Id,Maxlen,Width
Arguments: .w, .w, .w, .l, .w, .w, .w
With runtime error checking, a Maxlen of 0 is the error “Maxlen
MUST be greater than zero”. In the style of Blitz Basic 2, only that
check catches it: without it, a Maxlen of 0 overwrites memory.
StringText$
The contents of a string gadget.
Function, result $. Help text: (GadgetList#,Id)
Arguments: .w, .w
TextGadget
Adds a text gadget, a button with a text, to the gadget list. A plain one is on only while it is held down; a toggle gadget changes between on and off with each click. The flags select a toggle gadget, positions and sizes relative to the window, membership in the current button group and others.
Statement. Help text: GadgetList#,X,Y,Flags,Id,Text$
Arguments: .w, .w, .w, .l, .w, $
Toggle
Selects or deselects a gadget, or without On or Off turns its state over.
Statement. Help text: GadgetList#,Id [,On|Off]
2 forms:
.w, .w, .w.w, .w
VPropBody
The vertical size of the knob of a proportional gadget.
Function, result .q. Help text: (GadgetList#,Id)
Arguments: .w, .w
VPropPot
The vertical position of the knob of a proportional gadget.
Function, result .q. Help text: (GadgetList#,Id)
Arguments: .w, .w