8000 Updated WINDOW command help · chrisws/smallbasic.github.io@ab7f9e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit ab7f9e4

Browse files
committed
Updated WINDOW command help
1 parent 75e5226 commit ab7f9e4

File tree

8 files changed

+419
-181
lines changed

8 files changed

+419
-181
lines changed
Lines changed: 171 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,94 @@
11
# WINDOW
22

3-
> WINDOW [x1,y1,x2,y2]
3+
> WINDOW [x1,y2,x2,y1]
44
5-
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.
66

7+
The WINDOW command allows you to redefine the corners of the display screen as a pair of "world" coordinates.
78

89
The world space defined by WINDOW is disabled by a WINDOW command with no parameters.
910

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).
1312

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+
```
1520

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+
```
1730
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()
4031
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()
4140
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
4482
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()
4591
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
4892
select case asc(inkey)
4993
case 0
5094
print "one"
@@ -55,32 +99,100 @@ case 2
5599
case else
56100
print "unk"
57101
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()
83168

84-
~~~
169+
Raises the virtual keypad on android.
85170

171+
### textScreen()
172+
173+
Select the text mode for output. Text mode can display more text but is slow.
174+
175+
```
176+
w = window()
177+
w.textScreen()
178+
for i = 0 to 1000
179+
? "hello " + i
180+
next for
181+
```
182+
183+
### theme
184+
185+
Returns the active window colour theme.
186+
187+
```
188+
w = window()
189+
const theme = w.theme
190+
const colBkGnd = theme.background
191+
const colText = theme.text5
192+
const colFile = theme.text2
193+
const colDir = theme.text3
194+
const colText2 = theme.text4
195+
const colNav = theme.text1
196+
const colNav2 = theme.text6
86197
198+
```

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ <h2 id="smallbasic-version-0.12.10-has-been-released">SmallBASIC version 0.12.10
146146
<p><a href="/posts/2017-24-12-1.html">Read more</a></p>
147147
</div>
148148
<div class="pagefooter">
149-
This page was last edited on Sat, 11 Apr 2020 13:32:33 +1000
149+
This page was last edited on Thu, 16 Jul 2020 21:30:36 +1000
150150
|
151151
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
152152
processed with

pages/android_changelog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ <h1 id="android-changelog">Android Changelog</h1>
346346
</ul>
347347
</div>
348348
<div class="pagefooter">
349-
This page was last edited on Sun, 22 Dec 2019 16:06:55 +1000
349+
This page was last edited on Thu, 16 Jul 2020 21:28:07 +1000
350350
|
351351
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
352352
processed with

pages/changelog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ <h1 id="changelog">Changelog</h1>
13691369
DIM supports more variables now</code></pre>
13701370
</div>
13711371
<div class="pagefooter">
1372-
This page was last edited on Tue, 19 May 2020 21:53:19 +1000
1372+
This page was last edited on Thu, 16 Jul 2020 21:28:07 +1000
13731373
|
13741374
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
13751375
processed with

pages/download.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ <h2 id="language-reference">Language Reference</h2>
9090
<p><a href="http://sourceforge.net/projects/smallbasic/files/Language%20Reference/sbref_v2.txt/download" target="_blank">Offline help text</a></p>
9191
</div>
9292
<div class="pagefooter">
93-
This page was last edited on Mon, 16 Mar 2020 06:59:04 +1000
93+
This page was last edited on Thu, 16 Jul 2020 21:28:07 +1000
9494
|
9595
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
9696
processed with

reference/1015.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ <h2 id="example-2">Example 2:</h2>
292292
</div>
293293
</div>
294294
<div class="pagefooter">
295-
This page was last edited on Sat, 17 Mar 2018 11:54:15 +1000
295+
This page was last edited on Mon, 27 Jul 2020 18:41:33 +1000
296296
| 42E2
297297
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
298298
processed with

0 commit comments

Comments
 (0)
0