home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 298.lha / PopInfo_v3.1 / SimpleRequest.c < prev   
C/C++ Source or Header  |  1980-12-04  |  3KB  |  89 lines

  1. #include <intuition/intuitionbase.h>
  2. #include <stdio.h>
  3. #include <pragma/all.h>
  4. #include <proto/all.h>
  5. #include "PopInfo.i"
  6.  
  7. #define OKAY 1
  8. #define CANCEL 0
  9.  
  10. static short SimpleRequestXYBorder[]={
  11.     0,0,101,0,101,12,0,12,0,0};
  12. static struct Border SimpleRequestBorder={
  13.     -1,-1,6,0,JAM1,5,SimpleRequestXYBorder,NULL};
  14. static struct IntuiText OkayText={
  15.     0,1,JAM1,5,2,NULL,NULL,NULL};
  16. static struct IntuiText CancelText={
  17.     0,1,JAM1,5,2,NULL,NULL,NULL};
  18. static struct Gadget OkayGadget={
  19.     NULL,8,20,100,11,GADGHCOMP,RELVERIFY,BOOLGADGET,
  20.     (APTR)&SimpleRequestBorder,NULL,&OkayText,NULL,NULL,OKAY,NULL};
  21. static struct Gadget CancelGadget={
  22.     &OkayGadget,120,20,100,11,GADGHCOMP,RELVERIFY,BOOLGADGET,
  23.     (APTR)&SimpleRequestBorder,NULL,&CancelText,NULL,NULL,CANCEL,NULL};
  24.  
  25. static struct IntuiText SimpleRequestText={
  26.     0,1,JAM1,8,7,NULL,NULL,NULL};
  27.  
  28. static struct NewWindow SimpleRequestWindow={
  29.     50,30,230,36,0,3,GADGETUP|VANILLAKEY,ACTIVATE|RMBTRAP,NULL,
  30.     NULL,NULL,NULL,NULL,0,0,0,0,CUSTOMSCREEN};
  31.  
  32. static struct Window *QWindow;
  33. static struct IntuiMessage *MyMsg;
  34. extern struct IntuitionBase *IntuitionBase;
  35.  
  36. simplerequest(Window,text,x,y,pos,neg)
  37. struct Window *Window;
  38. char *text;
  39. int x,y;
  40. char *pos, *neg;
  41. {
  42.     int Class,Code;
  43.     char key;
  44.     SimpleRequestWindow.Screen=(struct Screen *) Window->WScreen;
  45.     SimpleRequestWindow.Width=strlen(text)*8+16;
  46.     SimpleRequestText.LeftEdge=8;
  47.     if (SimpleRequestWindow.Width<230) {
  48.         SimpleRequestWindow.Width=230;
  49.         SimpleRequestText.LeftEdge=(214-(strlen(text)*8))/2+8;
  50.     }
  51.     if (SimpleRequestWindow.Width>640) SimpleRequestWindow.Width=640;
  52.     CancelGadget.LeftEdge=(SimpleRequestWindow.Width)-108;
  53.     if (x==-1 || y==-1) {
  54.         x=Window->WScreen->MouseX; y=Window->WScreen->MouseY;
  55.     }
  56.     if (x==-2 || y==-2) {
  57.         x=Window->WScreen->MouseX-20; y=Window->WScreen->MouseY-25;
  58.     }
  59.     if (x==-3 || y==-3) {
  60.         x=Window->WScreen->MouseX-SimpleRequestWindow.Width+20;
  61.         y=Window->WScreen->MouseY-SimpleRequestWindow.Height+11;
  62.     }        
  63.     if (x<0) x=0; if (y<0) y=0;
  64.     if (x>640-SimpleRequestWindow.Width) x=640-SimpleRequestWindow.Width;
  65.     if (y>SimpleRequestWindow.Screen->Height-36)
  66.         y=SimpleRequestWindow.Screen->Height-36;
  67.     SimpleRequestWindow.TopEdge=y; SimpleRequestWindow.LeftEdge=x;
  68.     CancelText.IText=neg; CancelText.LeftEdge=(100-(strlen(neg)*8))/2;
  69.     OkayText.IText=pos; OkayText.LeftEdge=(100-(strlen(pos)*8))/2;
  70.     ScreenToFront(Window->WScreen);
  71.     QWindow=(struct Window *) OpenWindow(&SimpleRequestWindow);
  72.     SetAPen(QWindow->RPort,1);
  73.     RectFill(QWindow->RPort,4,2,(SimpleRequestWindow.Width-5),33);
  74.     AddGList(QWindow,&CancelGadget,-1,2,NULL);
  75.     RefreshGList(&CancelGadget,QWindow,NULL,2);
  76.     SimpleRequestText.IText=text;
  77.     PrintIText(QWindow->RPort,&SimpleRequestText,0,0);
  78.     waitforinput:
  79.     Wait (1<<QWindow->UserPort->mp_SigBit);
  80.     MyMsg=GetMsg(QWindow->UserPort);
  81.     ReplyMsg(MyMsg);
  82.     Class=MyMsg->Class; Code=MyMsg->Code; key=toupper((char ) Code);
  83.     if (Class==VANILLAKEY && key!='Y' && key!='N') goto waitforinput;
  84.     CloseWindow(QWindow);
  85.     RemoveGList(QWindow,&CancelGadget,2);
  86.     if (((struct Gadget *) MyMsg->IAddress)->GadgetID==OKAY || key=='Y') return(TRUE);
  87.     return(FALSE);
  88. }
  89.