blitzoslib
Blitz OS gives a Blitz mode program a simple user interface of its
own, drawn into a bitmap with the drawing commands of Blitz mode. A
page is a Blitz object, numbered from 0, that holds a number of
boxes. InitPage makes a page for a bitmap, AddBox defines each
box, RedrawPage draws them, and BlitzEvent, called in the main
loop, lets the user work them with the joystick, the cursor keys, the
keyboard and the mouse.
BitMap 0,320,200,3
BLITZ
InitPage 0,0,3
AddBox 0,0,10,10,80,16,2,"Start"
AddBox 0,1,10,30,80,16,2,"Quit"
RedrawPage
SelectBox 0
Repeat
VWait
e=BlitzEvent
Until e=-1 AND BoxSelected=1The type of AddBox is the kind of box times 2, plus 1 for a bevel
drawn the other way round:
| Kind | Box |
|---|---|
| 0 | view: shows a part of a bitmap, or lines printed with BoxPrint |
| 1 | button; a text with several parts separated by | makes it step through them |
| 2 | string box, for typing a text after the prompt given as text |
| 3 | prop, a knob moved horizontally, vertically or both |
| 4 | shape or display box |
| 5 | list |
| 6 | drag box, for dragging with the mouse |
BlitzEvent returns -1 when a button was clicked, 1 when a box was
activated, 2 when a prop knob or a drag box moved, and 0 otherwise.
Return works as the fire button; left Alt with left Amiga and right
Amiga with right Alt work as the mouse buttons. The mouse needs
Mouse On.
The commands that name only a box work on the used page, the one made
or used last. A page that is not made is the error “UnInitialised
Page”, a box beyond the page’s number of boxes “Illegal Box# For
Page”. These checks are always on, except that SpotBox checks its
page, and SelectBox Box# its box number, only with runtime error
checking. Most commands that change a box do
not draw it; RedrawBox does.
Library number 117. It manages Page objects, by default at most 4 (the compiler options set the maximum).
Commands
ActivateSelectedBox
Activates the selected box, as pressing fire does; a string box starts taking text, a prop box its knob, a drag box dragging.
Statement. No help text.
No arguments.
AddBox
Defines box Box# of a page at x,y, w by h pixels, of the type the introduction describes. With text$, a button or view shows the text, a list box gets its parts, separated by |, as its entries, and a string box gets it as its prompt; with two shapes, a button shows a shape from the first to the second, chosen by its value.
Statement. Help text: Page#,Box#,x,y,w,h,type[,text$]|[,shape,shape]
3 forms:
.w, .w, .w, .w, .w, .w, .w.w, .w, .w, .w, .w, .w, .w, $.w, .w, .w, .w, .w, .w, .w, .w, .w
The box is not drawn. A string box needs room for its prompt, else this is the error “No Room For String”.
BlitzEvent
Handles the input of the user on the used page once and returns what happened, as the introduction describes. Call it once per frame.
Function, result .w. Help text: ;handles user input and returns event
No arguments.
BoxPrint
Prints String$, or line Line of a text in bank Bank#, into a view box. A box of one line scrolls it to the left; a higher box scrolls up by one line and prints into its last line.
Statement. Help text: Box#[,String$]|[Bank#,Line]
2 forms:
.w, $.w, .w, .w
In the bank, a line ends at a line feed or a 0. The bank is not changed.
BoxPropX
The horizontal position of the knob of a prop box.
Function, result .q. Help text: Box#
Arguments: .w
BoxPropY
The vertical position of the knob of a prop box.
Function, result .q. Help text: Box#
Arguments: .w
BoxSelected
The number of the selected box of the used page.
Function, result .w. No help text.
No arguments.
BoxShow
Shows in a view box the part of Bitmap# from x,y on; with dx,dy, moves that part by so many pixels.
Statement. Help text: Box#[,Bitmap#,x,y]|[dx,dy]
2 forms:
.w, .w, .w, .w.w, .w, .w
BoxString
The text typed into a string box, without the spaces at its end, of the used page or of the page given.
Function, result $. Help text: (Box#)|(Page#,Box#)
2 forms:
.w.w, .w
An answer of only spaces, such as that of a box never typed into, is the empty string.
BoxValue
The value of a box of the used page, or of the page given.
Function, result .w. Help text: (Box#)|(Page#,Box#)
2 forms:
.w.w, .w
ChangeBox
As SetBox with a value, for a box of the page given.
Statement. Help text: Page#,Box#,Value
Arguments: .w, .w, .w
DeSelectBox
Draws the selected box as not pressed and ends typing, moving a knob or dragging. Afterwards no box is selected, and BoxSelected returns -1.
Statement. No help text.
No arguments.
DisableBox
Disables a box; it is drawn plain and cannot be selected with the mouse, the joystick or the cursor keys. The box is not drawn.
Statement. Help text: Box#
Arguments: .w
EnableBox
Enables a disabled box again. The box is not drawn.
Statement. Help text: Box#
Arguments: .w
FreePage
Frees the boxes of a page.
Statement. Help text: Page#
Arguments: .w
InitPage
Makes a page of NumBoxes empty boxes that draws into the bitmap BitMap#, and makes it the used page. Old boxes of the page are freed.
Statement. Help text: Page#,BitMap#,NumBoxes
Arguments: .w, .w, .w
With runtime error checking, a NumBoxes of 32768 or more is the
error “Illegal Number of Boxes”.
MouseEnabled
True while BlitzEvent follows the mouse, after it moved; the joystick or the cursor keys switch back to the selection by direction.
Function, result .w. No help text.
No arguments.
Page
The object of a page of boxes, as the introduction describes.
Object name. No help text.
RedrawBox
Draws a box of the used page.
Statement. Help text: Box#
Arguments: .w
RedrawPage
Draws all boxes of the used page.
Statement. No help text.
No arguments.
SelectBox
Selects box Box# and draws it and the box selected before; 0,x,y selects the box at x,y, and x+,y+ the nearest box in that direction from the selected one.
Statement. Help text: [Box#]|[x+,y+][0,x,y] ;deselects previously selected
3 forms:
.w.w, .w.w, .w, .w
A negative Box# selects no box. With runtime error checking, a
Box# the page does not have is the error “Illegal Box# For Page”.
SetBox
Sets the value of a box, which of its texts or shapes it shows; a negative value counts from the end. For a prop box, xprop,yprop set the position of the knob, from 0 to 1. The box is not drawn.
Statement. Help text: Box#[,Value]|[xprop,yprop]
2 forms:
.w, .w.w, .q, .q
A value beyond the box’s number of texts is the error “Value Out of Range”; the prop form on another box “Not a Prop Box”.
SetBoxColor
Sets the background colour of a box and draws it.
Statement. Help text: Box#,color
Arguments: .w, .w
SetBoxString
Puts a text into a string box, after its prompt. The box is not drawn.
Statement. Help text: Box#,String$
Arguments: .w, $
SetBoxTitle
Gives a box a new text, as AddBox with a text does. The box is not drawn.
Statement. Help text: Box#,String$
Arguments: .w, $
SetPagePens
The colours of a page, c0 dark, c1 light, c2 the middle colour of the boxes and c3 the text. InitPage sets 1, 3, 2 and 1, not the defaults the help text names.
Statement. Help text: Page#,c0,c1,c2,c3 (defaults: 3,1,2,3)
Arguments: .w, .w, .w, .w, .w
SpotBox
The box the mouse pointer was over at the last BlitzEvent.
Function, result .w. Help text: ; returns box that mouse is over
No arguments.
With runtime error checking, a page that is not made, was freed or has no boxes is the error “UnInitialised Page”.
ToggleBox
Turns the bevel of a box the other way round. The box is not drawn.
Statement. Help text: Box#
Arguments: .w