ARC PROCEDURE LIBRARY

Lee Calcraft completes the mouse selection procedures with routines to draw raised selection boxes.

By using the procedures supplied in the last two issues, it is an easy matter to create a customised selection screen for menus or whatever. The two procedures supplied this month can be used to replace PROCdrawgrid from last month so as to generate more stylish selection and display screens.

PROCdrawplinths

The first of this month's additions, PROCdrawplinths, is a direct replacement for PROCdrawgrid. It uses the same arrays to define its shape and position, and requires no alteration to FNgetboxno in order to detect user-selections made on the new block of plinths. The only difference is in the specification of the colours to be used. We now need five different colours to draw the plinths. These are catered for by extending the data arrays from 12 elements to 17.

These five colours are given in order of brightness, the middle colour being the colour of the main face of the plinth, with elements 13 and 14 providing highlights, and 16 and 17 providing shading.

In the accompanying example these have been set up in PROCinitcolours. The plinth-drawing procedure has been written in such a way as to work in both 16 and 256 colour modes without alteration. The example uses mode 12, and we must therefore define some suitable colours. This is performed in PROCinitpalette.

If you append the accompanying procedures to last month's program, and alter the lines indicated in the table, you will see the new screen display.

100 PROCinitialise:PROCinitpalette:PROCinitcolours
130 PROCdrawplinths(area1%(),"Fruits")
140 PROCdrawplinths(area2%(),"")
330 DIM area1%(17)
340 DIM area2%(17)

Alter these lines from last month's program.

When using 256 colour modes, you will not need to redefine the palette (so the reference to PROCinitpalette in line 100 should be removed) and a special conven-tion is used for specifying colour numbers. Each is made up by adding together the required colour and tint numbers. Thus for example, if you require colour 63 and tint 192 for a particular effect, place the number 63+192 (i.e. 255) in the appropriate array element.

To try this out in mode 15, delete the reference to PROCinitpallette in line 100, and use the following five colour numbers in PROCinitcolours: 63+192, 62+192, 57+192, 52, 0.

PROCplinth

The main procedure PROCdrawplinths calls PROCplinth, and although you do not need details of this procedure for drawing banks of selection plinths, it is very useful in its own right for drawing raised or sunken plinth objects of any dimension.

It will work in any graphics mode, and takes 11 parameters. The first 4 are the X and Y co-ordinates of the bottom left-hand corner of the object, and its width and height. The 5th is the depth of the plinth in graphics units. The next 5 parameters are colour numbers, exactly as described above. Finally the flag raised indicates whether the plinth is raised (TRUE) or sunken (FALSE).

When designing screens for specific applications, considerable care is needed in selecting sets of colours if good effects are to be achieved. To this end, you may find the Colour Selector in RISC User Volume 2 Issue 2 page 39 particularly useful for the 256-colour modes, while for the 16-colour modes, try the Screen Manager from Volume 1 Issue 5.

The collection of procedures and functions covered so far should make it easy to create sophisticated mouse-controlled selection screens for any program without the headaches implicit in the use of the WIMP. Next month we will be covering new topics.

1000 REM >Procs3
1010 :=================================
1020 DEFPROCinitcolours
1030 area1%(13)=7
1040 area1%(14)=13
1050 area1%(15)=14
1060 area1%(16)=15
1070 area1%(17)=0
1080 :
1090 area2%(13)=7
1100 area2%(14)=13
1110 area2%(15)=14
1120 area2%(16)=15
1130 area2%(17)=0
1140 ENDPROC
1150 :=================================
1160 DEFPROCinitpalette
1170 COLOUR 13,192,192,224
1180 COLOUR 14,148,148,180
1190 COLOUR 15,112,112,148
1200 ENDPROC
1210 :=================================
1220 DEFPROCdrawplinths(a%(),text$)
1230 REM Draws set of plinths
1240 LOCAL ix%,iy%,no%
1250 a%(6)=a%(2)*a%(4)
1260 a%(7)=a%(3)*a%(5)
1270 IF a%(0)=-1 THEN a%(0)=(1280-a%(6))DIV 2
1280 IF text$<>"" THEN PROCrestore(text$):VDU5
1290 FOR iy%=a%(1)+a%(7)-a%(3) TO a%(1)
STEP -a%(3)
1300 FOR ix%=a%(0) TO a%(0)+a%(6)-a%(2)
STEP a%(2)
1310 PROCplinth(ix%,iy%,a%(2),a%(3),8,a%(13),a%(14),a%(15),a%(16),a%(17),TRUE)
1320 IF text$<>"" THEN
1330 MOVE ix%+a%(11),iy%+a%(3)-a%(12)
1340 READ text$:GCOL a%(10):PRINTtext$
1350 ENDIF
1360 NEXT
1370 NEXT
1380 IF text$<>"" THEN VDU4:OFF
1390 ENDIF
1400 ENDPROC
1410 :=================================
1420 DEFPROCplinth(x,y,wx,wy,w,c0,c1,c2,c3,c4,raised)
1430 IF NOT raised THEN SWAP c1,c3
1440 GCOL c1 AND 63 TINT c1
1450 RECTANGLE FILL x,y,wx,wy
1460 GCOL c3 AND 63 TINT c3
1470 RECTANGLE FILL x+w,y,wx-2*w,w
1480 RECTANGLE FILL x+wx-w,y,w,wy-w
1490 MOVE x,y:MOVE x+w,y
1500 PLOT85,x+w,y+w:MOVE x+wx-w,y+wy-w
1510 MOVE x+wx,y+wy-w
1520 PLOT85,x+wx,y+wy:PLOT85,x+wx,y+wy
1530 IF NOT raised THEN SWAP c0,c4
1540 GCOL c0 AND 63 TINT c0
1550 LINE x,y+wy,x+w,y+wy-w
1560 GCOL c4 AND 63 TINT c4
1570 LINE x+wx,y,x+wx-w,y+w
1580 GCOL c2 AND 63 TINT c2
1590 RECTANGLE FILL x+w,y+w,wx-2*w,wy-2*w
1600 ENDPROC