home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
No Fragments Archive 10: Diskmags
/
nf_archive_10.iso
/
MAGS
/
ST_USER
/
1990
/
USERNV90.MSA
/
TEXT_GEM.DOC
< prev
next >
Wrap
Text File
|
1990-05-24
|
4KB
|
80 lines
GEM
Roland Waddilove finishes off his examination of the
VDI with a quick look at some powerful functions
You'll be pleased to hear that we've almost finished our exploration on the
ST's virtual device interface, or VDI for short. This part of GEM contains
dozens of graphic functions that are used in all GEM programs and before you
can master GEM you must first unveil the VDI's mysteries. This month, in the
final part of this series, I'll be showing some of the functions we haven't yet
looked at. They're a mixed bunch, but they are important as we'll see.
One of the features of the ST that hits you right between the eyes the
first time you see the machine is the GUI - the graphic user interface. Windows
can be opened, resized, moved and closed simply by pointing and clicking with
the mouse.
We have looked at a vast number of VDI functions and these are the
functions used to draw text and graphics inside windows. The window's contents
never spill outside the borders because the operating system won't let it,
right? Wrong! Open a window, print some text then draw a few lines and you'l
see a horrible mess on the screen. What has gone wrong?
It's up to you - the programmer - to ensure that text and graphics stay
within the borders of the window and you can easily do this by setting a
clipping rectangle. You give the VDI the coordinates of a ractangle on the
screen and tell it that text and graphics must only appear within its borders -
anything outside must be "clipped off". (In a GEM application you would
calculate the borders of the window and pass the coordinates to the VDI as the
clipping rectangle. Then all output will be restricted to the window.
The function you need is:
short handle, clipflag,xyarray[4];
vs_clip(handle,clipflag,xyarray);
The 'handle' parameter is the good old VDI handle and the 'clipflag' is
either 1 to enable clipping or 0 to disable it. The 'xyarray' is an array
containing the coordinates of the top-left-hand corner and bottom-right-hand
corner of the clipping rectangle. So if you wanted to restrict all output to a
box in the centre of the screen you could use:
xyarray[0] = 220; /* top left x coordinate */
xyarray[1] = 50; /* top left y coordinate */
xyarray[2] = 420; /* bottom right x coordinate */
xyarray[3] = 150; /* bottom right y coordinate */
vs_clip(handle,1,xyarray);
A couple of graphic functions that we haven't yet looked at are circles and
ellipses. Both a fairly straightforward and are quite similar. Before you start
you'll need to set the writing mode, interior style, fill colour index, fill
perimeter visibility and user defined fill pattern (if necessary). We have
covered these functions before - they're the same ones that are used for
rectangles so I'll just give you a brief reminder what their syntax is:
vswr_mode(handle,mode); /* set writing mode */
vsf_interior(handle,style); /* set fill interior style */
vsf_style(handle,style); /* select pattern or hatch style */
vsf_color(handle,color); /* select fill colour */
vsf_perimeter(handle,flag); /* set perimeter visibility */
vsf_udpat(handle,fillpat,planes); /* set user defined fill pattern */
You don't have to set all these parameters before calling the circle and
ellipse drawing functions because the VDI usually defaults to sensible values,
but if you can't see anything onscreen, then try setting them.
The circle function is:
short handle, x, y, radius;
v_circle(handle, x, y, radius);
The ellipse function is equally simple:
short handle, x, y, xradius, yradius;
v_ellipse(handle, x, y, xradius, yradius);
The ellipse, of course, requires two radii (dig out your school maths
books). And that just about rounds off our look at the VDI. I haven't covered
all of the functions, just the most important ones. There are others, but
you'll rarely need them. Now let's see you put all this theory into practice. I
have given you a couple of dozen VDI functions so let's see who can supply
Atari ST User with the best demo. The wining entries will appear on a future
cover disk - fame and fortune awaits you do get cracking!