You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The WINDOW command allows you to redefine the corners of the display screen as a pair of "world" coordinates. WINDOW is also overloaded as a function, returning a system object providing access to the following sub-commands: graphicsScreen1, graphicsScreen2, textScreen, alert, ask, menu, message, showKeypad, insetTextScreen
5
+
Specifies "world" coordinates for the screen.
6
6
7
+
The WINDOW command allows you to redefine the corners of the display screen as a pair of "world" coordinates.
7
8
8
9
The world space defined by WINDOW is disabled by a WINDOW command with no parameters.
9
10
10
-
This is a demo from http://smallbasic.sourceforge.net/?q=comment/1502#comment-1502
11
-
It shows how to use the additional WINDOW sub-commands (It is not the traditional use of WINDOW [x1,y1,x2,y2] ).
12
-
Tested with SmallBASIC version 0.12.6 (Linux).
11
+
Note: the unusal coordinates are intended for Quick BASIC compatibility (possible bug).
13
12
14
-
~~~
13
+
```
14
+
window 1, 320, 320, 1
15
+
rect 0, 0, 160, 160, 1 filled
16
+
rect 160, 160, 320, 320, 2 filled
17
+
rect 160, 0, 320, 160, 3 filled
18
+
rect 0, 160, 160, 320, 4 filled
19
+
```
15
20
16
-
' create the window object, this provides access to a number of sub-commands
21
+
## WINDOW sub-commands (non-standard)
22
+
23
+
WINDOW is also overloaded as a function, returning a system object which provides access to the following sub-commands.
24
+
25
+
### alert(message, title)
26
+
27
+
Display an alert message.
28
+
29
+
```
17
30
w = window()
18
-
' select graphics mode screen 1 for output
19
-
w.graphicsScreen1()
20
-
for i = 0 to 10
21
-
print "this is printed on screen 1"
22
-
next i
23
-
w.message("[1] click to continue. ")
24
-
pause
25
-
' select graphics mode screen 1 for output
26
-
w.graphicsScreen2()
27
-
color 1,3
28
-
cls
29
-
print "this is printed on screen 2"
30
-
w.message("[2] click to continue. ")
31
-
pause
32
-
w.graphicsScreen1()
33
-
print "back to screen 1"
34
-
w.message("[3] click to continue. ")
35
-
pause
36
-
' select the text mode for output
37
-
' text mode can display more text but is slow
38
-
' also this is currently broken and will cause a crash
39
-
'w.textScreen()
40
31
w.alert("This is an alert", "title")
32
+
```
33
+
34
+
### ask(message, title)
35
+
36
+
Display a prompt to retrieve a user selection.
37
+
38
+
```
39
+
w = window()
41
40
w.ask("Yes or no?", "Question")
42
-
print "your answer was "; w.answer
43
-
w.message("[4] click to continue. ")
41
+
if w.answer == 0 then
42
+
w.alert("Yes!", "Answer")
43
+
else
44
+
w.alert("No", "Answer")
45
+
endif
46
+
```
47
+
48
+
### graphicsScreen1(), graphicsScreen2()
49
+
50
+
Select graphics mode screen 1 or 2 for output.
51
+
52
+
```
53
+
dim v(30)
54
+
for i = 0 to 30
55
+
v[i] = rnd
56
+
next i
57
+
58
+
sub draw_chart(n,s)
59
+
color 1,15: cls
60
+
chart n, v, s, 1, 1, xmax-2, ymax-2
61
+
end
62
+
63
+
w = window()
64
+
w.
F438
graphicsScreen2(): draw_chart(1, 5)
65
+
w.graphicsScreen1(): draw_chart(2, 3)
66
+
67
+
while 1
68
+
b = !b
69
+
if b then w.graphicsScreen1() else w.graphicsscreen2()
70
+
pause
71
+
wend
72
+
```
73
+
### insetTextScreen(x, y, w, h)
74
+
75
+
```
76
+
w = window()
77
+
? "How does this look?"
78
+
w.insetTextScreen(5,10,90,90)
79
+
for i = 0 to 200
80
+
? "This is in the text screen"
81
+
next i
44
82
pause
83
+
```
84
+
85
+
### menu(option1, option2...)
86
+
87
+
Displays a popup menu. The user response is available via INKEY.
88
+
89
+
```
90
+
w = window()
45
91
w.menu("option1", "option2", "option3")
46
-
' weirdly the result is sent to the keyboard handler
47
-
' it should at least go to w.answer. also there is no option for placement
48
92
select case asc(inkey)
49
93
case 0
50
94
print "one"
@@ -55,32 +99,100 @@ case 2
55
99
case else
56
100
print "unk"
57
101
end select
58
-
w.message("[5] click to continue. ")
59
-
pause
60
-
' this raises the virtual keypad on android
61
-
w.showKeypad()
62
-
' set the font size
63
-
' arg1 = size
64
-
' arg2 = unit amount for size, "px" or "em"
65
-
' px= pixels
66
-
' em= emphasis - this is a multiplication factor for the current size
67
-
' arg3= bold 1=on 0=off
68
-
' arg4= italic 1=on, 0=off
69
-
' this sets the font to be double in size with bold and italic
70
-
' using pixels is likely to give an unexpected result in android
71
-
w.setFont(2, "em", 1,1)
72
-
cls
73
-
? "How does this look?"
74
-
w.insetTextScreen(5,10,90,90)
75
-
for i = 0 to 200
76
-
? "This is in the text screen"
77
-
next i
78
-
' comment out the above cls to see the bug
79
-
w.message("spot the bug ?")
80
-
w.setFont(11, "px", 0,0)
81
-
? "press a key to end..."
82
-
pause
102
+
```
103
+
104
+
### message(str)
105
+
106
+
Displays a status message at the bottom of the screen.
107
+
108
+
```
109
+
w = window()
110
+
w.message("Click to continue. ")
111
+
```
112
+
113
+
### setFont(size, unit, bold, italic)
114
+
115
+
Sets the font to be double in size with bold and italic.
116
+
117
+
"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.
118
+
119
+
```
120
+
w = window()
121
+
dim buf
122
+
123
+
sub text(s)
124
+
local x, y, j, size, width, height
125
+
buf << s
126
+
y = ymax / 2
127
+
cls
128
+
size = 30
129
+
for j = len(buf) - 1 to 0 step - 1
130
+
size -= 2
131
+
w.setFont(size, "px", 0, 1)
132
+
width = txtw(buf[j])
133
+
height = txth(buf[j])
134
+
x = (xmax - width) / 2
135
+
y -= height
136
+
at x, y: print buf[j]
137
+
next j
138
+
delay 1200
139
+
end
140
+
141
+
text "A long time ago, in a galaxy far, far away..."
142
+
text "It is a period of civil war. Rebel"
143
+
text "spaceships, striking from a hidden"
144
+
text "base, have won their first victory"
145
+
text "against the evil Galactic Empire."
146
+
text "During the battle, Rebel spies managed"
147
+
text "to steal secret plans to the Empire's"
148
+
text "ultimate weapon, the Death Star, an"
149
+
text "armored space station with enough"
150
+
text "power to destroy an entire planet."
151
+
text "Pursued by the Empire's sinister agents,"
152
+
text "Princess Leia races home aboard her"
153
+
text "starship, custodian of the stolen plans"
154
+
text "that can save her people and restore"
155
+
text "freedom to the galaxy...."
156
+
```
157
+
158
+
### setSize(w, h)
159
+
160
+
Sets the width and height of the SmallBASIC window.
161
+
162
+
```
163
+
w = window()
164
+
w.setSize(800, 680)
165
+
```
166
+
167
+
### showKeypad()
83
168
84
-
~~~
169
+
Raises the virtual keypad on android.
85
170
171
+
### textScreen()
172
+
173
+
Select the text mode for output. Text mode can display more text but is slow.
0 commit comments