Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / HTML / iuwgraf4.htm
1 <html>\r
2 <HEAD><TITLE>iiuwgraph</TITLE>\r
3 </HEAD>\r
4 <body>\r
5 <H1 align=center>unit IIUWGRAPH: class;</H1>\r
6 <H2 align=center><IMG SRC="loglanmm.gif" ALT="LOGLAN's LOGO"></IMG>a predefined Loglan'82 class </H2>\r
7 \r
8 {    this predefined class enables basic graphic operations\r
9      for DOS machines based on <B>486</B> or 386 processors \r
10 }<P>\r
11 \r
12 {this document gives the specification of new version of IIUWGRAPH \r
13         class<BR>\r
14  made in October 1994 by <B><I>Frederic Pataud </I></B>à Pau}<P>\r
15 <HR>\r
16 <A NAME="Table of Contents"><B>Table of Contents</B></A>.<BR>\r
17 \r
18 <DIR>\r
19 <li> {IIUWGRAPH class}\r
20 <ul>\r
21 <li> {PROCEDURES of OVERALL CONTROL}\r
22 <ul>\r
23 <LI>unit <A HREF = "#GRON">GRON</A> : procedure (i: integer);\r
24 <LI>unit    <A HREF = "#GROFF">GROFF</A> : procedure;\r
25 <LI>unit    <A HREF = "#CLS">CLS</A> : procedure;\r
26 <LI>unit    <A HREF = "#COLOR">COLOR</A> : procedure(co : integer);\r
27 <LI>unit    <A HREF = "#STYLE">STYLE</A> : procedure(styl : integer);\r
28 <LI>unit    <A HREF = "#BORDER">BORDER</A> : procedure (background_Colour: integer);\r
29 <LI>unit    <A HREF = "#PALLET">PALLET</A> : procedure (nr : integer);\r
30 </ul>\r
31 <LI>{ PROCEDURES CONTROLLING POSITION }\r
32 <ul>\r
33 <LI>unit    <A HREF = "#MOVE">MOVE</A> : procedure (x,y :integer);\r
34 <LI>unit    <A HREF = "#INXPOS">INXPOS</A> : function: integer;\r
35 <LI>unit    <A HREF = "#INYPOS">INYPOS</A> : function : integer;\r
36 <LI>unit    <A HREF = "#PUSHXY">PUSHXY</A> : procedure;\r
37 <LI>unit    <A HREF = "#POPXY">POPXY</A>: procedure;\r
38 </ul>\r
39 <LI>{ PROCEDURES SERVING POINTS and LINES}\r
40 <ul>\r
41 <LI>unit    <A HREF = "#POINT">POINT</A> : procedure(x,y: integer);\r
42 <LI>unit    <A HREF = "#INPIX">INPIX</A> : function (x,y : integer) : integer;\r
43 <LI>unit    <A HREF = "#DRAW">DRAW</A> : procedure( x,y : integer);\r
44 <LI>unit    <A HREF = "#intens">intens</A>: procedure(Size :integer; xCoord,yCoord:arrayof integer, \r
45 Colour,Filled :integer);\r
46 <li>unit <a href="#CIRB">cirb </a> {draw a circle} procedure;\r
47 <LI>unit    <A HREF = "#HFILL">hfill</A>: procedure( x : integer);\r
48 <LI>unit    <A HREF = "#VFILL">vfill</A>: procedure( y : integer);\r
49 <LI>unit    <A HREF = "#PATERN">patern</A>: procedure( x1,y1,x2,y2,c,b : integer);\r
50 </ul>\r
51 <LI>{ Procedures operating on bitmaps }\r
52 <ul>\r
53 <LI>unit    <A HREF = "#GETMAP">GETMAP </A> : function (x,y : integer) : arrayof integer;\r
54 <LI>unit    <A HREF = "#PUTMAP">PUTMAP </A> : procedure ( a: arrayof integer);\r
55 <LI>unit    <A HREF = "#ORMAP">ORMAP </A> : procedure ( a : arrayof integer);\r
56 <LI>unit    <A HREF = "#XORMAP">XORMAP </A> : procedure ( a: arrayof integer);\r
57 </ul>\r
58 <LI>{Procedures operating on characters and strings}\r
59 <ul>\r
60 <LI>unit    <A HREF = "#outstring">outstring</A>: procedure(x,y: integer, s: string, back_col, front_col: \r
61   integer);\r
62 <LI>unit     <A HREF = "#track">track</A>: procedure( x,y,c,valeur : integer);\r
63 <LI>unit    <A HREF = "#inkey">inkey </A> : function : integer;\r
64 <LI>unit    <A HREF = "#HASCII">HASCII </A> : procedure(c: integer);\r
65 <LI>unit    <A HREF = "#hfont">hfont</A>: function( x,y,lg,min,max,default,col_f,col_e,col_c : integer):                    \r
66    integer;\r
67 <LI>unit    <A HREF = "#HPAGE">HPAGE </A> : procedure(x,y,long: integer, A: arrayof char, back, front: \r
68   integer);\r
69 </ul>\r
70 </ul>\r
71 \r
72 <LI>unit    <A HREF = "#MOUSE">MOUSE</A>: class;\r
73 <ul>\r
74 <LI>unit    <A HREF = "#init">init</A>: procedure(checkMouse, checkKeyboard: integer);\r
75 <LI>unit    <A HREF = "#getmovement">getmovement</A>: procedure(checkMouse, checkKeyboard: \r
76    integer);\r
77 <LI>unit    <A HREF = "#getpress">getpress</A>: function(v,p,h,l,r,c : integer): Boolean;\r
78 <LI>unit    <A HREF = "#showcursor">showcursor</A>: procedure;\r
79 <LI>unit    <A HREF = "#hidecursor">hidecursor</A>: procedure;\r
80 </ul>\r
81 <LI>   a sample<A HREF = "#sample program"> program</A>\r
82 </dir>\r
83 \r
84 <HR>\r
85 \r
86 \r
87 \r
88 {    the early versions of library IIUWGRAPH have been elaborated by \r
89        Piotr Carlsson, Miroslawa Milkowska, Janina Jankowska, \r
90        Michal Jankowski  at  Institute of Informatics, \r
91        University of Warsaw 1987,<P>\r
92        and added to Loglan system by Danuta Szczepanska 1987, <P>\r
93  \r
94        the recent versions were done at LITA, Pau,<P>\r
95        by<P>\r
96        Pawel Susicki  (1991) for Unix,<P>\r
97        Sebastien Bernard (1992) for ATARI, see a separate document,<BR>\r
98        Eric Becourt et Jerôme Larrieu (1993) for Unix and Xwindows, see a \r
99         separate document on Xiiuwgraf ,\r
100  <P>\r
101  \r
102 <P>\r
103 fait à Pau, le 15 Novembre 1994,  par Andrzej Salwicki, LITA}<P>\r
104 \r
105 { the predefined class IIUWGRAPH is included in all versions of interpreter of \r
106 Loglan, with the <I>exception</I> of the present version of interpreter for \r
107 VAX/VMS.}<P>\r
108 <HR> \r
109 <P>\r
110 <PRE>\r
111 <b>unit</b> IIUWGRAPH: <b>class</b>;\r
112 <B>   hidden</B>   MaxX, MaxY,  current_X, current_Y, is_graphic_On,       \r
113               current_Colour, current_Background_Colour,  current_Style, \r
114               current_Palette,  current_Pattern ; \r
115 \r
116 \r
117                 \r
118 <B>   const</B>  MaxX =            \r
119           MaxY =            \r
120 \r
121 {    the screen's coordinates are \r
122         \r
123        (0,0)   ----------------------&gt   (MaxX,0) \r
124            ¦ \r
125            ¦ \r
126            ¦ \r
127           V \r
128        (0, MaxY)                            (MaxX,MaxY) \r
129 \r
130 }\r
131  \r
132 \r
133 <B>   var</B>  currentDriver : integer,                     { see NOCARD below }  \r
134           current_X, current_Y:  integer         { it is the current position } \r
135           is_graphic_On:  Boolean,         { evidently tells whether we are in                  \r
136                         graphics mode } \r
137           current_Colour : integer,             { } \r
138           current_Background_Colour : integer, \r
139           current_Style : integer,              { } \r
140           current_Palette : integer, \r
141           current_Pattern  \r
142 </PRE>\r
143 \r
144 <H2><B>unit </B> <A \r
145 NAME="GRON"> GRON </A> <B> procedure </B> \r
146 (i: integer);</H2>\r
147       {  procedure sets the monitor in graphic mode and clears the  buffer \r
148         of screen. The parameter determines the resolution and the number of \r
149         colours.<BR>\r
150 The user should assure that the resolution chosen should correspond to that \r
151 which is set by means of command <BR>\r
152 SET go32 drivers {path}&lt driver.file&gt  &lt width&gt  &lt height&gt &lt \r
153 noColours&gt \r
154 eg.<BR>\r
155 set go32 drivers c:\loglan\svga\drivers\vesa.grn gw 1024 gh 480 nc 256<BR>\r
156 <P>    An execution of instruction call gron(i) <B><I>must precede</I> \r
157 </B> any of the graphic commands described below.<P>\r
158 <PRE>\r
159 case (i)\r
160   {\r
161   0 : 640x480x16\r
162   1 : 640x480x256\r
163   2 : 800x600x16\r
164   3 : 800x600x256\r
165   4 : 1024x768x16\r
166   5 : 1024x768x256\r
167   6 : 1280x1024x16\r
168   7 : 1280x1024x256\r
169   8 : 1600x1280x16\r
170   9 : 1600x1280x256\r
171  }\r
172 </PRE>       }\r
173 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
174 \r
175 <H2><B>unit</B> <A \r
176 NAME="GROFF"> GROFF </A><B> procedure</B\r
177 >;</H2>\r
178       {  the procedure sets the monitor in the text mode filling it with \r
179         spaces.<P>\r
180          DO NOT FORGET to set the monitor in the text mode before \r
181 you terminate  your program<P>\r
182        }<P>\r
183 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
184 \r
185 \r
186 <H2><B>unit</B> <A NAME="CLS"> CLS </A>  . \r
187 : <B> procedure</B>;</H2>\r
188        { the screen will be cleared and filled with colour 0  }<P>\r
189 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
190 \r
191 \r
192 \r
193 { PROCEDURES  CONTROLLING THE COLOURS }<P>\r
194 \r
195 <H2><B>unit </B> <A \r
196 NAME="COLOR"> COLOR </A>  . : \r
197 <B> procedure</B>(co : integer);</H2>\r
198 {               sets current color to co <BR>\r
199         for monochrome displays, 0 means black, non-0 - white<BR>\r
200         for color displays, 0 means background<BR>\r
201      see PALLET<P>\r
202 }      <P>\r
203 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
204 \r
205 <H2><B>unit </B> <A \r
206 NAME="STYLE"> STYLE </A>   : \r
207 <B> procedure</B>(styl : integer);</H2>\r
208 {       sets style of lines and fill shades to a combination<P>\r
209         of current color and background color (for mono -<P>\r
210         white and black, respectively) according to 5 predefined<P>\r
211         patterns:<P>\r
212 <PRE>\r
213                 0       ....\r
214                 1       ****\r
215                 2       ***.\r
216                 3       **..\r
217                 4       *.*.\r
218                 5       *...\r
219 </PRE>\r
220         where   '*' means current color,  '.' background colour<P>\r
221 When drawing the segments the subsequent pixels will have colour determined \r
222 by cyclic application of style pattern. The first and the last pixels of a segment \r
223 will have always current colour.<P>\r
224 When filling contours the given style will be applied to horizontal lines with even \r
225 coordinate. The style for odd lines is determined automatically.<P>\r
226 The same applies for perpendicular lines.<P>\r
227 }\r
228 <P>\r
229 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
230 \r
231 <H2><B>unit </B> <A \r
232 NAME="BORDER"> BORDER </A>  . : \r
233 <B>procedure</B> (background_Colour: \r
234 integer);</H2>\r
235         \r
236 <P>     {  sets actual background color to i  ( i = 0,1,...,15 )  }<P>\r
237 \r
238 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
239 \r
240 <H2><B>unit </B> <A \r
241 NAME="PALLET"> PALLET </A>   : \r
242 <B>procedure</B> (nr : integer);</H2>\r
243         {the following line makes an example, it is not valid for, say,\r
244 256 colours\r
245 <P>\r
246 the codes of colors are <I>usually i.e. when you have 16 colours,</I> as follows<P>\r
247                 0       black<P>\r
248                 1       blue dark<P>\r
249                 2       green dark<P>\r
250                 3       turquoise dark<P>\r
251                 4       red dark<P>\r
252                 5       violet<P>\r
253                 6       brown<P>\r
254                 7       grey light<P>\r
255                 8       grey dark        <P>\r
256                 9       blue<P>\r
257                 10      green<P>\r
258                 11      turquoise<P>\r
259                 12      red light<P>\r
260                 13      rose<P>\r
261                 14      yellow<P>\r
262                 15      white<P>\r
263   \r
264 <P>      }<P>\r
265 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
266 \r
267 \r
268 \r
269 <H2>{ PROCEDURES CONTROLLING POSITION }</H2>\r
270 \r
271 <H2><B>unit </B> <A \r
272 NAME="MOVE">MOVE</A>  : \r
273 <B>procedure</B> (x,y :integer);</H2>\r
274         { procedure MOVE sets the current position on the screen on the pixel \r
275         with coordinates<P>\r
276              x  - column,<P>\r
277              y - line   }<P>\r
278          { precondition of  MOVE:<P>\r
279                  0*x*MaxX  &amp  0*y*MaxY <P>\r
280           }<P>\r
281 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
282 \r
283 <H2><B>unit </B> <A \r
284 NAME="INXPOS">INXPOS</A>  : \r
285 <B>function</B>: integer;</H2>\r
286        { function INXPOS returns the x coordinate of the current position }<P>\r
287 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
288 \r
289 \r
290 <H2><B>unit </B> <A \r
291 NAME="INYPOS">INYPOS</A>   : \r
292 <B>function</B> : integer;</H2>\r
293         { function INYPOS returns the y coordinate of the current position }<P>\r
294 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
295 \r
296 \r
297 <H2><B>unit </B> <A \r
298 NAME="PUSHXY">PUSHXY</A>  : \r
299 <B>procedure</B>;</H2>\r
300 {       pushes current position, color &amp  style onto the stack.<P>\r
301         The stack is kept internally, max depth is 16<P>\r
302 }\r
303 <P>\r
304 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
305 \r
306 <H2><B>unit  </B><A \r
307 NAME="POPXY">POPXY</A>  : \r
308 <B>procedure</B>;</H2>\r
309 \r
310 {       restores position, color &amp  style from internal stack   }<P>\r
311 \r
312 { Example<P>\r
313 <PRE>unit  DIAGONAL : procedure;<P>\r
314     var ix, iy : integer;<P>\r
315 begin<P>\r
316         call PUSHXY;<P>\r
317         ix := INXPOS;<P>\r
318         iy := INYPOS;<P>\r
319         call DRAW(ix+10, iy+10);<P>\r
320         call POPXY<P>\r
321 end DIAGONAL;<P>\r
322 </PRE>}\r
323 <P>\r
324 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
325 \r
326 \r
327 <H2>{ PROCEDURES SERVING POINTS &amp  \r
328 LINES}</H2>\r
329 \r
330 <H2><B>unit </B> <A \r
331 NAME="POINT">POINT</A>  : \r
332 <B>procedure</B>(x,y: integer);</H2>\r
333 {               moves current position to pixel (x,y) and sets it to the current color \r
334 <P>\r
335  }<P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
336 \r
337 <P>\r
338 <H2><B>unit </B> <A \r
339 NAME="INPIX">INPIX</A>   : <B>function</B> \r
340 (x,y : integer) : integer;</H2>\r
341         {       <P>\r
342                 moves to pixel (x,y) and returns its color setting;<P>\r
343         }\r
344 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
345 <P>\r
346 \r
347 <H2><B>unit </B> <A \r
348 NAME="DRAW">DRAW</A>  : \r
349 <B>procedure</B>( x,y : integer);</H2>\r
350         {   <P>\r
351         draws a line from current screen position to (<I>x,y</I>);<P>\r
352         sets current position to (<I>x,y</I>);<P>\r
353         line is drawn in current color, with both terminal pixels<P>\r
354         always turned white ( non-background) for non-black<P>\r
355         ( non-background ) line color.<P>\r
356         }\r
357 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
358 <P>\r
359 <H2><B>unit </B> <A \r
360 NAME="intens">intens</A>  : \r
361 <B>procedure</B>(Size :integer; \r
362 xCoord,yCoord:arrayof integer, Colour,Filled \r
363 :integer);</H2>\r
364  \r
365 /* draw a polygon*/\r
366 { draw a simple, closed polygon of Size points, the edges of the polygon go from \r
367 (<I>xCoord[i], yCoord[i]</I>) to (<I>xCoord[i+1], yCoord[i+1]</I>) for i = 1, ..., Size-1\r
368 The colour used will be <I>Colour</I>. The polygon will be filled iff <I>Filled</I>&lt \r
369 &gt 0.\r
370 }<P>\r
371 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
372 <BR><P>\r
373 <H2><B>unit  </B><A NAME="CIRB"> CIRB</A>  : <B>procedure</B> (xi, yi, rx,ry : integer, alfa, beta : real, \r
374 cbord, fill : integer);<P></H2>\r
375 \r
376 \r
377         {\r
378 <P>     draws a circle (or ellipse, depending on aspect value, see below),<P>\r
379         optionally filling its interior; <P>\r
380         does not preserve position;<P>\r
381         (<I>xi,yi</I>) -  are center coordinates,<P>\r
382         <I>rx</I> - radius in pixels (horizontally),<BR>\r
383         <I>ry</I> - radius in pixels (perpendicularly),<P>\r
384         <I>alfa, beta</I> - starting &amp  ending angles; if alfa=beta a full<P>\r
385                circle is drawn; values should be given in radians;<P>\r
386         <I>cbord</I> - border color,<P>\r
387         <I>fill</I> - if fill &lt &gt 0, interior is filled in current style&amp color<P>\r
388         }\r
389 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
390 <P>\r
391 <H2><B>unit </B> <A NAME="hfill">hfill</A>  : \r
392 <B>procedure</B>( x : integer);</H2>\r
393         {  draw an horizontal line between the current position and<P>\r
394         (x,currentY) with the current color, after it change the current<P>\r
395         position to (x, currentY)<P>\r
396         }<P>\r
397 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
398 \r
399 <H2><B>unit  </B><A NAME="vfill">vfill</A>  : \r
400 <B>procedure</B>( y : integer);</H2>\r
401        {   draw a vertical line between the current position and<P>\r
402         (currentX,y) with the current color, after it change the current<P>\r
403         position to (currentX,y)<P>\r
404        }<P>\r
405 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
406 \r
407 <H2><B>unit </B> <A \r
408 NAME="patern">patern</A>  : \r
409 <B>procedure</B>( x1,y1,x2,y2,c,b : \r
410 integer);</H2>\r
411       {    draw a <B><I>rectangle</I></B> between the points (<I>x1,y1</I>) and \r
412 (<I>x2</I>,<I>y2</I>) with the<P>\r
413         color <I>c</I> (the current color is not change). if <I>b</I>=0 then the box \r
414 is<P>\r
415         empty else it is filled.<P>\r
416        }<P>\r
417 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
418 \r
419 <H2>{ Procedures operating on bitmaps }</H2>\r
420 \r
421 <H2><B>unit </B> <A \r
422 NAME="GETMAP">GETMAP</A>   : \r
423 <B>function</B> (x,y : integer) : <B>arrayof</B> \r
424 integer;</H2>\r
425                 {saves rectangular area between current position as<P>\r
426         top left corner and (ix,iy) as bottom right corner,<P>\r
427         including border lines;<P>\r
428         position remains unchanged.<P>\r
429         array of integer should have  <P>\r
430                 4+(rows**columns/8* *coeff)<P>\r
431         bytes. The coefficient coeff is 1 for Hercules, 2 for CGA, 4 for EGA<P>\r
432         card.<P>\r
433          ATTENTION: in DOS 286 environment a bigger size of the array may \r
434         necessitate the use of <I>loglan</I> with<I> the option H+</I>, see also \r
435 memavail <P>\r
436            }<P>\r
437 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
438 \r
439 <H2><B>unit </B> <A \r
440 NAME="PUTMAP">PUTMAP</A>   : \r
441 <B>procedure</B> ( a: <B>arrayof</B> \r
442 integer);</H2>\r
443         {sets rectangular area of screen pixels to that saved<P>\r
444         by "getmap" in "iarray";<P>\r
445         same size is restored, with top left corner in current<P>\r
446         position;<P>\r
447         position remains unchanged.<P>\r
448         }\r
449 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
450 <P>\r
451 <H2><B>unit </B> <A \r
452 NAME="ORMAP">ORMAP</A>   : \r
453 <B>procedure</B> ( a : <B>arrayof \r
454 </B>integer);</H2>\r
455         {same as putmap, but saved bitmap is or'ed into screen<P>\r
456         rather than just set.<P>\r
457         }\r
458 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
459 <P>\r
460 <H2><B>unit </B> <A NAME="XORMAP">XORMAP </A>  : \r
461 <B>procedure</B> ( a: \r
462 <B>arrayof</B> integer);</H2>\r
463         {same as putmap, but saved bitmap is xor'ed into screen<P>\r
464         rather than just set.<P>\r
465         }\r
466 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
467 <P>\r
468 \r
469 <H2>{Procedures operating on characters and strings}</H2>\r
470 \r
471 <H2><B>unit </B> <A \r
472 NAME="outstring">outstring</A>  : \r
473 <B>procedure</B>(x,y: integer, s: string, back_col, \r
474 front_col: integer);</H2>\r
475    { <I>x, y</I> are the coordinates where to put the string,<P>\r
476       <I>s</I>     is the string to be shown, in <I>front_col</I> colour letters on the \r
477 <I>back_col</I>         colour background<P>\r
478     }<P>\r
479 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
480 \r
481 <H2><B>unit  </B> <A NAME="track">track</A>  \r
482 : <B>procedure</B>( x,y,c,valeur : integer);\r
483 </H2>\r
484    {    write an integer value <I>valeur</I> at the position (<I>x,y</I>) with the \r
485 color <I>c</I>.\r
486          It does not change the current position nor the current color<P>\r
487    }<P>\r
488 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
489 \r
490 <H2><B>unit </B> <A NAME="inkey ">inkey \r
491 </A>  : <B>function</B> : integer;</H2>\r
492 \r
493     {     returns next character from keyboard buffer;<P>\r
494         0 is returned if buffer is empty;<P>\r
495         special keys are returned as negative numbers;<P>\r
496         ALT-NUM method may be used for entering character codes<P>\r
497         above 127 (this makes entering special keys 128-132<P>\r
498         impossible);<P>\r
499         if a character is returned, it is also removed<P>\r
500         from the buffer, so MS-DOS will not see it (CTRL-C!);<P>\r
501         typeahead is allowed, echo is suppressed.<P>\r
502    }<P>\r
503 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
504 \r
505 <H2><B>unit </B> <A NAME="HASCII \r
506 ">HASCII </A>  : <B>procedure</B>(c: \r
507 integer);</H2>\r
508         {'xor's the character = chr(c) in a 8*8 box with top left corner<P>\r
509         in the current position;<P>\r
510         moves current position by (8,0);<P>\r
511         call hascii(0)- sets complete box to black ( =background ),<P>\r
512         with no change in position.<P>\r
513 }\r
514 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
515 <P>\r
516 \r
517 \r
518 <H2><B>unit  </B><A NAME="hfont">hfont</A>  \r
519 : <B>function</B>( \r
520 x,y,lg,min,max,default,col_f,col_e,col_c : integer):    \r
521                                                                           integer;</H2>\r
522 \r
523         {       arrange a small 1 line window for <B><I>reading</I></B> an integer value \r
524 from this window,\r
525 the position of the window corner is (<I>x, y</I>),\r
526 the length of the window is <I>lg</I> characters,\r
527 the value v should be greater than <I>min</I> and smaller than <I>max</I>,\r
528 the default value read is <I>default</I>,<P>\r
529 the colour of the window is <I>col_f</I>,<BR>\r
530 the colour of the digits is <I>col_e,</I><BR>\r
531 the colour of cursor is <I>col_c</I><P>\r
532 \r
533  reads in graphic mode an integer in the window which begins at the (x,y)\r
534         position, window is lg caracteres long. the maximum length of the<P>\r
535         integer that is read is 10. there is a default value, a minimum value\r
536         and a maximum value. the window is drawn with the col_f color, the  \r
537         cursor is in the col_c color and the integer is writing in the col_e<P>\r
538         color. you can use 0..9,+,-,backspace,escape and return keys. }<P>\r
539 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
540 \r
541 \r
542 <H2><B>unit </B> <A NAME="HPAGE">HPAGE </A>  : <B>procedure</B>(x,y,long: \r
543 integer, A: arrayof char, back, front: integer);</H2>\r
544         { this procedure arranges a 1-line high window in position <I>x,y</I> of \r
545 length  <I>long</I> in which a portion of text <I>A</I> is shown in colour \r
546 <I>front</I> on the     background colour <I>back</I>. <P>\r
547         Making use of  keys controlling the cursor {left, right, PgUp, PgDn}<P>\r
548         the user can scroll the text (horizontally) in the window. Pressing the \r
549         Enter key terminates the procedure}         <P>\r
550 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
551 \r
552 <P align=left><B>end</B> IIUWGRAPH;<P>\r
553 \r
554 \r
555 \r
556 <HR>\r
557 <P><H2><B>unit </B> <A NAME="MOUSE">MOUSE</A>  .: \r
558 <B>class</B>; </H2>\r
559     <P><HR>\r
560 <H6>{   <I>init</I> -lors de l'initialisation de la souris, on peut définir les événements qui vont faire réagir la \r
561 fonction getpress; le premier et le deuxième paramètre représentent respectivement la souris et le clavier, si une \r
562 valeur non nulle est donnée comme paramètre alors getpress réagira à l'événement.<P>\r
563 \r
564         Une paire (1,1) va permettre de prendre en compte à la fois les événements de la souris et ceux du clavier; \r
565 une paire (1,0) quand à elle ne prendra en compte que la souris. Pour une plus grande souplesse d'utilisation, il est \r
566 possible lors du programme, après l'initalisation, de changer cette prise en compte, cela se fera par l'appel de la \r
567 procedure <I>getmovement</I>, procédure ayant les mêmes paramètres (avec le même ordre) que la fonction \r
568 init.<P>\r
569 \r
570         Pour detecter les événements, on utilisa la fonction <I>getpress</I>, qui retourne un booléen indiquant la \r
571 présence ou l'absence d'événement (respectivement les valeurs true et false). Il est bon de noter qu'ainsi définie la \r
572 fonction getpress n'est pas bloquante. Les paramètres en retour sont soit nuls (pas d'événement) soit \r
573 correspondent:<P>\r
574 \r
575         bool:=getpress(v,p,h,l,r,c : integer);<P>\r
576                 v = position en y de la souris<P>\r
577                 p = keyboard status (Touche control_left,control_right, alt, alt_gr, shift_left, shift_right)<P>\r
578                 h = position en x de la souris<P>\r
579                 l  = touche clavier<P>\r
580                 r = flags<P>\r
581                 c = boutons de la souris (0=aucun, 1=gauche, 2=droite, 3=gauche et droite)<P>\r
582                         Nb: le bouton central n'est pas géré.<P>\r
583 \r
584 NOTEZ BIEN! Lorsque les événements du clavier sont pris en compte dans le gestionnaire, <B>il</B> <B>ne faut \r
585 pas </B>utiliser les fonctions d'entrées clavier readl, readln, hfont, hfont8, hpage, inkey,...) <I>sous peine de \r
586 plantage de l'ordinateur</I>.<P>\r
587 }</H6>\r
588 <HR>\r
589 <P>\r
590 <H2>    <B>unit </B> <A NAME="init">init</A>  \r
591 : <B>procedure</B>(checkMouse, \r
592 checkKeyboard: integer); </H2>\r
593          { initializes the Mouse driver.<P>\r
594             tells which events will be checked:<P>\r
595             if checkMouse &lt &gt 0 then the events of Mouse will be reported to getpress, see below otherwise \r
596 ignored;<P>\r
597             if checkKeyboard &lt &gt 0 then the events of Keyboard will be reported to getpress, otherwise ignored<P>\r
598                  <B><I>Attention please!</I></B>  While the events of the keyboard are taken under control by \r
599 <I>init</I> or <I>getmovement</I><P>\r
600                 <B><I>do not use</I></B> the functions or procedures: read, readln, hfont, hfont8, hpage, inkey \r
601 that read keys<P>\r
602                 YOU RISK TO HANG YOUR SYSTEM!<P>\r
603 <B>         }</B><P>\r
604     <B>end</B> init <P>\r
605 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
606 \r
607 <H2><B>    unit  </B><A \r
608 NAME="getmovement">getmovement</A>  : \r
609 <B>procedure</B>(checkMouse, checkKeyboard: \r
610 integer); </H2>\r
611         tells which events will be checked:<P>\r
612             if checkMouse &lt &gt 0 then the events of Mouse will be reported to getpress, see below otherwise \r
613 ignored;<P>\r
614             if checkKeyboard &lt &gt 0 then the events of Keyboard will be reported to getpress, otherwise ignored<P>\r
615                  <B><I>Attention please!</I></B>  While the events of the keyboard are taken under control by \r
616 <I>init</I> or <I>getmovement</I><P>\r
617                 <B><I>do not use</I></B> the functions or procedures: read, readln, hfont, hfont8, hpage, inkey \r
618 that read keys<P>\r
619                 YOU RISK TO HANG YOUR SYSTEM!<P>\r
620     <B>end</B> getmovement;<P>\r
621 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
622 \r
623 <H2><B>    unit </B> <A \r
624 NAME="getpress">getpress</A>  : \r
625 <B>function</B>(v,p,h,l,r,c : integer): \r
626 Boolean;</H2>\r
627         {  <I>v</I> =  y coordinate of the cursor,<P>\r
628             <I>h</I> =  x coordinate of the cursor,<P>\r
629             <I>p</I> =  keybord status control_left,control_right, alt, alt_gr, shift_left, shift_right<P>\r
630                     <I>l</I>  = code of key pressed<P>\r
631             <I>r</I> = flags<P>\r
632             <I>c</I> = buttons pressed (0=aucun, 1=gauche, 2=droite, 3=gauche et droite)<P>\r
633                         Nb: the middle button is not taken into account.<P>\r
634     <B>end</B> getpress<P>\r
635 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
636 \r
637 \r
638 <H2>    <B>unit </B> <A \r
639 NAME="showcursor">showcursor</A>  : \r
640 <B>procedure</B>; </H2>\r
641         {the cursor becomes visible and follows the movements of the mouse}<P>\r
642     end showcursor;<P>\r
643 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
644 \r
645 <H2>    <B>unit </B> <A \r
646 NAME="hidecursor">hidecursor</A> : \r
647 <B>procedure</B>; </H2>\r
648         {the cursor becomes invisible}<P>\r
649     end hidecursor;<P>\r
650 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A><BR>\r
651 \r
652 <P align=left><B>end</B> MOUSE;<P>\r
653 \r
654 <HR>\r
655 \r
656 <H2>Enclosed you find a <A NAME="sample program">sample program</A>  .</H2>\r
657 <PRE>\r
658 Program SystemeGraph; \r
659        (* by Frederic Pataud, October 1994 *) \r
660 Begin \r
661 Pref iiuwgraph block     (* inherit the graphic functions *) \r
662  Begin \r
663  Pref mouse block       (* inherit the mouse functions *) \r
664 \r
665 \r
666 (*********************************************************************) \r
667 (*                   P r o g r a m  m e   P r i n c i p a l                  *) \r
668 (*********************************************************************) \r
669      var v,p,h,i : integer, \r
670        l,r,c : integer, \r
671        rep : arrayof char, \r
672        d : boolean, \r
673        xx,yy : arrayof integer, \r
674        status,code,x,y,flags,button : integer; \r
675     \r
676    Begin \r
677       \r
678      call gron(0);            (* enter the graphic mode *) \r
679      call init(1,0);            (* initialize the mouse, disregard the keyboard events, check for mouse events *) \r
680       \r
681      call showcursor;           (* show cursor *) \r
682      call patern(5,5,635,475,2,0);         (* make a frame around the screen *) \r
683      call outstring(10,10,"x=",2,0); \r
684      call outstring(100,10,"y=",2,0); \r
685      call outstring(10,30,"status = ",2,0); \r
686      call outstring(10,50,"code   = ",2,0); \r
687      call outstring(10,70,"flags  = ",2,0); \r
688      call outstring(10,90,"button = ",2,0); \r
689      call patern(100,210,300,320,3,1);         (* make a rectangle filled in colour 3 *) \r
690 \r
691      array xx dim (1:6); \r
692      array yy dim (1:6); \r
693      xx(1):=410; yy(1):=10; \r
694      xx(2):=450; yy(2):=30; \r
695      xx(3):=460; yy(3):=50; \r
696      xx(4):=430; yy(4):=80; \r
697      xx(5):=420; yy(5):=40; \r
698      xx(6):=480; yy(6):=30; \r
699      call intens(6,xx,yy,8,1);          (* show a polygon filled*) \r
700      for i:=1 to 6 \r
701       do \r
702        yy(i):=yy(i)+100; \r
703       od; \r
704      call intens(6,xx,yy,15,0);         (* show another polygon empty *) \r
705       \r
706      call cirb(500,300,50,40,100,3500,10,0);    (* draw an empty pie or camembert *) \r
707      call cirb(400,400,40,40,600,4000,11,1);     (* draw a filled pie *) \r
708 \r
709 \r
710      i:=hfont(100,350,6,-9999999,9999999,500,9,0,15);      (* read integer from a window *) \r
711      call hpage(100,400,10,unpack("Il fait beau dans ma verte campagne"),9,0);   (* show text *) \r
712      rep:=hfont8(100,430,10,80,unpack("tototutu"),9,0,15);              (* read text *) \r
713       \r
714      call getmovement(1,1);           (* take into consideration both key events and mouse events *) \r
715       \r
716      do \r
717       d:=getpress(v,p,h,l,r,c);         (* ask about an event *) \r
718       if (d) \r
719       then call outstring(10,400,"Event",2,0); \r
720            call patern(80,25,130,100,0,1); \r
721            call track(40,10,v,0,4);             (* print integer *) \r
722            call track(140,10,p,0,4); \r
723            call track(80,30,h,0,4); \r
724            call track(80,50,l,0,4); \r
725            call track(80,70,r,0,4); \r
726            call track(80,90,c,0,4); \r
727            if((h=164 and l=27) or (c=3))                 (* exit if either two buttons were pressed c=3 or Ctrl+Esc key *) \r
728            then exit; \r
729            fi; \r
730       fi; \r
731      od; \r
732      call groff;                                (* leave the graphic mode and return to the text mode *) \r
733      writeln("i=",i); \r
734      for i:=lower(rep) to upper(rep) \r
735      do \r
736        write(rep(i)); \r
737      od; \r
738      writeln; \r
739    End \r
740  End \r
741 End. \r
742 </PRE>\r
743 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>\r
744 <p align=LEFT>\r
745 <HR>\r
746 <Address> <A HREF = "http://www.univ-pau.fr/~salwicki/GMyAS.html">GMyAS</A> Last update Sun 7 May \r
747 1995 </Address> \r
748 </BODY>\r
749 </html>\r
750 \r