home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 6
/
FreshFish_September1994.bin
/
new
/
misc
/
math
/
mathplot
/
macros
/
apig.mapl
next >
Wrap
Text File
|
1994-07-16
|
5KB
|
230 lines
/* Example, how to use APIG with MathPlot */
/* Plots two functions with variable parameter */
/* Needs APIG.library in LIBS: */
options results
IF ~SHOW('L','rexxsupport.library') THEN
CALL ADDLIB('rexxsupport.library',0,-30)
IF ~SHOW('L','apig.library') THEN
CALL ADDLIB('apig.library',0,-30)
/* Get Name of the screen */
info stem a.
screen = a.pubscreen
/* The two functions */
setfunc "0 cos(a-asin(x))"
setfunc "1 cos(pi-asin(x)-a)"
setintervall "xmin -1 xmax 1 ymin -1 ymax 1 xaxis 0 yaxis 0"
call set_apig_globals()
scr = Lockpubscreen(screen)
scrvinfo = GETVISUALINFO(scr) /* NewGadgets need this */
scrfont = GETVALUE(scr,40,4,'p') /* NewGadgets need this */
/* points to TextAttr */
glistpointer = ALLOCVEC(4,MEMF_CLEAR) /* a pointer for context */
conxgad = CREATECONTEXT(glistpointer)
previousgadget = conxgad
myid = 10
/* we now create and initialize a NewGadget structure */
newgadx = MAKENEWGADGET(scrvinfo,scrfont,10,27 ,145,15,"Slide Me !",
,PLACETEXT_ABOVE,myid,null())
testtext = "Test %2ld"
gadtext = ALLOCVEC(length(testtext)+1,MEMF_CLEAR)
call export(gadtext,testtext)
gadtaglist = ALLOCATETAGITEMS(10)
call SETTAGSLOT(gadtaglist,0,GTSL_MIN,'n',-20)
call SETTAGSLOT(gadtaglist,1,GTSL_MAX,'n',20)
call SETTAGSLOT(gadtaglist,2,GTSL_LEVEL,'n',0)
call SETTAGSLOT(gadtaglist,3,GTSL_MAXLEVELLEN,'n',30)
call SETTAGSLOT(gadtaglist,4,GTSL_LEVELFORMAT,'p',gadtext)
call SETTAGSLOT(gadtaglist,5,GTSL_LEVELPLACE,'n',PLACETEXT_BELOW)
call SETTAGSLOT(gadtaglist,6,TAG_DONE,'n',0)
/*
previousgadget = CREATEGADGET(SLIDER_KIND,previousgadget,newgadx,
,GTSL_MIN,1,
,GTSL_MAX,16,
,GTSL_LEVEL,6,
,GTSL_MAXLEVELLEN,30,
,GTSL_LEVELFORMAT,"test %2ld",
,TAG_DONE,0)
*/
previousgadget = CREATEGADGETA(SLIDER_KIND, previousgadget, newgadx,gadtaglist)
/*
say c2x(GTSL_MIN) "," c2x(GTSL_LEVEL) "," c2x(GTSL_LEVELFORMAT)
*/
call openwin()
call unlockpubscreen(null(),scr)
call FREEVISUALINFO(scrvinfo)
call FREEGADGETS(conxgad)
call FREETHIS(newgadx)
call FREETAGITEMS(gadtaglist)
call FREEVEC(glistpointer)
call FREEVEC(gadtext)
exit
/* ------------------------------------------------------------ */
openwin:
portname = "scrtagsport"
p = openport(portname)
wintitle = "MathPlot+APIG"
wintaglist = makewintaglist() /* build tag list for window */
win = openwindowtaglist(portname,null(),wintaglist)
call GT_REFRESHWINDOW(win,null())
exitme = 0
do while exitme = 0
call waitpkt(portname)
do forever
msg = '0000 0000'x
msg = getpkt(portname)
if msg = '0000 0000'x then leave
msgclass = getarg(msg,0)
gadcode = getarg(msg,1)
gadaddr = getarg(msg,8)
gadid = getarg(msg,9)
if gadcode > 32768 then gadcode = -(65536 - gadcode)
x = reply(msg,0)
select
when msgclass = IDCMP_CLOSEWINDOW then exitme = 1
when msgclass = IDCMP_MOUSEMOVE then do
/*
if gadid = 10 then
do
*/
string=getstrgad(win, gadid, null())
/*
say "Gadget" c2x(gadaddr) "," gadid ", Code" gadcode "," c2x(previousgadget)
*/
setconst "a " gadcode"/20"
plot 0 normal
plot 1 normal
/*
end
*/
end
otherwise nop
end
end
end
call CLOSEWINDOW(win)
call FREETAGITEMS(wintaglist)
call FREEVEC(mytitle)
return 1
/* ------------------------------------------------------------ */
makewintaglist:
winidcmp = IDCMP_CLOSEWINDOW+IDCMP_GADGETUP+IDCMP_MOUSEMOVE+IDCMP_GADGETDOWN
winflags = WFLG_CLOSEGADGET + WFLG_DRAGBAR
/*
+ WFLG_GIMMEZEROZERO
*/
mytaglist = ALLOCATETAGITEMS(40)
call SETTAGSLOT(mytaglist,0,WA_LEFT,'n',10)
call SETTAGSLOT(mytaglist,1,WA_TOP,'n',50)
call SETTAGSLOT(mytaglist,2,WA_WIDTH,'n',170)
call SETTAGSLOT(mytaglist,3,WA_HEIGHT,'n',60)
call SETTAGSLOT(mytaglist,4,WA_DETAILPEN,'n',2)
call SETTAGSLOT(mytaglist,5,WA_BLOCKPEN,'n',3)
call SETTAGSLOT(mytaglist,6,WA_MINWIDTH,'n',40)
call SETTAGSLOT(mytaglist,7,WA_MAXWIDTH,'n',640)
call SETTAGSLOT(mytaglist,8,WA_MINHEIGHT,'n',80)
call SETTAGSLOT(mytaglist,9,WA_MAXHEIGHT,'n',400)
/*
call SETTAGSLOT(mytaglist,10,WA_SIZEGADGET,'n',1)
*/
call SETTAGSLOT(mytaglist,10,WA_DRAGBAR,'n',1)
call SETTAGSLOT(mytaglist,11,WA_CLOSEGADGET,'n',1)
call SETTAGSLOT(mytaglist,12,WA_ACTIVATE,'n',1)
/*
call SETTAGSLOT(mytaglist,14,WA_GIMMEZEROZERO,'n',1)
*/
mytitle = ALLOCVEC(length(wintitle)+1,MEMF_CLEAR)
call export(mytitle,wintitle)
call SETTAGSLOT(mytaglist,13,WA_TITLE,'p',mytitle)
call SETTAGSLOT(mytaglist,14,WA_FLAGS,'n',winflags)
call SETTAGSLOT(mytaglist,15,WA_IDCMP,'n',winidcmp)
call SETTAGSLOT(mytaglist,16,WA_CUSTOMSCREEN,'p',scr)
call SETTAGSLOT(mytaglist,17,WA_GADGETS,'p',conxgad)
call SETTAGSLOT(mytaglist,18,TAG_DONE,'n',0)
return mytaglist