WINDOW
WINDOW [x1, x2, y2, y1]
Specifies “world” coordinates for the screen. The WINDOW command
allows you to redefine the corners of the display screen as a pair of
“world” coordinates. The coordinates of the upper-left corner of the
screen is given by [x1, y1]
, the lower-left corner by
[x2, y2]
.
The world space defined by WINDOW is disabled by a WINDOW command without parameters.
Example
' Coordinate system with corners:
' upper-left = [-20,-10]
' lower-right= [ 20, 10]
20
x1 = -10
y1 = -10
x2 = 20
y2 =
window x1, x2, y2, y1
rect -20, -10 STEP 1, 1, 14 filled ' Yellow: upper-left
rect 19, -10 STEP 1, 1, 13 filled ' Magenta: upper-right
rect 19, 9 STEP 1, 1, 12 filled ' Red: lower-right
rect -20, 9 STEP 1, 1, 10 filled ' Green: lower-left
circle 0, 0, 1, 1, 15 filled ' White: center
WINDOW sub-commands (non-standard)
WINDOW is also overloaded as a function, returning a system object which provides access to the following sub-commands.
alert(message, title)
Display an alert window. The title of the window is
title
and the context is message
.
window()
w = "This is an alert", "title") w.alert(
ask(message, title)
Display a prompt window to retrieve a user selection. The choices are
“Yes” and “No”. The title of the window is title
and the
context is message
. The answer is stored in the
window-object variable answer
: 0
for “Yes” and
1
for “No”.
window()
w =
"Yes or no?", "Question")
w.ask(
if w.answer == 0 then
print "Yes"
else
print "No"
endif
graphicsScreen1(), graphicsScreen2()
Select graphics mode screen 1 or 2 for output. When switching to a different screen, the context of the previous screen is stored in RAM. When switching back to the previous screen, the context will be restored.
window()
w =
' Set output to screen 1
w.graphicsScreen1() rect 100,100 STEP 100,100, 15 filled
' Set output to screen 2
w.graphicsScreen2() rect 150,150 STEP 100,100, 14 filled
' Switch between both screens, no need to redaw the rectangles
while 1
b = !bif b then
w.graphicsScreen1()else
w.graphicsscreen2()endif
delay(500)
wend
insetTextScreen(x1, y1, x2, y2)
Insert an area for text output from position [x1, y1]
to
position [x2, y2]
window()
w = "How does this look?"
? 5,10,90,90)
w.insetTextScreen(for i = 0 to 200
"This is in the text screen"
? next i
pause
menu(option1 [, option2, …, optionN)
Displays a popup menu with the entries option1
to
optionN
. INKEY will return the number of the selected
option starting with 0
.
window()
w =
"option1", "option2", "option3")
w.menu(
select case asc(inkey)
case 0
print "one"
case 1
print "two"
case 2
print "three"
case else
print "unk"
end select
message(str)
Displays a status message str
at the bottom of the
screen.
window()
w = "Click to continue. ") w.message(
setFont(size, unit, bold, italic)
Sets the font size to size
. unit
can be set
to “em” to make size relative to the existing size. Any other value will
cause size to be avaluated as pixels. bold
can be set to
0
or 1
to enable or disable bold font style.
italic
can be set to 0
or 1
to
enable or disable italic font style.
window()
w =
15, "px", 0, 0)
w.setFont(print "Fixed size 15px"
2, "em", 0, 0)
w.setFont(print "Relative size 15px * 2"
15, "px", 1, 0)
w.setFont(print "Fixed size 15px bold"
15, "px", 0, 1)
w.setFont(print "Fixed size 15px italic"
15, "px", 1, 1)
w.setFont(print "Fixed size 15px bold italic"
setLocation(x, y)
Sets the location of the window on the screen. The upper-left corner
of the window will be at position [x, y]
in pixel.
window()
w = 100, 100) w.setLocation(
setSize(w, h)
Sets the width w
and height h
in pixel of
the SmallBASIC window.
window()
w = 800, 680) w.setSize(
showKeypad()
Raises the virtual keypad on android.
window()
w = w.showKeypad()
hideKeypad()
Hides the virtual keypad on android.
window()
w = w.hideKeypad()
textScreen()
Select the text mode for output. Text mode can display more text but is slow.
window()
w =
w.textScreen()for i = 0 to 1000
"hello " + i
? next for
theme
Returns the active window colour theme.
window()
w = const theme = w.theme
const colBkGnd = theme.background
const colText = theme.text5
const colFile = theme.text2
const colDir = theme.text3
const colText2 = theme.text4
const colNav = theme.text1
const colNav2 = theme.text6