home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / disks / disk376.lzh / Matrix / src / NTSC / Intui2.c < prev    next >
C/C++ Source or Header  |  1990-10-10  |  7KB  |  265 lines

  1.  /********************************************************************/
  2.  /****                                                            ****/
  3.  /****                                                            ****/
  4.  /****    Program          : Intui2.c                             ****/
  5.  /****                                                            ****/
  6.  /****    Version          : 01.00                                ****/
  7.  /****                                                            ****/
  8.  /****    Erstversion      : 01.07.1990                           ****/
  9.  /****                                                            ****/
  10.  /****    Letzte Änderung  : 09.08.1990                           ****/
  11.  /****                                                            ****/
  12.  /****    Compiliert mit   : siehe MAKEFILE                       ****/
  13.  /****                                                            ****/
  14.  /****    Gelinkt mit      : siehe MAKEFILE                       ****/
  15.  /****                                                            ****/
  16.  /********************************************************************/
  17.  /****                                                            ****/
  18.  /****                                                            ****/
  19.  /****               Copyright by Rüdiger Dreier                  ****/
  20.  /****                                                            ****/
  21.  /****                                                            ****/
  22.  /********************************************************************/
  23.  
  24.  char Gleichungen[4],Variablen[4];
  25.  struct Window *Window2;
  26.  extern LONG Breite,Hoehe;
  27.  
  28.  SHORT paare3[]=
  29.   {
  30.    0,0,0,9,33,9,33,0,0,0
  31.   };
  32.  SHORT paare1[]=
  33.   {
  34.    -2,-2,122,-2,122,10,-2,10,-2,-2
  35.   };
  36.  struct Border Rand=
  37.   {
  38.    0,0,2,3,JAM2,5,(SHORT *)&paare1,NULL
  39.   };
  40.  struct Border Rand1 =
  41.   {
  42.    -1,-1,2,3,JAM2,5,paare3,0
  43.   };
  44.  
  45.  struct IntuiText Bedeutung2=
  46.   {
  47.    1,0,JAM1,-110,0,NULL,"Equations  :",NULL
  48.   };
  49.  struct IntuiText Bedeutung1=
  50.   {
  51.    1,0,JAM1,-110,0,NULL,"Variables  :",NULL
  52.   };
  53.  
  54.  struct StringInfo VariablenString=
  55.   {
  56.    Gleichungen,NULL,0,3,0,0,5,0,0,0,NULL,0,NULL
  57.   };
  58.  struct StringInfo GleichungenString=
  59.   {
  60.    Variablen,NULL,0,3,0,0,5,0,0,0,NULL,0,NULL
  61.   };
  62.  
  63.  struct IntuiText Texte=
  64.   {
  65.    2,3,JAM2,0,0,0," OK ",0
  66.   };
  67.  
  68.  struct Gadget OKgadget=
  69.   {
  70.    NULL    ,86,70,32,8,GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,(APTR)&Rand1,0,&Texte,NULL,NULL,4,0
  71.   };
  72.  struct Gadget gadget2=
  73.   {
  74.    &OKgadget,140,30,32,8,GADGHCOMP,GADGIMMEDIATE|RELVERIFY|STRINGCENTER|LONGINT,STRGADGET,(APTR)&Rand1,0,&Bedeutung2,0,(APTR)&GleichungenString,1,0 
  75.   };
  76.  struct Gadget gadget1=
  77.   {
  78.    &gadget2 ,140,45,32,8,GADGHCOMP,GADGIMMEDIATE|RELVERIFY|STRINGCENTER|LONGINT,STRGADGET,(APTR)&Rand1,0,&Bedeutung1,0,(APTR)&VariablenString,0,0 
  79.   };
  80.  
  81.  struct NewWindow Fenster2=
  82.   {
  83.    210,110,200,90,0,1,GADGETUP,ACTIVATE|WINDOWDRAG,
  84.    &gadget1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  85.    CUSTOMSCREEN
  86.   };
  87.  
  88.  
  89.  VOID NeueWerte(VOID)
  90.   {
  91.    USHORT GadgetID;
  92.    SHORT ENDE=1;
  93.    
  94.    VariablenString.LongInt  =0;
  95.    VariablenString.BufferPos=0;
  96.    GleichungenString.LongInt=0;
  97.    GleichungenString.BufferPos=0;
  98.    Gleichungen[0]=0;
  99.    Variablen[0]=0;
  100.    
  101.    if(!(Window2=(struct Window *)OpenWindow(&Fenster2)))return;
  102.    
  103.    ActivateGadget(&gadget2,Window2,NULL); /* Direkte Eingabe ermöglichen */
  104.    
  105.    while(ENDE)
  106.     {
  107.      Wait(1L<<Window2->UserPort->mp_SigBit);
  108.      while(EventAbfrage(Window2,&msgInfo))
  109.       {
  110.        /* Es gibt nur das Ereignis GADGETDOWN */
  111.        GadgetID=((struct Gadget *)msgInfo.IAddress)->GadgetID;
  112.        switch(GadgetID)
  113.         {
  114.          case 1:
  115.           {
  116.            ActivateGadget(&gadget1,Window2,NULL);
  117.            break;
  118.           }
  119.          case 4:
  120.          case 0:            
  121.           {
  122.            if(GleichungenString.LongInt<=10 && VariablenString.LongInt<=7 &&
  123.               GleichungenString.LongInt>  0 && VariablenString.LongInt >0)
  124.             {
  125.              ENDE=0;
  126.             }
  127.            else
  128.             {
  129.              ActivateGadget(&gadget2,Window2,NULL);
  130.             }
  131.            break;
  132.           }
  133.         }
  134.       }
  135.     }
  136.    Spalten=VariablenString.LongInt+1;
  137.    Zeilen =GleichungenString.LongInt;
  138.    Breite=620/Spalten;
  139.    Hoehe =80/Zeilen;
  140.    CloseWindow(Window2);
  141.   }
  142.  
  143.  
  144.  #define CANCELID FALSE
  145.  #define OKID     TRUE
  146.  
  147.  SHORT Paare1[]=
  148.   {
  149.    -1,-1,48,-1,48,8,-1,8,-1,-1
  150.   };
  151.  SHORT Paare2[]=
  152.   {
  153.    0,0,320,0,320,98,0,98,0,0
  154.   };
  155.  SHORT Paare3[]=
  156.   {
  157.    -2,-2,280,-2,280,9,-2,9,-2,-2
  158.   };
  159.  
  160.  char __FileName[40],__UFileName[40];
  161.  
  162.  struct Border textrand=
  163.   {
  164.    0,0,1,2,JAM2,5,Paare1,NULL
  165.   };
  166.  struct Border Reqrand =
  167.   {
  168.    0,0,1,2,JAM2,5,Paare2,NULL
  169.   };
  170.  struct Border filerand=
  171.   {
  172.    0,0,1,2,JAM2,5,Paare3,NULL
  173.   };
  174.  
  175.  struct StringInfo __FileNameInfo =
  176.   {
  177.    __FileName,__UFileName,0,40,0,0,0,0,0,0,0,0,0
  178.   };
  179.  
  180.  struct IntuiText oktext    =
  181.   {
  182.    1,3,JAM2,0,0,NULL,"  OK  ",0
  183.   };
  184.  struct IntuiText canceltext=
  185.   {
  186.    1,3,JAM2,0,0,NULL,"Cancel",0
  187.   };
  188.  struct IntuiText Reqtext3  =
  189.   {
  190.    1,3,JAM2,25,45,NULL,NULL,0
  191.   };
  192.  struct IntuiText Reqtext2  =
  193.   {
  194.    1,3,JAM1,25,30,NULL,"Enter a name for the fil:",&Reqtext3
  195.   };
  196.  struct IntuiText Reqtext   =
  197.   {
  198.    1,3,JAM2,104,15,NULL,"File-Requester",&Reqtext2
  199.   };
  200.  
  201.  struct Gadget filegadget   =
  202.   {
  203.    0          ,20,65,280,8,SELECTED|GADGHCOMP,STRINGCENTER|GADGIMMEDIATE|RELVERIFY,REQGADGET|STRGADGET ,(APTR)&filerand,NULL,NULL       ,0,(APTR)&__FileNameInfo,OKID       ,0
  204.   };
  205.  struct Gadget okgadget     =
  206.   {
  207.    &filegadget,20,80,48,8, GADGHCOMP,GADGIMMEDIATE|RELVERIFY,REQGADGET|BOOLGADGET,(APTR)&textrand,NULL,&oktext    ,0,0                               ,OKID    ,0
  208.   };
  209.  struct Gadget cancelgadget =
  210.   {
  211.    &okgadget  ,252,80,48,8,GADGHCOMP,GADGIMMEDIATE|RELVERIFY,REQGADGET|BOOLGADGET,(APTR)&textrand,NULL,&canceltext,0,0                               ,CANCELID,0
  212.   };
  213.  
  214.  struct Requester Req=
  215.   {
  216.    0,20,20,321,99,0,0,&cancelgadget,&Reqrand,&Reqtext,0,2,0,0,0
  217.   };
  218.  
  219.  SHORT FileRequest(struct Window *Window,
  220.                    char *ReqText,
  221.                    SHORT x,
  222.                    SHORT y,
  223.                    char *Ziel)
  224.   {
  225.    SHORT laenge,ENDE=1;
  226.    long Rueckgabe;
  227.    
  228.    Req.LeftEdge=x;
  229.    Req.TopEdge=y;
  230.    
  231.    laenge=strlen(ReqText)*8;
  232.    Reqtext3.LeftEdge=(321-laenge)/2;
  233.    Reqtext3.IText=ReqText;
  234.    
  235.    Request(&Req,Window);
  236.    
  237.    Delay(5);
  238.    ActivateGadget(&filegadget,Window,&Req);
  239.    while(ENDE)
  240.     {
  241.      Wait(1L<<Window->UserPort->mp_SigBit);
  242.      while(laenge=EventAbfrage(Window,&msgInfo))
  243.       {
  244.        Rueckgabe=((struct Gadget *)msgInfo.IAddress)->GadgetID;
  245.        if(laenge==GADGETUP)
  246.         {
  247.          ENDE=0;
  248.         }
  249.       }
  250.     }
  251.    EndRequest(&Req,Window);
  252.    
  253.    if(Rueckgabe==OKID)
  254.     {
  255.      strcpy(Ziel,__FileName);
  256.      return(TRUE);
  257.     }
  258.    else
  259.     {
  260.      strcpy(Ziel,"");
  261.      return(FALSE);
  262.     }
  263.   }
  264.  
  265.