2 <HEAD><TITLE>iiuwgraph</TITLE></HEAD>
\r
3 <H1 align=center>unit IIUWGRAPH: class;</H1>
\r
4 <H2>a predefined Loglan'82 <IMG SRC="http://www.univ-pau.fr/~salwicki/loglanmm.gif" ALT="LOGLAN"></IMG> class </H2>
\r
6 { this predefined class enables basic graphic operations
\r
7 for DOS machines based on <B>486 </B> or 386 processors
\r
10 {this document gives the specification of new version of IIUWGRAPH
\r
12 made in October 1994 by <B><I>Frederic Pataud </I></B>à Pau}<P>
\r
14 <A NAME="Table of Contents"><B>Table of Contents</B></A>.<BR>
\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
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
54 <LI>unit <A HREF = "#hfont8">hfont8</A>: function( x,y,lg,maxlg: integer,
\r
55 default: arrayof char,col_f,col_e,col_c : integer): arrayof char;
\r
56 <LI>unit <A HREF = "#HPAGE">HPAGE </A> : procedure(x,y,long: integer, A: arrayof char, back, front:
\r
58 <LI>unit <A HREF = "#MOUSE">MOUSE</A>: class;
\r
59 <LI>unit <A HREF = "#init">init</A>: procedure(checkMouse, checkKeyboard: integer);
\r
60 <LI>unit <A HREF = "#getmovement">getmovement</A>: procedure(checkMouse, checkKeyboard:
\r
62 <LI>unit <A HREF = "#getpress">getpress</A>: function(v,p,h,l,r,c : integer): Boolean;
\r
63 <LI>unit <A HREF = "#showcursor">showcursor</A>: procedure;
\r
64 <LI>unit <A HREF = "#hidecursor">hidecursor</A>: procedure;
\r
65 <LI> <A HREF = "#sample program">a sample program</A>
\r
72 { the early versions of library IIUWGRAPH have been elaborated by
\r
73 Piotr Carlsson, Miroslawa Milkowska, Janina Jankowska,
\r
74 Michal Jankowski at Institute of Informatics,
\r
75 University of Warsaw 1987,<P>
\r
76 and added to Loglan system by Danuta Szczepanska 1987, <P>
\r
78 the recent versions were done at LITA, Pau,<P>
\r
80 Pawel Susicki (1991) for Unix,<P>
\r
81 Sebastien Bernard (1992) for ATARI, see a separate document,<BR>
\r
82 Eric Becourt et Jerôme Larrieu (1993) for Unix and Xwindows, see a
\r
83 separate document on Xiiuwgraf ,
\r
87 fait à Pau, le 15 Novembre 1994, par Andrzej Salwicki, LITA}<P align=left>
\r
89 { the predefined class IIUWGRAPH is included in all versions of interpreter of
\r
90 Loglan, with the <I>exception</I> of the present version of interpreter for
\r
95 <B>hidden</B> MaxX, MaxY, current_X, current_Y, is_graphic_On,
\r
96 current_Colour, current_Background_Colour, current_Style,
\r
97 current_Palette, current_Pattern ;
\r
101 <B>const</B> MaxX =
\r
104 { the screen's coordinates are
\r
106 (0,0) ----------------------> (MaxX,0)
\r
111 (0, MaxY) (MaxX,MaxY)
\r
116 <B>var</B> currentDriver : integer, { see NOCARD below }
\r
117 current_X, current_Y: integer { it is the current position }
\r
118 is_graphic_On: Boolean, { evidently tells whether we are in
\r
120 current_Colour : integer, { }
\r
121 current_Background_Colour : integer,
\r
122 current_Style : integer, { }
\r
123 current_Palette : integer,
\r
127 <H2><B>unit </B> <A
\r
128 NAME="GRON"> GRON </A> <B> procedure </B>
\r
130 { procedure sets the monitor in graphic mode and clears the buffer
\r
131 of screen. The parameter determines the resolution and the number of
\r
133 The user should assure that the resolution chosen should correspond to that
\r
134 which is set by means of command <BR>
\r
135 SET go32 drivers {path}< driver.file> < width> < height> <
\r
138 set go32 drivers c:\loglan\svga\drivers\vesa.grn gw 1024 gh 480 nc 256<BR>
\r
139 <P> An execution of instruction call gron(i) <B><I>must precede</I>
\r
140 </B> any of the graphic commands described below.<P>
\r
156 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
158 <H2><B>unit </B> <A
\r
159 NAME="GROFF"> GROFF </A><B> procedure </B>; </H2>
\r
160 { the procedure sets the monitor in the text mode filling it with
\r
162 DO NOT FORGET to set the monitor in the text mode before
\r
163 you terminate your program<P>
\r
165 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
168 <H2><B>unit </B> <A NAME="CLS"> CLS </A> .
\r
169 : <B> procedure</B>;</H2>
\r
170 { the screen will be cleared and filled with colour 0 }<P>
\r
171 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A><P>
\r
175 <H2>{ PROCEDURES CONTROLLING THE COLOURS }</H2>
\r
178 <H2><B>unit </B> <A
\r
179 NAME="COLOR"> COLOR </A> :
\r
180 <B> procedure</B>(co : integer);</H2>
\r
181 { sets current color to co <BR>
\r
182 for monochrome displays, 0 means black, non-0 - white<BR>
\r
183 for color displays, 0 means background<BR>
\r
186 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
188 <H2><B>unit </B> <A
\r
189 NAME="STYLE"> STYLE </A> :
\r
190 <B> procedure</B>(styl : integer);</H2>
\r
191 { sets style of lines and fill shades to a combination<P>
\r
192 of current color and background color (for mono -<P>
\r
193 white and black, respectively) according to 5 predefined<P>
\r
203 where '*' means current color, '.' background colour<P>
\r
204 When drawing the segments the subsequent pixels will have colour determined
\r
205 by cyclic application of style pattern. The first and the last pixels of a segment
\r
206 will have always current colour.<P>
\r
207 When filling contours the given style will be applied to horizontal lines with even
\r
208 coordinate. The style for odd lines is determined automatically.<P>
\r
209 The same applies for perpendicular lines.<P>
\r
212 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
214 <H2><B>unit </B> <A
\r
215 NAME="BORDER"> BORDER </A> . :
\r
216 <B>procedure</B> (background_Colour:
\r
219 <P> { sets actual background color to i ( i = 0,1,...,15 ) }<P>
\r
221 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
223 <H2><B>unit </B> <A
\r
224 NAME="PALLET"> PALLET </A> :
\r
225 <B>procedure</B> (nr : integer);</H2>
\r
226 {the following line makes an example, it is not valid for, say,
\r
229 the codes of colors are <I>usually i.e. when you have 16 colours,</I> as follows<P>
\r
249 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
253 <H2>{ PROCEDURES CONTROLLING POSITION }</H2>
\r
255 <H2><B>unit </B> <A
\r
256 NAME="MOVE">MOVE</A> :
\r
257 <B>procedure</B> (x,y :integer);</H2>
\r
258 { procedure MOVE sets the current position on the screen on the pixel
\r
259 with coordinates<P>
\r
262 { precondition of MOVE:
\r
263 <I>0<x<MaxX & 0<y<MaxY </I>
\r
265 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
267 <H2><B>unit </B> <A
\r
268 NAME="INXPOS">INXPOS</A> :
\r
269 <B>function</B>: integer;</H2>
\r
270 { function INXPOS returns the x coordinate of the current position }<P>
\r
271 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
274 <H2><B>unit </B> <A
\r
275 NAME="INYPOS">INYPOS</A> :
\r
276 <B>function</B> : integer;</H2>
\r
277 { function INYPOS returns the y coordinate of the current position }<P>
\r
278 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
281 <H2><B>unit </B> <A
\r
282 NAME="PUSHXY">PUSHXY</A> :
\r
283 <B>procedure</B>;</H2>
\r
284 { pushes current position, color & style onto the stack.<P>
\r
285 The stack is kept internally, max depth is 16<P>
\r
288 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
290 <H2><B>unit </B><A
\r
291 NAME="POPXY">POPXY</A> :
\r
292 <B>procedure</B>;</H2>
\r
294 { restores position, color & style from internal stack }<P>
\r
297 <PRE>unit DIAGONAL : procedure;
\r
298 var ix, iy : integer;
\r
303 call DRAW(ix+10, iy+10);
\r
308 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
311 <H2>{ PROCEDURES SERVING POINTS &
\r
314 <H2><B>unit </B> <A
\r
315 NAME="POINT">POINT</A> :
\r
316 <B>procedure</B>(x,y: integer);</H2>
\r
317 { moves current position to pixel (x,y) and sets it to the current color
\r
319 }<P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
322 <H2><B>unit </B> <A
\r
323 NAME="INPIX">INPIX</A> : <B>function</B>
\r
324 (x,y : integer) : integer;</H2>
\r
326 moves to pixel (x,y) and returns its color setting;<P>
\r
328 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
331 <H2><B>unit </B> <A
\r
332 NAME="DRAW">DRAW</A> :
\r
333 <B>procedure</B>( x,y : integer);</H2>
\r
335 draws a line from current screen position to (<I>x,y</I>);<P>
\r
336 sets current position to (<I>x,y</I>);<P>
\r
337 line is drawn in current color, with both terminal pixels<P>
\r
338 always turned white ( non-background) for non-black<P>
\r
339 ( non-background ) line color.<P>
\r
341 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
343 <H2><B>unit </B> <A
\r
344 NAME="intens">intens</A> :
\r
345 <B>procedure</B>(Size :integer;
\r
346 xCoord,yCoord:arrayof integer, Colour,Filled
\r
349 /* draw a polygon*/
\r
350 { draw a simple, closed polygon of Size points, the edges of the polygon go from
\r
351 (<I>xCoord[i], yCoord[i]</I>) to (<I>xCoord[i+1], yCoord[i+1]</I>) for i = 1, ..., Size-1
\r
352 The colour used will be <I>Colour</I>. The polygon will be filled iff <I>Filled</I><
\r
355 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
357 <H2><B>unit </B><A NAME="CIRB"> CIRB</A> : <B>procedure</B> (xi, yi, rx,ry : integer, alfa, beta : real,
\r
358 cbord, fill : integer);<P></H2>
\r
362 <P> draws a circle (or ellipse, depending on aspect value, see below),<P>
\r
363 optionally filling its interior; <P>
\r
364 does not preserve position;<P>
\r
365 (<I>xi,yi</I>) - are center coordinates,<P>
\r
366 <I>rx</I> - radius in pixels (horizontally),<BR>
\r
367 <I>ry</I> - radius in pixels (perpendicularly),<P>
\r
368 <I>alfa, beta</I> - starting & ending angles; if alfa=beta a full<P>
\r
369 circle is drawn; values should be given in radians;<P>
\r
370 <I>cbord</I> - border color,<P>
\r
371 <I>fill</I> - if fill < > 0, interior is filled in current style& color<P>
\r
373 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
375 <H2><B>unit </B> <A NAME="hfill">hfill</A> :
\r
376 <B>procedure</B>( x : integer);</H2>
\r
377 { draw an horizontal line between the current position and<P>
\r
378 (x,currentY) with the current color, after it change the current<P>
\r
379 position to (x, currentY)<P>
\r
381 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
383 <H2><B>unit </B><A NAME="vfill">vfill</A> :
\r
384 <B>procedure</B>( y : integer);</H2>
\r
385 { draw a vertical line between the current position and<P>
\r
386 (currentX,y) with the current color, after it change the current<P>
\r
387 position to (currentX,y)<P>
\r
389 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
391 <H2><B>unit </B> <A
\r
392 NAME="patern">patern</A> :
\r
393 <B>procedure</B>( x1,y1,x2,y2,c,b :
\r
395 { draw a <B><I>rectangle</I></B> between the points (<I>x1,y1</I>) and
\r
396 (<I>x2</I>,<I>y2</I>) with the<P>
\r
397 color <I>c</I> (the current color is not change). if <I>b</I>=0 then the box
\r
399 empty else it is filled.<P>
\r
401 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
403 <H2>{ Procedures operating on bitmaps }</H2>
\r
405 <H2><B>unit </B> <A
\r
406 NAME="GETMAP">GETMAP</A> :
\r
407 <B>function</B> (x,y : integer) : <B>arrayof</B>
\r
409 {saves rectangular area between current position as<P>
\r
410 top left corner and (ix,iy) as bottom right corner,<P>
\r
411 including border lines;<P>
\r
412 position remains unchanged.<P>
\r
413 array of integer should have <P>
\r
414 4+(rows**columns/8* *coeff)<P>
\r
415 bytes. The coefficient coeff is 1 for Hercules, 2 for CGA, 4 for EGA<P>
\r
417 ATTENTION: in DOS 286 environment a bigger size of the array may
\r
418 necessitate the use of <I>loglan</I> with<I> the option H+</I>, see also
\r
421 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
423 <H2><B>unit </B> <A
\r
424 NAME="PUTMAP">PUTMAP</A> :
\r
425 <B>procedure</B> ( a: <B>arrayof</B>
\r
427 {sets rectangular area of screen pixels to that saved<P>
\r
428 by "getmap" in "iarray";<P>
\r
429 same size is restored, with top left corner in current<P>
\r
431 position remains unchanged.<P>
\r
433 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
435 <H2><B>unit </B> <A
\r
436 NAME="ORMAP">ORMAP</A> :
\r
437 <B>procedure</B> ( a : <B>arrayof
\r
439 {same as putmap, but saved bitmap is or'ed into screen<P>
\r
440 rather than just set.<P>
\r
442 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
444 <H2><B>unit </B> <A NAME="XORMAP
\r
445 ">XORMAP </A> : <B>procedure</B> ( a:
\r
446 <B>arrayof</B> integer);</H2>
\r
447 {same as putmap, but saved bitmap is xor'ed into screen<P>
\r
448 rather than just set.<P>
\r
450 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
453 <H2>{Procedures operating on characters and strings}</H2>
\r
455 <H2><B>unit </B> <A
\r
456 NAME="outstring">outstring</A> :
\r
457 <B>procedure</B>(x,y: integer, s: string, back_col,
\r
458 front_col: integer);</H2>
\r
459 { <I>x, y</I> are the coordinates where to put the string,<P>
\r
460 <I>s</I> is the string to be shown, in <I>front_col</I> colour letters on the
\r
461 <I>back_col</I> colour background<P>
\r
463 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
465 <H2><B>unit </B> <A NAME="track">track</A>
\r
466 : <B>procedure</B>( x,y,c,valeur : integer);
\r
468 { write an integer value <I>valeur</I> at the position (<I>x,y</I>) with the
\r
470 It does not change the current position nor the current color<P>
\r
472 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
474 <H2><B>unit </B> <A NAME="inkey ">inkey
\r
475 </A> : <B>function</B> : integer;</H2>
\r
477 { returns next character from keyboard buffer;<P>
\r
478 0 is returned if buffer is empty;<P>
\r
479 special keys are returned as negative numbers;<P>
\r
480 ALT-NUM method may be used for entering character codes<P>
\r
481 above 127 (this makes entering special keys 128-132<P>
\r
483 if a character is returned, it is also removed<P>
\r
484 from the buffer, so MS-DOS will not see it (CTRL-C!);<P>
\r
485 typeahead is allowed, echo is suppressed.<P>
\r
487 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
489 <H2><B>unit </B> <A NAME="HASCII
\r
490 ">HASCII </A> : <B>procedure</B>(c:
\r
492 {'xor's the character = chr(c) in a 8*8 box with top left corner<P>
\r
493 in the current position;<P>
\r
494 moves current position by (8,0);<P>
\r
495 call hascii(0)- sets complete box to black ( =background ),<P>
\r
496 with no change in position.<P>
\r
498 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
502 <H2><B>unit </B><A NAME="hfont">hfont</A>
\r
503 : <B>function</B>(
\r
504 x,y,lg,min,max,default,col_f,col_e,col_c : integer):
\r
507 { arrange a small 1 line window for <B><I>reading</I></B> an integer value
\r
509 the position of the window corner is (<I>x, y</I>),
\r
510 the length of the window is <I>lg</I> characters,
\r
511 the value v should be greater than <I>min</I> and smaller than <I>max</I>,
\r
512 the default value read is <I>default</I>,<P>
\r
513 the colour of the window is <I>col_f</I>,<BR>
\r
514 the colour of the digits is <I>col_e,</I><BR>
\r
515 the colour of cursor is <I>col_c</I><P>
\r
517 reads in graphic mode an integer in the window which begins at the (x,y)
\r
518 position, window is lg caracteres long. the maximum length of the<P>
\r
519 integer that is read is 10. there is a default value, a minimum value
\r
520 and a maximum value. the window is drawn with the col_f color, the
\r
521 cursor is in the col_c color and the integer is writing in the col_e<P>
\r
522 color. you can use 0..9,+,-,backspace,escape and return keys. }<P>
\r
523 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
525 <H2><B>unit </B><A NAME="hfont8">hfont8</A>
\r
526 : <B>function</B>(
\r
527 x,y,lg,maxlg: integer,default: arrayof char,
\r
528 col_f,col_e,col_c : integer): arrayof char;</H2>
\r
530 { arrange a small 1 line window for <B><I>reading</I></B> an array of characters (<I>text</I>)
\r
532 the position of the window corner is (<I>x, y</I>),
\r
533 the length of the window is <I>lg</I> characters,
\r
534 the text should not be longer than <I>maxlg</I> characters,
\r
535 the default text shown is <I>default</I>,<P>
\r
536 the colour of the window is <I>col_f</I>,<BR>
\r
537 the colour of the digits is <I>col_e,</I><BR>
\r
538 the colour of cursor is <I>col_c</I><P>
\r
540 reads in graphic mode a text (i.e. an array of characters)
\r
541 in the window which begins at the (x,y)
\r
542 position, window is lg caracteres long. the maximum length of the
\r
543 text that is read is maxlg. there is a default text shown,
\r
544 the window is drawn with the col_f color, the
\r
545 cursor is in the col_c color and the integer is writing in the col_e<P>
\r
546 color.<P> You can use 0..9,+,-,backspace,escape and return keys. }<P>
\r
547 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
550 <H2><B>unit </B> <A NAME="HPAGE
\r
551 ">HPAGE </A> : <B>procedure</B>(x,y,long:
\r
552 integer, A: arrayof char, back, front: integer);</H2>
\r
553 { this procedure arranges a 1-line high window in position <I>x,y</I> of
\r
554 length <I>long</I> in which a portion of text <I>A</I> is shown in colour
\r
555 <I>front</I> on the background colour <I>back</I>. <P>
\r
556 Making use of keys controlling the cursor {left, right, PgUp, PgDn}<P>
\r
557 the user can scroll the text (horizontally) in the window. Pressing the
\r
558 Enter key terminates the procedure} <P>
\r
559 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
561 <P align=left><B>end</B> IIUWGRAPH;<P>
\r
566 <P><H2><B>unit </B> <A
\r
567 NAME="MOUSE">MOUSE</A> :
\r
568 <B>class</B>; </H2>
\r
570 <I>You can safely skip the following french text if you can not read french.<BR>
\r
571 It is put here for the convenience of my french students.<BR>
\r
575 <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
576 fonction getpress; le premier et le deuxième paramètre représentent respectivement la souris et le clavier, si une
\r
577 valeur non nulle est donnée comme paramètre alors getpress réagira à l'événement.<P>
\r
579 Une paire (1,1) va permettre de prendre en compte à la fois les événements de la souris et ceux du clavier;
\r
580 une paire (1,0) quand à elle ne prendra en compte que la souris. Pour une plus grande souplesse d'utilisation, il est
\r
581 possible lors du programme, après l'initalisation, de changer cette prise en compte, cela se fera par l'appel de la
\r
582 procedure <I>getmovement</I>, procédure ayant les mêmes paramètres (avec le même ordre) que la fonction
\r
585 Pour detecter les événements, on utilisa la fonction <I>getpress</I>, qui retourne un booléen indiquant la
\r
586 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
587 fonction getpress n'est pas bloquante. Les paramètres en retour sont soit nuls (pas d'événement) soit
\r
590 bool:=getpress(v,p,h,l,r,c : integer);<P>
\r
591 v = position en y de la souris<P>
\r
592 p = keyboard status (Touche control_left,control_right, alt, alt_gr, shift_left, shift_right)<P>
\r
593 h = position en x de la souris<P>
\r
594 l = touche clavier<P>
\r
596 c = boutons de la souris (0=aucun, 1=gauche, 2=droite, 3=gauche et droite)<P>
\r
597 Nb: le bouton central n'est pas géré.<P>
\r
599 NOTEZ BIEN! Lorsque les événements du clavier sont pris en compte dans
\r
600 le gestionnaire, <B>il ne faut
\r
601 pas </B>utiliser les fonctions d'entrées clavier readl, readln, hfont, hfont8, hpage, inkey,...) <I>sous peine de
\r
602 plantage de l'ordinateur</I>.<P>
\r
606 <H2> <B>unit </B> <A NAME="init">init</A>
\r
607 : <B>procedure</B>(checkMouse,
\r
608 checkKeyboard: integer); </H2>
\r
609 { initializes the Mouse driver.<P>
\r
610 tells which events will be checked:<P>
\r
611 if checkMouse < > 0 then the events of Mouse will be
\r
612 reported to <A HREF = "#getpress">getpress</A>, otherwise
\r
614 if checkKeyboard < > 0 then the events of Keyboard will be
\r
615 reported to getpress, otherwise ignored<P>
\r
616 <B><I>Attention please!</I></B> While the events of
\r
617 the keyboard are taken under control by
\r
618 <I>init</I> or <I>getmovement</I><P>
\r
619 <B><I>do not use</I></B> the functions or procedures: read,
\r
620 readln, hfont, hfont8, hpage, inkey
\r
622 YOU RISK TO HANG YOUR SYSTEM!<P>
\r
624 <B>end</B> init <P>
\r
625 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
627 <H2><B> unit </B><A
\r
628 NAME="getmovement">getmovement</A> :
\r
629 <B>procedure</B>(checkMouse, checkKeyboard:
\r
631 tells which events will be checked:<P>
\r
632 if checkMouse < > 0 then the events of Mouse will be
\r
633 reported to <A HREF = "#getpress">getpress</A>, otherwise
\r
635 if checkKeyboard < > 0 then the events of Keyboard will be
\r
636 reported to getpress, otherwise ignored<P>
\r
637 <B><I>Attention please!</I></B> While the events of the
\r
638 keyboard are taken under control by
\r
639 <I>init</I> or <I>getmovement</I><P>
\r
640 <B><I>do not use</I></B> the functions or procedures: read,
\r
641 readln, hfont, hfont8, hpage, inkey
\r
643 YOU RISK TO HANG YOUR SYSTEM!<P>
\r
644 <B>end</B> getmovement;<P>
\r
645 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
647 <H2><B> unit </B> <A
\r
648 NAME="getpress">getpress</A> :
\r
649 <B>function</B>(v,p,h,l,r,c : integer):
\r
651 { <I>v</I> = y coordinate of the cursor,<P>
\r
652 <I>h</I> = x coordinate of the cursor,<P>
\r
653 <I>p</I> = keybord status control_left,control_right, alt, alt_gr, shift_left, shift_right<P>
\r
654 <I>l</I> = code of key pressed<P>
\r
655 <I>r</I> = flags<P>
\r
656 <I>c</I> = buttons pressed (0=none, 1=left, 2=right, 3=both)<P>
\r
657 Nb: the middle button is not taken into account.<P>
\r
658 <B>end</B> getpress<P>
\r
659 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
662 <H2> <B>unit </B> <A
\r
663 NAME="showcursor">showcursor</A> :
\r
664 <B>procedure</B>; </H2>
\r
665 {the cursor becomes visible and follows the movements of the mouse}<P>
\r
667 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
669 <H2> <B>unit </B> <A
\r
670 NAME="hidecursor">hidecursor</A> :
\r
671 <B>procedure</B>; </H2>
\r
672 {the cursor becomes invisible}<P>
\r
674 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A><BR>
\r
676 <P align=left><B>end</B> MOUSE;<P>
\r
680 <H2>Enclosed you find a <A NAME="sample program">sample program</A> .</H2>
\r
682 Program SystemeGraph;
\r
683 (* by Frederic Pataud, October 1994 *)
\r
685 Pref iiuwgraph block (* inherit the graphic functions *)
\r
687 Pref mouse block (* inherit the mouse functions *)
\r
690 (*********************************************************************)
\r
691 (* P r o g r a m m e P r i n c i p a l *)
\r
692 (*********************************************************************)
\r
693 var v,p,h,i : integer,
\r
695 rep : arrayof char,
\r
697 xx,yy : arrayof integer,
\r
698 status,code,x,y,flags,button : integer;
\r
702 call gron(0); (* enter the graphic mode *)
\r
703 call init(1,0); (* initialize the mouse, disregard the keyboard events, check for mouse events *)
\r
705 call showcursor; (* show cursor *)
\r
706 call patern(5,5,635,475,2,0); (* make a frame around the screen *)
\r
707 call outstring(10,10,"x=",2,0);
\r
708 call outstring(100,10,"y=",2,0);
\r
709 call outstring(10,30,"status = ",2,0);
\r
710 call outstring(10,50,"code = ",2,0);
\r
711 call outstring(10,70,"flags = ",2,0);
\r
712 call outstring(10,90,"button = ",2,0);
\r
713 call patern(100,210,300,320,3,1); (* make a rectangle filled in colour 3 *)
\r
715 array xx dim (1:6);
\r
716 array yy dim (1:6);
\r
717 xx(1):=410; yy(1):=10;
\r
718 xx(2):=450; yy(2):=30;
\r
719 xx(3):=460; yy(3):=50;
\r
720 xx(4):=430; yy(4):=80;
\r
721 xx(5):=420; yy(5):=40;
\r
722 xx(6):=480; yy(6):=30;
\r
723 call intens(6,xx,yy,8,1); (* show a polygon filled*)
\r
728 call intens(6,xx,yy,15,0); (* show another polygon empty *)
\r
730 call cirb(500,300,50,40,100,3500,10,0); (* draw an empty pie or camembert *)
\r
731 call cirb(400,400,40,40,600,4000,11,1); (* draw a filled pie *)
\r
734 i:=hfont(100,350,6,-9999999,9999999,500,9,0,15); (* read integer from a window *)
\r
735 call hpage(100,400,10,unpack("Il fait beau dans ma verte campagne"),9,0); (* show text *)
\r
736 rep:=hfont8(100,430,10,80,unpack("tototutu"),9,0,15); (* read text *)
\r
738 call getmovement(1,1); (* take into consideration both key events and mouse events *)
\r
741 d:=getpress(v,p,h,l,r,c); (* ask about an event *)
\r
743 then call outstring(10,400,"Event",2,0);
\r
744 call patern(80,25,130,100,0,1);
\r
745 call track(40,10,v,0,4); (* print integer *)
\r
746 call track(140,10,p,0,4);
\r
747 call track(80,30,h,0,4);
\r
748 call track(80,50,l,0,4);
\r
749 call track(80,70,r,0,4);
\r
750 call track(80,90,c,0,4);
\r
751 if((h=164 and l=27) or (c=3)) (* exit if either two buttons were pressed c=3 or Ctrl+Esc key *)
\r
756 call groff; (* leave the graphic mode and return to the text mode *)
\r
758 for i:=lower(rep) to upper(rep)
\r
767 <P ALIGN=RIGHT><A HREF = "#Table of Contents">to ToC</A>
\r
770 <Address> <A HREF = "http://www.univ-pau.fr/~salwicki/GMyAS.html">GMyAS</A> Last update Sun 7 May
\r