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
Wrap
C/C++ Source or Header
|
1980-12-04
|
3KB
|
89 lines
#include <intuition/intuitionbase.h>
#include <stdio.h>
#include <pragma/all.h>
#include <proto/all.h>
#include "PopInfo.i"
#define OKAY 1
#define CANCEL 0
static short SimpleRequestXYBorder[]={
0,0,101,0,101,12,0,12,0,0};
static struct Border SimpleRequestBorder={
-1,-1,6,0,JAM1,5,SimpleRequestXYBorder,NULL};
static struct IntuiText OkayText={
0,1,JAM1,5,2,NULL,NULL,NULL};
static struct IntuiText CancelText={
0,1,JAM1,5,2,NULL,NULL,NULL};
static struct Gadget OkayGadget={
NULL,8,20,100,11,GADGHCOMP,RELVERIFY,BOOLGADGET,
(APTR)&SimpleRequestBorder,NULL,&OkayText,NULL,NULL,OKAY,NULL};
static struct Gadget CancelGadget={
&OkayGadget,120,20,100,11,GADGHCOMP,RELVERIFY,BOOLGADGET,
(APTR)&SimpleRequestBorder,NULL,&CancelText,NULL,NULL,CANCEL,NULL};
static struct IntuiText SimpleRequestText={
0,1,JAM1,8,7,NULL,NULL,NULL};
static struct NewWindow SimpleRequestWindow={
50,30,230,36,0,3,GADGETUP|VANILLAKEY,ACTIVATE|RMBTRAP,NULL,
NULL,NULL,NULL,NULL,0,0,0,0,CUSTOMSCREEN};
static struct Window *QWindow;
static struct IntuiMessage *MyMsg;
extern struct IntuitionBase *IntuitionBase;
simplerequest(Window,text,x,y,pos,neg)
struct Window *Window;
char *text;
int x,y;
char *pos, *neg;
{
int Class,Code;
char key;
SimpleRequestWindow.Screen=(struct Screen *) Window->WScreen;
SimpleRequestWindow.Width=strlen(text)*8+16;
SimpleRequestText.LeftEdge=8;
if (SimpleRequestWindow.Width<230) {
SimpleRequestWindow.Width=230;
SimpleRequestText.LeftEdge=(214-(strlen(text)*8))/2+8;
}
if (SimpleRequestWindow.Width>640) SimpleRequestWindow.Width=640;
CancelGadget.LeftEdge=(SimpleRequestWindow.Width)-108;
if (x==-1 || y==-1) {
x=Window->WScreen->MouseX; y=Window->WScreen->MouseY;
}
if (x==-2 || y==-2) {
x=Window->WScreen->MouseX-20; y=Window->WScreen->MouseY-25;
}
if (x==-3 || y==-3) {
x=Window->WScreen->MouseX-SimpleRequestWindow.Width+20;
y=Window->WScreen->MouseY-SimpleRequestWindow.Height+11;
}
if (x<0) x=0; if (y<0) y=0;
if (x>640-SimpleRequestWindow.Width) x=640-SimpleRequestWindow.Width;
if (y>SimpleRequestWindow.Screen->Height-36)
y=SimpleRequestWindow.Screen->Height-36;
SimpleRequestWindow.TopEdge=y; SimpleRequestWindow.LeftEdge=x;
CancelText.IText=neg; CancelText.LeftEdge=(100-(strlen(neg)*8))/2;
OkayText.IText=pos; OkayText.LeftEdge=(100-(strlen(pos)*8))/2;
ScreenToFront(Window->WScreen);
QWindow=(struct Window *) OpenWindow(&SimpleRequestWindow);
SetAPen(QWindow->RPort,1);
RectFill(QWindow->RPort,4,2,(SimpleRequestWindow.Width-5),33);
AddGList(QWindow,&CancelGadget,-1,2,NULL);
RefreshGList(&CancelGadget,QWindow,NULL,2);
SimpleRequestText.IText=text;
PrintIText(QWindow->RPort,&SimpleRequestText,0,0);
waitforinput:
Wait (1<<QWindow->UserPort->mp_SigBit);
MyMsg=GetMsg(QWindow->UserPort);
ReplyMsg(MyMsg);
Class=MyMsg->Class; Code=MyMsg->Code; key=toupper((char ) Code);
if (Class==VANILLAKEY && key!='Y' && key!='N') goto waitforinput;
CloseWindow(QWindow);
RemoveGList(QWindow,&CancelGadget,2);
if (((struct Gadget *) MyMsg->IAddress)->GadgetID==OKAY || key=='Y') return(TRUE);
return(FALSE);
}