program mausdemo;
{ (c) 1991 by H.-J. SCHLOáAREK }
USES crt,graph,maus;
CONST
     leer4='    ';
     leer30='                             ';
VAR
     mode,treiber:INTEGER;
     x,y,maxx,maxy,wa,altx,alty:INTEGER;
     m_taste:INTEGER;
     ch:CHAR;
PROCEDURE max_bereich;
begin
     mausan(false);
     setzbereich(0,maxx,0,maxy);       { Alten Mausbereich setzen }
     mausan(true);
end;
PROCEDURE bereich_setzen;              { Neuen Mausbereich setzen }
begin
     SETCOLOR(1);
     RECTANGLE(20,40,maxx div 2,maxy div 2);
     OUTTEXTXY(22,45,'<ESC> setzt alten Mausbereich.');
     setzbereich(21,maxx div 2 - 1,41,maxy div 2 - 1);
end;

begin
    DIRECTVIDEO:=FALSE; x:=0;y:=0;wa:=1;
{ Wenn Directvideo auf False gesetzt k”nnen Ausgaben auch mit Write }
{ und Gotoxy(x,y) im Grafikmodus augegeben werden. Angaben wie im Textmodus }
{ Fr Pixelgenaue Textpositonen ist nur OUTTEXTXY geeignet }
{ Im Programm sind beide M”glichkeiten aufgefhrt }
    treiber:=DETECT;
    INITGRAPH(treiber,mode,'');
    maxx:=GETMAXX;maxy:=GETMAXY;
    mausinit;
    SETCOLOR(yellow);textcolor(13);
    RECTANGLE(0,0,maxx,maxy);
    LINE(0,maxy-28,maxx,maxy-28);
    LINE(0,16,maxx,16);
    SETCOLOR(9);
    OUTTEXTXY(260,6,'M A U S D E M O');
    OUTTEXTXY(3,20,'Linke Maustaste aendert den Mauscursor, mit rechter Taste'
   +' zeichnen ');
    OUTEXTXY(3,30,'Beide Maustasten beenden das Demo.');
    OUTTEXTXY(3,maxy - 14,'Mausber. neu, rechte Maustaste.');
    IF NOT install THEN
    begin
     GOTOXY(2,5);
     WRITE('Kein Maustreiber vorhanden, Programm wird abgebrochen.');
     DELAY(2000);
     CLOSEGRAPH;
     HALT(1);
    end;
     GOTOXY(56,24);
     WRITE('X-POS.:');
     GOTOXY(69,24);
     WRITE('Y-POS.:');
    mauswahl(wa);                  { Neuen Mauscursor setzen }
    mausan(true);                  { Maus anschalten }
    REPEAT
    ch:=' ';
     WHILE KEYPRESSED DO
        begin
        ch:=READKEY;
        IF ch = #0 THEN ch:=READKEY;
        end;
     mausxy(x,y,m_taste);          { Mausposition ermitteln }
     GOTOXY(63,24); WRITE(leer4);
     GOTOXY(63,24); WRITE(x);
     GOTOXY(76,24); WRITE(leer4);
     GOTOXY(76,24); WRITE(y);
     MOVETO(x,y);
     IF m_taste = 1 THEN            { Abfrage ob linke Maustaste gedrckt }
      begin
      inc(wa);
      DELAY(250);
      IF wa > 6 THEN wa:=1;
      mauswahl(wa);
      end;
      IF (x > 2) AND (x < 100) AND (y > maxy-14) AND (m_taste = 2) THEN
         bereich_setzen;
      IF ch = #27 THEN max_bereich;
      WHILE m_taste = 2 DO
         begin
         mausxy(x,y,m_taste);
         IF (altx <> x) OR (alty <> y) THEN
             begin
              mausan(false);LINETO(x,y); mausan(true);
              altx:=x;alty:=y;
             end;
         end;
    UNTIL m_taste = 3;
    CLOSEGRAPH;
end.



