home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / EXAMPLES / PLOC.P < prev    next >
Text File  |  2000-02-11  |  1KB  |  79 lines

  1. program loc;
  2.  
  3. #include "Vogle.h"
  4.  
  5.     var dev, name: string_t;
  6.         i, bt, curpnt, act, nchars: integer;
  7.         x, y, sx, sy: real;
  8.  
  9. begin
  10.     write('Enter device name: ');
  11.     readln(dev);
  12.  
  13.     PrefSize(512, 512);
  14.     Vinit(dev);
  15.  
  16.     Color(BLACK);
  17.     Clear;
  18.  
  19.     Color(BLUE);
  20.  
  21.     (*
  22.      * draw some axes
  23.      *)
  24.     Move2(0.0, 1.0);
  25.     Draw2(0.0, -1.0);
  26.  
  27.     Move2(1.0, 0.0);
  28.     Draw2(-1.0, 0.0);
  29.  
  30.     Color(GREEN);
  31.  
  32.     act := 0;
  33.     curpnt := 0;
  34.     (*
  35.      * locator returns whether a mouse button has been
  36.      * pressed or not. In a device such as the tektronix
  37.      * where you have to wait for a keypress to get the
  38.      * position of the crosshairs locator returns 0
  39.      * automatically on every second call. A return value
  40.      * of 2 indicates the second mouse button has been pressed.
  41.      * A return value of 1 indicates the first mouse button has
  42.      * been pressed. We wait for the locator to return zero so
  43.      * that we know the mouse button has been released.
  44.      *)
  45.     bt := 0;
  46.     while (bt <> 2) do
  47.         begin
  48.         bt := Locator(x, y);
  49.         if (bt = -1) then
  50.             begin
  51.             Vexit;
  52.             writeln('No locator device found');
  53.             halt;
  54.             end
  55.         else if (bt = 0) then
  56.             act := 1
  57.         else if (act <> 0) then
  58.             begin
  59.             act := 0;
  60.             if (bt = 1) then
  61.                 begin
  62.                 if (curpnt <> 0) then
  63.                     begin
  64.                     Move2(sx, sy);
  65.                     Draw2(x, y);
  66.                     curpnt := 0
  67.                     end
  68.                 else
  69.                     curpnt := 1;
  70.                 sx := x;
  71.                 sy := y
  72.                 end
  73.             end
  74.         end;
  75.  
  76.     Vexit
  77.  
  78. end.
  79.