gtlib
The commands of this library make gadgets with the system’s
gadtools.library, which gives them the standard look of AmigaOS. A
GTList is a Blitz object, numbered from 0, that collects them: each
GTButton, GTCycle, GTSlider and so on adds one gadget with its
id, position, size, label and flags, and AttachGTList adds all of
them to a window. GadgetHit then gives the id of the gadget used.
GTButton 0,1,10,10,100,14,"Quit",16
GTCheckBox 0,2,10,30,26,11,"Sound",2+256
GTSlider 0,3,90,50,120,12,"Volume",1,0,64,32
AttachGTList 0,0The flags of a gadget are the sum of these values. The low ones place
the label Text$; the others switch on options of the gadget kinds
named:
| Value | Meaning |
|---|---|
| 1, 2, 4, 8 | label left of, right of, above or below the gadget |
| 16 | label inside the gadget |
| 32 | label highlighted |
| 64 | disabled (all kinds but text and number gadgets) |
| 128 | reports when it is pressed, not only when it is released (button, integer, string, slider, scroller, shape) |
| 256 | checked at the start (check box) |
| 512 | scaled to the given size (check box, mutual exclude) |
| 1024 | vertical (slider, scroller) |
| 2048 | with arrows (scroller) |
| 4096 | read only (list view) |
| 8192 | a toggle button that stays selected (button) |
GTTags gives the next gadget further GadTools tags. Positions are
relative to the inside of the window: the window border sizes of the
used screen and the height of its font are added to them, unless
GTGimmeCludge On is set. GTSetAttrs, GTGetAttrs and the
GTSet.../GTGet... commands read and change gadgets later.
Most commands work in Amiga mode only; GTEnable, GTDisable,
GTToggle, GTStatus, GTArrowSize and GTGimmeCludge work in both
modes.
The commands that make gadgets take the border sizes and the font from
the used screen, so a screen must be used before them, with Screen,
WbToScreen or FindScreen; with runtime error checking, a missing
one is the error “No currently used object!”.
Several gadgets of a list can have the same id. GTSetAttrs,
GTChangeList and GTSetHighlight then work on the last of them, the
other commands on the first, and GTFreeGadget removes them all. A
GadTools kind that makes helper gadgets may need the last one.
Based on the bbgtlib guide by Acid Software.
Library number 141. It manages GTList objects, by default at most 5 (the compiler options set the maximum).
Commands
AttachGTList
Adds the gadgets of the GTList to a window and draws them.
Statement. Help text: GTList#,Window#
Arguments: .w, .w
With runtime error checking, attaching a list to the window it is already attached to is the error “GTList already attached to window!”.
DetachGTList
Removes the gadgets of the GTList from its window.
Statement. Help text: GTList#
Arguments: .w
GTArrowSize
The size of the arrows of scrollers made from now on with arrows; the start value is 16.
Statement. Help text: size
Arguments: .w
GTBevelBox
Draws a bevelled box, in GadTools’ style, into the window of the GTList; raised with the flags 0, recessed with any other value.
Statement. Help text: GTList#,x,y,w,h,flags
Arguments: .w, .l, .l, .l, .l, .l
GTButton
Adds a button. A flag makes it a toggle button that stays selected.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags
Arguments: .w, .w, .w, .w, .w, .w, $, .l
GTChangeList
Gives a list view a list array with new entries; without the list, takes its entries away, so that the list can be changed.
Statement. Help text: GTList#,id [ ,List() ]
2 forms:
.w, .w, array().w, .w
GTCheckBox
Adds a check box; flags make it checked at the start or scaled to the given size.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags
Arguments: .w, .w, .w, .w, .w, .w, $, .l
GTCycle
Adds a cycle gadget, which steps through the choices in Options$, separated by |; active is the choice shown first, from 0.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags,Options$[,active]
2 forms:
.w, .w, .w, .w, .w, .w, $, .l, $.w, .w, .w, .w, .w, .w, $, .l, $, .w
GTDisable
Makes a gadget unusable; it is not redrawn.
Statement. Help text: GTList#,Id
Arguments: .w, .w
GTEnable
Makes a gadget usable again; it is not redrawn.
Statement. Help text: GTList#,Id
Arguments: .w, .w
GTFreeGadget
Removes the gadget, or all gadgets in a row with that id, from the GTList and frees them.
Statement or function, result .w. Help text: GTList#,id
Arguments: .w, .w
GTGadPtr
The address of the gadget, for calling the system directly.
Function, result .l. Help text: (GTList#,id)
Arguments: .w, .w
GTGetAttrs
The value of one GadTools tag of a gadget, or 0 if there is no such gadget.
Function, result .l. Help text: (GTList#,id,Tag)
Arguments: .w, .w, .l
GTGetInteger
The value of an integer gadget.
Function, result .l. Help text: GTList#,id
Arguments: .w, .w
GTGetString
The contents of a string gadget.
Function, result $. Help text: GTList#,id
Arguments: .w, .w
GTGimmeCludge
With On, the positions of gadgets made from now on are taken as they are, without adding the window border sizes of the used screen and the height of its font. Use it for a GimmeZeroZero window, whose positions already start inside the borders.
Statement. Help text: On/Off
Arguments: .w
GTInteger
Adds a gadget for typing a whole number, with a start value.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags,default
Arguments: .w, .w, .w, .w, .w, .w, $, .l, .l
GTList
The object that collects GadTools gadgets, as the introduction describes.
Object name. Help text: A GadTools GadgetList
GTListView
Adds a list view that shows the entries of a list array, optionally with the entry selected and the first entry shown; a flag makes it read only.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags,list()[,selected[,top]]
3 forms:
.w, .w, .w, .w, .w, .w, $, .l, array(), .w.w, .w, .w, .w, .w, .w, $, .l, array(), .w, .w.w, .w, .w, .w, .w, .w, $, .l, array()
The list array must be of a type whose first field is a word and whose second field is the string shown, as GadTools reads its entries as system list nodes:
NEWTYPE .entry
pri.w
name$
End NEWTYPE
Dim List files.entry(20)While the list view shows the list, change the list only between two
GTChangeList calls.
GTMX
Adds a mutual exclude gadget, a set of radio buttons for the choices in Options$, separated by |; active is the one selected first, from 0.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags,Options$[,active]
2 forms:
.w, .w, .w, .w, .w, .w, $, .l, $.w, .w, .w, .w, .w, .w, $, .l, $, .w
GTNumber
Adds a gadget that shows a number, with a border; the user cannot change it.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags,value
Arguments: .w, .w, .w, .w, .w, .w, $, .l, .l
GTPalette
Adds a palette gadget for choosing one of the colours of depth bitplanes, optionally with a colour selected.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags,depth[,Color]
2 forms:
.w, .w, .w, .w, .w, .w, $, .l, .l.w, .w, .w, .w, .w, .w, $, .l, .l, .w
GTScroller
Adds a scroller for Total units of which Visible are shown, at Top; flags make it vertical and give it arrows.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags,Visible,Total[,Top]
2 forms:
.w, .w, .w, .w, .w, .w, $, .l, .w, .w.w, .w, .w, .w, .w, .w, $, .l, .w, .w, .w
GTSetAttrs
Changes a gadget through GadTools tags, given as tag and value pairs; at most 15 pairs.
Statement or function, result .l. Help text: GTList#,id [,Tag,Value...]
Arguments: .w, .w, { .l, .l }...
Most tags of a gadget’s kind can be changed this way, for example the
level of a slider (GTSL_Level, $80080028), the choice of a cycle
gadget (GTCY_Active, $8008000F) or the state of a check box
(GTCB_Checked, $80080004). Tags that only set up a gadget, such as
the format of a slider’s level, cannot be changed afterwards.
GTSetHighlight
Selects an entry of a list view and scrolls it into view.
Statement. Help text: GTList#,id,value
Arguments: .w, .w, .l
GTSetInteger
Sets the value of an integer gadget or a number gadget.
Statement. Help text: GTList#,id,value
Arguments: .w, .w, .l
GTSetString
Sets the text of a string gadget or a text gadget.
Statement. Help text: GTList#,id,string$
Arguments: .w, .w, $
GTShape
Adds a button that shows a shape, optionally with a second shape for the selected state. It has no label.
Statement. Help text: GTList#,id,x,y,flags,Shape#[,Shape#]
2 forms:
.w, .w, .w, .w, .l, .w.w, .w, .w, .w, .l, .w, .w
GTSlider
Adds a slider from Min to Max, at Level; a flag makes it vertical.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags,Min,Max[,Level]
2 forms:
.w, .w, .w, .w, .w, .w, $, .l, .w, .w.w, .w, .w, .w, .w, .w, $, .l, .w, .w, .w
GTStatus
1 if the gadget is selected, else 0.
Function, result .b. Help text: GTList#,Id
Arguments: .w, .w
GTString
Adds a string gadget for up to MaxChars characters, optionally with a text in it.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags,MaxChars [,default$]
2 forms:
.w, .w, .w, .w, .w, .w, $, .l, .w.w, .w, .w, .w, .w, .w, $, .l, .w, $
GTTags
Further GadTools tags, as tag and value pairs, for the next gadget made; at most 15 pairs, which nothing checks.
Statement. Help text: Tag,Value [,Tag,Value...]
Arguments: { .l, .l }...
The tags are those of gadtools.library, described in the AmigaOS
autodocs; they start at $80080000. This makes a slider that shows
its level, with the format %2ld (GTSL_LevelFormat, $8008002A)
in up to 4 characters (GTSL_MaxLevelLen, $80080029):
f$="%2ld"
GTTags $8008002A,&f$,$80080029,4
GTSlider 0,2,90,70,120,12,"Level",2,0,10GTText
Adds a gadget that shows a text, with a border; the user cannot change it.
Statement. Help text: GTList#,id,x,y,w,h,Text$,flags,Display$
Arguments: .w, .w, .w, .w, .w, .w, $, .l, $
GTToggle
Selects or deselects a gadget, or without On or Off turns its state over; it is not redrawn.
Statement. Help text: GTList#,Id [,On|Off]
2 forms:
.w, .w, .w.w, .w