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