home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************/
- /**** ****/
- /**** ****/
- /**** Program : Maus.c ****/
- /**** ****/
- /**** Version : 03.71 ****/
- /**** ****/
- /**** Erstversion : 14.08.1988 ****/
- /**** ****/
- /**** Letzte Änderung : 05.08.1990 ****/
- /**** ****/
- /**** Compiliert mit : siehe MAKEFILE ****/
- /**** ****/
- /**** Gelinkt mit : siehe MAKEFILE ****/
- /**** ****/
- /********************************************************************/
- /**** ****/
- /**** ****/
- /**** Copyright by Rüdiger Dreier ****/
- /**** ****/
- /**** ****/
- /********************************************************************/
-
-
- /* Einbinden der Includes */
-
- #ifdef DEBUG
- #include "Plotter.h"
- #include <proto/tool.h>
- #endif
- #include <string.h>
- #include <intuition/intuitionbase.h>
- #include <proto/mathieeedoubbas.h>
- #include <proto/mathieeedoubtrans.h>
-
-
- /* Variablendeklaration für Abfragefenster */
-
- struct RastPort *RastPort2;
- struct Window *Window2;
-
- UBYTE MinXText[8],MaxXText[8],MinYText[8],MaxYText[8];
-
- /* Definition der Umrandungen */
- SHORT paare1[]=
- {
- -2,-2,122,-2,122,10,-2,10,-2,-2
- };
- SHORT paare2[]=
- {
- -2,-2,222,-2,222,10,-2,10,-2,-2
- };
- SHORT paare3[]=
- {
- 0,0,0,9,33,9,33,0,0,0
- };
- struct Border Rand2=
- {
- 0,0,FARBE2,FARBE3,JAM2,5,(SHORT *)&paare2,NULL
- };
- struct Border Rand=
- {
- 0,0,FARBE2,FARBE3,JAM2,5,(SHORT *)&paare1,NULL
- };
- struct Border Rand1 =
- {
- -1,-1,FARBE2,FARBE3,JAM2,5,paare3,0
- };
-
- /* Definition der benötigten Texte */
-
- struct IntuiText Bedeutung4=
- {
- FARBE1,FARBE0,JAM1,-65,0,NULL,MinXText,NULL
- };
- struct IntuiText Bedeutung3=
- {
- FARBE1,FARBE0,JAM1,-65,0,NULL,MaxXText,NULL
- };
- struct IntuiText Bedeutung2=
- {
- FARBE1,FARBE0,JAM1,-65,0,NULL,MinYText,NULL
- };
- struct IntuiText Bedeutung1=
- {
- FARBE1,FARBE0,JAM1,-65,0,NULL,MaxYText,NULL
- };
- struct IntuiText BedeutungFormel=
- {
- FARBE1,FARBE0,JAM1,6,-20,NULL,MAUS_ENTERFUNC,NULL
- };
-
- /* Definitionen für TextGadgets */
-
- struct StringInfo TextStringFormel=
- {
- Abgeleitet[0],undoFormel,0,MAXCHARS,0,0,5,0,0,0,NULL,0,NULL
- };
- struct StringInfo TextString1=
- {
- NULL,undo1,0,20,0,0,5,0,0,0,NULL,0,NULL
- };
- struct StringInfo TextString2=
- {
- NULL,undo1,0,20,0,0,5,0,0,0,NULL,0,NULL
- };
- struct StringInfo TextString3=
- {
- NULL,undo1,0,20,0,0,5,0,0,0,NULL,0,NULL
- };
- struct StringInfo TextString4=
- {
- NULL,undo1,0,20,0,0,5,0,0,0,NULL,0,NULL
- };
-
- struct IntuiText Texte=
- {
- FARBE2,FARBE3,JAM2,0,0,0," OK ",0
- };
-
- /* Definitionen für Gadgets */
-
- struct Gadget OKgadget=
- {
- NULL ,100,100,32,8,GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,(APTR)&Rand1,0,&Texte,NULL,NULL,4,0
- };
- struct Gadget FormelGadget=
- {
- &OKgadget ,10,50,220,10,GADGHCOMP,RELVERIFY|STRINGCENTER,STRGADGET,(APTR)&Rand2,0,&BedeutungFormel,0,(APTR)&TextStringFormel,NULL,0
- };
- struct Gadget gadget4=
- {
- &OKgadget ,70,20,120,10,GADGHCOMP,GADGIMMEDIATE|RELVERIFY|STRINGCENTER,STRGADGET,(APTR)&Rand,0,&Bedeutung4,0,(APTR)&TextString4,3,0
- };
- struct Gadget gadget3=
- {
- &gadget4,70,35,120,10,GADGHCOMP,GADGIMMEDIATE|RELVERIFY|STRINGCENTER,STRGADGET,(APTR)&Rand,0,&Bedeutung3,0,(APTR)&TextString3,2,0
- };
- struct Gadget gadget2=
- {
- &gadget3,70,50,120,10,GADGHCOMP,GADGIMMEDIATE|RELVERIFY|STRINGCENTER,STRGADGET,(APTR)&Rand,0,&Bedeutung2,0,(APTR)&TextString2,1,0
- };
- struct Gadget gadget1=
- {
- &gadget2,70,65,120,10,GADGHCOMP,GADGIMMEDIATE|RELVERIFY|STRINGCENTER,STRGADGET,(APTR)&Rand,0,&Bedeutung1,0,(APTR)&TextString1,0,0
- };
-
- /* Definition des allg. Fensters */
-
- struct NewWindow Fenster2=
- {
- 100,10,200,115,FARBE0,FARBE1,GADGETUP,ACTIVATE|WINDOWDRAG,
- &gadget1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
- CUSTOMSCREEN
- };
-
- /* Routine bestimmt Ausschnitt per Maus */
- VOID AusSchnitt(DOUBLE *x1,
- DOUBLE *y1,
- DOUBLE *x2,
- DOUBLE *y2)
- {
- long x,y,xs=0,ys=0,xe=0,ye=0;
- char click=0;
-
- SetDrMd(RastPort,COMPLEMENT); /* DrawMode verändern */
-
- while(click<=1)
- {
- /* Wartet bis 2 mal geklickt */
- Wait(1L<<Window->UserPort->mp_SigBit);
- while(EventAbfrage(Window,&msgInfo))
- {
- /* X/YOffset gibt linke/obere Ecke des View-Ports an */
- x=msgInfo.MouseX+XOffset;
- y=msgInfo.MouseY+YOffset;
- if(x<Abstand+1)
- {
- x=Abstand+1;
- }
- if(x>Abstand+xx)
- {
- x=Abstand+xx;
- }
- if(y<Abstand+1)
- {
- y=Abstand+1;
- }
- if(y>Abstand+yy)
- {
- y=Abstand+yy;
- }
-
- switch(msgInfo.NachrichtenArt)
- {
- case MOUSEBUTTONS:
- {
- if(msgInfo.code==SELECTDOWN)
- {
- /* Erster Klick : Box neu zeichnen */
- click=1;
- xs=xe=x;
- ys=ye=y;
- Box(RastPort,ys,ys,xe,ye);
- }
- else
- {
- /* Zweiter Klick : Box löschen */
- click=2;
- Box(RastPort,xs,ys,xe,ye);
- xe=x;
- ye=y;
- };
- break;
- }
- case RAWKEY:
- {
- if(Groesse==GROSS)
- {
- TastaturAbfrage();
- }
- }
- case MOUSEMOVE:
- {
- if (click==1)
- {
- /* Box löschen und an neuer Position neu zeichnen */
- Box(RastPort,xs,ys,xe,ye);
- xe=x;
- ye=y;
- Box(RastPort,xs,ys,xe,ye);
- }
- }
- }
- }
- }
- SetDrMd(RastPort,JAM1);
-
- /* Bestimmung von xmp/n und ymp/n */
- if (xe>xs)
- {
- *x2=Flt(xe-Abstand);
- *x1=Flt(xs-Abstand);
- }
- else
- {
- *x1=Flt(xe-Abstand);
- *x2=Flt(xs-Abstand);
- }
-
- if (ye<ys)
- {
- *y2=Flt(ye-Abstand);
- *y1=Flt(ys-Abstand);
- }
- else
- {
- *y1=Flt(ye-Abstand);
- *y2=Flt(ys-Abstand);
- }
-
- *x1=Div(Sub(*x1,x0),xm);
- *x2=Div(Sub(*x2,x0),xm);
- *y1=Div(Add(Neg(*y1),y0),ym);
- *y2=Div(Add(Neg(*y2),y0),ym);
-
- /* Gleiche Grenzen werden nicht angenommen */
- if(!(Cmp(*x1,*x2)) || !(Cmp(*y1,*y2)))
- {
- UmwandlungInIntervall();
- }
-
- /* Zahlenwerte auch in Strings speichern */
- UmwFtoS(xmnstring,x1,5);
- UmwFtoS(xmpstring,x2,5);
- UmwFtoS(ymnstring,y1,5);
- UmwFtoS(ympstring,y2,5);
- }
-
- /* Ermittelt neues Intervall für Funktion */
- /* bzw. ermitteln neue Konstanten */
- VOID Grenzen(char *xn,
- char *yn,
- char *xp,
- char *yp)
- {
- struct Gadget *GadgetPtr;
- USHORT GadgetID;
-
- /* Strings kopieren */
- TextString4.Buffer=xn;
- TextString3.Buffer=xp;
- TextString2.Buffer=yn;
- TextString1.Buffer=yp;
-
- /* Zwei Routinen benutzen gleiches Fenster mit Gadgets */
- Fenster2.FirstGadget=&gadget1;
- Fenster2.Width =200;
-
- if(!(Window2=(struct Window *)OpenWindow(&Fenster2)))return;
-
- RastPort2=Window2->RPort;
-
- ActivateGadget(&gadget4,Window2,NULL); /* Direkte Eingabe ermöglichen */
-
- /* Endlosschleife */
- FOREVER
- {
- Wait(1L<<Window2->UserPort->mp_SigBit);
- while(EventAbfrage(Window2,&msgInfo))
- {
- /* Es gibt nur das Ereignis GADGETDOWN */
- GadgetID=((struct Gadget *)msgInfo.IAddress)->GadgetID;
- switch(GadgetID)
- {
- case 4:
- {
- CloseWindow(Window2);
- return;
- }
- case 3:
- {
- GadgetPtr=&gadget3;
- goto Einsprung2;
- }
- case 2:
- {
- GadgetPtr=&gadget2;
- goto Einsprung2;
- }
- case 1:
- {
- GadgetPtr=&gadget1;
- Einsprung2:
- ActivateGadget(GadgetPtr,Window2,NULL);
- break;
- }
- case 0:
- {
- CloseWindow(Window2);
- return;
- }
- }
- }
- }
- }
-
-
- /* Eingabe der neuen Funktion, alter Wert wird übergeben */
- VOID __asm Funktionseingabe(register __a0 UBYTE *string)
- {
- /* Siehe Grenzen */
- Fenster2.FirstGadget=&FormelGadget;
- Fenster2.Width=240;
-
- strcpy(Abgeleitet[0],string); /* Wird zum Anzeigen des Strings benutzt */
- if(!(Window2=(struct Window *)OpenWindow(&Fenster2)))return;
-
- ActivateGadget(&FormelGadget,Window2,NULL);
-
- Wait(1L<<Window2->UserPort->mp_SigBit);
- EventAbfrage(Window2,&msgInfo);
- /* Wenn <RETURN> oder Mausklich auf <OK> -> Beenden */
- CloseWindow(Window2);
- strcpy(string,Abgeleitet[0]);
- }
-
-
- /* Kopiert Text in die passenden Variablen, die */
- /* im Fenster dann angezeigt werden. */
-
- /* Für Intervalleingabe */
- VOID TextFuerIntervall()
- {
- strcpy(MinXText,"X-Min :");
- strcpy(MinYText,"Y-Min :");
- strcpy(MaxXText,"X-Max :");
- strcpy(MaxYText,"Y-Max :");
- }
-
- /* Für Konstanteneingabe */
- VOID TextFuerKonstanten()
- {
- strcpy(MinXText," A :");
- strcpy(MinYText," C :");
- strcpy(MaxXText," B :");
- strcpy(MaxYText," D :");
- }
-
-
-
-