Screen/Graphics Advanced User Interface
- Version
- 1
- Authors:
- Nicholas Christopoulos
Copyright ©2001-2003 SmallBASIC Project
Abstract
This paper is a purpose for an advanced library for
Screen/Graphics Advanced User Interface
Introduction
This problem isn't hard but, also, not easy at all.
There are several parts that we must think.
- SB works on several environments. Others have a GUI others have not.
- SB must support a similar interface on all of them.
- Using 'events' mechanism isn't a good choice for novices.
By studing old interfaces like TI BASIC, dBase and Clipper.
I suggest the following mechanism.
There must be only one form, next versions of the library may be a lot of forms.
This form is the whole screen, next versions of the library may be a window.
Characteristics
- User's UI commands are stored automatically in a list.
- This list executed when an 'run-ui-commands' like command is called.
- Similar there will must be a 'reset-ui-list' command.
If scroll is required, scroll bars must be created automatically by SB.
- SB must creates a virtual buffer to be used for UI-commands.
- This buffer must be scrolled if doesn't fit on screen.
- User must can move to each ACCEPT/BUTTON commands by using arrows, mouse and pen.
In next versions, as I said, there must be a dynamic list of forms.
Multiple elements of the same structures can solve the problem.
The default will be the whole screen and with this way the code will remain the same.
One problem is how to use multiple forms together.
Interface
Input
ACCEPT [AT/LC x,y;] [{USING format; | SIZE n;}] [prompt;] @var [VALID expr]
alias USING = USG
alias VALID = VALIDATE
Similar to INPUT, the ACCEPT reads a string from stdin.
The difference is that ACCEPT and DISPLAY commands are stored
in ui-list.
ACCEPT parameters
- AT/LC x,y
- Position; default = next row from previous ACCEPT/DISPLAY.
There must be supported both units, virtual-characters and pixels.
So, LC stands for pseudo-character mode, and AT for pixels.
- USING format
- Input mask
- SIZE n
- Size of field in bytes
- prompt
- prompt...
- var
- the variable
- VALID
- USE-like validation expression/function.
If the 'validation' returns false, there must be no exit from this.
Output
DISPLAY [AT/LC x,y;] [{USING format; | SIZE n;}] string [USE UDP]
alias USING = USG
- AT x,y
- position; default = next row from previous ACCEPT/DISPLAY
- USING format
- Output mask
- SIZE n
- Size of field in bytes
- USE...
- Interaction
Buttons
BUTTON x,y [,width,height]; text [{USE udf}|ID id}]
- USE
- If click/[ENTER] then executed
- ID
- Returned id
Generic
FRMEXEC @id
Runs a set of UI commands (accept,display,button)
Returns
id = 0 = normal exit
id = -1 = cancel/escape exit
any other = button ID
FRMRESET
Clears all UI-elements from memory