-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05-07-windows.html
356 lines (284 loc) · 15.7 KB
/
05-07-windows.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<!doctype html>
<html lang="en">
<head>
<!--
This Amos Professional Manual is written by asymetrix for the Amiga community and should stay completely FREE FOREVER.
Created 2008. :)
It was created from the original AMOS Professional Manual by Europress Software Ltd.
It has been updated by Fredrik Rambris.
-->
<title>Windows - AMOS Professional Manual</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="keywords" content="Amos Professional, Amiga, Programming, Basic, Francois Lionet, Europress Software Ltd, Amos, computing, code, AmigaDOS">
<meta name="author" content="asymetrix,Fredrik Rambris">
<link rel="GitHub" href="https://github.com/fredrik-rambris/amospromanual">
<meta property="og:site_name" content="AMOS Professional Manual">
<meta property="og:image" content="https://amospromanual.dev/images/cover.jpg">
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="canonical" href="https://amospromanual.dev/05-07-windows.html">
</head>
<body>
<section>
<h1>Windows</h1>
<p>
The AMOS Professional programmer expects to be able to produce file selectors, warning boxes
and on-screen control panels with a few simple lines of code. The range of windowing
command featured in this Chapter allow you to create interactive dialogue boxes by restricting
text and graphics operations to selected areas of the current screen.</p>
<p>
A "window" is simply a rectangular display area, which must first be opened before electronic
life can course through it. Your current screen is treated as a window, and opened automatically
by the AMOS Professional system as window number zero. All other windows have to be
opened by you, and you are advised not to re-open window zero or change its size or position.</p>
</section>
<section id="01-creating-windows">
<h2>Creating windows</h2>
<h3 class="command" id="i-wind-open">WIND OPEN</h3>
<p><i>instruction: create a window</i><br>
<b>Wind Open</b> number,x,y,width,height<br>
<b>Wind Open</b> number,x,y,width,height,border</p>
<p>
The window opened by this instruction will be displayed on screen and used for all subsequent
text operation until you command otherwise. WIND OPEN must be qualified by a window
number (don't forget that zero has already been allocated to the current screen), followed by the
x,y graphic coordinates setting the top left-hand corner of the new window, followed by the
width and height of the new window in the number of characters needed. You may also specify
an optional border style, with values ranging from 1 to 16.</p>
<p>
Because the Amiga employs its blitter to draw windows, they must always lie on a 16-pixel
boundary. AMOS Professional automatically rounds your x-coordinates to the nearest multiple
of 16. Additionally, if you have specified a border for your window, the x and y-coordinates will
be incremented by an additional 8 pixels. In this way, you can be sure that your windows
always start at the correct screen boundary. There are no boundary restrictions on the y-
coordinates. Titles can also be included in window borders, which will be dealt with a little later.
Try this example:</p>
<code class="prefix edit">For W=1 To 3
Wind Open W,(W-1)*96,50,10,15,W
Paper W+3 : Pen W+6 : Clw
Print "Window";W
Next W
</code>
<h3 class="command" id="i-window">WINDOW</h3>
<p><i>instruction: change the current window</i><br>
<b>Window</b> number</p>
<p>This command sets the window number specified as the active window, to be used for all future
text operations. There is an automatic saving system for re-drawing the contents of windows,
which is explained below.</p>
For now, run the last example from Direct mode and enter the following statements:
<code class="prefix direct">Window 1: Print "AMOS"</code>
<br>
<code class="prefix direct">Window 3: Print "open windows on the world"</code>
<br>
<code class="prefix direct">Window 2: "lets me"</code>
<p>The active window is host to the flashing text cursor, unless it has been made invisible with a
CURS OFF command.</p>
<h3 class="command" id="i-border">BORDER</h3>
<p><i>instruction: change window border</i><br>
<b>Border</b> number,paper, pen</p>
<p>This command allows you to change the style and colour of the current window border. Border
style numbers range from 1 to 16, and the paper and pen colours can be selected from any
available colour index numbers. Any of these parameters can be omitted from the BORDER
instruction as long as the commas are included for any missing values: If the last example is still
on screen, enter these lines from direct mode:</p>
<code class="prefix direct">Border 3,2,3</code>
<br>
<code class="prefix direct">Border 2,,</code>
<h3 class="command" id="i-title-top">TITLE TOP</h3>
<p><i>instruction: set title at top of current window</i><br>
<b>Title Top</b> title$</p>
<p>Use this command to set a border title at the top of the current window to your chosen title
string. This facility will only operate with bordered windows, as follows:</p>
<code class="prefix edit">Cls: Wind Open 4,1,1,20,10,1
Title Top "Top of the morning"
</code>
<h3 class="command" id="i-title-bottom">TITLE BOTTOM</h3>
<p><i>instruction: set title at bottom of current window</i><br>
<b>Title Bottom</b> title$</p>
<p>Similarly, this instruction assigns a string to the bottom title of the current window, like this:</p>
<code class="prefix edit">Cls : Wind Open 5,75,50,24,15
Border 5,6,
Title Bottom "Bottom of the barrel"
</code>
</section>
<section id="02-manipulating-windows">
<h2>Manipulating windows</h2>
<h3 class="command" id="fn-windon">WINDON</h3>
<p><i>function: return the value of the current window</i><br>
w=<b>Windon</b></p>
<p>Before using windows in your programs, you will need to refer to their identification numbers.
This function returns the value of the current window. For example:</p>
<code class="prefix edit">Do
Cls : Wind Open Rnd(99)+1,1,1,25,5,1
Print "Window number ";Windon : Wait Key
Loop
</code>
<h3 class="command" id="i-wind-save">WIND SAVE</h3>
<p><i>instruction: save the contents of the current window</i><br>
<b>Wind Save</b></p>
<p>
This command is extremely valuable for the AMOS Professional programmer. Once activated,
the WIND SAVE feature allows you to move your windows anywhere on screen without
corrupting the existing display, by the following method. The contents of the current window is
saved as soon as the command is used, and then every time a new window is opened, the
contents of the windows underneath get saved automatically. The screen is then re-drawn
whenever a window is moved to a new position or closed.</p>
<p>
As you begin a new program, the current window (the default screen) consumes 32k of valuable
memory, and this would be wasted if you were to save it as background beneath a small
dialogue box. To solve this problem, create a dummy window of the size you need, and place it
over the zone you want to save. Now execute your WIND SAVE command and continue with
your program. When this dialogue box is called up, the area beneath it will be saved as part of
your dummy window, so it will automatically be restored after your box has been removed.</p>
<h3 class="command" id="i-wind-close">WIND CLOSE</h3>
<p><i>instruction: close the current window</i><br>
<b>Wind Close</b></p>
<p>
The WIND CLOSE command deletes the current window. If the WIND SAVE command has
been activated, the deleted window will be replaced by the saved graphics, otherwise the area
will be totally erased from the screen. Here is an example:</p>
<code class="prefix edit">Wind Open 1,1,8,35,18,1 : Print "Press a key to close this window"
Wait Key
Wind Close
</code>
<h3 class="command" id="i-wind-move">WIND MOVE</h3>
<p><i>instruction: move the current window</i><br>
<b>Wind Move</b> x,y</p>
<p>
The current window can 'be moved to any acceptable graphic coordinates. Give the new x,y-
coordinates after the WIND MOVE command, and the x-coordinate will be rounded to the
nearest 16-pixel boundary automatically. Here is an example:</p>
<code class="prefix edit">Wind Save : Wind Open 1,0,2,30,10,1 : Wind Save
For M=1 To 100
Pen Rnd(15) : Paper Rnd(15) : Print : Centre "Making Movies"
Wind Move Rnd(30)+1,Rnd(100)+1
Wait VbI
Next M
</code>
<p>
<b>SCROLL ON/OFF</b><br>
<i>instructions: toggle window scrolling on and off</i><br>
<b>Scroll On</b><br>
<b>Scroll Off</b></p>
<p>
The SCROLL commands are used to control the scrolling of the current window. SCROLL OFF
turns off the scrolling, and whenever the cursor passes beyond the bottom of the window it will
reappear from the top. SCROLL ON starts the scrolling process again, so that a new line is
inserted when the cursor tries to pass beyond the bottom of the window.</p>
<h3 class="command" id="i-wind-size">WIND SIZE</h3>
<p><i>instruction: change the size of the current window</i><br>
<b>Wind Size</b> width, height</p>
<p>
To change the size of the current window, specify the new width and new height in terms of the
number of characters. If WIND SAVE has been activated, the original contents of the window
will be re-drawn by this instruction. If the new window size is smaller than the original, any
parts of the original image that lie outside of the new window boundaries will be lost.
Alternatively, if the new window is larger, the space around the saved area will be filled with
the current paper colour. Please note that the text cursor is always re-set to coordinates 0,0.
For example:</p>
<code class="prefix edit">Wind Open 1,16,16,22,10,2
Print "I want to be wider!"
Wind Save
Wait 50
Wind Size 30,10
</code>
<h3 class="command" id="i-clw">CLW</h3>
<p><i>instruction: clear the current window</i><br>
<b>Clw</b></p>
<p>This simple command erases the contents of the current window and replaces it with a block of
the current PAPER colour.</p>
<p>Like this:</p>
<code class="prefix edit">Cls: Paper 4 : Wind Open 1,1,1,12,5,1
Window 1: Print "Clear Off" : Wait 75
Paper 9 : Clw
</code>
</section>
<section id="03-creating-slider-bars">
<h2>Creating slider bars</h2>
<p>One of the standard uses of windows is to create interactive slider bars, like the one at the right-
hand side of your AMOS Professional Edit Screen.</p>
<h3 class="command" id="i-hslider">HSLIDER</h3>
<p><i>instruction: draw a horizontal slider bar</i><br>
<b>Hslider</b> x1 ,y1 To x2,y2, units, position, length</p>
<p>
Horizontal slider bars are set up by giving the HSLIDER command, qualified by the following
parameters: the x,y-coordinates of the top left-hand corner of the bar in pixels followed by the
x,y-coordinates of the bottom right-hand corner, then the number of individual units that the
slider is divided into. Next, you must specify the position of the active slider box or control
button from the left-hand end of the slider, measured in the same sized units as the slider
divisions. Finally, give the length of the slider control box in these units. The size of each unit is
calculated with this formula:</p>
<code class="prefix edit">Hslider 10,10 To 100,20,100,20,5
Hslider 10,50 To 150,100,25,10,10
</code>
<h3 class="command" id="i-vslider">VSLIDER</h3>
<p><i>instruction: draw a vertical slider</i><br>
<b>Vslider</b> x1 ,y1 To x2,y2,units,position,length</p>
<p>This works in the same way as Hslider, and sets up vertical slider bars. For a working
demonstration, examine the vertical slider in the Editor window, where the number of units into
which the slider is divided is set to the number of lines in the current program.</p>
<p>Here is a simpler example:</p>
<code class="prefix edit">Vslider 10,10 To 20,100,100,20,5
Vslider 250,0 To 319,199,10,2,6
</code>
<h3 class="command" id="i-set-slider">SET SLIDER</h3>
<p><i>instruction: set fill pattern for slider bar</i><br>
<b>Set Slider</b> ink1,paper1,outline1,pattern1,ink2,paper2,outline2,pattern2</p>
<p>SET SLIDER is used to set up the colours and patterns used for your slider bars and their
control boxes.</p>
<p>Simply give the index numbers of the ink, paper, outline and pattern to be used for the slider
bar, followed by the ink paper, outline and pattern to be used by the slider control box. If
negative values are used for either pattern, a sprite image will be commandeered from the sprite
bank, allowing even more spectacular effects. Try this example:</p>
<code class="prefix edit">Centre "<Press a key>" : Curs Off
Do
A1=Rnd(15) : B1=Rnd(15) : C1=Rnd(15) : D1=Rnd(24)
A2=Rnd(15) : B2=Rnd(15) : C2=Rnd(15) : D2=Rnd(24)
Set Slider Al ,B1,C1,D1,A2,B2,C2,D2
Hslider 10,10 To 300,60,100,20,25
Vslider 10,60 To 20,190,100,20,25
Wait Key
Loop
</code>
<p>Having set up your slider bars, you will want to activate them using the mouse. A simple routine
to create working slider bars needs to be included in your main program. As always, remember
to test out the ready-made example programs, for a working guide.</p>
</section>
<section id="04-displaying-a-text-window">
<h2>Displaying a text window</h2>
<p>To end this Chapter, here is an extremely useful AMOS Professional feature that allows the
display of a text file directly on screen. Text can be displayed in its own independent screen, it
may be scrolled through at will, the display window can be dragged around the screen and
there is even a facility to include a title line.</p>
<h3 class="command" id="i-read-text-dollar">READ TEXT$</h3>
<p><i>instruction: display a text window on screen</i><br>
<b>Read Text$</b> name$<br>
<b>Read Text$</b> name$,address, length</p>
<p>
In its simplest form, the READ TEXT$ command reads the text held in a specified filename on
disc, for example:</p>
<code class="prefix ex">Read Text$ Fsel$("**")</code>
<p>
You can move through the displayed text using scroll bars, the arrow icons or via the following
key combinations:</p>
<pre>
<b>Key Press Effect</b>
<kbd>Up Arrow</kbd>/<kbd>Down Arrow</kbd> Move up/down by one line
<kbd>Shift</kbd>+<kbd>Up Arrow</kbd>/<kbd>Down Arrow</kbd> Scroll up/down by one page
<kbd>Ctrl</kbd>+<kbd>Up Arrow</kbd>/<kbd>Down Arrow</kbd> Jump directly to top/bottom of text
<kbd>Esc</kbd> or <kbd>Return</kbd> Exit
</pre>
<p>To read some text from an address in memory, there is an alternative version of the READ
TEXT$ command. In this case the name$ parameter refers to a <b>title</b> line that will be printed at
the top of the viewing window. Address holds the address of the first line of the text to be read.
Length specifies the length of the text to be read, in bytes.</p>
</section>
<footer>
<a href="05-06-text.html" rel="prev">Text</a>
<a href="./">Contents</a>
<a href="14-appendix-g-command-index.html">Index</a>
<a href="05-08-the-joystick-and-mouse.html" rel="next">The Joystick and Mouse</a>
</footer>
</body>
</html>